feat(transaction): tabbing between income and expenses persists entered data (#1422)

This commit is contained in:
Roger Saner
2026-04-11 00:56:05 +02:00
committed by GitHub
parent 257286431b
commit 88747e5716
3 changed files with 25 additions and 4 deletions

View File

@@ -0,0 +1,21 @@
import { Controller } from "@hotwired/stimulus"
const ACTIVE_CLASSES = ["bg-container", "text-primary", "shadow-sm"]
const INACTIVE_CLASSES = ["hover:bg-container", "text-subdued", "hover:text-primary", "hover:shadow-sm"]
export default class extends Controller {
static targets = ["tab", "natureField"]
selectTab(event) {
event.preventDefault()
const selectedTab = event.currentTarget
this.natureFieldTarget.value = selectedTab.dataset.nature
this.tabTargets.forEach(tab => {
const isActive = tab === selectedTab
tab.classList.remove(...(isActive ? INACTIVE_CLASSES : ACTIVE_CLASSES))
tab.classList.add(...(isActive ? ACTIVE_CLASSES : INACTIVE_CLASSES))
})
}
}