Skip to content

Commit

Permalink
fix(checkbox): allow overriding of theme props through attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
casserni committed Nov 27, 2018
1 parent 27ac0d9 commit 92fac6f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import noop = require('lodash/noop');
import * as React from 'react';

import { Box } from './Box';
import { Box, IBoxProps } from './Box';
import { Flex } from './Flex';
import { Icon } from './Icon';
import { styled } from './utils';
Expand All @@ -14,10 +14,12 @@ export interface ICheckboxProps {
width?: string;
height?: string;
onChange?: (checked: boolean) => void;

attributes?: IBoxProps;
}

export const BasicCheckbox = (props: ICheckboxProps) => {
const { id, className, width, height, disabled, onChange = noop } = props;
const { id, className, width, height, disabled, onChange = noop, attributes } = props;

const [checked, setValue] = React.useState(props.checked || false);
const isChecked = props.hasOwnProperty('checked') ? props.checked : checked;
Expand All @@ -44,7 +46,7 @@ export const BasicCheckbox = (props: ICheckboxProps) => {
radius="@md"
items="center"
justify="center"
bg={isChecked ? '@toggle.checked.bg' : '@toggle.bg'}
bg={isChecked ? '@checkbox.checked.bg' : '@checkbox.bg'}
cursor={disabled ? 'not-allowed' : 'pointer'}
width={width || '20px'}
height={height || '20px'}
Expand All @@ -53,8 +55,9 @@ export const BasicCheckbox = (props: ICheckboxProps) => {
fontSize: '14px',
transition: 'background-color .15s ease-in-out',
}}
{...attributes}
>
{isChecked && <Icon icon="check" fg="@toggle.checked.fg" />}
{isChecked && <Icon icon="check" fg="@checkbox.checked.fg" />}
</Flex>
</Box>
);
Expand Down

0 comments on commit 92fac6f

Please sign in to comment.