From 03197b1ab992540b951fcbc6f841cfcd42a757f3 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 11 Jun 2022 16:42:33 +0200 Subject: Add kick sequencer --- src/view/sequencer/block.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/view/sequencer/block.ts (limited to 'src/view/sequencer/block.ts') diff --git a/src/view/sequencer/block.ts b/src/view/sequencer/block.ts new file mode 100644 index 0000000..5776120 --- /dev/null +++ b/src/view/sequencer/block.ts @@ -0,0 +1,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') + } + } + } + } + ) +} -- cgit v1.2.3