Update checkbox API (#663)

* Update checkbox API

* Fix test
This commit is contained in:
Emilien Chauvet
2023-07-14 18:44:32 -07:00
committed by GitHub
parent b971464fe5
commit efd4ed16d6
7 changed files with 14 additions and 26 deletions

View File

@ -6,7 +6,7 @@ import { IconCheck } from '@/ui/icons/index';
type OwnProps = {
checked: boolean;
indeterminate?: boolean;
onChange?: (newCheckedValue: boolean) => void;
onChange: () => void;
};
const StyledContainer = styled.div`
@ -65,18 +65,13 @@ export function Checkbox({ checked, onChange, indeterminate }: OwnProps) {
}
}, [ref, indeterminate, checked]);
function handleChange(event: React.ChangeEvent<HTMLInputElement>) {
onChange?.(event.target.checked);
}
return (
<StyledContainer>
<StyledContainer onClick={onChange}>
<input
ref={ref}
type="checkbox"
data-testid="input-checkbox"
checked={checked}
onChange={handleChange}
/>
{checked && <IconCheck />}
</StyledContainer>