Skip to content

Commit

Permalink
feat: allow OakCheckBox to be controlled
Browse files Browse the repository at this point in the history
  • Loading branch information
carlmw committed Mar 25, 2024
1 parent 6661973 commit 248b30f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/components/atoms/InternalCheckBox/InternalCheckBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ export type BaseCheckBoxProps = {
id: string;
disabled?: boolean;
value: string;
/**
* Uncontrolled checked state
*/
defaultChecked?: boolean;
/**
* Controlled checked state
*/
checked?: boolean;
onHovered?: (value: string, id: string, duration: number) => void;
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
Expand Down
4 changes: 3 additions & 1 deletion src/components/molecules/OakCheckBox/OakCheckBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export const OakCheckBox = (props: OakCheckBoxProps) => {
value,
displayValue = value,
disabled = false,
defaultChecked = false,
defaultChecked,
checked,
onChange,
onFocus,
onBlur,
Expand Down Expand Up @@ -121,6 +122,7 @@ export const OakCheckBox = (props: OakCheckBoxProps) => {
onFocus={onFocus}
onBlur={onBlur}
defaultChecked={defaultChecked}
checked={checked}
disabled={disabled}
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ input:checked + .c7 {
>
<input
className="c3 c4 c5 c6"
defaultChecked={false}
disabled={false}
id="checkbox-1"
name="checkbox-1"
Expand Down

0 comments on commit 248b30f

Please sign in to comment.