aboutsummaryrefslogtreecommitdiff
path: root/src/view/sequencer/block.ts
blob: 5776120a3feda838d6f769820cfe9c975395383f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import h, { classNames } from 'lib/h'

interface Params {
  checked: boolean,
  onCheck: (checked: boolean) => void
}

export function view({ checked, onCheck }: Params) {
  return h('div', 
    { className: classNames({
        'g-Sequencer__Block': true,
        'g-Sequencer__Block--Checked': checked
      }),
      onclick: (e: Event) => {
        checked = !checked
        onCheck(checked)
        let target = e.target as HTMLElement
        if (target !== undefined) {
          if (checked) {
            target.classList.add('g-Sequencer__Block--Checked')
          } else {
            target.classList.remove('g-Sequencer__Block--Checked')
          }
        }
      }
    }
  )
}