Skip to content
Merged
Show file tree
Hide file tree
Changes from 140 commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
b686844
Setup card2
coderitual Mar 3, 2023
b60d904
Mark legacy card as a deprecated
coderitual Mar 6, 2023
e85cafb
Extract clickable component
coderitual Mar 6, 2023
cd4c8fd
Add basic behaviour
coderitual Mar 6, 2023
06f4a46
Change size
coderitual Mar 6, 2023
eea5129
Change naming convention for card
coderitual Mar 10, 2023
a06eac5
Add radio variant for API evalation
coderitual Mar 10, 2023
daa77a5
Add card checkbox template
coderitual Mar 13, 2023
d9f853d
Add checkbox for testing
coderitual Mar 14, 2023
5fc75a7
Add checkbox indicator
coderitual Mar 14, 2023
c807fc4
Use default checkbox indicator if not provided
coderitual Mar 20, 2023
7744571
Add checkbox indicator
coderitual Mar 21, 2023
5ad87d6
Add prop types
coderitual Mar 21, 2023
4ea9c32
Remove unnecessaary comment
coderitual Mar 21, 2023
b80229b
Remove unnecesasry type import
coderitual Mar 21, 2023
f76072e
Remove indicator input from dom tree
coderitual Mar 21, 2023
32c4a27
Temp change class name for card
coderitual Mar 22, 2023
3d24783
Add slots positions
coderitual Mar 22, 2023
9b781cf
Change story
coderitual Mar 22, 2023
78e083f
Add outline and solid variants
coderitual Mar 22, 2023
c37e32e
Add css colors
coderitual Mar 22, 2023
723b341
Add comment
coderitual Mar 22, 2023
d6934b1
Override checkbox color
coderitual Mar 22, 2023
cc30356
Add bg color to card
coderitual Mar 23, 2023
97bbdfc
Add dev stories to card checkbox
coderitual Mar 23, 2023
8f3c583
Remove user select
coderitual Mar 23, 2023
b139e10
Add all variants to states table
coderitual Mar 23, 2023
120d5b2
Add story with indicator position
coderitual Mar 23, 2023
01003b7
Add states
coderitual Mar 23, 2023
8bae397
add disabled data state
coderitual Mar 23, 2023
d4e5fdf
Override checkbox check color
coderitual Mar 23, 2023
49504ed
Change story table
coderitual Mar 23, 2023
a1b8d59
Handle indicator color for disabled and invalid
coderitual Mar 23, 2023
738122c
Change indicator position
coderitual Mar 23, 2023
357c132
Add focus style
coderitual Mar 23, 2023
c886fa4
Add js docs
coderitual Mar 23, 2023
00fcf03
Add basic tests
coderitual Mar 23, 2023
4560604
Fix type
coderitual Mar 23, 2023
198b16b
Change doc
coderitual Mar 24, 2023
0f34a7e
Add focus state
coderitual Mar 24, 2023
7fe266d
Add focus state
coderitual Mar 24, 2023
b4485d2
Use box shadow instead of outline
coderitual Mar 24, 2023
628d98f
Remove unnecessary focus part
coderitual Mar 24, 2023
81ff648
Focus
coderitual Mar 24, 2023
a4843f9
Add animated icons
coderitual Mar 24, 2023
f86e013
Add animated examples
coderitual Mar 24, 2023
0645d99
Add more cards
coderitual Mar 24, 2023
b391b52
Update story
coderitual Mar 24, 2023
88dac64
Change default story
coderitual Mar 24, 2023
3b27fde
Remove unnecessary packages
coderitual Mar 24, 2023
5224faa
Fix yarn.lock
coderitual Mar 24, 2023
1efc2e4
Add ios event to press state
coderitual Mar 27, 2023
3d400f1
Add gap to stories
coderitual Mar 27, 2023
47a6d94
Change label structure
coderitual Mar 27, 2023
f29ff53
Update physics animation
coderitual Mar 27, 2023
6153b7b
Add focus
coderitual Apr 4, 2023
deb68b3
Add focus on keyboard only
coderitual Apr 4, 2023
18615af
Remove unecessary css variables
coderitual Apr 4, 2023
4d89b27
Add more state to atributes
coderitual Apr 6, 2023
da8cafe
Remove redundant style
coderitual Apr 7, 2023
5d4f93e
Fix hovering over invalid checkbox
coderitual Apr 7, 2023
d804a53
Sync hover animations
coderitual Apr 7, 2023
9d77583
Add card radio
coderitual Apr 7, 2023
5e5b12d
Add stories for radio
coderitual Apr 21, 2023
95596bb
Change indicator default position
coderitual Apr 21, 2023
66b69a2
Change checkbox bg color
coderitual Apr 21, 2023
a95c52e
Add shade hex color function
coderitual Apr 24, 2023
ede2872
Change section name
coderitual Apr 24, 2023
39bc24d
Customise colors
coderitual Apr 24, 2023
762dfd4
Rename components
coderitual May 4, 2023
45241be
Refactor components naming
coderitual May 4, 2023
2181f3c
Fix colors in radio indicator
coderitual May 4, 2023
d34d8d6
Adjust docs
coderitual May 4, 2023
463e883
Fix radio isPristine check
coderitual May 4, 2023
7361c74
Revert "Fix radio isPristine check"
coderitual May 4, 2023
bcb4f96
Use fake borders on solid variant
coderitual May 5, 2023
41157ac
Add check on hover style
coderitual May 5, 2023
807a4d4
Add border colors
coderitual May 5, 2023
cfa368c
Adjust ligtht and dark colors
coderitual May 5, 2023
e302ac9
Remove unused var
coderitual May 5, 2023
7e7909c
Remove tap highlight from ios
coderitual May 5, 2023
8ef6736
Fix stories
coderitual May 8, 2023
efafa56
Add card radio story
coderitual May 8, 2023
18a86a1
Add card radio group
coderitual May 9, 2023
ce3294c
Change default story to CardRadiogroup
coderitual May 9, 2023
a58e81e
Refactor Card Radio to rely on Card Radio Group
coderitual May 9, 2023
c5dd2ee
Add jsdocs
coderitual May 9, 2023
786a684
Import required type
coderitual May 9, 2023
950a03c
Add direction
coderitual May 9, 2023
5006a59
Pass required props to indicators
coderitual May 9, 2023
f3d2c63
Fix type err
coderitual May 9, 2023
ea96f6b
Clean up code
coderitual May 9, 2023
6bc1190
Fix types and tests
coderitual May 9, 2023
812ef61
Change error message
coderitual May 10, 2023
acc82b1
Handle indeterminate state
coderitual May 10, 2023
6af3093
Fix card radio styles and adjust properties mapping
coderitual May 10, 2023
48e4fd6
Add state dark to radio
coderitual May 10, 2023
ebe4d74
Fix radio circle inside color
coderitual May 10, 2023
c042c5d
Add radio group tests
coderitual May 11, 2023
6295cff
Fix test
coderitual May 11, 2023
73f0e91
Fix tests
coderitual May 11, 2023
0f82149
Fix tests
coderitual May 11, 2023
1c77747
Add card radio tests
coderitual May 11, 2023
5c829ec
Improve Card radio test
coderitual May 11, 2023
27ee45f
Fix card radio tests
coderitual May 11, 2023
899a5c4
Add more tests to card radio
coderitual May 11, 2023
012d051
Remove Card export only component
coderitual May 11, 2023
6613236
Add chromatic
coderitual May 11, 2023
c6dddc7
Change folders
coderitual May 11, 2023
8649f4b
Add export
coderitual May 11, 2023
cdaa678
Revert "Change folders"
coderitual May 11, 2023
04933be
Change name
coderitual May 11, 2023
e9ece51
Add states light to checkbox
coderitual May 11, 2023
8ea14fc
Use compound components naming
coderitual May 12, 2023
95c5bc0
Add subcomponents
coderitual May 12, 2023
6fce7a8
Fix ts
coderitual May 12, 2023
9fbf427
Add custom images
coderitual May 15, 2023
ca90fc8
Add hacky fix to border radius artifact
coderitual May 15, 2023
fc9aaae
Remove clip-path
coderitual May 15, 2023
2afb61f
Change border
coderitual May 16, 2023
b4728b2
Add accessibility docs do card checkbox
coderitual May 16, 2023
8ef2ad5
Add a11y rules to card radio
coderitual May 16, 2023
24afc32
Add tests to card checkbox
coderitual May 17, 2023
b126479
Add a11y docs to cardradiogroup
coderitual May 17, 2023
c888b61
Add tests to radio, fix checkbox and radio
coderitual May 18, 2023
874f56b
Remove utils
coderitual May 18, 2023
a0ebdf1
Add focus state configuration
coderitual May 18, 2023
8958751
Add prop documentation
coderitual May 18, 2023
678d937
Fix direction in passing to flex
coderitual May 18, 2023
f14a51c
Add customisation section in mdx
coderitual May 18, 2023
c5325c5
Adjust focus color
coderitual May 18, 2023
8e13100
Fox controlled state in card checkbox
coderitual May 18, 2023
1c18d00
Adjust card checkbox stories
coderitual May 18, 2023
fcc4058
Add hover stories
coderitual May 18, 2023
9d14310
Check chromatic story
coderitual May 19, 2023
f1ac389
Add chromatic stories
coderitual May 19, 2023
b606172
Improve stories in card radio
coderitual May 19, 2023
6379260
Add def state
coderitual May 19, 2023
0ccc539
Merge remote-tracking branch 'origin/master' into card-component
coderitual May 19, 2023
b950d14
Merge remote-tracking branch 'origin/master' into card-component
coderitual May 19, 2023
63566fa
Review
coderitual May 19, 2023
643036a
Fix comment
coderitual May 19, 2023
cef1c49
Improve animated story for radio
coderitual May 19, 2023
d86eefe
Use padding box for bg clip
coderitual May 19, 2023
b727efe
Fix story wrap in radio group
coderitual May 19, 2023
6a5c44b
Fix card radio story
coderitual May 20, 2023
84777ae
Use outer background instead of border
coderitual May 22, 2023
6d62720
Add bg and border positon
coderitual May 22, 2023
913fd72
Revert "Add bg and border positon"
coderitual May 22, 2023
e0033de
Revert "Use outer background instead of border"
coderitual May 22, 2023
6b8052f
Use outer background instead of border
coderitual May 22, 2023
8d6d836
Code review
coderitual May 22, 2023
4314773
Fix story
coderitual May 22, 2023
a0b12a0
Code review
coderitual May 22, 2023
9ccb9be
Code review
coderitual May 22, 2023
fa9cd0e
Code review
coderitual May 22, 2023
3a7cb4f
Fix clicking on border
coderitual May 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file added .storybook/public/images/avatar_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .storybook/public/images/avatar_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions .storybook/public/images/calipers.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .storybook/public/images/image_1.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .storybook/public/images/image_2.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion deprecated.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{"componentName": "HeaderContent", "className": "sg-header__content"},
{"componentName": "HeaderLeft", "className": "sg-header__left"},
{"componentName": "HeaderMiddle", "className": "sg-header__middle"},
{"componentName": "HeaderRight", "className": "sg-header__right"}
{"componentName": "HeaderRight", "className": "sg-header__right"},
{"componentName": "Card", "className": "sg-card"}
]
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@hot-loader/react-dom": "^16.8.6",
"@khanacademy/flow-to-ts": "^0.5.2",
"@microsoft/api-extractor": "^7.33.8",
"@rive-app/react-canvas": "^3.0.38",
"@storybook/addon-a11y": "^6.5.13",
"@storybook/addon-actions": "^6.5.13",
"@storybook/addon-docs": "^6.5.13",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as CardCheckbox from './CardCheckbox.stories.mdx';
import {generateChromaticStory} from '../../chromatic/utils';

