Skip to content

Commit 92fac6f

Browse files
committed
fix(checkbox): allow overriding of theme props through attributes
1 parent 27ac0d9 commit 92fac6f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Checkbox.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import noop = require('lodash/noop');
22
import * as React from 'react';
33

4-
import { Box } from './Box';
4+
import { Box, IBoxProps } from './Box';
55
import { Flex } from './Flex';
66
import { Icon } from './Icon';
77
import { styled } from './utils';
@@ -14,10 +14,12 @@ export interface ICheckboxProps {
1414
width?: string;
1515
height?: string;
1616
onChange?: (checked: boolean) => void;
17+
18+
attributes?: IBoxProps;
1719
}
1820

1921
export const BasicCheckbox = (props: ICheckboxProps) => {
20-
const { id, className, width, height, disabled, onChange = noop } = props;
22+
const { id, className, width, height, disabled, onChange = noop, attributes } = props;
2123

2224
const [checked, setValue] = React.useState(props.checked || false);
2325
const isChecked = props.hasOwnProperty('checked') ? props.checked : checked;
@@ -44,7 +46,7 @@ export const BasicCheckbox = (props: ICheckboxProps) => {
4446
radius="@md"
4547
items="center"
4648
justify="center"
47-
bg={isChecked ? '@toggle.checked.bg' : '@toggle.bg'}
49+
bg={isChecked ? '@checkbox.checked.bg' : '@checkbox.bg'}
4850
cursor={disabled ? 'not-allowed' : 'pointer'}
4951
width={width || '20px'}
5052
height={height || '20px'}
@@ -53,8 +55,9 @@ export const BasicCheckbox = (props: ICheckboxProps) => {
5355
fontSize: '14px',
5456
transition: 'background-color .15s ease-in-out',
5557
}}
58+
{...attributes}
5659
>
57-
{isChecked && <Icon icon="check" fg="@toggle.checked.fg" />}
60+
{isChecked && <Icon icon="check" fg="@checkbox.checked.fg" />}
5861
</Flex>
5962
</Box>
6063
);

0 commit comments

Comments
 (0)