diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-04-22 12:35:53 +0200 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-04-22 12:35:53 +0200 |
commit | fce651a618ca6d0d64fbcea757c3e0f582e1b437 (patch) | |
tree | b49ff4a2e8b237b54fdc22f3c51e67af13d05c7f /components/ui.tsx | |
parent | b0d6721ba9c3cb0a74c376791d41e446a2f57d14 (diff) |
beginnings of theme settings
Diffstat (limited to 'components/ui.tsx')
-rw-r--r-- | components/ui.tsx | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/components/ui.tsx b/components/ui.tsx index 1e9997a..c92ebfe 100644 --- a/components/ui.tsx +++ b/components/ui.tsx @@ -122,26 +122,12 @@ export function CheckBox(props: { id?: string; onclick?: (state: boolean) => void; }) { - var [gotDefaultState, setGotDefaultState] = useState(false); - var [on, setOn] = useState(props.state); - - useEffect(() => { - if (gotDefaultState) return; - setOn(props.state); - if (typeof props.state !== 'undefined') setGotDefaultState(true); - }); - - var toggle = () => { - setOn(!on); - props.onclick && props.onclick(!on); - }; - return <div - onClick={toggle} + onClick={() => props.onclick && props.onclick(!props.state)} id={props.id} - className={'checkbox dispinbl ' + (on ? 'on' : 'off')} + className={'checkbox dispinbl ' + (props.state ? 'on' : 'off')} > - {on + {props.state ? <CheckBoxIcon /> : <CheckBoxOutlineBlankIcon />} </div>; |