export const Default = generateChromaticStory(CardCheckbox, {
storiesToHover: ['statesDark', 'statesLight'],
});
const {includeStories, ...meta} = CardCheckbox.default;

export default meta;
153 changes: 153 additions & 0 deletions src/components/card-interactive/CardCheckbox.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
import * as React from 'react';
import CardCheckbox from './CardCheckbox';
import {render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import {testA11y} from '../../axe';

describe('<CardCheckbox />', () => {
it('renders unchecked checkbox input, without label', () => {
const checkbox = render(<CardCheckbox />);
const checkboxInput = checkbox.getByRole('checkbox') as HTMLInputElement;

expect(checkboxInput.checked).toBe(false);
expect(checkbox.queryByLabelText('my label')).not.toBeInTheDocument();
});

it('renders CardRadio with accessible name and checkbox role', () => {
const label = 'Option A';

render(<CardCheckbox>{label}</CardCheckbox>);
const checkboxInput = screen.getByRole('checkbox', {
name: label,
}) as HTMLInputElement;

expect(checkboxInput).toBeInTheDocument();
expect(checkboxInput.checked).toBe(false);
});

it('does not allow checking disabled item', () => {
render(<CardCheckbox disabled>Option A</CardCheckbox>);
userEvent.click(screen.getByLabelText('Option A'));
expect(screen.getByLabelText('Option A')).not.toBeChecked();
});

it('checks/unchecks when either checkbox, input or label is clicked or space is pressed', () => {
const checkbox = render(<CardCheckbox>my label</CardCheckbox>);
const checkboxInput = checkbox.getByRole('checkbox') as HTMLInputElement;

expect(checkboxInput.checked).toBe(false);
userEvent.click(checkboxInput);
expect(checkboxInput).toEqual(document.activeElement);

expect(checkboxInput.checked).toBe(true);
userEvent.keyboard('{space}');
expect(checkboxInput.checked).toBe(false);
userEvent.click(checkbox.getByText('my label'));
expect(checkboxInput.checked).toBe(true);
});

it('allows aria-labbelledby to override accessible name', () => {
render(
<CardCheckbox aria-labelledby="labelid">
Option A<span id="labelid">Custom Label Option A</span>
</CardCheckbox>
);

const checkboxInput = screen.getByRole('checkbox', {
name: 'Custom Label Option A',
}) as HTMLInputElement;

expect(checkboxInput).toBeInTheDocument();
});

it('allows descriibedby to define accessible description', () => {
render(
<CardCheckbox aria-describedby="descriptionid">
Option A<span id="descriptionid">Custom Description Option A</span>
</CardCheckbox>
);

const checkboxInput = screen.getByRole('checkbox', {
description: 'Custom Description Option A',
}) as HTMLInputElement;

expect(checkboxInput).toBeInTheDocument();
});

it('it renders as checked by default', () => {
const checkbox = render(
<CardCheckbox defaultChecked>my label</CardCheckbox>
);
const checkboxInput = checkbox.getByRole('checkbox') as HTMLInputElement;

expect(checkboxInput.checked).toBe(true);
});

it('renders as unchecked by default', () => {
const checkbox = render(
<CardCheckbox defaultChecked={false}>my label</CardCheckbox>
);
const checkboxInput = checkbox.getByRole('checkbox') as HTMLInputElement;

expect(checkboxInput.checked).toBe(false);
});

it('works in controlled mode', () => {
const ControlledCheckbox = () => {
const [checked, setChecked] = React.useState(false);

return (
<CardCheckbox
checked={checked}
onChange={() => setChecked(val => !val)}
aria-labelledby="label"
>
<label id="label">placeholder</label>
</CardCheckbox>
);
};

const checkbox = render(<ControlledCheckbox />);
const checkboxInput = checkbox.getByRole('checkbox') as HTMLInputElement;

expect(checkboxInput.checked).toBe(false);
userEvent.click(checkboxInput);
expect(checkboxInput.checked).toBe(true);
userEvent.click(checkboxInput);
expect(checkboxInput.checked).toBe(false);
});

describe('a11y', () => {
it('should have no a11y violations when children is provided', async () => {
await testA11y(
<CardCheckbox aria-labelledby="label">
<label id="label">placeholder</label>
</CardCheckbox>
);
});

it('should have no a11y violations when checked', async () => {
await testA11y(
<CardCheckbox aria-labelledby="label" checked>
<label id="label">placeholder</label>
</CardCheckbox>
);
});

it('should have no a11y violations when disabled', async () => {
await testA11y(
<CardCheckbox aria-labelledby="label" disabled>
<label id="label">placeholder</label>
</CardCheckbox>
);
});

it('should have no a11y violations when required', async () => {
await testA11y(
<CardCheckbox aria-labelledby="label" required>
<label id="label">placeholder</label>
</CardCheckbox>
);
});
});
});
Loading