import { useMemo } from 'react'; import { CheckboxCheckedIcon } from '../Icons'; import Label from './Label'; export interface CheckboxProps extends Omit, 'className' | 'children' | 'title' | 'value' | 'onClick' > { id?: string label?: string disabled?: boolean dimensions?: string tooltip?: string value: boolean setValue?: (newValue: boolean) => void } function Checkbox({ id, disabled, tooltip, label, dimensions = 'w-fit', value, setValue, ...props }: CheckboxProps) { const cursor = useMemo( () => { if (disabled) { return 'cursor-not-allowed'; } else if (setValue) { return 'cursor-pointer'; } else { return '' } }, [disabled, setValue]); const bgColor = useMemo( () => { return value !== false ? 'clr-primary' : 'clr-app' }, [value]); function handleClick(event: React.MouseEvent): void { event.preventDefault(); if (disabled || !setValue) { return; } setValue(!value); } return ( ); } export default Checkbox;