Skip to content
This repository has been archived by the owner on Mar 31, 2021. It is now read-only.

Commit

Permalink
Fixup disabled Checkbox and Radio
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Oct 26, 2018
1 parent 91dc8df commit 786ef92
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/Checkbox/Checkbox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Make the checkbox disabled with the `disabled` prop.

<Playground>
<Checkbox disabled label="Click me" />
<Checkbox checked disabled label="Click me" />
</Playground>

## States
Expand Down
3 changes: 3 additions & 0 deletions src/Checkbox/styled.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export const HiddenCheckbox = HiddenInput({
transform: rotate(45deg);
width: 6px;
`,
disabledTickCss: css`
border-color: ${palette('grayLighter')};
`,
themePrefix: 'Checkbox'
});

Expand Down
3 changes: 2 additions & 1 deletion src/Radio/Radio.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import Radio from './index';
Make the Radio disabled with the `disabled` prop.

<Playground>
<Radio disabled name="weather" label="Sunny" />
<Radio disabled name="hasFannypack" label="Yes" />
<Radio checked disabled name="hasFannypack" label="No" />
</Playground>

## States
Expand Down
3 changes: 3 additions & 0 deletions src/Radio/styled.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export const HiddenRadio = HiddenInput({
transform: translate(-50%, -50%);
width: 8px;
`,
disabledTickCss: css`
background: ${palette('grayLighter')};
`,
themePrefix: 'Radio'
});

Expand Down
10 changes: 7 additions & 3 deletions src/_utils/HiddenInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { palette, theme } from 'styled-tools';
import { tint } from 'polished';
import Input from 'reakit/Input';

export default ({ Icon, tickCss, themePrefix }) => styled(Input)`
export default ({ Icon, disabledTickCss, tickCss, themePrefix }) => styled(Input)`
clip: rect(0, 0, 0, 0);
height: 1px;
margin: -1px;
Expand All @@ -27,9 +27,10 @@ export default ({ Icon, tickCss, themePrefix }) => styled(Input)`
${theme(`${themePrefix}.icon.focus`)};
}
}
&:checked + ${Icon} {
&:not([disabled]):checked + ${Icon} {
border-color: ${props => tint(0.3, palette('primary')(props))};
}
&:checked + ${Icon} {
& {
${props =>
props.state &&
Expand All @@ -47,4 +48,7 @@ export default ({ Icon, tickCss, themePrefix }) => styled(Input)`
${theme(`${themePrefix}.icon.checked`)};
}
}
&[disabled]:checked + ${Icon}::before {
${disabledTickCss};
}
`;

0 comments on commit 786ef92

Please sign in to comment.