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

Commit

Permalink
style(checkbox): update checkbox styling (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbuchann authored and Méril committed Jan 9, 2019
1 parent 1edc154 commit 062f0fb
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 11 deletions.
22 changes: 17 additions & 5 deletions src/Atoms/Inputs/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,21 @@ const Wrapper = styled.div`
outline: 1px solid transparent;
}
input:disabled + label::after,
input:checked + label::after {
opacity: 1;
transform: scale(1) rotate(-45deg);
}
input:disabled + label::before {
background-color: ${theme('inputCheckboxColorDisabled')};
border: none;
}
input:disabled + label::after {
border-left: 2px solid ${theme('inputCheckboxCheckColorDisabled')};
border-bottom: 2px solid ${theme('inputCheckboxCheckColorDisabled')};
}
`

type InputPropsType = { +name?: string, +type: HtmlInputType } & E2ePropType
Expand Down Expand Up @@ -61,25 +72,26 @@ export const CheckboxLabel: ReactComponentFunctional<{
&::before {
background-color: ${theme('inputBackgroundColor')};
border: 2px solid ${theme('inputBorderColor')};
border: 1px solid ${theme('inputBorderColor')};
box-sizing: border-box;
content: '';
height: 16px;
left: 1px;
position: absolute;
top: calc(50% - 0.5rem);
width: 16px;
border-radius: 2px;
}
&::after {
background: none;
border-left: 1px solid ${theme('inputBackgroundColor')};
border-bottom: 1px solid ${theme('inputBackgroundColor')};
border-left: 2px solid ${theme('inputBackgroundColor')};
border-bottom: 2px solid ${theme('inputBackgroundColor')};
box-sizing: border-box;
content: '';
height: 5px;
left: 0.3125rem;
margin-top: -0.1875rem;
left: 5px;
margin-top: -3px;
position: absolute;
opacity: 0;
top: 50%;
Expand Down
5 changes: 4 additions & 1 deletion src/Atoms/Inputs/Input.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ storiesOf('Atoms/Inputs/Input', module)
</>
))
.add('with checkbox', () => (
<Input label="Checkbox" name="test" type="checkbox" />
<div>
<Input disabled label="Disabled Checkbox" name="test" type="checkbox" />
<Input label="Checkbox" name="test2" type="checkbox" />
</div>
))
.add('with radio', () => (
<div>
Expand Down
22 changes: 17 additions & 5 deletions src/Atoms/Inputs/__snapshots__/Input.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -804,13 +804,24 @@ exports[`Input should render correctly with type="checkbox" 1`] = `
outline: 1px solid transparent;
}
.c0 input:disabled + label::after,
.c0 input:checked + label::after {
opacity: 1;
-webkit-transform: scale(1) rotate(-45deg);
-ms-transform: scale(1) rotate(-45deg);
transform: scale(1) rotate(-45deg);
}
.c0 input:disabled + label::before {
background-color: rgba(0,0,0,0.10);
border: none;
}
.c0 input:disabled + label::after {
border-left: 2px solid #757679;
border-bottom: 2px solid #757679;
}
.c1 {
border: 0;
-webkit-clip: rect(0,0,0,0);
Expand Down Expand Up @@ -844,25 +855,26 @@ exports[`Input should render correctly with type="checkbox" 1`] = `
.c2::before {
background-color: #FFF;
border: 2px solid #CCC;
border: 1px solid #CCC;
box-sizing: border-box;
content: '';
height: 16px;
left: 1px;
position: absolute;
top: calc(50% - 0.5rem);
width: 16px;
border-radius: 2px;
}
.c2::after {
background: none;
border-left: 1px solid #FFF;
border-bottom: 1px solid #FFF;
border-left: 2px solid #FFF;
border-bottom: 2px solid #FFF;
box-sizing: border-box;
content: '';
height: 5px;
left: 0.3125rem;
margin-top: -0.1875rem;
left: 5px;
margin-top: -3px;
position: absolute;
opacity: 0;
top: 50%;
Expand Down
2 changes: 2 additions & 0 deletions src/Tools/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const theme = {
inputBackgroundColorDisabled: palette.gray0,
inputBorderColor: palette.gray2,
inputBorderRadius: borderRadius,
inputCheckboxCheckColorDisabled: palette.gray4,
inputCheckboxColorDisabled: palette.blackAlpha10,
inputCheckedColor: palette.orient,
inputColor: palette.gray5,
inputLabelColor: palette.gray4,
Expand Down

0 comments on commit 062f0fb

Please sign in to comment.