@nypl/design-system-react-components 0.27.0 → 0.28.0
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 +29 -0
- package/dist/components/Accordion/Accordion.d.ts +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -5
- package/dist/components/Button/Button.d.ts +2 -10
- package/dist/components/ButtonGroup/ButtonGroup.d.ts +22 -0
- package/dist/components/Card/Card.d.ts +2 -2
- package/dist/components/Checkbox/Checkbox.d.ts +10 -8
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
- package/dist/components/DatePicker/DatePicker.d.ts +1 -1
- package/dist/components/Form/Form.d.ts +2 -2
- package/dist/components/Grid/SimpleGrid.d.ts +6 -3
- package/dist/components/Heading/Heading.d.ts +2 -5
- package/dist/components/HelperErrorText/HelperErrorText.d.ts +1 -5
- package/dist/components/Hero/Hero.d.ts +13 -9
- package/dist/components/Icons/Icon.d.ts +6 -5
- package/dist/components/Icons/IconSvgs.d.ts +21 -21
- package/dist/components/Image/Image.d.ts +8 -5
- package/dist/components/Link/Link.d.ts +1 -9
- package/dist/components/List/List.d.ts +7 -11
- package/dist/components/Logo/Logo.d.ts +2 -5
- package/dist/components/Logo/LogoSvgs.d.ts +39 -39
- package/dist/components/Notification/Notification.d.ts +1 -1
- package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +2 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +1 -1
- package/dist/components/SearchBar/SearchBar.d.ts +3 -2
- package/dist/components/Select/Select.d.ts +2 -5
- package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -4
- package/dist/components/SkipNavigation/SkipNavigation.d.ts +17 -0
- package/dist/components/StatusBadge/StatusBadge.d.ts +2 -3
- package/dist/components/StructuredContent/StructuredContent.d.ts +2 -2
- package/dist/components/Table/Table.d.ts +1 -1
- package/dist/components/Template/Template.d.ts +2 -0
- package/dist/components/Text/Text.d.ts +1 -1
- package/dist/components/TextInput/TextInput.d.ts +21 -9
- package/dist/components/Toggle/Toggle.d.ts +1 -5
- package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
- package/dist/design-system-react-components.cjs.development.js +856 -1155
- package/dist/design-system-react-components.cjs.development.js.map +1 -1
- package/dist/design-system-react-components.cjs.production.min.js +1 -1
- package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
- package/dist/design-system-react-components.esm.js +858 -1220
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/helpers/types.d.ts +1 -0
- package/dist/index.d.ts +26 -47
- package/dist/theme/components/buttonGroup.d.ts +11 -0
- package/dist/theme/components/card.d.ts +104 -8
- package/dist/theme/components/componentWrapper.d.ts +4 -3
- package/dist/theme/components/customTable.d.ts +11 -14
- package/dist/theme/components/fieldset.d.ts +4 -3
- package/dist/theme/components/helperErrorText.d.ts +4 -3
- package/dist/theme/components/hero.d.ts +1 -1
- package/dist/theme/components/horizontalRule.d.ts +4 -3
- package/dist/theme/components/icon.d.ts +47743 -1
- package/dist/theme/components/image.d.ts +563 -10
- package/dist/theme/components/label.d.ts +4 -3
- package/dist/theme/components/list.d.ts +6 -7
- package/dist/theme/components/logo.d.ts +474 -1
- package/dist/theme/components/notification.d.ts +20 -16
- package/dist/theme/components/progressIndicator.d.ts +6 -4
- package/dist/theme/components/select.d.ts +4 -4
- package/dist/theme/components/skeletonLoader.d.ts +14 -10
- package/dist/theme/components/skipNavigation.d.ts +22 -0
- package/dist/theme/components/slider.d.ts +7 -6
- package/dist/theme/components/structuredContent.d.ts +10 -9
- package/dist/theme/components/text.d.ts +7 -1
- package/dist/theme/components/toggle.d.ts +6 -4
- package/dist/theme/provider.d.ts +2 -4
- package/dist/utils/componentCategories.d.ts +1 -1
- package/dist/utils/interfaces.d.ts +5 -0
- package/dist/utils/utils.d.ts +2 -18
- package/package.json +2 -2
- package/src/__tests__/setup.ts +3 -3
- package/src/__tests__/utils/utils.test.ts +1 -23
- package/src/components/AccessibilityGuide/SkipNavigation.stories.mdx +22 -14
- package/src/components/Accordion/Accordion.stories.mdx +43 -44
- package/src/components/Accordion/Accordion.test.tsx +5 -13
- package/src/components/Accordion/Accordion.tsx +14 -18
- package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +6 -6
- package/src/components/Autosuggest/Autosuggest.stories.mdx +1 -1
- package/src/components/Autosuggest/Autosuggest.stories.tsx +23 -25
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +21 -37
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +4 -17
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +18 -21
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +1 -100
- package/src/components/Button/Button.stories.mdx +89 -126
- package/src/components/Button/Button.test.tsx +16 -30
- package/src/components/Button/Button.tsx +14 -20
- package/src/components/ButtonGroup/ButtonGroup.stories.mdx +147 -0
- package/src/components/ButtonGroup/ButtonGroup.test.tsx +141 -0
- package/src/components/ButtonGroup/ButtonGroup.tsx +99 -0
- package/src/components/ButtonGroup/__snapshots__/ButtonGroup.test.tsx.snap +117 -0
- package/src/components/Card/Card.stories.mdx +143 -177
- package/src/components/Card/Card.test.tsx +36 -97
- package/src/components/Card/Card.tsx +78 -74
- package/src/components/Chakra/Box.stories.mdx +2 -6
- package/src/components/Chakra/Center.stories.mdx +5 -23
- package/src/components/Chakra/Flex.stories.mdx +4 -6
- package/src/components/Chakra/Stack.stories.mdx +9 -10
- package/src/components/Checkbox/Checkbox.stories.mdx +1 -1
- package/src/components/Checkbox/Checkbox.test.tsx +2 -2
- package/src/components/Checkbox/Checkbox.tsx +20 -13
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +6 -17
- package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +1 -7
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +33 -29
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +0 -11
- package/src/components/ComponentWrapper/ComponentWrapper.tsx +3 -10
- package/src/components/DatePicker/DatePicker.stories.mdx +23 -37
- package/src/components/DatePicker/DatePicker.test.tsx +21 -19
- package/src/components/DatePicker/DatePicker.tsx +57 -49
- package/src/components/Form/Form.stories.mdx +46 -31
- package/src/components/Form/Form.test.tsx +1 -18
- package/src/components/Form/Form.tsx +7 -7
- package/src/components/Grid/SimpleGrid.stories.mdx +73 -49
- package/src/components/Grid/SimpleGrid.test.tsx +7 -9
- package/src/components/Grid/SimpleGrid.tsx +14 -11
- package/src/components/Heading/Heading.stories.mdx +27 -72
- package/src/components/Heading/Heading.test.tsx +18 -44
- package/src/components/Heading/Heading.tsx +7 -10
- package/src/components/HelperErrorText/HelperErrorText.stories.mdx +1 -3
- package/src/components/HelperErrorText/HelperErrorText.tsx +1 -5
- package/src/components/Hero/Hero.stories.mdx +219 -216
- package/src/components/Hero/Hero.test.tsx +107 -223
- package/src/components/Hero/Hero.tsx +63 -61
- package/src/components/Icons/Icon.stories.mdx +172 -118
- package/src/components/Icons/Icon.test.tsx +8 -16
- package/src/components/Icons/Icon.tsx +75 -29
- package/src/components/Icons/IconSvgs.tsx +42 -42
- package/src/components/Image/Image.stories.mdx +45 -132
- package/src/components/Image/Image.test.tsx +16 -31
- package/src/components/Image/Image.tsx +28 -12
- package/src/components/Link/Link.stories.mdx +30 -80
- package/src/components/Link/Link.test.tsx +25 -53
- package/src/components/Link/Link.tsx +43 -56
- package/src/components/Link/__snapshots__/Link.test.tsx.snap +1 -2
- package/src/components/List/List.stories.mdx +20 -31
- package/src/components/List/List.test.tsx +24 -43
- package/src/components/List/List.tsx +25 -36
- package/src/components/Logo/Logo.stories.mdx +94 -50
- package/src/components/Logo/Logo.test.tsx +10 -19
- package/src/components/Logo/Logo.tsx +50 -17
- package/src/components/Logo/LogoSvgs.tsx +78 -78
- package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +4 -4
- package/src/components/Modal/Modal.stories.mdx +8 -9
- package/src/components/Modal/Modal.test.tsx +5 -10
- package/src/components/Modal/Modal.tsx +1 -1
- package/src/components/Notification/Notification.stories.mdx +10 -28
- package/src/components/Notification/Notification.test.tsx +9 -12
- package/src/components/Notification/Notification.tsx +34 -37
- package/src/components/Pagination/Pagination.stories.mdx +2 -2
- package/src/components/Pagination/Pagination.tsx +15 -10
- package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +27 -53
- package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +9 -10
- package/src/components/ProgressIndicator/ProgressIndicator.tsx +17 -21
- package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +0 -10
- package/src/components/Radio/Radio.stories.mdx +1 -1
- package/src/components/Radio/Radio.tsx +9 -6
- package/src/components/RadioGroup/RadioGroup.stories.mdx +15 -16
- package/src/components/RadioGroup/RadioGroup.test.tsx +2 -8
- package/src/components/RadioGroup/RadioGroup.tsx +28 -24
- package/src/components/SearchBar/SearchBar.stories.mdx +1 -1
- package/src/components/SearchBar/SearchBar.test.tsx +1 -1
- package/src/components/SearchBar/SearchBar.tsx +14 -22
- package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +0 -12
- package/src/components/Select/Select.stories.mdx +8 -23
- package/src/components/Select/Select.test.tsx +6 -7
- package/src/components/Select/Select.tsx +13 -26
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +17 -56
- package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +7 -21
- package/src/components/SkeletonLoader/SkeletonLoader.tsx +9 -8
- package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +33 -33
- package/src/components/SkipNavigation/SkipNavigation.stories.mdx +90 -0
- package/src/components/SkipNavigation/SkipNavigation.test.tsx +63 -0
- package/src/components/SkipNavigation/SkipNavigation.tsx +51 -0
- package/src/components/SkipNavigation/__snapshots__/SkipNavigation.test.tsx.snap +130 -0
- package/src/components/Slider/Slider.stories.mdx +19 -53
- package/src/components/Slider/Slider.test.tsx +2 -2
- package/src/components/Slider/Slider.tsx +10 -12
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +2 -9
- package/src/components/StatusBadge/StatusBadge.stories.mdx +6 -21
- package/src/components/StatusBadge/StatusBadge.test.tsx +2 -3
- package/src/components/StatusBadge/StatusBadge.tsx +3 -10
- package/src/components/StructuredContent/StructuredContent.stories.mdx +30 -58
- package/src/components/StructuredContent/StructuredContent.test.tsx +42 -44
- package/src/components/StructuredContent/StructuredContent.tsx +9 -18
- package/src/components/StyleGuide/Bidirectionality.stories.mdx +9 -23
- package/src/components/StyleGuide/Buttons.stories.mdx +62 -62
- package/src/components/StyleGuide/ColorCard.tsx +2 -4
- package/src/components/StyleGuide/Colors.stories.mdx +7 -8
- package/src/components/StyleGuide/DesignTokens.stories.mdx +5 -7
- package/src/components/StyleGuide/Forms.stories.mdx +0 -1
- package/src/components/StyleGuide/Iconography.stories.mdx +59 -77
- package/src/components/StyleGuide/Spacing.stories.mdx +0 -1
- package/src/components/StyleGuide/Typography.stories.mdx +15 -18
- package/src/components/Table/Table.stories.mdx +85 -1
- package/src/components/Table/Table.test.tsx +57 -1
- package/src/components/Table/Table.tsx +7 -4
- package/src/components/Table/__snapshots__/Table.test.tsx.snap +121 -0
- package/src/components/Tabs/Tabs.stories.mdx +1 -1
- package/src/components/Tabs/Tabs.test.tsx +2 -2
- package/src/components/Tabs/Tabs.tsx +26 -27
- package/src/components/Template/Template.stories.mdx +49 -54
- package/src/components/Template/Template.tsx +9 -3
- package/src/components/Text/Text.stories.mdx +5 -11
- package/src/components/Text/Text.test.tsx +3 -6
- package/src/components/Text/Text.tsx +3 -5
- package/src/components/TextInput/TextInput.stories.mdx +10 -22
- package/src/components/TextInput/TextInput.test.tsx +32 -62
- package/src/components/TextInput/TextInput.tsx +61 -30
- package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +1 -0
- package/src/components/Toggle/Toggle.stories.mdx +5 -16
- package/src/components/Toggle/Toggle.test.tsx +2 -3
- package/src/components/Toggle/Toggle.tsx +9 -10
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +13 -29
- package/src/components/VideoPlayer/VideoPlayer.test.tsx +18 -23
- package/src/components/VideoPlayer/VideoPlayer.tsx +13 -10
- package/src/docs/Chakra.stories.mdx +14 -11
- package/src/docs/Welcome.stories.mdx +23 -43
- package/src/helpers/types.ts +1 -0
- package/src/hooks/tests/useNYPLTheme.test.tsx +1 -1
- package/src/hooks/useNYPLTheme.stories.mdx +3 -6
- package/src/index.ts +51 -45
- package/src/theme/components/buttonGroup.ts +10 -0
- package/src/theme/components/card.ts +50 -15
- package/src/theme/components/componentWrapper.ts +5 -1
- package/src/theme/components/customTable.ts +8 -2
- package/src/theme/components/fieldset.ts +5 -1
- package/src/theme/components/helperErrorText.ts +5 -1
- package/src/theme/components/hero.ts +2 -2
- package/src/theme/components/horizontalRule.ts +5 -1
- package/src/theme/components/icon.ts +7 -1
- package/src/theme/components/image.ts +14 -3
- package/src/theme/components/label.ts +5 -1
- package/src/theme/components/list.ts +8 -2
- package/src/theme/components/logo.ts +5 -1
- package/src/theme/components/notification.ts +38 -14
- package/src/theme/components/progressIndicator.ts +10 -5
- package/src/theme/components/select.ts +5 -2
- package/src/theme/components/skeletonLoader.ts +8 -2
- package/src/theme/components/skipNavigation.ts +26 -0
- package/src/theme/components/slider.ts +13 -1
- package/src/theme/components/structuredContent.ts +11 -1
- package/src/theme/components/text.ts +12 -5
- package/src/theme/components/toggle.ts +9 -3
- package/src/theme/index.ts +4 -0
- package/src/theme/provider.tsx +1 -1
- package/src/utils/componentCategories.ts +13 -5
- package/src/utils/interfaces.ts +5 -0
- package/src/utils/utils.ts +2 -32
- package/dist/components/Accordion/AccordionTypes.d.ts +0 -5
- package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +0 -8
- package/dist/components/Button/ButtonTypes.d.ts +0 -8
- package/dist/components/DatePicker/DatePickerTypes.d.ts +0 -5
- package/dist/components/Form/FormTypes.d.ts +0 -2
- package/dist/components/Grid/GridTypes.d.ts +0 -9
- package/dist/components/Heading/HeadingTypes.d.ts +0 -14
- package/dist/components/Hero/HeroTypes.d.ts +0 -12
- package/dist/components/Icons/IconTypes.d.ts +0 -77
- package/dist/components/Image/ImageTypes.d.ts +0 -22
- package/dist/components/Link/LinkTypes.d.ts +0 -8
- package/dist/components/List/ListTypes.d.ts +0 -5
- package/dist/components/Logo/LogoTypes.d.ts +0 -54
- package/dist/components/Notification/NotificationTypes.d.ts +0 -5
- package/dist/components/ProgressIndicator/ProgressIndicatorTypes.d.ts +0 -8
- package/dist/components/Select/SelectTypes.d.ts +0 -8
- package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +0 -5
- package/dist/components/StatusBadge/StatusBadgeTypes.d.ts +0 -5
- package/dist/components/StructuredContent/StructuredContentTypes.d.ts +0 -5
- package/dist/components/Text/TextTypes.d.ts +0 -6
- package/dist/components/TextInput/TextInputTypes.d.ts +0 -25
- package/dist/components/Toggle/ToggleTypes.d.ts +0 -4
- package/dist/components/VideoPlayer/VideoPlayerTypes.d.ts +0 -9
- package/dist/helpers/enums.d.ts +0 -4
- package/dist/utils/siteSections.d.ts +0 -2
- package/src/components/Accordion/AccordionTypes.tsx +0 -5
- package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +0 -8
- package/src/components/Button/ButtonTypes.tsx +0 -8
- package/src/components/DatePicker/DatePickerTypes.tsx +0 -5
- package/src/components/Form/FormTypes.tsx +0 -3
- package/src/components/Grid/GridTypes.tsx +0 -9
- package/src/components/Heading/HeadingTypes.tsx +0 -15
- package/src/components/Hero/HeroTypes.tsx +0 -20
- package/src/components/Icons/IconTypes.tsx +0 -83
- package/src/components/Image/ImageTypes.ts +0 -24
- package/src/components/Link/LinkTypes.tsx +0 -8
- package/src/components/List/ListTypes.tsx +0 -5
- package/src/components/Logo/LogoTypes.tsx +0 -56
- package/src/components/Notification/NotificationTypes.tsx +0 -5
- package/src/components/ProgressIndicator/ProgressIndicatorTypes.ts +0 -8
- package/src/components/Select/SelectTypes.tsx +0 -10
- package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +0 -5
- package/src/components/StatusBadge/StatusBadgeTypes.tsx +0 -5
- package/src/components/StructuredContent/StructuredContentTypes.tsx +0 -5
- package/src/components/Text/TextTypes.tsx +0 -6
- package/src/components/TextInput/TextInputTypes.tsx +0 -48
- package/src/components/Toggle/ToggleTypes.tsx +0 -4
- package/src/components/VideoPlayer/VideoPlayerTypes.tsx +0 -10
- package/src/helpers/enums.ts +0 -4
- package/src/utils/siteSections.ts +0 -10
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from "@storybook/addon-docs";
|
|
8
8
|
import { withDesign } from "storybook-addon-designs";
|
|
9
9
|
|
|
10
|
+
import Image from "../Image/Image";
|
|
10
11
|
import Table from "./Table";
|
|
11
12
|
import DSProvider from "../../theme/provider";
|
|
12
13
|
import { getCategory } from "../../utils/componentCategories";
|
|
@@ -36,7 +37,7 @@ import { getCategory } from "../../utils/componentCategories";
|
|
|
36
37
|
| Component Version | DS Version |
|
|
37
38
|
| ----------------- | ---------- |
|
|
38
39
|
| Added | `0.25.9` |
|
|
39
|
-
| Latest | `0.
|
|
40
|
+
| Latest | `0.28.0` |
|
|
40
41
|
|
|
41
42
|
## Table of Contents
|
|
42
43
|
|
|
@@ -47,6 +48,7 @@ import { getCategory } from "../../utils/componentCategories";
|
|
|
47
48
|
- [With Row Dividers](#with-row-dividers)
|
|
48
49
|
- [With Row Headers](#with-row-headers)
|
|
49
50
|
- [With Custom Header Colors](#with-custom-header-colors)
|
|
51
|
+
- [With JSX Elements](#with-jsx-elements)
|
|
50
52
|
|
|
51
53
|
## Overview
|
|
52
54
|
|
|
@@ -190,3 +192,85 @@ color contrast.
|
|
|
190
192
|
/>
|
|
191
193
|
</DSProvider>
|
|
192
194
|
</Canvas>
|
|
195
|
+
|
|
196
|
+
## With JSX Elements
|
|
197
|
+
|
|
198
|
+
export const characterHeaders = ["First Name", "Last Name", "Avatar"];
|
|
199
|
+
export const charactersData = [
|
|
200
|
+
[
|
|
201
|
+
"Tom",
|
|
202
|
+
"Nook",
|
|
203
|
+
<Image
|
|
204
|
+
alt="Tom Nook"
|
|
205
|
+
size="small"
|
|
206
|
+
src="https://play.nintendo.com/images/AC_Tom_FRYtwIN.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png"
|
|
207
|
+
/>,
|
|
208
|
+
],
|
|
209
|
+
[
|
|
210
|
+
"Isabelle",
|
|
211
|
+
"-",
|
|
212
|
+
,
|
|
213
|
+
<Image
|
|
214
|
+
alt="Isabelle"
|
|
215
|
+
size="small"
|
|
216
|
+
src="https://play.nintendo.com/images/AC_Isabelle_7XU6aGu.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png"
|
|
217
|
+
/>,
|
|
218
|
+
],
|
|
219
|
+
[
|
|
220
|
+
"K.K.",
|
|
221
|
+
"Slider",
|
|
222
|
+
,
|
|
223
|
+
<Image
|
|
224
|
+
alt="K.K Slider"
|
|
225
|
+
size="small"
|
|
226
|
+
src="https://play.nintendo.com/images/AC_KK_jh4yj5t.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png"
|
|
227
|
+
/>,
|
|
228
|
+
],
|
|
229
|
+
];
|
|
230
|
+
|
|
231
|
+
It's possible to pass in JSX elements in the `tableData` prop.
|
|
232
|
+
|
|
233
|
+
```jsx
|
|
234
|
+
export const charactersData = [
|
|
235
|
+
[
|
|
236
|
+
"Tom",
|
|
237
|
+
"Nook",
|
|
238
|
+
<Image
|
|
239
|
+
alt="Tom Nook"
|
|
240
|
+
size="small"
|
|
241
|
+
src="https://play.nintendo.com/images/AC_Tom_FRYtwIN.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png"
|
|
242
|
+
/>,
|
|
243
|
+
],
|
|
244
|
+
[
|
|
245
|
+
"Isabelle",
|
|
246
|
+
"-",
|
|
247
|
+
,
|
|
248
|
+
<Image
|
|
249
|
+
alt="Isabelle"
|
|
250
|
+
size="small"
|
|
251
|
+
src="https://play.nintendo.com/images/AC_Isabelle_7XU6aGu.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png"
|
|
252
|
+
/>,
|
|
253
|
+
],
|
|
254
|
+
[
|
|
255
|
+
"K.K.",
|
|
256
|
+
"Slider",
|
|
257
|
+
,
|
|
258
|
+
<Image
|
|
259
|
+
alt="K.K Slider"
|
|
260
|
+
size="small"
|
|
261
|
+
src="https://play.nintendo.com/images/AC_KK_jh4yj5t.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png"
|
|
262
|
+
/>,
|
|
263
|
+
],
|
|
264
|
+
];
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
<Canvas>
|
|
268
|
+
<DSProvider>
|
|
269
|
+
<Table
|
|
270
|
+
columnHeaders={characterHeaders}
|
|
271
|
+
id="jsx-example"
|
|
272
|
+
showRowDividers
|
|
273
|
+
tableData={charactersData}
|
|
274
|
+
/>
|
|
275
|
+
</DSProvider>
|
|
276
|
+
</Canvas>
|
|
@@ -3,6 +3,7 @@ import { render, screen } from "@testing-library/react";
|
|
|
3
3
|
import { axe } from "jest-axe";
|
|
4
4
|
import renderer from "react-test-renderer";
|
|
5
5
|
|
|
6
|
+
import Image from "../Image/Image";
|
|
6
7
|
import Table from "./Table";
|
|
7
8
|
|
|
8
9
|
export const columnHeaders = [
|
|
@@ -14,7 +15,6 @@ export const columnHeaders = [
|
|
|
14
15
|
"Zipcode",
|
|
15
16
|
"State",
|
|
16
17
|
];
|
|
17
|
-
|
|
18
18
|
export const tableData = [
|
|
19
19
|
["Tom", "Nook", "Tanukichi", "Main Street", "New York", "23458", "NY"],
|
|
20
20
|
["Isabelle", "-", "Shizue", "Walnut Street", "New York", "23458", "NY"],
|
|
@@ -29,6 +29,41 @@ export const tableData = [
|
|
|
29
29
|
"NY",
|
|
30
30
|
],
|
|
31
31
|
];
|
|
32
|
+
export const characterHeaders = ["First Name", "Last Name", "Avatar"];
|
|
33
|
+
export const charactersData = [
|
|
34
|
+
[
|
|
35
|
+
"Tom",
|
|
36
|
+
"Nook",
|
|
37
|
+
<Image
|
|
38
|
+
alt="Tom Nook"
|
|
39
|
+
key="tom"
|
|
40
|
+
size="small"
|
|
41
|
+
src="https://play.nintendo.com/images/AC_Tom_FRYtwIN.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png"
|
|
42
|
+
/>,
|
|
43
|
+
],
|
|
44
|
+
[
|
|
45
|
+
"Isabelle",
|
|
46
|
+
"-",
|
|
47
|
+
,
|
|
48
|
+
<Image
|
|
49
|
+
alt="Isabelle"
|
|
50
|
+
key="isa"
|
|
51
|
+
size="small"
|
|
52
|
+
src="https://play.nintendo.com/images/AC_Isabelle_7XU6aGu.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png"
|
|
53
|
+
/>,
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
"K.K.",
|
|
57
|
+
"Slider",
|
|
58
|
+
,
|
|
59
|
+
<Image
|
|
60
|
+
alt="K.K Slider"
|
|
61
|
+
key="kk"
|
|
62
|
+
size="small"
|
|
63
|
+
src="https://play.nintendo.com/images/AC_KK_jh4yj5t.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png"
|
|
64
|
+
/>,
|
|
65
|
+
],
|
|
66
|
+
];
|
|
32
67
|
|
|
33
68
|
describe("Table Accessibility", () => {
|
|
34
69
|
it("passes axe accessibility test with the columnHeaders and tableData prop", async () => {
|
|
@@ -80,6 +115,17 @@ describe("Table", () => {
|
|
|
80
115
|
);
|
|
81
116
|
});
|
|
82
117
|
|
|
118
|
+
it("renders JSX elements from the data array", () => {
|
|
119
|
+
render(
|
|
120
|
+
<Table
|
|
121
|
+
columnHeaders={characterHeaders}
|
|
122
|
+
id="jsx-example"
|
|
123
|
+
tableData={charactersData}
|
|
124
|
+
/>
|
|
125
|
+
);
|
|
126
|
+
expect(screen.getAllByRole("img")).toHaveLength(3);
|
|
127
|
+
});
|
|
128
|
+
|
|
83
129
|
it("renders the UI snapshot correctly", () => {
|
|
84
130
|
const basic = renderer
|
|
85
131
|
.create(<Table id="basic" tableData={tableData} />)
|
|
@@ -140,6 +186,15 @@ describe("Table", () => {
|
|
|
140
186
|
const withOtherProps = renderer
|
|
141
187
|
.create(<Table id="props" tableData={tableData} data-testid="props" />)
|
|
142
188
|
.toJSON();
|
|
189
|
+
const withJSXData = renderer
|
|
190
|
+
.create(
|
|
191
|
+
<Table
|
|
192
|
+
columnHeaders={characterHeaders}
|
|
193
|
+
id="jsx-example"
|
|
194
|
+
tableData={charactersData}
|
|
195
|
+
/>
|
|
196
|
+
)
|
|
197
|
+
.toJSON();
|
|
143
198
|
|
|
144
199
|
expect(basic).toMatchSnapshot();
|
|
145
200
|
expect(withCaption).toMatchSnapshot();
|
|
@@ -148,5 +203,6 @@ describe("Table", () => {
|
|
|
148
203
|
expect(withCustomHeaderColors).toMatchSnapshot();
|
|
149
204
|
expect(withChakraProps).toMatchSnapshot();
|
|
150
205
|
expect(withOtherProps).toMatchSnapshot();
|
|
206
|
+
expect(withJSXData).toMatchSnapshot();
|
|
151
207
|
});
|
|
152
208
|
});
|
|
@@ -11,6 +11,10 @@ import {
|
|
|
11
11
|
} from "@chakra-ui/react";
|
|
12
12
|
import * as React from "react";
|
|
13
13
|
|
|
14
|
+
interface CustomColors {
|
|
15
|
+
backgroundColor?: string;
|
|
16
|
+
color?: string;
|
|
17
|
+
}
|
|
14
18
|
export interface TableProps {
|
|
15
19
|
/** Additional class name for the `Table` component. */
|
|
16
20
|
className?: string;
|
|
@@ -26,7 +30,7 @@ export interface TableProps {
|
|
|
26
30
|
* component. The default value is false. */
|
|
27
31
|
showRowDividers?: boolean;
|
|
28
32
|
/** Two-dimensional array used to populate the table rows. */
|
|
29
|
-
tableData: string[][];
|
|
33
|
+
tableData: (string | JSX.Element)[][];
|
|
30
34
|
/** Displays `Table` title element. */
|
|
31
35
|
titleText?: string;
|
|
32
36
|
/** If true, the first cell of each row in the `Table` component will be
|
|
@@ -41,7 +45,7 @@ export interface TableProps {
|
|
|
41
45
|
export const Table = chakra((props: React.PropsWithChildren<TableProps>) => {
|
|
42
46
|
const {
|
|
43
47
|
className,
|
|
44
|
-
columnHeaders,
|
|
48
|
+
columnHeaders = [],
|
|
45
49
|
columnHeadersBackgroundColor,
|
|
46
50
|
columnHeadersTextColor,
|
|
47
51
|
id,
|
|
@@ -51,8 +55,7 @@ export const Table = chakra((props: React.PropsWithChildren<TableProps>) => {
|
|
|
51
55
|
useRowHeaders = false,
|
|
52
56
|
...rest
|
|
53
57
|
} = props;
|
|
54
|
-
|
|
55
|
-
const customColors = {};
|
|
58
|
+
const customColors: CustomColors = {};
|
|
56
59
|
|
|
57
60
|
columnHeadersBackgroundColor &&
|
|
58
61
|
(customColors["backgroundColor"] = columnHeadersBackgroundColor);
|
|
@@ -1580,3 +1580,124 @@ exports[`Table renders the UI snapshot correctly 7`] = `
|
|
|
1580
1580
|
</tbody>
|
|
1581
1581
|
</table>
|
|
1582
1582
|
`;
|
|
1583
|
+
|
|
1584
|
+
exports[`Table renders the UI snapshot correctly 8`] = `
|
|
1585
|
+
<table
|
|
1586
|
+
className="chakra-table css-1xdhyk6"
|
|
1587
|
+
id="jsx-example"
|
|
1588
|
+
role="table"
|
|
1589
|
+
>
|
|
1590
|
+
<thead
|
|
1591
|
+
className="css-0"
|
|
1592
|
+
>
|
|
1593
|
+
<tr
|
|
1594
|
+
className="css-0"
|
|
1595
|
+
role="row"
|
|
1596
|
+
>
|
|
1597
|
+
<th
|
|
1598
|
+
className="css-0"
|
|
1599
|
+
scope="col"
|
|
1600
|
+
>
|
|
1601
|
+
First Name
|
|
1602
|
+
</th>
|
|
1603
|
+
<th
|
|
1604
|
+
className="css-0"
|
|
1605
|
+
scope="col"
|
|
1606
|
+
>
|
|
1607
|
+
Last Name
|
|
1608
|
+
</th>
|
|
1609
|
+
<th
|
|
1610
|
+
className="css-0"
|
|
1611
|
+
scope="col"
|
|
1612
|
+
>
|
|
1613
|
+
Avatar
|
|
1614
|
+
</th>
|
|
1615
|
+
</tr>
|
|
1616
|
+
</thead>
|
|
1617
|
+
<tbody
|
|
1618
|
+
className="css-0"
|
|
1619
|
+
>
|
|
1620
|
+
<tr
|
|
1621
|
+
className="css-0"
|
|
1622
|
+
role="row"
|
|
1623
|
+
>
|
|
1624
|
+
<td
|
|
1625
|
+
className="css-0"
|
|
1626
|
+
role="gridcell"
|
|
1627
|
+
>
|
|
1628
|
+
Tom
|
|
1629
|
+
</td>
|
|
1630
|
+
<td
|
|
1631
|
+
className="css-0"
|
|
1632
|
+
role="gridcell"
|
|
1633
|
+
>
|
|
1634
|
+
Nook
|
|
1635
|
+
</td>
|
|
1636
|
+
<td
|
|
1637
|
+
className="css-0"
|
|
1638
|
+
role="gridcell"
|
|
1639
|
+
>
|
|
1640
|
+
<img
|
|
1641
|
+
alt="Tom Nook"
|
|
1642
|
+
className="css-0"
|
|
1643
|
+
src="https://play.nintendo.com/images/AC_Tom_FRYtwIN.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png"
|
|
1644
|
+
/>
|
|
1645
|
+
</td>
|
|
1646
|
+
</tr>
|
|
1647
|
+
<tr
|
|
1648
|
+
className="css-0"
|
|
1649
|
+
role="row"
|
|
1650
|
+
>
|
|
1651
|
+
<td
|
|
1652
|
+
className="css-0"
|
|
1653
|
+
role="gridcell"
|
|
1654
|
+
>
|
|
1655
|
+
Isabelle
|
|
1656
|
+
</td>
|
|
1657
|
+
<td
|
|
1658
|
+
className="css-0"
|
|
1659
|
+
role="gridcell"
|
|
1660
|
+
>
|
|
1661
|
+
-
|
|
1662
|
+
</td>
|
|
1663
|
+
<td
|
|
1664
|
+
className="css-0"
|
|
1665
|
+
role="gridcell"
|
|
1666
|
+
>
|
|
1667
|
+
<img
|
|
1668
|
+
alt="Isabelle"
|
|
1669
|
+
className="css-0"
|
|
1670
|
+
src="https://play.nintendo.com/images/AC_Isabelle_7XU6aGu.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png"
|
|
1671
|
+
/>
|
|
1672
|
+
</td>
|
|
1673
|
+
</tr>
|
|
1674
|
+
<tr
|
|
1675
|
+
className="css-0"
|
|
1676
|
+
role="row"
|
|
1677
|
+
>
|
|
1678
|
+
<td
|
|
1679
|
+
className="css-0"
|
|
1680
|
+
role="gridcell"
|
|
1681
|
+
>
|
|
1682
|
+
K.K.
|
|
1683
|
+
</td>
|
|
1684
|
+
<td
|
|
1685
|
+
className="css-0"
|
|
1686
|
+
role="gridcell"
|
|
1687
|
+
>
|
|
1688
|
+
Slider
|
|
1689
|
+
</td>
|
|
1690
|
+
<td
|
|
1691
|
+
className="css-0"
|
|
1692
|
+
role="gridcell"
|
|
1693
|
+
>
|
|
1694
|
+
<img
|
|
1695
|
+
alt="K.K Slider"
|
|
1696
|
+
className="css-0"
|
|
1697
|
+
src="https://play.nintendo.com/images/AC_KK_jh4yj5t.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png"
|
|
1698
|
+
/>
|
|
1699
|
+
</td>
|
|
1700
|
+
</tr>
|
|
1701
|
+
</tbody>
|
|
1702
|
+
</table>
|
|
1703
|
+
`;
|
|
@@ -73,7 +73,7 @@ describe("Tabs Accessibility", () => {
|
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
describe("Tabs", () => {
|
|
76
|
-
const getTabByName = (name) => screen.getByRole("tab", { name });
|
|
76
|
+
const getTabByName = (name: string) => screen.getByRole("tab", { name });
|
|
77
77
|
|
|
78
78
|
it("renders all tabs but only one panel at a time with children", () => {
|
|
79
79
|
render(
|
|
@@ -191,7 +191,7 @@ describe("Tabs", () => {
|
|
|
191
191
|
|
|
192
192
|
it("invokes the callback function", () => {
|
|
193
193
|
let selectedIndex = 0;
|
|
194
|
-
const onChange = (index) => (selectedIndex = index);
|
|
194
|
+
const onChange = (index: number) => (selectedIndex = index);
|
|
195
195
|
|
|
196
196
|
render(<Tabs tabsData={animalCrossing} onChange={onChange} />);
|
|
197
197
|
|
|
@@ -10,10 +10,8 @@ import {
|
|
|
10
10
|
} from "@chakra-ui/react";
|
|
11
11
|
import * as React from "react";
|
|
12
12
|
|
|
13
|
-
import { IconNames, IconRotationTypes, IconSizes } from "../Icons/IconTypes";
|
|
14
|
-
import Icon from "../Icons/Icon";
|
|
15
|
-
import { ButtonTypes } from "../Button/ButtonTypes";
|
|
16
13
|
import Button from "../Button/Button";
|
|
14
|
+
import Icon from "../Icons/Icon";
|
|
17
15
|
import useCarouselStyles from "../../hooks/useCarouselStyles";
|
|
18
16
|
import useWindowSize from "../../hooks/useWindowSize";
|
|
19
17
|
|
|
@@ -47,7 +45,7 @@ export interface TabsProps {
|
|
|
47
45
|
* An internal function used to update the hash in the URL.
|
|
48
46
|
* This function is only used when `useHash` is `true`.
|
|
49
47
|
*/
|
|
50
|
-
const onClickHash = (tabHash) => {
|
|
48
|
+
const onClickHash = (tabHash: string) => {
|
|
51
49
|
window.location.hash = tabHash;
|
|
52
50
|
};
|
|
53
51
|
|
|
@@ -55,9 +53,12 @@ const onClickHash = (tabHash) => {
|
|
|
55
53
|
* This returns an object with `Tab` and `TabPanel` components to rendered in
|
|
56
54
|
* `TabList` and `TabPanels` components respectively.
|
|
57
55
|
*/
|
|
58
|
-
const getElementsFromData = (
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
const getElementsFromData = (
|
|
57
|
+
data: TabsDataProps[],
|
|
58
|
+
useHash: boolean
|
|
59
|
+
): TabPanelProps => {
|
|
60
|
+
const tabs: React.ReactNode[] = [];
|
|
61
|
+
const panels: React.ReactNode[] = [];
|
|
61
62
|
|
|
62
63
|
if (!data?.length) {
|
|
63
64
|
return { tabs: [], panels: [] };
|
|
@@ -76,7 +77,7 @@ const getElementsFromData = (data, useHash): TabPanelProps => {
|
|
|
76
77
|
<Tab
|
|
77
78
|
fontSize={["0", null, "1"]}
|
|
78
79
|
key={index}
|
|
79
|
-
onClick={useHash ? () => onClickHash(`tab${index + 1}`) :
|
|
80
|
+
onClick={useHash ? () => onClickHash(`tab${index + 1}`) : undefined}
|
|
80
81
|
>
|
|
81
82
|
{tab.label}
|
|
82
83
|
</Tab>
|
|
@@ -107,14 +108,14 @@ const getElementsFromData = (data, useHash): TabPanelProps => {
|
|
|
107
108
|
* the DOM when building up the `Tabs` component using child component.
|
|
108
109
|
*/
|
|
109
110
|
const getElementsFromChildren = (children): TabPanelProps => {
|
|
110
|
-
const tabs = [];
|
|
111
|
-
const panels = [];
|
|
111
|
+
const tabs: React.ReactNode[] = [];
|
|
112
|
+
const panels: React.ReactNode[] = [];
|
|
112
113
|
|
|
113
114
|
if (!children?.length) {
|
|
114
115
|
return { tabs: [], panels: [] };
|
|
115
116
|
}
|
|
116
117
|
|
|
117
|
-
children.forEach((child) => {
|
|
118
|
+
children.forEach((child: JSX.Element) => {
|
|
118
119
|
if (child.type === TabList || child.props.mdxType === "TabList") {
|
|
119
120
|
tabs.push(child);
|
|
120
121
|
|
|
@@ -187,39 +188,37 @@ export const Tabs = chakra((props: React.PropsWithChildren<TabsProps>) => {
|
|
|
187
188
|
}, [goToStart, windowDimensions.width]);
|
|
188
189
|
const previousButton = (
|
|
189
190
|
<Button
|
|
190
|
-
|
|
191
|
-
|
|
191
|
+
aria-label="Previous"
|
|
192
|
+
id={`tabs-previous-${id}`}
|
|
193
|
+
onClick={prevSlide}
|
|
194
|
+
__css={{
|
|
192
195
|
...styles.buttonArrows,
|
|
193
196
|
left: "0",
|
|
194
197
|
}}
|
|
195
|
-
buttonType={ButtonTypes.Primary}
|
|
196
|
-
id={`tabs-previous-${id}`}
|
|
197
|
-
onClick={prevSlide}
|
|
198
198
|
>
|
|
199
199
|
<Icon
|
|
200
|
-
iconRotation=
|
|
200
|
+
iconRotation="rotate90"
|
|
201
201
|
id={`tabs-previous-icon-${id}`}
|
|
202
|
-
name=
|
|
203
|
-
size=
|
|
202
|
+
name="arrow"
|
|
203
|
+
size="small"
|
|
204
204
|
/>
|
|
205
205
|
</Button>
|
|
206
206
|
);
|
|
207
207
|
const nextButton = (
|
|
208
208
|
<Button
|
|
209
|
-
|
|
210
|
-
|
|
209
|
+
aria-label="Next"
|
|
210
|
+
id={`tabs-next-${id}`}
|
|
211
|
+
onClick={nextSlide}
|
|
212
|
+
__css={{
|
|
211
213
|
...styles.buttonArrows,
|
|
212
214
|
right: "0",
|
|
213
215
|
}}
|
|
214
|
-
buttonType={ButtonTypes.Primary}
|
|
215
|
-
id={`tabs-next-${id}`}
|
|
216
|
-
onClick={nextSlide}
|
|
217
216
|
>
|
|
218
217
|
<Icon
|
|
219
|
-
iconRotation=
|
|
218
|
+
iconRotation="rotate270"
|
|
220
219
|
id={`tabs-next-icon-${id}`}
|
|
221
|
-
name=
|
|
222
|
-
size=
|
|
220
|
+
name="arrow"
|
|
221
|
+
size="small"
|
|
223
222
|
/>
|
|
224
223
|
</Button>
|
|
225
224
|
);
|