Skip to content

Commit

Permalink
Merge pull request #412 from vrk-kpa/fix/checkbox-adjustments
Browse files Browse the repository at this point in the history
[Feature] Checkbox adjustments
  • Loading branch information
ketsappi authored Nov 26, 2020
2 parents dccf99d + fcdaba6 commit de3ba04
Show file tree
Hide file tree
Showing 11 changed files with 331 additions and 271 deletions.
12 changes: 12 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,15 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


The MIT License (MIT)

Copyright (c) 2018-present, React Training LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

192 changes: 0 additions & 192 deletions src/components/Form/Checkbox.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export {
DropdownItem,
DropdownItemProps,
} from './Dropdown/Dropdown';
export { Checkbox, CheckboxProps } from './Form/Checkbox';
export {
Toggle,
ToggleProps,
Expand Down
16 changes: 4 additions & 12 deletions src/core/Form/Checkbox/Checkbox.baseStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ const errorStyles = ({ theme }: SuomifiThemeProp) => css`
fill: ${theme.colors.alertBase};
}
}
& .fi-checkbox_status {
color: ${theme.colors.alertBase};
}
}
`;

Expand Down Expand Up @@ -85,7 +82,7 @@ const largeVariantStyles = ({ theme }: SuomifiThemeProp) => css`
top: 4px;
}
}
& .fi-checkbox_hintText {
& .fi-hint-text {
padding-left: ${theme.spacing.xxl};
}
}
Expand Down Expand Up @@ -139,20 +136,15 @@ export const baseStyles = withSuomifiTheme(
z-index: -9999;
}
& .fi-checkbox_hintText {
display: block;
& .fi-hint-text {
padding-left: ${theme.spacing.l};
${theme.typography.bodyTextSmall};
color: ${theme.colors.depthDark1};
margin-bottom: 0;
}
& .fi-checkbox_status {
& .fi-status-text {
display: block;
margin-top: ${theme.spacing.xxs};
color: ${theme.colors.blackBase};
font-size: 14px;
line-height: 18px;
font-weight: 600;
}
${largeVariantStyles({ theme })};
Expand Down
2 changes: 1 addition & 1 deletion src/core/Form/Checkbox/Checkbox.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
import { Checkbox } from './Checkbox';
import { Checkbox } from 'suomifi-ui-components';
import { useState } from 'react';

const [checked, setChecked] = useState(false);
Expand Down
64 changes: 64 additions & 0 deletions src/core/Form/Checkbox/Checkbox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,68 @@ describe('props', () => {
expect(container.firstChild).toMatchSnapshot();
});
});

describe('hintText', () => {
it('has the hint text element', () => {
const { getByText } = render(
<Checkbox hintText="Example hint text">Text</Checkbox>,
);
expect(getByText('Example hint text')).toHaveClass('fi-hint-text');
});

it('will be added to input aria-describedby', () => {
const { getByRole } = render(
<Checkbox id="123" hintText="Example hint text">
Text
</Checkbox>,
);
expect(getByRole('checkbox')).toHaveAttribute(
'aria-describedby',
'123-hintText',
);
});
});

describe('statusText', () => {
it('has the status text element', () => {
const { getByText } = render(
<Checkbox statusText="Example status text">Text</Checkbox>,
);
const statusText = getByText('Example status text');
expect(statusText).toHaveClass('fi-status-text');
});

it('will be added to input aria-describedby', () => {
const { getByRole } = render(
<Checkbox id="123" statusText="Example status text">
Text
</Checkbox>,
);
expect(getByRole('checkbox')).toHaveAttribute(
'aria-describedby',
'123-statusText',
);
});
});

describe('disabled', () => {
it('has disabled attribute and classname', () => {
const { container, getByRole } = render(
<Checkbox disabled statusText="Example status text">
Text
</Checkbox>,
);
expect(container.firstChild).toHaveClass('fi-checkbox--disabled');
expect(getByRole('checkbox')).toHaveAttribute('disabled');
});
});

describe('className', () => {
it('has the given custom className', () => {
const { container } = render(
<Checkbox className="custom-style">Text</Checkbox>,
);
expect(container.firstChild).toHaveClass('custom-style');
});
});
});
Loading

0 comments on commit de3ba04

Please sign in to comment.