import { html } from 'htm/preact' import { FunctionComponent, JSX } from 'preact' import { Signal, useSignal } from '@preact/signals' type HTMLCheckbox = Omit export const Checkbox:FunctionComponent<{ checkedState?:Signal; } & JSX.HTMLAttributes> = function (props) { let { checkedState, ..._props } = props if (!checkedState) checkedState = useSignal(false) const classes = (['checkbox', props.class]) .filter(Boolean).join(' ').trim() function onChange (ev) { const isChecked = ev.target.checked if (checkedState!.value !== isChecked) checkedState!.value = isChecked props.onChange && props.onChange(ev) } const containerClasses = ([ 'box-container', checkedState.value ? 'checked' : '' ]).filter(Boolean).join(' ') return html`` } export default Checkbox function Svg () { return html`` }