reshaped 3.3.11 → 3.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/bundle.css +1 -1
- package/dist/bundle.d.ts +1 -1
- package/dist/bundle.js +16 -17
- package/dist/cjs/themes/_generator/utilities/generateColors.d.ts +1 -1
- package/dist/cjs/themes/_generator/utilities/generateColors.js +3 -2
- package/dist/cjs/themes/_generator/utilities/tests/color.test.js +32 -31
- package/dist/cjs/themes/slate/theme.css +1 -1
- package/dist/components/Accordion/tests/Accordion.stories.d.ts +30 -8
- package/dist/components/Accordion/tests/Accordion.stories.js +172 -119
- package/dist/components/ActionBar/tests/ActionBar.stories.d.ts +12 -3
- package/dist/components/ActionBar/tests/ActionBar.stories.js +51 -36
- package/dist/components/ActionBar/tests/ActionBar.test.stories.d.ts +15 -0
- package/dist/components/ActionBar/tests/ActionBar.test.stories.js +26 -0
- package/dist/components/Actionable/Actionable.js +1 -1
- package/dist/components/Actionable/tests/Actionable.stories.d.ts +19 -5
- package/dist/components/Actionable/tests/Actionable.stories.js +88 -63
- package/dist/components/Actionable/tests/Actionable.test.stories.d.ts +32 -0
- package/dist/components/Actionable/tests/Actionable.test.stories.js +130 -0
- package/dist/components/Alert/Alert.js +1 -1
- package/dist/components/Alert/tests/Alert.stories.d.ts +12 -3
- package/dist/components/Alert/tests/Alert.stories.js +51 -86
- package/dist/components/Alert/tests/Alert.test.stories.d.ts +15 -0
- package/dist/components/Alert/tests/Alert.test.stories.js +26 -0
- package/dist/components/Autocomplete/Autocomplete.js +9 -2
- package/dist/components/Autocomplete/tests/Autocomplete.stories.d.ts +6 -2
- package/dist/components/Autocomplete/tests/Autocomplete.stories.js +94 -111
- package/dist/components/Autocomplete/tests/Autocomplete.test.stories.d.ts +23 -0
- package/dist/components/Autocomplete/tests/Autocomplete.test.stories.js +86 -0
- package/dist/components/Avatar/Avatar.js +1 -1
- package/dist/components/Avatar/tests/Avatar.stories.d.ts +14 -4
- package/dist/components/Avatar/tests/Avatar.stories.js +94 -80
- package/dist/components/Avatar/tests/Avatar.test.stories.d.ts +17 -0
- package/dist/components/Avatar/tests/Avatar.test.stories.js +39 -0
- package/dist/components/Badge/tests/Badge.stories.d.ts +33 -8
- package/dist/components/Badge/tests/Badge.stories.js +238 -212
- package/dist/components/Badge/tests/Badge.test.stories.d.ts +20 -0
- package/dist/components/Badge/tests/Badge.test.stories.js +44 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +2 -2
- package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts +1 -0
- package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.d.ts +24 -5
- package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.js +114 -95
- package/dist/components/Breadcrumbs/tests/Breadcrumbs.test.stories.d.ts +23 -0
- package/dist/components/Breadcrumbs/tests/Breadcrumbs.test.stories.js +76 -0
- package/dist/components/Button/Button.js +5 -2
- package/dist/components/Button/Button.module.css +1 -1
- package/dist/components/Button/Button.types.d.ts +1 -0
- package/dist/components/Button/tests/Button.stories.d.ts +2 -2
- package/dist/components/Button/tests/Button.stories.js +77 -74
- package/dist/components/Button/tests/Button.test.stories.d.ts +27 -0
- package/dist/components/Button/tests/Button.test.stories.js +112 -0
- package/dist/components/Calendar/tests/Calendar.test.stories.d.ts +26 -0
- package/dist/components/Calendar/tests/Calendar.test.stories.js +161 -0
- package/dist/components/Card/tests/Card.stories.d.ts +0 -1
- package/dist/components/Card/tests/Card.stories.js +0 -11
- package/dist/components/Card/tests/Card.test.stories.d.ts +35 -0
- package/dist/components/Card/tests/Card.test.stories.js +54 -0
- package/dist/components/Carousel/Carousel.js +52 -4
- package/dist/components/Carousel/Carousel.types.d.ts +4 -0
- package/dist/components/Carousel/CarouselControl.js +1 -1
- package/dist/components/Carousel/tests/Carousel.stories.d.ts +23 -4
- package/dist/components/Carousel/tests/Carousel.stories.js +199 -102
- package/dist/components/Checkbox/tests/Checkbox.test.stories.d.ts +25 -0
- package/dist/components/Checkbox/tests/Checkbox.test.stories.js +104 -0
- package/dist/components/CheckboxGroup/tests/CheckboxGroup.test.stories.d.ts +22 -0
- package/dist/components/CheckboxGroup/tests/CheckboxGroup.test.stories.js +78 -0
- package/dist/components/Container/tests/Container.stories.d.ts +12 -3
- package/dist/components/Container/tests/Container.stories.js +50 -31
- package/dist/components/Container/tests/Container.test.stories.d.ts +15 -0
- package/dist/components/Container/tests/Container.test.stories.js +26 -0
- package/dist/components/ContextMenu/ContextMenu.js +13 -9
- package/dist/components/ContextMenu/tests/ContextMenu.stories.js +2 -3
- package/dist/components/ContextMenu/tests/ContextMenu.test.stories.d.ts +26 -0
- package/dist/components/ContextMenu/tests/ContextMenu.test.stories.js +53 -0
- package/dist/components/Dismissible/Dismissible.js +1 -1
- package/dist/components/Dismissible/tests/Dismissible.stories.d.ts +10 -3
- package/dist/components/Dismissible/tests/Dismissible.stories.js +51 -34
- package/dist/components/Dismissible/tests/Dismissible.test.stories.d.ts +19 -0
- package/dist/components/Dismissible/tests/Dismissible.test.stories.js +42 -0
- package/dist/components/Divider/tests/Divider.test.stories.d.ts +18 -0
- package/dist/components/Divider/tests/Divider.test.stories.js +47 -0
- package/dist/components/DropdownMenu/tests/DropdownMenu.test.stories.d.ts +37 -0
- package/dist/components/DropdownMenu/tests/DropdownMenu.test.stories.js +117 -0
- package/dist/components/FileUpload/tests/FileUpload.test.stories.d.ts +22 -0
- package/dist/components/FileUpload/tests/FileUpload.test.stories.js +52 -0
- package/dist/components/FormControl/FormControlCaption.js +1 -1
- package/dist/components/FormControl/FormControlLabel.js +1 -1
- package/dist/components/FormControl/tests/FormControl.stories.d.ts +11 -5
- package/dist/components/FormControl/tests/FormControl.stories.js +78 -73
- package/dist/components/FormControl/tests/FormControl.test.stories.d.ts +20 -0
- package/dist/components/FormControl/tests/FormControl.test.stories.js +49 -0
- package/dist/components/Grid/tests/Grid.stories.d.ts +20 -5
- package/dist/components/Grid/tests/Grid.stories.js +164 -149
- package/dist/components/Grid/tests/Grid.test.stories.d.ts +19 -0
- package/dist/components/Grid/tests/Grid.test.stories.js +42 -0
- package/dist/components/Hidden/tests/Hidden.stories.d.ts +4 -1
- package/dist/components/Hidden/tests/Hidden.stories.js +28 -25
- package/dist/components/Hidden/tests/Hidden.test.stories.d.ts +15 -0
- package/dist/components/Hidden/tests/Hidden.test.stories.js +20 -0
- package/dist/components/HiddenVisually/tests/HiddenVisually.stories.d.ts +4 -1
- package/dist/components/HiddenVisually/tests/HiddenVisually.stories.js +8 -5
- package/dist/components/HiddenVisually/tests/HiddenVisually.test.stories.d.ts +15 -0
- package/dist/components/HiddenVisually/tests/HiddenVisually.test.stories.js +20 -0
- package/dist/components/Hotkey/tests/Hotkey.test.stories.d.ts +15 -0
- package/dist/components/Hotkey/tests/Hotkey.test.stories.js +26 -0
- package/dist/components/Icon/tests/Icon.stories.d.ts +12 -3
- package/dist/components/Icon/tests/Icon.stories.js +69 -60
- package/dist/components/Icon/tests/Icon.test.stories.d.ts +16 -0
- package/dist/components/Icon/tests/Icon.test.stories.js +35 -0
- package/dist/components/Image/tests/Image.stories.d.ts +24 -5
- package/dist/components/Image/tests/Image.stories.js +95 -75
- package/dist/components/Image/tests/Image.test.stories.d.ts +25 -0
- package/dist/components/Image/tests/Image.test.stories.js +80 -0
- package/dist/components/Link/tests/Link.test.stories.d.ts +29 -0
- package/dist/components/Link/tests/Link.test.stories.js +87 -0
- package/dist/components/Loader/Loader.js +1 -1
- package/dist/components/Loader/Loader.types.d.ts +1 -0
- package/dist/components/Loader/tests/Loader.stories.js +8 -8
- package/dist/components/Loader/tests/Loader.test.stories.d.ts +16 -0
- package/dist/components/Loader/tests/Loader.test.stories.js +32 -0
- package/dist/components/MenuItem/tests/MenuItem.test.stories.d.ts +26 -0
- package/dist/components/MenuItem/tests/MenuItem.test.stories.js +100 -0
- package/dist/components/Modal/tests/Modal.test.stories.d.ts +32 -0
- package/dist/components/Modal/tests/Modal.test.stories.js +149 -0
- package/dist/components/Overlay/tests/Overlay.stories.d.ts +4 -2
- package/dist/components/Overlay/tests/Overlay.stories.js +53 -53
- package/dist/components/Overlay/tests/Overlay.test.stories.d.ts +28 -0
- package/dist/components/Overlay/tests/Overlay.test.stories.js +146 -0
- package/dist/components/Pagination/tests/Pagination.test.stories.d.ts +23 -0
- package/dist/components/Pagination/tests/Pagination.test.stories.js +86 -0
- package/dist/components/PinField/tests/PinField.stories.d.ts +0 -1
- package/dist/components/PinField/tests/PinField.stories.js +10 -19
- package/dist/components/PinField/tests/PinField.test.stories.d.ts +29 -0
- package/dist/components/PinField/tests/PinField.test.stories.js +177 -0
- package/dist/components/Popover/tests/Popover.test.stories.d.ts +40 -0
- package/dist/components/Popover/tests/Popover.test.stories.js +167 -0
- package/dist/components/Progress/Progress.js +2 -2
- package/dist/components/Progress/Progress.types.d.ts +1 -0
- package/dist/components/Progress/tests/Progress.stories.js +10 -10
- package/dist/components/Progress/tests/Progress.test.stories.d.ts +16 -0
- package/dist/components/Progress/tests/Progress.test.stories.js +35 -0
- package/dist/components/Radio/tests/Radio.test.stories.d.ts +30 -0
- package/dist/components/Radio/tests/Radio.test.stories.js +118 -0
- package/dist/components/RadioGroup/tests/RadioGroup.test.stories.d.ts +22 -0
- package/dist/components/RadioGroup/tests/RadioGroup.test.stories.js +78 -0
- package/dist/components/Reshaped/tests/Reshaped.stories.d.ts +33 -0
- package/dist/components/Reshaped/tests/Reshaped.stories.js +88 -0
- package/dist/components/Resizable/Resizable.js +1 -0
- package/dist/components/Resizable/tests/Resizable.stories.d.ts +3 -0
- package/dist/components/Resizable/tests/Resizable.stories.js +4 -0
- package/dist/components/Resizable/tests/Resizable.test.stories.d.ts +19 -0
- package/dist/components/Resizable/tests/Resizable.test.stories.js +25 -0
- package/dist/components/Scrim/tests/Scrim.test.stories.d.ts +15 -0
- package/dist/components/Scrim/tests/Scrim.test.stories.js +25 -0
- package/dist/components/ScrollArea/ScrollArea.js +1 -1
- package/dist/components/ScrollArea/ScrollArea.module.css +1 -1
- package/dist/components/ScrollArea/tests/ScrollArea.stories.d.ts +17 -4
- package/dist/components/ScrollArea/tests/ScrollArea.stories.js +114 -139
- package/dist/components/ScrollArea/tests/ScrollArea.test.stories.d.ts +23 -0
- package/dist/components/ScrollArea/tests/ScrollArea.test.stories.js +66 -0
- package/dist/components/Select/tests/Select.stories.d.ts +1 -1
- package/dist/components/Select/tests/Select.stories.js +5 -12
- package/dist/components/Select/tests/Select.test.stories.d.ts +27 -0
- package/dist/components/Select/tests/Select.test.stories.js +132 -0
- package/dist/components/Skeleton/tests/Skeleton.test.stories.d.ts +15 -0
- package/dist/components/Skeleton/tests/Skeleton.test.stories.js +23 -0
- package/dist/components/Slider/tests/Slider.stories.d.ts +0 -1
- package/dist/components/Slider/tests/Slider.stories.js +8 -9
- package/dist/components/Slider/tests/Slider.test.stories.d.ts +38 -0
- package/dist/components/Slider/tests/Slider.test.stories.js +150 -0
- package/dist/components/Stepper/Stepper.js +1 -1
- package/dist/components/Stepper/tests/Stepper.stories.js +0 -3
- package/dist/components/Stepper/tests/Stepper.test.stories.d.ts +18 -0
- package/dist/components/Stepper/tests/Stepper.test.stories.js +28 -0
- package/dist/components/Switch/tests/Switch.test.stories.d.ts +23 -0
- package/dist/components/Switch/tests/Switch.test.stories.js +79 -0
- package/dist/components/Table/index.d.ts +1 -1
- package/dist/components/Table/tests/Table.stories.d.ts +5 -5
- package/dist/components/Table/tests/Table.test.stories.d.ts +25 -0
- package/dist/components/Table/tests/Table.test.stories.js +93 -0
- package/dist/components/Tabs/tests/Tabs.stories.js +4 -4
- package/dist/components/Tabs/tests/Tabs.test.stories.d.ts +28 -0
- package/dist/components/Tabs/tests/Tabs.test.stories.js +128 -0
- package/dist/components/Text/tests/Text.stories.d.ts +28 -7
- package/dist/components/Text/tests/Text.stories.js +148 -125
- package/dist/components/Text/tests/Text.test.stories.d.ts +18 -0
- package/dist/components/Text/tests/Text.test.stories.js +49 -0
- package/dist/components/TextArea/TextArea.module.css +1 -1
- package/dist/components/TextArea/tests/TextArea.stories.js +1 -1
- package/dist/components/TextArea/tests/TextArea.test.stories.d.ts +29 -0
- package/dist/components/TextArea/tests/TextArea.test.stories.js +99 -0
- package/dist/components/TextField/tests/TextField.stories.js +1 -1
- package/dist/components/TextField/tests/TextField.test.stories.d.ts +29 -0
- package/dist/components/TextField/tests/TextField.test.stories.js +99 -0
- package/dist/components/Theme/tests/Theme.test.stories.d.ts +24 -0
- package/dist/components/Theme/tests/Theme.test.stories.js +133 -0
- package/dist/components/Timeline/tests/Timeline.test.stories.d.ts +18 -0
- package/dist/components/Timeline/tests/Timeline.test.stories.js +32 -0
- package/dist/components/Toast/tests/Toast.test.stories.d.ts +16 -0
- package/dist/components/Toast/tests/Toast.test.stories.js +101 -0
- package/dist/components/Tooltip/tests/Tooltip.stories.js +0 -14
- package/dist/components/Tooltip/tests/Tooltip.test.stories.d.ts +19 -0
- package/dist/components/Tooltip/tests/Tooltip.test.stories.js +40 -0
- package/dist/components/View/View.js +1 -2
- package/dist/components/View/tests/View.stories.d.ts +112 -28
- package/dist/components/View/tests/View.stories.js +1092 -1012
- package/dist/components/View/tests/View.test.stories.d.ts +20 -0
- package/dist/components/View/tests/View.test.stories.js +50 -0
- package/dist/components/_private/Flyout/FlyoutContent.js +1 -1
- package/dist/components/_private/Flyout/tests/Flyout.stories.js +4 -4
- package/dist/components/_private/Flyout/tests/Flyout.test.stories.d.ts +28 -0
- package/dist/components/_private/Flyout/tests/Flyout.test.stories.js +205 -0
- package/dist/components/_private/Portal/tests/Portal.stories.js +1 -1
- package/dist/hooks/_private/useSingletonHotkeys.d.ts +3 -3
- package/dist/hooks/_private/useSingletonHotkeys.js +1 -1
- package/dist/hooks/tests/useDrag.stories.js +1 -0
- package/dist/hooks/tests/useDrag.test.stories.d.ts +26 -0
- package/dist/hooks/tests/useDrag.test.stories.js +120 -0
- package/dist/hooks/tests/useElementId.stories.d.ts +6 -0
- package/dist/hooks/tests/useElementId.stories.js +19 -0
- package/dist/hooks/tests/useHotkeys.test.stories.d.ts +39 -0
- package/dist/hooks/tests/useHotkeys.test.stories.js +119 -0
- package/dist/hooks/tests/useRTL.stories.d.ts +6 -0
- package/dist/hooks/tests/useRTL.stories.js +25 -0
- package/dist/hooks/tests/useResponsiveClientValue.stories.d.ts +9 -1
- package/dist/hooks/tests/useResponsiveClientValue.stories.js +22 -9
- package/dist/hooks/tests/useScrollLock.stories.d.ts +6 -0
- package/dist/hooks/tests/useScrollLock.stories.js +22 -0
- package/dist/hooks/tests/useToggle.stories.d.ts +8 -0
- package/dist/hooks/tests/useToggle.stories.js +54 -0
- package/dist/hooks/useHotkeys.js +0 -2
- package/dist/hooks/useScrollLock.d.ts +1 -0
- package/dist/hooks/useScrollLock.js +7 -3
- package/dist/index.d.ts +1 -1
- package/dist/tests/ShadowDOM.stories.js +1 -1
- package/dist/themes/_generator/tests/themes.stories.d.ts +3 -0
- package/dist/themes/_generator/tests/themes.stories.js +7 -11
- package/dist/themes/_generator/utilities/generateColors.d.ts +1 -1
- package/dist/themes/_generator/utilities/generateColors.js +3 -2
- package/dist/themes/slate/theme.css +1 -1
- package/dist/utilities/helpers.d.ts +1 -0
- package/dist/utilities/helpers.js +3 -0
- package/dist/utilities/scroll/lock.d.ts +1 -0
- package/dist/utilities/scroll/lock.js +3 -3
- package/dist/utilities/scroll/lockSafari.d.ts +1 -1
- package/dist/utilities/scroll/lockSafari.js +4 -5
- package/dist/utilities/scroll/lockStandard.d.ts +4 -1
- package/dist/utilities/scroll/lockStandard.js +7 -2
- package/dist/utilities/storybook/Example.js +1 -2
- package/package.json +42 -41
- package/dist/components/Theme/tests/Theme.stories.d.ts +0 -13
- package/dist/components/Theme/tests/Theme.stories.js +0 -80
- package/dist/utilities/storybook/Example.module.css +0 -1
@@ -15,7 +15,7 @@ export default {
|
|
15
15
|
},
|
16
16
|
};
|
17
17
|
const imgUrl = "https://images.unsplash.com/photo-1632502361954-0dd92ce797db?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1625&q=80";
|
18
|
-
export const
|
18
|
+
export const variantAndColor = () => (<Example>
|
19
19
|
<Example.Item title="variant: solid">
|
20
20
|
<View gap={4} direction="row">
|
21
21
|
<Button onClick={() => { }}>Button</Button>
|
@@ -28,9 +28,6 @@ export const variant = () => (<Example>
|
|
28
28
|
<Button onClick={() => { }} color="positive">
|
29
29
|
Button
|
30
30
|
</Button>
|
31
|
-
<Button onClick={() => { }} color="media">
|
32
|
-
Button
|
33
|
-
</Button>
|
34
31
|
</View>
|
35
32
|
</Example.Item>
|
36
33
|
<Example.Item title="variant: faded">
|
@@ -47,9 +44,6 @@ export const variant = () => (<Example>
|
|
47
44
|
<Button onClick={() => { }} color="positive" variant="faded">
|
48
45
|
Button
|
49
46
|
</Button>
|
50
|
-
<Button onClick={() => { }} color="media" variant="faded">
|
51
|
-
Button
|
52
|
-
</Button>
|
53
47
|
<div style={{ color: "#029CFD" }}>
|
54
48
|
<Button onClick={() => { }} color="inherit" variant="faded">
|
55
49
|
Inherit
|
@@ -71,6 +65,7 @@ export const variant = () => (<Example>
|
|
71
65
|
<Button onClick={() => { }} color="positive" variant="outline">
|
72
66
|
Button
|
73
67
|
</Button>
|
68
|
+
|
74
69
|
<div style={{ color: "#029CFD" }}>
|
75
70
|
<Button onClick={() => { }} color="inherit" variant="outline">
|
76
71
|
Inherit
|
@@ -99,20 +94,32 @@ export const variant = () => (<Example>
|
|
99
94
|
</div>
|
100
95
|
</View>
|
101
96
|
</Example.Item>
|
97
|
+
<Example.Item title="color: media">
|
98
|
+
<View backgroundColor="primary" borderRadius="medium" padding={4} direction="row" gap={4}>
|
99
|
+
<Button onClick={() => { }} color="media">
|
100
|
+
Button
|
101
|
+
</Button>
|
102
|
+
|
103
|
+
<Button onClick={() => { }} color="media" variant="faded">
|
104
|
+
Button
|
105
|
+
</Button>
|
106
|
+
</View>
|
107
|
+
</Example.Item>
|
102
108
|
</Example>);
|
103
109
|
export const icon = () => (<Example>
|
104
|
-
<Example.Item title="icon
|
110
|
+
<Example.Item title="icon">
|
105
111
|
<Button onClick={() => { }} icon={IconZap}>
|
106
112
|
Button
|
107
113
|
</Button>
|
108
114
|
</Example.Item>
|
109
|
-
|
115
|
+
|
116
|
+
<Example.Item title="endIcon">
|
110
117
|
<Button onClick={() => { }} endIcon={IconZap}>
|
111
118
|
Button
|
112
119
|
</Button>
|
113
120
|
</Example.Item>
|
114
121
|
|
115
|
-
<Example.Item title="icon
|
122
|
+
<Example.Item title="icon, endIcon">
|
116
123
|
<Button onClick={() => { }} icon={IconZap} endIcon={IconZap}>
|
117
124
|
Button
|
118
125
|
</Button>
|
@@ -122,40 +129,9 @@ export const icon = () => (<Example>
|
|
122
129
|
<Button onClick={() => { }} icon={IconZap} attributes={{ "aria-label": "Action" }}/>
|
123
130
|
</Example.Item>
|
124
131
|
</Example>);
|
125
|
-
export const elevated = () => (<Example>
|
126
|
-
<Example.Item title="color: neutral, elevated, variant: solid and outline">
|
127
|
-
<View gap={3} direction="row">
|
128
|
-
<Button elevated onClick={() => { }}>
|
129
|
-
Button
|
130
|
-
</Button>
|
131
|
-
<Button elevated variant="outline">
|
132
|
-
Button
|
133
|
-
</Button>
|
134
|
-
</View>
|
135
|
-
</Example.Item>
|
136
|
-
<Example.Item title="color: primary, elevated, variant: solid and outline">
|
137
|
-
<View gap={3} direction="row">
|
138
|
-
<Button elevated color="primary">
|
139
|
-
Button
|
140
|
-
</Button>
|
141
|
-
<Button elevated variant="outline" color="primary">
|
142
|
-
Button
|
143
|
-
</Button>
|
144
|
-
</View>
|
145
|
-
</Example.Item>
|
146
|
-
|
147
|
-
<Example.Item title="color: media, elevated, variant: solid">
|
148
|
-
<View gap={3} backgroundColor="primary-faded" padding={2} direction="row">
|
149
|
-
<Button color="media" elevated>
|
150
|
-
Button
|
151
|
-
</Button>
|
152
|
-
</View>
|
153
|
-
</Example.Item>
|
154
|
-
</Example>);
|
155
132
|
export const size = () => (<Example>
|
156
|
-
<Example.Item title="size: small
|
157
|
-
<View gap={
|
158
|
-
<Button size="small">Button</Button>
|
133
|
+
<Example.Item title="size: small">
|
134
|
+
<View gap={4} direction="row">
|
159
135
|
<Button size="small" icon={IconZap}>
|
160
136
|
Button
|
161
137
|
</Button>
|
@@ -168,9 +144,8 @@ export const size = () => (<Example>
|
|
168
144
|
</View>
|
169
145
|
</Example.Item>
|
170
146
|
|
171
|
-
<Example.Item title="size: medium
|
172
|
-
<View gap={
|
173
|
-
<Button>Button</Button>
|
147
|
+
<Example.Item title="size: medium">
|
148
|
+
<View gap={4} direction="row">
|
174
149
|
<Button icon={IconZap}>Button</Button>
|
175
150
|
<Button variant="outline" icon={IconZap}>
|
176
151
|
Button
|
@@ -181,9 +156,8 @@ export const size = () => (<Example>
|
|
181
156
|
</View>
|
182
157
|
</Example.Item>
|
183
158
|
|
184
|
-
<Example.Item title="size: large
|
185
|
-
<View gap={
|
186
|
-
<Button size="large">Button</Button>
|
159
|
+
<Example.Item title="size: large">
|
160
|
+
<View gap={4} direction="row">
|
187
161
|
<Button size="large" icon={IconZap}>
|
188
162
|
Button
|
189
163
|
</Button>
|
@@ -196,9 +170,8 @@ export const size = () => (<Example>
|
|
196
170
|
</View>
|
197
171
|
</Example.Item>
|
198
172
|
|
199
|
-
<Example.Item title="size: xlarge
|
200
|
-
<View gap={
|
201
|
-
<Button size="xlarge">Button</Button>
|
173
|
+
<Example.Item title="size: xlarge">
|
174
|
+
<View gap={4} direction="row">
|
202
175
|
<Button size="xlarge" icon={IconZap}>
|
203
176
|
Button
|
204
177
|
</Button>
|
@@ -211,12 +184,40 @@ export const size = () => (<Example>
|
|
211
184
|
</View>
|
212
185
|
</Example.Item>
|
213
186
|
|
214
|
-
<Example.Item title=
|
187
|
+
<Example.Item title="size: large, [m+] medium">
|
215
188
|
<Button size={{ s: "large", m: "medium" }} icon={IconZap}>
|
216
|
-
|
189
|
+
Responsive
|
217
190
|
</Button>
|
218
191
|
</Example.Item>
|
219
192
|
</Example>);
|
193
|
+
export const elevated = () => (<Example>
|
194
|
+
<Example.Item title="elevated, color: neutral">
|
195
|
+
<View direction="row" gap={4}>
|
196
|
+
<Button elevated onClick={() => { }}>
|
197
|
+
Button
|
198
|
+
</Button>
|
199
|
+
<Button elevated variant="outline" onClick={() => { }}>
|
200
|
+
Button
|
201
|
+
</Button>
|
202
|
+
</View>
|
203
|
+
</Example.Item>
|
204
|
+
|
205
|
+
<Example.Item title="elevated, color">
|
206
|
+
<View direction="row" gap={4}>
|
207
|
+
<Button elevated color="primary">
|
208
|
+
Button
|
209
|
+
</Button>
|
210
|
+
<Button elevated variant="outline" color="primary">
|
211
|
+
Button
|
212
|
+
</Button>
|
213
|
+
<View backgroundColor="primary" padding={4} borderRadius="medium">
|
214
|
+
<Button color="media" elevated>
|
215
|
+
Button
|
216
|
+
</Button>
|
217
|
+
</View>
|
218
|
+
</View>
|
219
|
+
</Example.Item>
|
220
|
+
</Example>);
|
220
221
|
export const rounded = () => (<Example>
|
221
222
|
<Example.Item title="rounded, size: small, all variants">
|
222
223
|
<View gap={3} direction="row">
|
@@ -288,46 +289,48 @@ export const fullWidth = () => (<Example>
|
|
288
289
|
export const loading = () => (<Example>
|
289
290
|
<Example.Item title="loading, color: neutral, all variants">
|
290
291
|
<View gap={3} direction="row">
|
291
|
-
<Button loading>
|
292
|
-
|
292
|
+
<Button loading loadingAriaLabel="Loading">
|
293
|
+
Button
|
294
|
+
</Button>
|
295
|
+
<Button loading loadingAriaLabel="Loading" variant="faded">
|
293
296
|
Button
|
294
297
|
</Button>
|
295
|
-
<Button loading variant="outline">
|
298
|
+
<Button loading loadingAriaLabel="Loading" variant="outline">
|
296
299
|
Button
|
297
300
|
</Button>
|
298
|
-
<Button loading variant="ghost">
|
301
|
+
<Button loading loadingAriaLabel="Loading" variant="ghost">
|
299
302
|
Button
|
300
303
|
</Button>
|
301
304
|
</View>
|
302
305
|
</Example.Item>
|
303
306
|
<Example.Item title="loading, color critical, all variants">
|
304
307
|
<View gap={3} direction="row">
|
305
|
-
<Button loading color="critical">
|
308
|
+
<Button loading loadingAriaLabel="Loading" color="critical">
|
306
309
|
Button
|
307
310
|
</Button>
|
308
|
-
<Button loading color="critical" variant="faded">
|
311
|
+
<Button loading loadingAriaLabel="Loading" color="critical" variant="faded">
|
309
312
|
Button
|
310
313
|
</Button>
|
311
|
-
<Button loading color="critical" variant="outline">
|
314
|
+
<Button loading loadingAriaLabel="Loading" color="critical" variant="outline">
|
312
315
|
Button
|
313
316
|
</Button>
|
314
|
-
<Button loading color="critical" variant="ghost">
|
317
|
+
<Button loading loadingAriaLabel="Loading" color="critical" variant="ghost">
|
315
318
|
Button
|
316
319
|
</Button>
|
317
320
|
</View>
|
318
321
|
</Example.Item>
|
319
322
|
<Example.Item title="loading, color positive, all variants">
|
320
323
|
<View gap={3} direction="row">
|
321
|
-
<Button loading color="positive">
|
324
|
+
<Button loading loadingAriaLabel="Loading" color="positive">
|
322
325
|
Button
|
323
326
|
</Button>
|
324
|
-
<Button loading color="positive" variant="faded">
|
327
|
+
<Button loading loadingAriaLabel="Loading" color="positive" variant="faded">
|
325
328
|
Button
|
326
329
|
</Button>
|
327
|
-
<Button loading color="positive" variant="outline">
|
330
|
+
<Button loading loadingAriaLabel="Loading" color="positive" variant="outline">
|
328
331
|
Button
|
329
332
|
</Button>
|
330
|
-
<Button loading color="positive" variant="ghost">
|
333
|
+
<Button loading loadingAriaLabel="Loading" color="positive" variant="ghost">
|
331
334
|
Button
|
332
335
|
</Button>
|
333
336
|
</View>
|
@@ -339,10 +342,10 @@ export const loading = () => (<Example>
|
|
339
342
|
|
340
343
|
<div style={{ position: "absolute", top: 16, left: 16 }}>
|
341
344
|
<View gap={3} direction="row">
|
342
|
-
<Button color="media" loading>
|
345
|
+
<Button color="media" loading loadingAriaLabel="Loading">
|
343
346
|
Button
|
344
347
|
</Button>
|
345
|
-
<Button color="media" variant="faded">
|
348
|
+
<Button color="media" variant="faded" loading loadingAriaLabel="Loading">
|
346
349
|
Button
|
347
350
|
</Button>
|
348
351
|
</View>
|
@@ -351,13 +354,13 @@ export const loading = () => (<Example>
|
|
351
354
|
</Example.Item>
|
352
355
|
|
353
356
|
<Example.Item title={["loading, long button text", "button size should stay the same"]}>
|
354
|
-
<Button loading color="primary">
|
357
|
+
<Button loading loadingAriaLabel="Loading" color="primary">
|
355
358
|
Long button text
|
356
359
|
</Button>
|
357
360
|
</Example.Item>
|
358
361
|
|
359
362
|
<Example.Item title={["loading, icon only", "button keep square 1/1 ratio"]}>
|
360
|
-
<Button icon={IconZap} rounded loading/>
|
363
|
+
<Button icon={IconZap} rounded loading loadingAriaLabel="Loading"/>
|
361
364
|
</Example.Item>
|
362
365
|
</Example>);
|
363
366
|
export const highlighted = () => (<Example>
|
@@ -486,7 +489,7 @@ export const group = () => (<Example>
|
|
486
489
|
</Example.Item>
|
487
490
|
<Example.Item title="variant: solid">
|
488
491
|
<View gap={2}>
|
489
|
-
{["neutral", "primary", "critical", "positive", "media"].map((color) => (<Button.Group>
|
492
|
+
{["neutral", "primary", "critical", "positive", "media"].map((color) => (<Button.Group key={color}>
|
490
493
|
<Button color={color}>One</Button>
|
491
494
|
<Button color={color}>Two</Button>
|
492
495
|
<Button color={color}>Three</Button>
|
@@ -495,7 +498,7 @@ export const group = () => (<Example>
|
|
495
498
|
</Example.Item>
|
496
499
|
<Example.Item title="variant: outline">
|
497
500
|
<View gap={2}>
|
498
|
-
{["neutral", "primary", "critical", "positive", "media"].map((color) => (<Button.Group>
|
501
|
+
{["neutral", "primary", "critical", "positive", "media"].map((color) => (<Button.Group key={color}>
|
499
502
|
<Button color={color} variant="outline">
|
500
503
|
One
|
501
504
|
</Button>
|
@@ -510,7 +513,7 @@ export const group = () => (<Example>
|
|
510
513
|
</Example.Item>
|
511
514
|
<Example.Item title="variant: faded">
|
512
515
|
<View gap={2}>
|
513
|
-
{["neutral", "primary", "critical", "positive", "media"].map((color) => (<Button.Group>
|
516
|
+
{["neutral", "primary", "critical", "positive", "media"].map((color) => (<Button.Group key={color}>
|
514
517
|
<Button color={color} variant="faded">
|
515
518
|
One
|
516
519
|
</Button>
|
@@ -526,7 +529,7 @@ export const group = () => (<Example>
|
|
526
529
|
|
527
530
|
<Example.Item title="variant: ghost">
|
528
531
|
<View gap={2}>
|
529
|
-
{["neutral", "primary", "critical", "positive"].map((color) => (<Button.Group>
|
532
|
+
{["neutral", "primary", "critical", "positive"].map((color) => (<Button.Group key={color}>
|
530
533
|
<Button color={color} variant="ghost">
|
531
534
|
One
|
532
535
|
</Button>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { StoryObj } from "@storybook/react";
|
2
|
+
import { fn } from "@storybook/test";
|
3
|
+
declare const _default: {
|
4
|
+
title: string;
|
5
|
+
component: import("../Button.types").Export;
|
6
|
+
parameters: {
|
7
|
+
iframe: {
|
8
|
+
url: string;
|
9
|
+
};
|
10
|
+
chromatic: {
|
11
|
+
disableSnapshot: boolean;
|
12
|
+
};
|
13
|
+
};
|
14
|
+
};
|
15
|
+
export default _default;
|
16
|
+
export declare const children: StoryObj;
|
17
|
+
export declare const href: StoryObj;
|
18
|
+
export declare const onClick: StoryObj<{
|
19
|
+
handleClick: ReturnType<typeof fn>;
|
20
|
+
}>;
|
21
|
+
export declare const hrefOnClick: StoryObj<{
|
22
|
+
handleClick: ReturnType<typeof fn>;
|
23
|
+
}>;
|
24
|
+
export declare const disabled: StoryObj;
|
25
|
+
export declare const className: StoryObj;
|
26
|
+
export declare const group: StoryObj;
|
27
|
+
export declare const groupClassName: StoryObj;
|
@@ -0,0 +1,112 @@
|
|
1
|
+
import { userEvent, expect, fn } from "@storybook/test";
|
2
|
+
import Button from "../index.js";
|
3
|
+
export default {
|
4
|
+
title: "Components/Button/tests",
|
5
|
+
component: Button,
|
6
|
+
parameters: {
|
7
|
+
iframe: {
|
8
|
+
url: "https://reshaped.so/docs/components/button",
|
9
|
+
},
|
10
|
+
chromatic: { disableSnapshot: true },
|
11
|
+
},
|
12
|
+
};
|
13
|
+
export const children = {
|
14
|
+
name: "children",
|
15
|
+
render: () => <Button>Trigger</Button>,
|
16
|
+
play: async ({ canvas }) => {
|
17
|
+
const el = canvas.getByText("Trigger");
|
18
|
+
expect(el).toBeInTheDocument();
|
19
|
+
expect(el.tagName).toBe("SPAN");
|
20
|
+
},
|
21
|
+
};
|
22
|
+
export const href = {
|
23
|
+
name: "href",
|
24
|
+
render: () => <Button href="https://reshaped.so">Trigger</Button>,
|
25
|
+
play: async ({ canvas }) => {
|
26
|
+
const el = canvas.getByRole("link");
|
27
|
+
expect(el).toHaveAttribute("href", "https://reshaped.so");
|
28
|
+
},
|
29
|
+
};
|
30
|
+
export const onClick = {
|
31
|
+
name: "onClick",
|
32
|
+
args: {
|
33
|
+
handleClick: fn(),
|
34
|
+
},
|
35
|
+
render: (args) => <Button onClick={args.handleClick}>Trigger</Button>,
|
36
|
+
play: async ({ canvas, args }) => {
|
37
|
+
const { handleClick } = args;
|
38
|
+
const el = canvas.getAllByRole("button")[0];
|
39
|
+
await userEvent.click(el);
|
40
|
+
expect(el).toHaveAttribute("type", "button");
|
41
|
+
expect(handleClick).toHaveBeenCalledTimes(1);
|
42
|
+
expect(handleClick).toHaveBeenCalledWith(expect.objectContaining({ target: el }));
|
43
|
+
},
|
44
|
+
};
|
45
|
+
export const hrefOnClick = {
|
46
|
+
name: "href + onClick",
|
47
|
+
args: {
|
48
|
+
handleClick: fn(),
|
49
|
+
},
|
50
|
+
render: (args) => (<Button onClick={(e) => {
|
51
|
+
e.preventDefault();
|
52
|
+
args.handleClick(e);
|
53
|
+
}} href="https://reshaped.so">
|
54
|
+
Trigger
|
55
|
+
</Button>),
|
56
|
+
play: async ({ canvas, args }) => {
|
57
|
+
const { handleClick } = args;
|
58
|
+
const el = canvas.getByRole("link");
|
59
|
+
await userEvent.click(el);
|
60
|
+
expect(el).toHaveAttribute("href", "https://reshaped.so");
|
61
|
+
expect(handleClick).toHaveBeenCalledTimes(1);
|
62
|
+
expect(handleClick).toHaveBeenCalledWith(expect.objectContaining({ target: el }));
|
63
|
+
},
|
64
|
+
};
|
65
|
+
export const disabled = {
|
66
|
+
name: "disabled",
|
67
|
+
render: () => (<Button disabled onClick={() => { }}>
|
68
|
+
Trigger
|
69
|
+
</Button>),
|
70
|
+
play: async ({ canvas }) => {
|
71
|
+
const el = canvas.getAllByRole("button")[0];
|
72
|
+
expect(el).toBeDisabled();
|
73
|
+
},
|
74
|
+
};
|
75
|
+
export const className = {
|
76
|
+
name: "className, attributes",
|
77
|
+
render: () => (<div data-testid="root">
|
78
|
+
<Button className="test-classname" attributes={{ id: "test-id" }}>
|
79
|
+
Trigger
|
80
|
+
</Button>
|
81
|
+
</div>),
|
82
|
+
play: async ({ canvas }) => {
|
83
|
+
const root = canvas.getByTestId("root").firstChild;
|
84
|
+
expect(root).toHaveClass("test-classname");
|
85
|
+
expect(root).toHaveAttribute("id", "test-id");
|
86
|
+
},
|
87
|
+
};
|
88
|
+
export const group = {
|
89
|
+
name: "group",
|
90
|
+
render: () => (<Button.Group>
|
91
|
+
<Button>Trigger</Button>
|
92
|
+
<Button>Trigger</Button>
|
93
|
+
</Button.Group>),
|
94
|
+
play: async ({ canvas }) => {
|
95
|
+
const el = canvas.getByRole("group");
|
96
|
+
expect(el).toBeInTheDocument();
|
97
|
+
expect(el.childElementCount).toEqual(2);
|
98
|
+
},
|
99
|
+
};
|
100
|
+
export const groupClassName = {
|
101
|
+
name: "group className, attributes",
|
102
|
+
render: () => (<div data-testid="root">
|
103
|
+
<Button.Group className="test-classname" attributes={{ id: "test-id" }}>
|
104
|
+
<Button>Trigger</Button>
|
105
|
+
</Button.Group>
|
106
|
+
</div>),
|
107
|
+
play: async ({ canvas }) => {
|
108
|
+
const root = canvas.getByTestId("root").firstChild;
|
109
|
+
expect(root).toHaveClass("test-classname");
|
110
|
+
expect(root).toHaveAttribute("id", "test-id");
|
111
|
+
},
|
112
|
+
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { StoryObj } from "@storybook/react";
|
2
|
+
import { fn } from "@storybook/test";
|
3
|
+
declare const _default: {
|
4
|
+
title: string;
|
5
|
+
component: (props: import("./..").CalendarProps) => import("react").JSX.Element;
|
6
|
+
parameters: {
|
7
|
+
iframe: {
|
8
|
+
url: string;
|
9
|
+
};
|
10
|
+
chromatic: {
|
11
|
+
disableSnapshot: boolean;
|
12
|
+
};
|
13
|
+
};
|
14
|
+
};
|
15
|
+
export default _default;
|
16
|
+
export declare const base: StoryObj;
|
17
|
+
export declare const onChange: StoryObj<{
|
18
|
+
handleChange: ReturnType<typeof fn>;
|
19
|
+
}>;
|
20
|
+
export declare const defaultValue: StoryObj;
|
21
|
+
export declare const value: StoryObj;
|
22
|
+
export declare const range: StoryObj;
|
23
|
+
export declare const minMax: StoryObj;
|
24
|
+
export declare const monthSelection: StoryObj;
|
25
|
+
export declare const ariaLabels: StoryObj;
|
26
|
+
export declare const keyboardNavigation: StoryObj;
|
@@ -0,0 +1,161 @@
|
|
1
|
+
import { expect, userEvent, fn } from "@storybook/test";
|
2
|
+
import Calendar from "../index.js";
|
3
|
+
export default {
|
4
|
+
title: "Components/Calendar/tests",
|
5
|
+
component: Calendar,
|
6
|
+
parameters: {
|
7
|
+
iframe: {
|
8
|
+
url: "https://reshaped.so/docs/components/calendar",
|
9
|
+
},
|
10
|
+
chromatic: { disableSnapshot: true },
|
11
|
+
},
|
12
|
+
};
|
13
|
+
export const base = {
|
14
|
+
name: "base",
|
15
|
+
render: () => <Calendar defaultMonth={new Date(2020, 0, 1)}/>,
|
16
|
+
play: async ({ canvas }) => {
|
17
|
+
const monthTitleEl = canvas.getByText("January 2020");
|
18
|
+
const gridEl = canvas.getByRole("grid");
|
19
|
+
const gridCellEls = canvas.getAllByRole("gridcell");
|
20
|
+
const dateEls = canvas.getAllByRole("checkbox");
|
21
|
+
const buttonEls = canvas.getAllByRole("button");
|
22
|
+
expect(monthTitleEl).toBeInTheDocument();
|
23
|
+
expect(gridEl).toBeInTheDocument();
|
24
|
+
expect(gridCellEls).toHaveLength(31);
|
25
|
+
expect(dateEls).toHaveLength(31);
|
26
|
+
expect(dateEls[0].getAttribute("aria-label")).toBe("Wednesday, January 1");
|
27
|
+
expect(dateEls[0]).toHaveAttribute("tabIndex", "0");
|
28
|
+
expect(dateEls[1]).toHaveAttribute("tabIndex", "-1");
|
29
|
+
// Previous month button
|
30
|
+
expect(buttonEls[0].getAttribute("aria-label")).toBe("Previous month");
|
31
|
+
// Month select button
|
32
|
+
expect(buttonEls[1].innerHTML).toContain("Select a month");
|
33
|
+
// Next month button
|
34
|
+
expect(buttonEls[2].getAttribute("aria-label")).toBe("Next month");
|
35
|
+
},
|
36
|
+
};
|
37
|
+
export const onChange = {
|
38
|
+
name: "onChange",
|
39
|
+
args: {
|
40
|
+
handleChange: fn(),
|
41
|
+
},
|
42
|
+
render: (args) => <Calendar defaultMonth={new Date(2020, 0)} onChange={args.handleChange}/>,
|
43
|
+
play: async ({ canvas, args }) => {
|
44
|
+
const dateEls = canvas.getAllByRole("checkbox");
|
45
|
+
await userEvent.click(dateEls[1]);
|
46
|
+
expect(args.handleChange).toHaveBeenCalledTimes(1);
|
47
|
+
// TODO: https://github.com/storybookjs/storybook/issues/30503
|
48
|
+
// expect(args.handleChange).toHaveBeenCalledWith({ value: new Date(2020, 0, 2) });
|
49
|
+
},
|
50
|
+
};
|
51
|
+
export const defaultValue = {
|
52
|
+
name: "defaultValue",
|
53
|
+
render: () => <Calendar defaultMonth={new Date(2020, 0)} defaultValue={new Date(2020, 0, 5)}/>,
|
54
|
+
play: async ({ canvas }) => {
|
55
|
+
const dateEls = canvas.getAllByRole("checkbox");
|
56
|
+
const selectedDateEl = dateEls[4];
|
57
|
+
expect(selectedDateEl).toBeInTheDocument();
|
58
|
+
expect(selectedDateEl).toHaveAttribute("tabIndex", "0");
|
59
|
+
expect(selectedDateEl).toHaveAttribute("aria-checked", "true");
|
60
|
+
await userEvent.click(dateEls[6], { delay: null });
|
61
|
+
expect(dateEls[6]).toHaveAttribute("aria-checked", "true");
|
62
|
+
},
|
63
|
+
};
|
64
|
+
export const value = {
|
65
|
+
name: "value",
|
66
|
+
render: () => <Calendar defaultMonth={new Date(2020, 0)} value={new Date(2020, 0, 5)}/>,
|
67
|
+
play: async ({ canvas }) => {
|
68
|
+
const dateEls = canvas.getAllByRole("checkbox");
|
69
|
+
const selectedDateEl = dateEls[4];
|
70
|
+
expect(selectedDateEl).toBeInTheDocument();
|
71
|
+
expect(selectedDateEl).toHaveAttribute("tabIndex", "0");
|
72
|
+
expect(selectedDateEl).toHaveAttribute("aria-checked", "true");
|
73
|
+
await userEvent.click(dateEls[6], { delay: null });
|
74
|
+
expect(dateEls[6]).toHaveAttribute("aria-checked", "false");
|
75
|
+
},
|
76
|
+
};
|
77
|
+
export const range = {
|
78
|
+
name: "defaultValue, range",
|
79
|
+
render: () => (<Calendar defaultMonth={new Date(2020, 0)} range defaultValue={{ start: new Date(2020, 0, 5), end: new Date(2020, 0, 7) }}/>),
|
80
|
+
play: async ({ canvas }) => {
|
81
|
+
const dateEls = canvas.getAllByRole("checkbox");
|
82
|
+
const startDateEl = dateEls[4];
|
83
|
+
const endDateEl = dateEls[6];
|
84
|
+
expect(startDateEl).toHaveAttribute("tabIndex", "0");
|
85
|
+
expect(startDateEl).toHaveAttribute("aria-checked", "true");
|
86
|
+
expect(endDateEl).toHaveAttribute("tabIndex", "-1");
|
87
|
+
expect(endDateEl).toHaveAttribute("aria-checked", "true");
|
88
|
+
await userEvent.click(dateEls[3], { delay: null });
|
89
|
+
expect(dateEls[3]).toHaveAttribute("aria-checked", "true");
|
90
|
+
expect(dateEls[3]).toHaveAttribute("tabIndex", "0");
|
91
|
+
expect(startDateEl).toHaveAttribute("aria-checked", "false");
|
92
|
+
expect(startDateEl).toHaveAttribute("tabIndex", "-1");
|
93
|
+
expect(endDateEl).toHaveAttribute("aria-checked", "false");
|
94
|
+
expect(endDateEl).toHaveAttribute("tabIndex", "-1");
|
95
|
+
// Click before the start date
|
96
|
+
await userEvent.click(dateEls[2], { delay: null });
|
97
|
+
expect(dateEls[2]).toHaveAttribute("aria-checked", "true");
|
98
|
+
expect(dateEls[2]).toHaveAttribute("tabIndex", "0");
|
99
|
+
expect(dateEls[3]).toHaveAttribute("aria-checked", "false");
|
100
|
+
expect(dateEls[3]).toHaveAttribute("tabIndex", "-1");
|
101
|
+
await userEvent.click(dateEls[4], { delay: null });
|
102
|
+
expect(dateEls[2]).toHaveAttribute("aria-checked", "true");
|
103
|
+
expect(dateEls[2]).toHaveAttribute("tabIndex", "0");
|
104
|
+
expect(dateEls[4]).toHaveAttribute("aria-checked", "true");
|
105
|
+
expect(dateEls[4]).toHaveAttribute("tabIndex", "-1");
|
106
|
+
},
|
107
|
+
};
|
108
|
+
export const minMax = {
|
109
|
+
name: "min, max",
|
110
|
+
render: () => (<Calendar min={new Date(2020, 0, 5)} max={new Date(2020, 0, 25)} defaultMonth={new Date(2020, 0)}/>),
|
111
|
+
play: async ({ canvas }) => {
|
112
|
+
const dateEls = canvas.getAllByRole("checkbox");
|
113
|
+
expect(dateEls).toHaveLength(21);
|
114
|
+
},
|
115
|
+
};
|
116
|
+
export const monthSelection = {
|
117
|
+
name: "month selection",
|
118
|
+
render: () => <Calendar defaultMonth={new Date(2020, 0)}/>,
|
119
|
+
play: async ({ canvas }) => {
|
120
|
+
const buttonEls = canvas.getAllByRole("button");
|
121
|
+
await userEvent.click(buttonEls[1], { delay: null });
|
122
|
+
const monthEls = canvas.getAllByRole("button").filter((el) => el.hasAttribute("data-rs-date"));
|
123
|
+
expect(monthEls).toHaveLength(12);
|
124
|
+
},
|
125
|
+
};
|
126
|
+
export const ariaLabels = {
|
127
|
+
name: "aria labels",
|
128
|
+
render: () => (<Calendar defaultMonth={new Date(2020, 0)} nextYearAriaLabel="Test next year" nextMonthAriaLabel="Test next month" renderDateAriaLabel={() => "Test date"} renderMonthAriaLabel={() => "Test month"} previousYearAriaLabel="Test previous year" previousMonthAriaLabel="Test previous month" monthSelectionAriaLabel="Test month selection"/>),
|
129
|
+
play: async ({ canvas }) => {
|
130
|
+
const buttonEls = canvas.getAllByRole("button");
|
131
|
+
const dateEls = canvas.getAllByRole("checkbox");
|
132
|
+
expect(buttonEls[0]).toHaveAttribute("aria-label", "Test previous month");
|
133
|
+
expect(buttonEls[1]).toHaveTextContent("Test month selection");
|
134
|
+
expect(buttonEls[2]).toHaveAttribute("aria-label", "Test next month");
|
135
|
+
expect(dateEls[0]).toHaveAttribute("aria-label", "Test date");
|
136
|
+
await userEvent.click(buttonEls[1], { delay: null });
|
137
|
+
const yearButtonEls = canvas.getAllByRole("button");
|
138
|
+
expect(yearButtonEls[0]).toHaveAttribute("aria-label", "Test previous year");
|
139
|
+
expect(yearButtonEls[1]).toHaveAttribute("aria-label", "Test next year");
|
140
|
+
expect(yearButtonEls[2]).toHaveAttribute("aria-label", "Test month");
|
141
|
+
},
|
142
|
+
};
|
143
|
+
export const keyboardNavigation = {
|
144
|
+
name: "keyboard navigation",
|
145
|
+
render: () => <Calendar defaultMonth={new Date(2020, 0)}/>,
|
146
|
+
play: async ({ canvas }) => {
|
147
|
+
const user = userEvent.setup();
|
148
|
+
const dateEls = canvas.getAllByRole("checkbox");
|
149
|
+
dateEls[0].focus();
|
150
|
+
await user.keyboard("{ArrowRight/}");
|
151
|
+
expect(document.activeElement).toHaveAttribute("data-rs-date", "2020-01-02");
|
152
|
+
await user.keyboard("{ArrowLeft/}");
|
153
|
+
expect(document.activeElement).toHaveAttribute("data-rs-date", "2020-01-01");
|
154
|
+
await user.keyboard("{ArrowDown/}");
|
155
|
+
expect(document.activeElement).toHaveAttribute("data-rs-date", "2020-01-08");
|
156
|
+
await user.keyboard("{ArrowUp/}");
|
157
|
+
expect(document.activeElement).toHaveAttribute("data-rs-date", "2020-01-01");
|
158
|
+
await user.keyboard("{ArrowUp/}");
|
159
|
+
expect(document.activeElement).toHaveAttribute("data-rs-date", "2019-12-25");
|
160
|
+
},
|
161
|
+
};
|
@@ -28,4 +28,3 @@ export declare const selected: () => React.JSX.Element;
|
|
28
28
|
export declare const elevated: () => React.JSX.Element;
|
29
29
|
export declare const bleed: () => React.JSX.Element;
|
30
30
|
export declare const height: () => React.JSX.Element;
|
31
|
-
export declare const testComposition: () => React.JSX.Element;
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import { Example, Placeholder } from "../../../utilities/storybook/index.js";
|
3
3
|
import Card from "../index.js";
|
4
|
-
import View from "../../View/index.js";
|
5
4
|
export default {
|
6
5
|
title: "Components/Card",
|
7
6
|
component: Card,
|
@@ -79,13 +78,3 @@ export const height = () => (<Example>
|
|
79
78
|
<Card height="200px"/>
|
80
79
|
</Example.Item>
|
81
80
|
</Example>);
|
82
|
-
export const testComposition = () => (<Example>
|
83
|
-
<Example.Item title="padding: 0, view with padding inside">
|
84
|
-
<Card padding={0}>
|
85
|
-
<Placeholder />
|
86
|
-
<View padding={4}>
|
87
|
-
<Placeholder />
|
88
|
-
</View>
|
89
|
-
</Card>
|
90
|
-
</Example.Item>
|
91
|
-
</Example>);
|