mirror of
https://github.com/we-promise/sure.git
synced 2026-04-13 00:57:22 +00:00
feat(transaction): tabbing between income and expenses persists entered data (#1422)
This commit is contained in:
@@ -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))
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user