diff options
author | Joris | 2025-04-19 12:36:38 +0200 |
---|---|---|
committer | Joris | 2025-04-19 12:38:24 +0200 |
commit | 632eef6424d8dc8d40c2906177892697679e7b85 (patch) | |
tree | 48d9cd60e9e96eab810b5f7bb3c7b1fa79e0438f /src/lib/form.ts | |
parent | 063d8ef9eaf874a941f4459e831057dd0a1b7ddd (diff) |
Add ZIG server
Diffstat (limited to 'src/lib/form.ts')
-rw-r--r-- | src/lib/form.ts | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/src/lib/form.ts b/src/lib/form.ts deleted file mode 100644 index 04a2654..0000000 --- a/src/lib/form.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { h } from 'lib/h' -import * as Layout from 'lib/layout' -import * as Button from 'lib/button' - -interface InputParams { - label: string, - attrs: object, -} - -export function input({ label, attrs }: InputParams): Element { - return h('label', - { className: 'g-Form__Field' }, - label, - h('input', attrs), - ) -} - -interface ColorInputParams { - colors: string[], - label: string, - initValue: string, - onInput: (value: string) => void, -} - -export function colorInput({ colors, label, initValue, onInput }: ColorInputParams): Element { - const input = h('input', - { value: initValue, - type: 'color', - oninput: (e: Event) => { - if (e.target !== null) { - onInput((e.target as HTMLInputElement).value) - } - } - } - ) as HTMLInputElement - return h('label', - { className: 'g-Form__Field' }, - label, - Layout.line( - {}, - input, - ...colors.map(color => - Button.raw({ className: 'g-Form__Color', - style: `background-color: ${color}`, - type: 'button', - onclick: () => { - input.value = color - onInput(color) - } - }) - ) - ) - ) -} |