import { useConfigs } from 'containers/ConfigsContext' import * as React from 'react' import { cx } from 'utils/cx' import { SimpleField } from './SettingsBar' type Props = { field: SimpleField onChange?(): void } export function SimpleToggleField({ field, onChange }: Props) { const { overwrite } = field const configContext = useConfigs() const value = configContext.val[field.key] return (
{ const enabled = e.currentTarget.checked configContext.set({ [field.key]: overwrite ? overwrite.onChange(enabled) : enabled }) if (onChange) onChange() }} checked={overwrite ? overwrite.value(value) : Boolean(value)} />
) }