diff --git a/src/lib/components/inputs/Checkbox/Checkbox.styles.tsx b/src/lib/components/inputs/Checkbox/Checkbox.styles.tsx index df08f002..cfbb29f0 100644 --- a/src/lib/components/inputs/Checkbox/Checkbox.styles.tsx +++ b/src/lib/components/inputs/Checkbox/Checkbox.styles.tsx @@ -62,4 +62,8 @@ export const SpanEl = styled.span` align-content: center; color: ${(props) => props.uncheckedTextColor}; ${(props) => typographyToCss(props.typography)}; + + & > svg { + color: ${(props) => props.checkedTextColor}; + } ` diff --git a/src/lib/components/inputs/Checkbox/Checkbox.tsx b/src/lib/components/inputs/Checkbox/Checkbox.tsx index 8b4b8929..01c6b7da 100644 --- a/src/lib/components/inputs/Checkbox/Checkbox.tsx +++ b/src/lib/components/inputs/Checkbox/Checkbox.tsx @@ -31,56 +31,42 @@ export type CheckboxProps = { className?: string } -export const Checkbox = forwardRef( - ( - { - id = _.uniqueId(), - checked = false, - checkedContent = , - uncheckedContent = , - ...props - }: CheckboxProps, - ref - ) => { - const [isChecked, setIsChecked] = useState(checked) +export const Checkbox = ({ + id = _.uniqueId(), + checked, + checkedContent, + uncheckedContent, + ...props +}: CheckboxProps) => { + const theme = useTheme() - useImperativeHandle(ref, () => { - return { - isChecked, - setIsChecked - } - }) + uncheckedContent ??= + checkedContent ??= - useEffect(() => { - props.onChange && props.onChange.call(isChecked) - }, [isChecked]) - - const theme = useTheme() - const styles: SpanProps = { - typography: props.typography || theme.typography.body2, - checkedBackground: props.checkedBackground || theme.colors.checkedBackground, - uncheckedBackground: props.uncheckedBackground || theme.colors.background, - uncheckedBorder: props.uncheckedBorder || theme.colors.uncheckedBorder, - checkedBorder: props.checkedBorder || theme.colors.checkedBackground, - checkedTextColor: props.checkedTextColor || theme.colors.checkedText, - uncheckedTextColor: props.uncheckedTextColor || theme.colors.uncheckedText, - width: props.width, - height: props.height, - spacing: theme.spacing.xxsmall, - ...props - } - - return ( - - - {checked ? checkedContent : uncheckedContent} - - ) + const styles: SpanProps = { + typography: props.typography || theme.typography.body2, + checkedBackground: props.checkedBackground || theme.colors.primary, + uncheckedBackground: props.uncheckedBackground || theme.colors.background, + uncheckedBorder: props.uncheckedBorder || theme.colors.uncheckedBorder, + checkedBorder: props.checkedBorder || theme.colors.onPrimary, + checkedTextColor: props.checkedTextColor || theme.colors.onPrimary, + uncheckedTextColor: props.uncheckedTextColor || theme.colors.uncheckedText, + width: props.width, + height: props.height, + spacing: theme.spacing.xxsmall, + ...props } -) + + return ( + + + {checked ? checkedContent : uncheckedContent} + + ) +}