@nypl/design-system-react-components 0.25.13 → 0.27.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 +85 -0
- package/README.md +10 -10
- package/dist/components/Accordion/Accordion.d.ts +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/dist/components/Button/Button.d.ts +2 -2
- package/dist/components/Card/Card.d.ts +11 -9
- package/dist/components/Checkbox/Checkbox.d.ts +2 -2
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +5 -4
- package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +1 -1
- package/dist/components/DatePicker/DatePicker.d.ts +5 -6
- package/dist/components/Fieldset/Fieldset.d.ts +5 -6
- package/dist/components/Form/Form.d.ts +6 -6
- package/dist/components/Grid/GridTypes.d.ts +7 -7
- package/dist/components/Grid/SimpleGrid.d.ts +1 -1
- package/dist/components/Heading/Heading.d.ts +1 -1
- package/dist/components/HelperErrorText/HelperErrorText.d.ts +9 -8
- package/dist/components/Hero/Hero.d.ts +2 -1
- package/dist/components/HorizontalRule/HorizontalRule.d.ts +2 -10
- package/dist/components/Icons/Icon.d.ts +2 -1
- package/dist/components/Image/Image.d.ts +2 -2
- package/dist/components/Label/Label.d.ts +7 -4
- package/dist/components/Link/Link.d.ts +1 -1
- package/dist/components/List/List.d.ts +11 -11
- package/dist/components/List/ListTypes.d.ts +1 -1
- package/dist/components/Logo/Logo.d.ts +2 -1
- package/dist/components/Logo/LogoSvgs.d.ts +2 -0
- package/dist/components/Logo/LogoTypes.d.ts +2 -0
- package/dist/components/Modal/Modal.d.ts +28 -8
- package/dist/components/Notification/Notification.d.ts +4 -4
- package/dist/components/Pagination/Pagination.d.ts +2 -2
- package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +3 -3
- package/dist/components/Radio/Radio.d.ts +4 -6
- package/dist/components/RadioGroup/RadioGroup.d.ts +12 -6
- package/dist/components/SearchBar/SearchBar.d.ts +4 -4
- package/dist/components/Select/Select.d.ts +10 -6
- package/dist/components/Select/SelectTypes.d.ts +4 -0
- package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -3
- package/dist/components/Slider/Slider.d.ts +6 -4
- package/dist/components/StatusBadge/StatusBadge.d.ts +5 -1
- package/dist/components/StructuredContent/StructuredContent.d.ts +2 -2
- package/dist/components/Table/Table.d.ts +1 -1
- package/dist/components/Tabs/Tabs.d.ts +4 -3
- package/dist/components/Template/Template.d.ts +4 -3
- package/dist/components/Text/Text.d.ts +1 -1
- package/dist/components/TextInput/TextInput.d.ts +5 -5
- package/dist/components/Toggle/Toggle.d.ts +3 -4
- package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
- package/dist/design-system-react-components.cjs.development.js +1767 -1180
- 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 +1774 -1188
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/hooks/useCarouselStyles.d.ts +3 -2
- package/dist/hooks/useNYPLTheme.d.ts +12 -0
- package/dist/index.d.ts +5 -2
- package/dist/styles.css +1 -1
- package/dist/theme/components/button.d.ts +10 -2
- package/dist/theme/components/card.d.ts +42 -22
- package/dist/theme/components/checkbox.d.ts +5 -4
- package/dist/theme/components/checkboxGroup.d.ts +1 -1
- package/dist/theme/components/componentWrapper.d.ts +2 -2
- package/dist/theme/components/customTable.d.ts +84 -1
- package/dist/theme/components/fieldset.d.ts +4 -14
- package/dist/theme/components/global.d.ts +23 -17
- package/dist/theme/components/heading.d.ts +53 -0
- package/dist/theme/components/helperErrorText.d.ts +1 -0
- package/dist/theme/components/hero.d.ts +20 -14
- package/dist/theme/components/label.d.ts +9 -10
- package/dist/theme/components/list.d.ts +99 -9
- package/dist/theme/components/radio.d.ts +6 -4
- package/dist/theme/components/radioGroup.d.ts +1 -1
- package/dist/theme/components/select.d.ts +28 -5
- package/dist/theme/components/skeletonLoader.d.ts +2 -2
- package/dist/theme/components/slider.d.ts +6 -3
- package/dist/theme/components/structuredContent.d.ts +197 -0
- package/dist/theme/components/textInput.d.ts +18 -6
- package/dist/theme/components/toggle.d.ts +7 -4
- package/dist/theme/foundations/global.d.ts +2 -0
- package/dist/theme/foundations/radii.d.ts +1 -0
- package/dist/theme/foundations/spacing.d.ts +46 -43
- package/package.json +17 -19
- package/src/components/Accordion/Accordion.stories.mdx +9 -9
- package/src/components/Accordion/Accordion.test.tsx +21 -0
- package/src/components/Accordion/Accordion.tsx +13 -9
- package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +276 -27
- package/src/components/Autosuggest/Autosuggest.stories.mdx +4 -3
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +21 -5
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +52 -31
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +8 -7
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +211 -12
- package/src/components/Button/Button.stories.mdx +87 -23
- package/src/components/Button/Button.test.tsx +25 -0
- package/src/components/Button/Button.tsx +18 -7
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +27 -7
- package/src/components/Card/Card.stories.mdx +287 -194
- package/src/components/Card/Card.test.tsx +102 -0
- package/src/components/Card/Card.tsx +73 -32
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +196 -36
- package/src/components/Chakra/Grid.stories.mdx +4 -4
- package/src/components/Checkbox/Checkbox.stories.mdx +62 -10
- package/src/components/Checkbox/Checkbox.test.tsx +32 -9
- package/src/components/Checkbox/Checkbox.tsx +20 -15
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +134 -7
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +65 -17
- package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +137 -81
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +31 -21
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +332 -97
- package/src/components/ComponentWrapper/ComponentWrapper.test.tsx +12 -0
- package/src/components/ComponentWrapper/ComponentWrapper.tsx +39 -41
- package/src/components/ComponentWrapper/__snapshots__/ComponentWrapper.test.tsx.snap +47 -34
- package/src/components/DatePicker/DatePicker.stories.mdx +63 -27
- package/src/components/DatePicker/DatePicker.test.tsx +89 -13
- package/src/components/DatePicker/DatePicker.tsx +62 -56
- package/src/components/DatePicker/_DatePicker.scss +71 -13
- package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +250 -206
- package/src/components/Fieldset/Fieldset.stories.mdx +33 -3
- package/src/components/Fieldset/Fieldset.test.tsx +58 -28
- package/src/components/Fieldset/Fieldset.tsx +35 -30
- package/src/components/Fieldset/__snapshots__/Fieldset.test.tsx.snap +40 -19
- package/src/components/Form/Form.stories.mdx +72 -39
- package/src/components/Form/Form.test.tsx +58 -15
- package/src/components/Form/Form.tsx +89 -67
- package/src/components/Form/__snapshots__/Form.test.tsx.snap +83 -5
- package/src/components/Grid/GridTypes.tsx +7 -7
- package/src/components/Grid/SimpleGrid.stories.mdx +34 -6
- package/src/components/Grid/SimpleGrid.test.tsx +9 -0
- package/src/components/Grid/SimpleGrid.tsx +29 -20
- package/src/components/Grid/__snapshots__/SimpleGrid.test.tsx.snap +16 -1
- package/src/components/Heading/Heading.stories.mdx +36 -3
- package/src/components/Heading/Heading.test.tsx +10 -0
- package/src/components/Heading/Heading.tsx +56 -50
- package/src/components/Heading/__snapshots__/Heading.test.tsx.snap +26 -7
- package/src/components/HelperErrorText/HelperErrorText.stories.mdx +64 -42
- package/src/components/HelperErrorText/HelperErrorText.test.tsx +15 -0
- package/src/components/HelperErrorText/HelperErrorText.tsx +40 -35
- package/src/components/HelperErrorText/__snapshots__/HelperErrorText.test.tsx.snap +35 -4
- package/src/components/Hero/Hero.stories.mdx +125 -95
- package/src/components/Hero/Hero.test.tsx +33 -0
- package/src/components/Hero/Hero.tsx +135 -126
- package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +89 -17
- package/src/components/HorizontalRule/HorizontalRule.stories.mdx +26 -4
- package/src/components/HorizontalRule/HorizontalRule.test.tsx +9 -19
- package/src/components/HorizontalRule/HorizontalRule.tsx +9 -26
- package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +18 -5
- package/src/components/Icons/Icon.stories.mdx +31 -6
- package/src/components/Icons/Icon.test.tsx +38 -0
- package/src/components/Icons/Icon.tsx +93 -76
- package/src/components/Icons/__snapshots__/Icon.test.tsx.snap +129 -0
- package/src/components/Image/Image.stories.mdx +29 -5
- package/src/components/Image/Image.test.tsx +8 -0
- package/src/components/Image/Image.tsx +38 -26
- package/src/components/Image/__snapshots__/Image.test.tsx.snap +24 -8
- package/src/components/Label/Label.stories.mdx +42 -20
- package/src/components/Label/Label.test.tsx +42 -17
- package/src/components/Label/Label.tsx +22 -13
- package/src/components/Label/__snapshots__/Label.test.tsx.snap +19 -15
- package/src/components/Link/Link.stories.mdx +25 -15
- package/src/components/Link/Link.test.tsx +21 -22
- package/src/components/Link/Link.tsx +8 -8
- package/src/components/Link/__snapshots__/Link.test.tsx.snap +37 -11
- package/src/components/List/List.stories.mdx +75 -40
- package/src/components/List/List.test.tsx +67 -19
- package/src/components/List/List.tsx +38 -25
- package/src/components/List/ListTypes.tsx +1 -1
- package/src/components/List/__snapshots__/List.test.tsx.snap +110 -8
- package/src/components/Logo/Logo.stories.mdx +30 -6
- package/src/components/Logo/Logo.test.tsx +17 -0
- package/src/components/Logo/Logo.tsx +18 -6
- package/src/components/Logo/LogoSvgs.tsx +4 -0
- package/src/components/Logo/LogoTypes.tsx +2 -0
- package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +73 -2
- package/src/components/Modal/Modal.stories.mdx +256 -136
- package/src/components/Modal/Modal.test.tsx +151 -9
- package/src/components/Modal/Modal.tsx +140 -20
- package/src/components/Modal/__snapshots__/Modal.test.tsx.snap +25 -0
- package/src/components/Notification/Notification.stories.mdx +25 -1
- package/src/components/Notification/Notification.test.tsx +23 -0
- package/src/components/Notification/Notification.tsx +46 -44
- package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +158 -29
- package/src/components/Pagination/Pagination.stories.mdx +25 -6
- package/src/components/Pagination/Pagination.test.tsx +25 -0
- package/src/components/Pagination/Pagination.tsx +6 -6
- package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +244 -27
- package/src/components/Placeholder/Placeholder.tsx +3 -1
- package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +76 -10
- package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +81 -11
- package/src/components/ProgressIndicator/ProgressIndicator.tsx +17 -9
- package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +101 -14
- package/src/components/Radio/Radio.stories.mdx +64 -12
- package/src/components/Radio/Radio.test.tsx +28 -8
- package/src/components/Radio/Radio.tsx +66 -63
- package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +103 -6
- package/src/components/RadioGroup/RadioGroup.stories.mdx +224 -89
- package/src/components/RadioGroup/RadioGroup.test.tsx +122 -62
- package/src/components/RadioGroup/RadioGroup.tsx +106 -100
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +1236 -1020
- package/src/components/SearchBar/SearchBar.stories.mdx +101 -36
- package/src/components/SearchBar/{SearchBar.Test.tsx → SearchBar.test.tsx} +46 -4
- package/src/components/SearchBar/SearchBar.tsx +17 -8
- package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +1039 -0
- package/src/components/Select/Select.stories.mdx +128 -49
- package/src/components/Select/Select.test.tsx +63 -16
- package/src/components/Select/Select.tsx +131 -92
- package/src/components/Select/SelectTypes.tsx +5 -0
- package/src/components/Select/__snapshots__/Select.test.tsx.snap +765 -425
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +42 -10
- package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +8 -0
- package/src/components/SkeletonLoader/SkeletonLoader.tsx +76 -72
- package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +169 -10
- package/src/components/Slider/Slider.stories.mdx +91 -42
- package/src/components/Slider/Slider.test.tsx +65 -17
- package/src/components/Slider/Slider.tsx +26 -19
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +403 -226
- package/src/components/StatusBadge/StatusBadge.stories.mdx +19 -1
- package/src/components/StatusBadge/StatusBadge.test.tsx +16 -0
- package/src/components/StatusBadge/StatusBadge.tsx +25 -20
- package/src/components/StatusBadge/__snapshots__/StatusBadge.test.tsx.snap +22 -3
- package/src/components/StructuredContent/StructuredContent.stories.mdx +131 -12
- package/src/components/StructuredContent/StructuredContent.test.tsx +34 -0
- package/src/components/StructuredContent/StructuredContent.tsx +80 -75
- package/src/components/StructuredContent/__snapshots__/StructuredContent.test.tsx.snap +102 -17
- package/src/components/StyleGuide/Bidirectionality.stories.mdx +5 -5
- package/src/components/StyleGuide/Breakpoints.stories.mdx +6 -6
- package/src/components/StyleGuide/Buttons.stories.mdx +2 -12
- package/src/components/StyleGuide/ColorCard.tsx +1 -1
- package/src/components/StyleGuide/Colors.stories.mdx +1 -2
- package/src/components/StyleGuide/DesignTokens.stories.mdx +56 -26
- package/src/components/StyleGuide/Forms.stories.mdx +27 -12
- package/src/components/StyleGuide/Iconography.stories.mdx +2 -12
- package/src/components/StyleGuide/Spacing.stories.mdx +80 -41
- package/src/components/StyleGuide/Typography.stories.mdx +30 -21
- package/src/components/Table/Table.stories.mdx +38 -11
- package/src/components/Table/Table.test.tsx +15 -0
- package/src/components/Table/Table.tsx +7 -7
- package/src/components/Table/__snapshots__/Table.test.tsx.snap +408 -5
- package/src/components/Tabs/Tabs.stories.mdx +52 -3
- package/src/components/Tabs/Tabs.test.tsx +16 -0
- package/src/components/Tabs/Tabs.tsx +10 -6
- package/src/components/Tabs/__snapshots__/Tabs.test.tsx.snap +394 -5
- package/src/components/Template/Template.stories.mdx +47 -43
- package/src/components/Template/Template.test.tsx +33 -0
- package/src/components/Template/Template.tsx +65 -60
- package/src/components/Template/__snapshots__/Template.test.tsx.snap +191 -20
- package/src/components/Text/Text.stories.mdx +20 -1
- package/src/components/Text/Text.test.tsx +12 -0
- package/src/components/Text/Text.tsx +6 -4
- package/src/components/Text/__snapshots__/Text.test.tsx.snap +21 -4
- package/src/components/TextInput/TextInput.stories.mdx +65 -19
- package/src/components/TextInput/TextInput.test.tsx +42 -28
- package/src/components/TextInput/TextInput.tsx +121 -113
- package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +96 -73
- package/src/components/Toggle/Toggle.stories.mdx +80 -22
- package/src/components/Toggle/Toggle.test.tsx +27 -9
- package/src/components/Toggle/Toggle.tsx +22 -18
- package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +128 -5
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +52 -4
- package/src/components/VideoPlayer/VideoPlayer.test.tsx +23 -0
- package/src/components/VideoPlayer/VideoPlayer.tsx +133 -126
- package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +81 -39
- package/src/docs/Chakra.stories.mdx +50 -9
- package/src/docs/Welcome.stories.mdx +160 -41
- package/src/hooks/useCarouselStyles.stories.mdx +22 -2
- package/src/hooks/useCarouselStyles.ts +3 -2
- package/src/hooks/useNYPLTheme.stories.mdx +101 -0
- package/src/hooks/useNYPLTheme.ts +30 -6
- package/src/hooks/useWindowSize.stories.mdx +23 -0
- package/src/index.ts +5 -2
- package/src/styles/base/_place-holder.scss +1 -1
- package/src/styles.scss +0 -1
- package/src/theme/components/button.ts +15 -7
- package/src/theme/components/card.ts +30 -19
- package/src/theme/components/checkbox.ts +10 -8
- package/src/theme/components/checkboxGroup.ts +1 -1
- package/src/theme/components/componentWrapper.ts +2 -2
- package/src/theme/components/customTable.ts +39 -31
- package/src/theme/components/fieldset.ts +1 -2
- package/src/theme/components/global.ts +25 -20
- package/src/theme/components/heading.ts +1 -1
- package/src/theme/components/helperErrorText.ts +1 -0
- package/src/theme/components/hero.ts +13 -15
- package/src/theme/components/label.ts +4 -3
- package/src/theme/components/list.ts +73 -66
- package/src/theme/components/notification.ts +2 -2
- package/src/theme/components/radio.ts +9 -9
- package/src/theme/components/radioGroup.ts +1 -1
- package/src/theme/components/select.ts +31 -22
- package/src/theme/components/skeletonLoader.ts +3 -3
- package/src/theme/components/slider.ts +8 -7
- package/src/theme/components/statusBadge.ts +2 -2
- package/src/theme/components/structuredContent.ts +66 -1
- package/src/theme/components/tabs.ts +2 -2
- package/src/theme/components/template.ts +9 -9
- package/src/theme/components/textInput.ts +13 -12
- package/src/theme/components/toggle.ts +17 -10
- package/src/theme/components/videoPlayer.ts +1 -1
- package/src/theme/foundations/colors.ts +1 -1
- package/src/theme/foundations/radii.ts +1 -0
- package/src/theme/foundations/spacing.ts +70 -22
- package/src/theme/foundations/typography.ts +2 -2
- package/src/utils/componentCategories.ts +1 -2
- package/dist/components/SearchBar/SearchBar.Test.d.ts +0 -1
- package/dist/helpers/generateUUID.d.ts +0 -1
- package/src/components/Modal/_Modal.scss +0 -18
- package/src/helpers/generateUUID.tsx +0 -5
|
@@ -46,6 +46,7 @@ export const layoutsEnumValues = getStorybookEnumValues(
|
|
|
46
46
|
},
|
|
47
47
|
options: imageRatiosEnumValues.options,
|
|
48
48
|
},
|
|
49
|
+
isBordered: { table: { defaultValue: { summary: "false" } } },
|
|
49
50
|
layout: {
|
|
50
51
|
table: { defaultValue: { summary: "LayoutTypes.Column" } },
|
|
51
52
|
options: layoutsEnumValues.options,
|
|
@@ -62,7 +63,17 @@ export const layoutsEnumValues = getStorybookEnumValues(
|
|
|
62
63
|
| Component Version | DS Version |
|
|
63
64
|
| ----------------- | ---------- |
|
|
64
65
|
| Added | `0.17.3` |
|
|
65
|
-
| Latest | `0.
|
|
66
|
+
| Latest | `0.26.0` |
|
|
67
|
+
|
|
68
|
+
## Table of Contents
|
|
69
|
+
|
|
70
|
+
- [Overview](#overview)
|
|
71
|
+
- [Component Props](#component-props)
|
|
72
|
+
- [Accessibility](#accessibility)
|
|
73
|
+
- [Card Placeholders in a Grid](#card-placeholders-in-a-grid)
|
|
74
|
+
- [Text Placeholders in a List](#text-placeholders-in-a-list)
|
|
75
|
+
|
|
76
|
+
## Overview
|
|
66
77
|
|
|
67
78
|
<Description of={SkeletonLoader} />
|
|
68
79
|
|
|
@@ -72,15 +83,17 @@ be customized.
|
|
|
72
83
|
Please note that the initial rendering below has the `width` prop set to `300px`
|
|
73
84
|
to better view the example. The default value is `100%`.
|
|
74
85
|
|
|
86
|
+
## Component Props
|
|
87
|
+
|
|
75
88
|
<Canvas withToolbar>
|
|
76
89
|
<Story
|
|
77
90
|
name="SkeletonLoader with Controls"
|
|
78
91
|
args={{
|
|
79
|
-
border: false,
|
|
80
92
|
className: undefined,
|
|
81
93
|
contentSize: 3,
|
|
82
94
|
headingSize: 1,
|
|
83
95
|
imageAspectRatio: "SkeletonLoaderImageRatios.Square",
|
|
96
|
+
isBordered: false,
|
|
84
97
|
layout: "LayoutTypes.Column",
|
|
85
98
|
showButton: false,
|
|
86
99
|
showContent: true,
|
|
@@ -101,40 +114,59 @@ to better view the example. The default value is `100%`.
|
|
|
101
114
|
|
|
102
115
|
<ArgsTable story="SkeletonLoader with Controls" />
|
|
103
116
|
|
|
104
|
-
|
|
117
|
+
## Accessibility
|
|
118
|
+
|
|
119
|
+
According to W3C's success criterion 2.2.2 for operable user interfaces:
|
|
120
|
+
|
|
121
|
+
> For any moving, blinking or scrolling information that (1) starts automatically,
|
|
122
|
+
> (2) lasts more than five seconds, and (3) is presented in parallel with other
|
|
123
|
+
> content, there is a mechanism for the user to pause, stop, or hide it unless
|
|
124
|
+
> the movement, blinking, or scrolling is part of an activity where it is essential;
|
|
125
|
+
|
|
126
|
+
The `SkeletonLoader` component can be used as a placeholder for local content
|
|
127
|
+
that is loaded in parallel but it typically does not last more than five (5)
|
|
128
|
+
seconds. For the DS usage, this is purely a visual cue and should not be picked
|
|
129
|
+
up by screen readers.
|
|
130
|
+
|
|
131
|
+
Resources:
|
|
132
|
+
|
|
133
|
+
- [W3C Perceivable Pause, Stop, Hide](https://www.w3.org/TR/WCAG/#pause-stop-hide)
|
|
134
|
+
- [More Accessible Skeletons](https://adrianroselli.com/2020/11/more-accessible-skeletons.html)
|
|
135
|
+
|
|
136
|
+
## Card Placeholders in a Grid
|
|
105
137
|
|
|
106
138
|
<Canvas>
|
|
107
139
|
<Story name="Placeholders in a Grid">
|
|
108
140
|
<SimpleGrid columns={3}>
|
|
109
141
|
<SkeletonLoader
|
|
110
142
|
imageAspectRatio={SkeletonLoaderImageRatios.Landscape}
|
|
111
|
-
|
|
143
|
+
isBordered
|
|
112
144
|
/>
|
|
113
145
|
<SkeletonLoader
|
|
114
146
|
imageAspectRatio={SkeletonLoaderImageRatios.Landscape}
|
|
115
|
-
|
|
147
|
+
isBordered
|
|
116
148
|
/>
|
|
117
149
|
<SkeletonLoader
|
|
118
150
|
imageAspectRatio={SkeletonLoaderImageRatios.Landscape}
|
|
119
|
-
|
|
151
|
+
isBordered
|
|
120
152
|
/>
|
|
121
153
|
<SkeletonLoader
|
|
122
154
|
imageAspectRatio={SkeletonLoaderImageRatios.Landscape}
|
|
123
|
-
|
|
155
|
+
isBordered
|
|
124
156
|
/>
|
|
125
157
|
<SkeletonLoader
|
|
126
158
|
imageAspectRatio={SkeletonLoaderImageRatios.Landscape}
|
|
127
|
-
|
|
159
|
+
isBordered
|
|
128
160
|
/>
|
|
129
161
|
<SkeletonLoader
|
|
130
162
|
imageAspectRatio={SkeletonLoaderImageRatios.Landscape}
|
|
131
|
-
|
|
163
|
+
isBordered
|
|
132
164
|
/>
|
|
133
165
|
</SimpleGrid>
|
|
134
166
|
</Story>
|
|
135
167
|
</Canvas>
|
|
136
168
|
|
|
137
|
-
|
|
169
|
+
## Text Placeholders in a List
|
|
138
170
|
|
|
139
171
|
<Canvas>
|
|
140
172
|
<Story name="Placeholders in a List">
|
|
@@ -107,6 +107,12 @@ describe("SkeletonLoader", () => {
|
|
|
107
107
|
<SkeletonLoader imageAspectRatio={SkeletonLoaderImageRatios.Square} />
|
|
108
108
|
)
|
|
109
109
|
.toJSON();
|
|
110
|
+
const withChakraProps = renderer
|
|
111
|
+
.create(<SkeletonLoader p="20px" color="ui.error.primary" />)
|
|
112
|
+
.toJSON();
|
|
113
|
+
const withOtherProps = renderer
|
|
114
|
+
.create(<SkeletonLoader data-testid="props" />)
|
|
115
|
+
.toJSON();
|
|
110
116
|
|
|
111
117
|
expect(basic).toMatchSnapshot();
|
|
112
118
|
expect(rowLayout).toMatchSnapshot();
|
|
@@ -118,5 +124,7 @@ describe("SkeletonLoader", () => {
|
|
|
118
124
|
expect(landscape).toMatchSnapshot();
|
|
119
125
|
expect(portrait).toMatchSnapshot();
|
|
120
126
|
expect(square).toMatchSnapshot();
|
|
127
|
+
expect(withChakraProps).toMatchSnapshot();
|
|
128
|
+
expect(withOtherProps).toMatchSnapshot();
|
|
121
129
|
});
|
|
122
130
|
});
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
import {
|
|
3
2
|
Box,
|
|
3
|
+
chakra,
|
|
4
4
|
Skeleton as ChakraSkeleton,
|
|
5
5
|
useMultiStyleConfig,
|
|
6
6
|
} from "@chakra-ui/react";
|
|
7
|
+
import * as React from "react";
|
|
7
8
|
|
|
8
9
|
import { SkeletonLoaderImageRatios } from "./SkeletonLoaderTypes";
|
|
9
10
|
import { LayoutTypes } from "../../helpers/enums";
|
|
10
11
|
|
|
11
12
|
export interface SkeletonLoaderProps {
|
|
12
|
-
/** Optional boolean value to control visibility of border around skeleton loader. */
|
|
13
|
-
border?: boolean;
|
|
14
13
|
/** Additional class name for the Skeleton component. */
|
|
15
14
|
className?: string;
|
|
16
15
|
/** Optional numeric value to control the number of lines for content
|
|
@@ -22,6 +21,8 @@ export interface SkeletonLoaderProps {
|
|
|
22
21
|
/** Optional value to control the aspect ratio of the image placeholder;
|
|
23
22
|
* default value is `SkeletonLoaderImageRatios.Square`. */
|
|
24
23
|
imageAspectRatio?: SkeletonLoaderImageRatios;
|
|
24
|
+
/** Optional boolean value to control visibility of border around skeleton loader. */
|
|
25
|
+
isBordered?: boolean;
|
|
25
26
|
/** Optional value to control the position of the image placeholder;
|
|
26
27
|
* default value is `LayoutTypes.Column`. */
|
|
27
28
|
layout?: LayoutTypes;
|
|
@@ -43,76 +44,79 @@ export interface SkeletonLoaderProps {
|
|
|
43
44
|
* The `SkeletonLoader` component renders a placeholder to be used while
|
|
44
45
|
* dynamic content is loading.
|
|
45
46
|
*/
|
|
46
|
-
export
|
|
47
|
-
props: React.PropsWithChildren<SkeletonLoaderProps>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Generates the Chakra skeleton loader `size` number of times for the
|
|
71
|
-
* "heading" and "content" areas defined by the `type` argument. The last
|
|
72
|
-
* element will have width of `lastWidth`.
|
|
73
|
-
*/
|
|
74
|
-
const getSkeletonElements = (type, size = 1, lastWidth = "80%") => {
|
|
75
|
-
return new Array(size).fill(null).map((_, i) => {
|
|
76
|
-
const width = i === size - 1 ? lastWidth : "100%";
|
|
77
|
-
const marginBottomValue =
|
|
78
|
-
i === size - 1 && type === "content" ? "0" : null;
|
|
79
|
-
return (
|
|
80
|
-
<ChakraSkeleton key={`${type}-${i}`} width={width}>
|
|
81
|
-
<Box
|
|
82
|
-
__css={styles[type]}
|
|
83
|
-
style={{ marginBottom: marginBottomValue }}
|
|
84
|
-
/>
|
|
85
|
-
</ChakraSkeleton>
|
|
86
|
-
);
|
|
47
|
+
export const SkeletonLoader = chakra(
|
|
48
|
+
(props: React.PropsWithChildren<SkeletonLoaderProps>) => {
|
|
49
|
+
const {
|
|
50
|
+
className,
|
|
51
|
+
contentSize = 3,
|
|
52
|
+
headingSize = 1,
|
|
53
|
+
imageAspectRatio = SkeletonLoaderImageRatios.Square,
|
|
54
|
+
isBordered = false,
|
|
55
|
+
layout = LayoutTypes.Column,
|
|
56
|
+
showButton = false,
|
|
57
|
+
showContent = true,
|
|
58
|
+
showHeading = true,
|
|
59
|
+
showImage = true,
|
|
60
|
+
width,
|
|
61
|
+
...rest
|
|
62
|
+
} = props;
|
|
63
|
+
const styles = useMultiStyleConfig("SkeletonLoader", {
|
|
64
|
+
isBordered,
|
|
65
|
+
imageAspectRatio,
|
|
66
|
+
showImage,
|
|
67
|
+
variant: layout,
|
|
87
68
|
});
|
|
88
|
-
};
|
|
89
69
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
</
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Generates the Chakra skeleton loader `size` number of times for the
|
|
72
|
+
* "heading" and "content" areas defined by the `type` argument. The last
|
|
73
|
+
* element will have width of `lastWidth`.
|
|
74
|
+
*/
|
|
75
|
+
const getSkeletonElements = (type, size = 1, lastWidth = "80%") => {
|
|
76
|
+
return new Array(size).fill(null).map((_, i) => {
|
|
77
|
+
const width = i === size - 1 ? lastWidth : "100%";
|
|
78
|
+
const marginBottomValue =
|
|
79
|
+
i === size - 1 && type === "content" ? "0" : null;
|
|
80
|
+
return (
|
|
81
|
+
<ChakraSkeleton key={`${type}-${i}`} width={width}>
|
|
82
|
+
<Box
|
|
83
|
+
__css={styles[type]}
|
|
84
|
+
style={{ marginBottom: marginBottomValue }}
|
|
85
|
+
/>
|
|
86
|
+
</ChakraSkeleton>
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<Box className={className} __css={styles} style={{ width }} {...rest}>
|
|
93
|
+
{showImage && (
|
|
94
|
+
<ChakraSkeleton>
|
|
95
|
+
<Box __css={{ ...styles.element, ...styles.image }} />
|
|
96
|
+
</ChakraSkeleton>
|
|
114
97
|
)}
|
|
98
|
+
<Box className={layout} __css={styles.container}>
|
|
99
|
+
{showHeading && (
|
|
100
|
+
<Box __css={styles.section}>
|
|
101
|
+
{getSkeletonElements("heading", headingSize, "80%")}
|
|
102
|
+
</Box>
|
|
103
|
+
)}
|
|
104
|
+
{showContent && (
|
|
105
|
+
<Box __css={styles.section}>
|
|
106
|
+
{getSkeletonElements("content", contentSize, "30%")}
|
|
107
|
+
</Box>
|
|
108
|
+
)}
|
|
109
|
+
{showButton && (
|
|
110
|
+
<Box __css={{ ...styles.section, ...styles.button }}>
|
|
111
|
+
<ChakraSkeleton borderRadius="16px">
|
|
112
|
+
<Box __css={styles.button} />
|
|
113
|
+
</ChakraSkeleton>
|
|
114
|
+
</Box>
|
|
115
|
+
)}
|
|
116
|
+
</Box>
|
|
115
117
|
</Box>
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
export default SkeletonLoader;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`SkeletonLoader renders the UI snapshot correctly 1`] = `
|
|
4
4
|
<div
|
|
5
|
-
className="css-
|
|
5
|
+
className="css-1xdhyk6"
|
|
6
6
|
style={
|
|
7
7
|
Object {
|
|
8
8
|
"width": undefined,
|
|
@@ -81,7 +81,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 1`] = `
|
|
|
81
81
|
|
|
82
82
|
exports[`SkeletonLoader renders the UI snapshot correctly 2`] = `
|
|
83
83
|
<div
|
|
84
|
-
className="css-
|
|
84
|
+
className="css-1xdhyk6"
|
|
85
85
|
style={
|
|
86
86
|
Object {
|
|
87
87
|
"width": undefined,
|
|
@@ -160,7 +160,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 2`] = `
|
|
|
160
160
|
|
|
161
161
|
exports[`SkeletonLoader renders the UI snapshot correctly 3`] = `
|
|
162
162
|
<div
|
|
163
|
-
className="css-
|
|
163
|
+
className="css-1xdhyk6"
|
|
164
164
|
style={
|
|
165
165
|
Object {
|
|
166
166
|
"width": undefined,
|
|
@@ -239,7 +239,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 3`] = `
|
|
|
239
239
|
|
|
240
240
|
exports[`SkeletonLoader renders the UI snapshot correctly 4`] = `
|
|
241
241
|
<div
|
|
242
|
-
className="css-
|
|
242
|
+
className="css-1xdhyk6"
|
|
243
243
|
style={
|
|
244
244
|
Object {
|
|
245
245
|
"width": undefined,
|
|
@@ -311,7 +311,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 4`] = `
|
|
|
311
311
|
|
|
312
312
|
exports[`SkeletonLoader renders the UI snapshot correctly 5`] = `
|
|
313
313
|
<div
|
|
314
|
-
className="css-
|
|
314
|
+
className="css-1xdhyk6"
|
|
315
315
|
style={
|
|
316
316
|
Object {
|
|
317
317
|
"width": undefined,
|
|
@@ -374,7 +374,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 5`] = `
|
|
|
374
374
|
|
|
375
375
|
exports[`SkeletonLoader renders the UI snapshot correctly 6`] = `
|
|
376
376
|
<div
|
|
377
|
-
className="css-
|
|
377
|
+
className="css-1xdhyk6"
|
|
378
378
|
style={
|
|
379
379
|
Object {
|
|
380
380
|
"width": undefined,
|
|
@@ -413,7 +413,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 6`] = `
|
|
|
413
413
|
|
|
414
414
|
exports[`SkeletonLoader renders the UI snapshot correctly 7`] = `
|
|
415
415
|
<div
|
|
416
|
-
className="css-
|
|
416
|
+
className="css-1xdhyk6"
|
|
417
417
|
style={
|
|
418
418
|
Object {
|
|
419
419
|
"width": undefined,
|
|
@@ -503,7 +503,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 7`] = `
|
|
|
503
503
|
|
|
504
504
|
exports[`SkeletonLoader renders the UI snapshot correctly 8`] = `
|
|
505
505
|
<div
|
|
506
|
-
className="css-
|
|
506
|
+
className="css-1xdhyk6"
|
|
507
507
|
style={
|
|
508
508
|
Object {
|
|
509
509
|
"width": undefined,
|
|
@@ -582,7 +582,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 8`] = `
|
|
|
582
582
|
|
|
583
583
|
exports[`SkeletonLoader renders the UI snapshot correctly 9`] = `
|
|
584
584
|
<div
|
|
585
|
-
className="css-
|
|
585
|
+
className="css-1xdhyk6"
|
|
586
586
|
style={
|
|
587
587
|
Object {
|
|
588
588
|
"width": undefined,
|
|
@@ -661,7 +661,166 @@ exports[`SkeletonLoader renders the UI snapshot correctly 9`] = `
|
|
|
661
661
|
|
|
662
662
|
exports[`SkeletonLoader renders the UI snapshot correctly 10`] = `
|
|
663
663
|
<div
|
|
664
|
-
className="css-
|
|
664
|
+
className="css-1xdhyk6"
|
|
665
|
+
style={
|
|
666
|
+
Object {
|
|
667
|
+
"width": undefined,
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
>
|
|
671
|
+
<div
|
|
672
|
+
className="chakra-skeleton css-1twknw3"
|
|
673
|
+
>
|
|
674
|
+
<div
|
|
675
|
+
className="css-0"
|
|
676
|
+
/>
|
|
677
|
+
</div>
|
|
678
|
+
<div
|
|
679
|
+
className="column css-0"
|
|
680
|
+
>
|
|
681
|
+
<div
|
|
682
|
+
className="css-0"
|
|
683
|
+
>
|
|
684
|
+
<div
|
|
685
|
+
className="chakra-skeleton css-tz3wol"
|
|
686
|
+
>
|
|
687
|
+
<div
|
|
688
|
+
className="css-0"
|
|
689
|
+
style={
|
|
690
|
+
Object {
|
|
691
|
+
"marginBottom": null,
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
/>
|
|
695
|
+
</div>
|
|
696
|
+
</div>
|
|
697
|
+
<div
|
|
698
|
+
className="css-0"
|
|
699
|
+
>
|
|
700
|
+
<div
|
|
701
|
+
className="chakra-skeleton css-1akrz52"
|
|
702
|
+
>
|
|
703
|
+
<div
|
|
704
|
+
className="css-0"
|
|
705
|
+
style={
|
|
706
|
+
Object {
|
|
707
|
+
"marginBottom": null,
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
/>
|
|
711
|
+
</div>
|
|
712
|
+
<div
|
|
713
|
+
className="chakra-skeleton css-1akrz52"
|
|
714
|
+
>
|
|
715
|
+
<div
|
|
716
|
+
className="css-0"
|
|
717
|
+
style={
|
|
718
|
+
Object {
|
|
719
|
+
"marginBottom": null,
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
/>
|
|
723
|
+
</div>
|
|
724
|
+
<div
|
|
725
|
+
className="chakra-skeleton css-qaeww3"
|
|
726
|
+
>
|
|
727
|
+
<div
|
|
728
|
+
className="css-0"
|
|
729
|
+
style={
|
|
730
|
+
Object {
|
|
731
|
+
"marginBottom": "0",
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
/>
|
|
735
|
+
</div>
|
|
736
|
+
</div>
|
|
737
|
+
</div>
|
|
738
|
+
</div>
|
|
739
|
+
`;
|
|
740
|
+
|
|
741
|
+
exports[`SkeletonLoader renders the UI snapshot correctly 11`] = `
|
|
742
|
+
<div
|
|
743
|
+
className="css-kle7zy"
|
|
744
|
+
style={
|
|
745
|
+
Object {
|
|
746
|
+
"width": undefined,
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
>
|
|
750
|
+
<div
|
|
751
|
+
className="chakra-skeleton css-1twknw3"
|
|
752
|
+
>
|
|
753
|
+
<div
|
|
754
|
+
className="css-0"
|
|
755
|
+
/>
|
|
756
|
+
</div>
|
|
757
|
+
<div
|
|
758
|
+
className="column css-0"
|
|
759
|
+
>
|
|
760
|
+
<div
|
|
761
|
+
className="css-0"
|
|
762
|
+
>
|
|
763
|
+
<div
|
|
764
|
+
className="chakra-skeleton css-tz3wol"
|
|
765
|
+
>
|
|
766
|
+
<div
|
|
767
|
+
className="css-0"
|
|
768
|
+
style={
|
|
769
|
+
Object {
|
|
770
|
+
"marginBottom": null,
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
/>
|
|
774
|
+
</div>
|
|
775
|
+
</div>
|
|
776
|
+
<div
|
|
777
|
+
className="css-0"
|
|
778
|
+
>
|
|
779
|
+
<div
|
|
780
|
+
className="chakra-skeleton css-1akrz52"
|
|
781
|
+
>
|
|
782
|
+
<div
|
|
783
|
+
className="css-0"
|
|
784
|
+
style={
|
|
785
|
+
Object {
|
|
786
|
+
"marginBottom": null,
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
/>
|
|
790
|
+
</div>
|
|
791
|
+
<div
|
|
792
|
+
className="chakra-skeleton css-1akrz52"
|
|
793
|
+
>
|
|
794
|
+
<div
|
|
795
|
+
className="css-0"
|
|
796
|
+
style={
|
|
797
|
+
Object {
|
|
798
|
+
"marginBottom": null,
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
/>
|
|
802
|
+
</div>
|
|
803
|
+
<div
|
|
804
|
+
className="chakra-skeleton css-qaeww3"
|
|
805
|
+
>
|
|
806
|
+
<div
|
|
807
|
+
className="css-0"
|
|
808
|
+
style={
|
|
809
|
+
Object {
|
|
810
|
+
"marginBottom": "0",
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
/>
|
|
814
|
+
</div>
|
|
815
|
+
</div>
|
|
816
|
+
</div>
|
|
817
|
+
</div>
|
|
818
|
+
`;
|
|
819
|
+
|
|
820
|
+
exports[`SkeletonLoader renders the UI snapshot correctly 12`] = `
|
|
821
|
+
<div
|
|
822
|
+
className="css-1xdhyk6"
|
|
823
|
+
data-testid="props"
|
|
665
824
|
style={
|
|
666
825
|
Object {
|
|
667
826
|
"width": undefined,
|