Skip to content

Commit

Permalink
fix(Checkbox): rid of unnessasary padding when label is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ej9x committed Jan 14, 2019
1 parent c0084ec commit d66aaf7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions src/components/Checkbox/Checkbox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { Checkbox } from './Checkbox';
describe('<Checkbox />', () => {
it('should shallow chekbox', () => {
const onChange = jest.fn();
const wrapper = shallow(<Checkbox onChange={ onChange } checked />);
const wrapper = shallow(
<Checkbox onChange={ onChange } label="Label" checked />,
);

expect(wrapper).toMatchInlineSnapshot(`
<Styled(checkboxWrapper)
Expand Down Expand Up @@ -35,12 +37,13 @@ describe('<Checkbox />', () => {
/>
<Styled(checkboxText)
tagName="div"
/>
>
Label
</Styled(checkboxText)>
</Styled(checkboxWrapper)>
`);
});


it('should call onChange callback with false', () => {
const onChange = jest.fn();
const wrapper = mount(<Checkbox onChange={ onChange } checked />);
Expand All @@ -49,7 +52,6 @@ describe('<Checkbox />', () => {
expect(onChange.mock.calls[0][0]).toBe(false);
});


it('should call onChange callback with true', () => {
const onChange = jest.fn();
const wrapper = mount(<Checkbox onChange={ onChange } />);
Expand All @@ -58,7 +60,6 @@ describe('<Checkbox />', () => {
expect(onChange.mock.calls[0][0]).toBe(true);
});


it('should not call onChange callback with disabled prop', () => {
const onChange = jest.fn();
const wrapper = mount(<Checkbox onChange={ onChange } disabled />);
Expand Down
6 changes: 3 additions & 3 deletions src/components/Checkbox/Checkbox.theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ const CheckboxTag = createStyledTag(`${name}Tag`, {
display: 'none',
});

const CheckboxTextTag = createStyledTag(`${name}Text`, {
paddingLeft: '12px',
const CheckboxTextTag = createStyledTag(`${name}Text`, props => ({
paddingLeft: props.label ? '12px' : '0',
cursor: 'pointer',
});
}));

export { theme, CheckboxSquareTag, CheckboxTag, CheckboxWrapperTag, CheckboxTextTag, CheckboxIconTag };

0 comments on commit d66aaf7

Please sign in to comment.