@nypl/design-system-react-components 0.25.13 → 0.26.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.
Files changed (299) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +10 -10
  3. package/dist/components/Accordion/Accordion.d.ts +1 -1
  4. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  5. package/dist/components/Button/Button.d.ts +2 -2
  6. package/dist/components/Card/Card.d.ts +11 -9
  7. package/dist/components/Checkbox/Checkbox.d.ts +2 -2
  8. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +5 -4
  9. package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +1 -1
  10. package/dist/components/DatePicker/DatePicker.d.ts +5 -6
  11. package/dist/components/Fieldset/Fieldset.d.ts +5 -6
  12. package/dist/components/Form/Form.d.ts +6 -6
  13. package/dist/components/Grid/GridTypes.d.ts +7 -7
  14. package/dist/components/Grid/SimpleGrid.d.ts +1 -1
  15. package/dist/components/Heading/Heading.d.ts +1 -1
  16. package/dist/components/HelperErrorText/HelperErrorText.d.ts +9 -8
  17. package/dist/components/Hero/Hero.d.ts +2 -1
  18. package/dist/components/HorizontalRule/HorizontalRule.d.ts +2 -10
  19. package/dist/components/Icons/Icon.d.ts +2 -1
  20. package/dist/components/Image/Image.d.ts +2 -2
  21. package/dist/components/Label/Label.d.ts +7 -4
  22. package/dist/components/Link/Link.d.ts +1 -1
  23. package/dist/components/List/List.d.ts +11 -11
  24. package/dist/components/List/ListTypes.d.ts +1 -1
  25. package/dist/components/Logo/Logo.d.ts +2 -1
  26. package/dist/components/Logo/LogoSvgs.d.ts +2 -0
  27. package/dist/components/Logo/LogoTypes.d.ts +2 -0
  28. package/dist/components/Notification/Notification.d.ts +4 -4
  29. package/dist/components/Pagination/Pagination.d.ts +2 -2
  30. package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +3 -3
  31. package/dist/components/Radio/Radio.d.ts +4 -6
  32. package/dist/components/RadioGroup/RadioGroup.d.ts +12 -6
  33. package/dist/components/SearchBar/SearchBar.d.ts +4 -4
  34. package/dist/components/Select/Select.d.ts +10 -6
  35. package/dist/components/Select/SelectTypes.d.ts +4 -0
  36. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -3
  37. package/dist/components/Slider/Slider.d.ts +6 -4
  38. package/dist/components/StatusBadge/StatusBadge.d.ts +5 -1
  39. package/dist/components/StructuredContent/StructuredContent.d.ts +2 -2
  40. package/dist/components/Table/Table.d.ts +1 -1
  41. package/dist/components/Tabs/Tabs.d.ts +4 -3
  42. package/dist/components/Template/Template.d.ts +4 -3
  43. package/dist/components/Text/Text.d.ts +1 -1
  44. package/dist/components/TextInput/TextInput.d.ts +5 -5
  45. package/dist/components/Toggle/Toggle.d.ts +3 -4
  46. package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
  47. package/dist/design-system-react-components.cjs.development.js +1663 -1139
  48. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  49. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  50. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  51. package/dist/design-system-react-components.esm.js +1667 -1143
  52. package/dist/design-system-react-components.esm.js.map +1 -1
  53. package/dist/hooks/useCarouselStyles.d.ts +3 -2
  54. package/dist/hooks/useNYPLTheme.d.ts +12 -0
  55. package/dist/index.d.ts +4 -1
  56. package/dist/styles.css +1 -1
  57. package/dist/theme/components/button.d.ts +10 -2
  58. package/dist/theme/components/card.d.ts +42 -22
  59. package/dist/theme/components/checkbox.d.ts +5 -4
  60. package/dist/theme/components/checkboxGroup.d.ts +1 -1
  61. package/dist/theme/components/componentWrapper.d.ts +2 -2
  62. package/dist/theme/components/customTable.d.ts +84 -1
  63. package/dist/theme/components/fieldset.d.ts +4 -14
  64. package/dist/theme/components/global.d.ts +23 -17
  65. package/dist/theme/components/heading.d.ts +53 -0
  66. package/dist/theme/components/helperErrorText.d.ts +1 -0
  67. package/dist/theme/components/hero.d.ts +20 -14
  68. package/dist/theme/components/label.d.ts +9 -10
  69. package/dist/theme/components/list.d.ts +99 -9
  70. package/dist/theme/components/radio.d.ts +6 -4
  71. package/dist/theme/components/radioGroup.d.ts +1 -1
  72. package/dist/theme/components/select.d.ts +34 -5
  73. package/dist/theme/components/skeletonLoader.d.ts +2 -2
  74. package/dist/theme/components/slider.d.ts +6 -3
  75. package/dist/theme/components/structuredContent.d.ts +197 -0
  76. package/dist/theme/components/textInput.d.ts +18 -6
  77. package/dist/theme/components/toggle.d.ts +7 -4
  78. package/dist/theme/foundations/global.d.ts +2 -0
  79. package/dist/theme/foundations/radii.d.ts +1 -0
  80. package/dist/theme/foundations/spacing.d.ts +46 -43
  81. package/package.json +5 -6
  82. package/src/components/Accordion/Accordion.stories.mdx +9 -9
  83. package/src/components/Accordion/Accordion.test.tsx +21 -0
  84. package/src/components/Accordion/Accordion.tsx +13 -9
  85. package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +276 -27
  86. package/src/components/Autosuggest/Autosuggest.stories.mdx +4 -3
  87. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +21 -5
  88. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +52 -31
  89. package/src/components/Breadcrumbs/Breadcrumbs.tsx +8 -7
  90. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +211 -12
  91. package/src/components/Button/Button.stories.mdx +87 -23
  92. package/src/components/Button/Button.test.tsx +25 -0
  93. package/src/components/Button/Button.tsx +18 -7
  94. package/src/components/Button/__snapshots__/Button.test.tsx.snap +27 -7
  95. package/src/components/Card/Card.stories.mdx +287 -194
  96. package/src/components/Card/Card.test.tsx +102 -0
  97. package/src/components/Card/Card.tsx +73 -32
  98. package/src/components/Card/__snapshots__/Card.test.tsx.snap +195 -35
  99. package/src/components/Chakra/Grid.stories.mdx +4 -4
  100. package/src/components/Checkbox/Checkbox.stories.mdx +62 -10
  101. package/src/components/Checkbox/Checkbox.test.tsx +32 -9
  102. package/src/components/Checkbox/Checkbox.tsx +20 -15
  103. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +134 -7
  104. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +65 -17
  105. package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +137 -81
  106. package/src/components/CheckboxGroup/CheckboxGroup.tsx +31 -21
  107. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +332 -97
  108. package/src/components/ComponentWrapper/ComponentWrapper.test.tsx +12 -0
  109. package/src/components/ComponentWrapper/ComponentWrapper.tsx +39 -41
  110. package/src/components/ComponentWrapper/__snapshots__/ComponentWrapper.test.tsx.snap +47 -34
  111. package/src/components/DatePicker/DatePicker.stories.mdx +63 -27
  112. package/src/components/DatePicker/DatePicker.test.tsx +89 -13
  113. package/src/components/DatePicker/DatePicker.tsx +62 -56
  114. package/src/components/DatePicker/_DatePicker.scss +71 -13
  115. package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +250 -206
  116. package/src/components/Fieldset/Fieldset.stories.mdx +33 -3
  117. package/src/components/Fieldset/Fieldset.test.tsx +58 -28
  118. package/src/components/Fieldset/Fieldset.tsx +35 -30
  119. package/src/components/Fieldset/__snapshots__/Fieldset.test.tsx.snap +40 -19
  120. package/src/components/Form/Form.stories.mdx +72 -39
  121. package/src/components/Form/Form.test.tsx +58 -15
  122. package/src/components/Form/Form.tsx +89 -67
  123. package/src/components/Form/__snapshots__/Form.test.tsx.snap +83 -5
  124. package/src/components/Grid/GridTypes.tsx +7 -7
  125. package/src/components/Grid/SimpleGrid.stories.mdx +34 -6
  126. package/src/components/Grid/SimpleGrid.test.tsx +9 -0
  127. package/src/components/Grid/SimpleGrid.tsx +29 -20
  128. package/src/components/Grid/__snapshots__/SimpleGrid.test.tsx.snap +16 -1
  129. package/src/components/Heading/Heading.stories.mdx +36 -3
  130. package/src/components/Heading/Heading.test.tsx +10 -0
  131. package/src/components/Heading/Heading.tsx +56 -50
  132. package/src/components/Heading/__snapshots__/Heading.test.tsx.snap +26 -7
  133. package/src/components/HelperErrorText/HelperErrorText.stories.mdx +64 -42
  134. package/src/components/HelperErrorText/HelperErrorText.test.tsx +15 -0
  135. package/src/components/HelperErrorText/HelperErrorText.tsx +40 -35
  136. package/src/components/HelperErrorText/__snapshots__/HelperErrorText.test.tsx.snap +35 -4
  137. package/src/components/Hero/Hero.stories.mdx +125 -95
  138. package/src/components/Hero/Hero.test.tsx +33 -0
  139. package/src/components/Hero/Hero.tsx +135 -126
  140. package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +89 -17
  141. package/src/components/HorizontalRule/HorizontalRule.stories.mdx +26 -4
  142. package/src/components/HorizontalRule/HorizontalRule.test.tsx +9 -19
  143. package/src/components/HorizontalRule/HorizontalRule.tsx +9 -26
  144. package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +18 -5
  145. package/src/components/Icons/Icon.stories.mdx +31 -6
  146. package/src/components/Icons/Icon.test.tsx +38 -0
  147. package/src/components/Icons/Icon.tsx +93 -76
  148. package/src/components/Icons/__snapshots__/Icon.test.tsx.snap +129 -0
  149. package/src/components/Image/Image.stories.mdx +29 -5
  150. package/src/components/Image/Image.test.tsx +8 -0
  151. package/src/components/Image/Image.tsx +38 -26
  152. package/src/components/Image/__snapshots__/Image.test.tsx.snap +24 -8
  153. package/src/components/Label/Label.stories.mdx +42 -20
  154. package/src/components/Label/Label.test.tsx +42 -17
  155. package/src/components/Label/Label.tsx +22 -13
  156. package/src/components/Label/__snapshots__/Label.test.tsx.snap +19 -15
  157. package/src/components/Link/Link.stories.mdx +25 -1
  158. package/src/components/Link/Link.test.tsx +21 -0
  159. package/src/components/Link/Link.tsx +8 -8
  160. package/src/components/Link/__snapshots__/Link.test.tsx.snap +37 -11
  161. package/src/components/List/List.stories.mdx +75 -40
  162. package/src/components/List/List.test.tsx +67 -19
  163. package/src/components/List/List.tsx +38 -25
  164. package/src/components/List/ListTypes.tsx +1 -1
  165. package/src/components/List/__snapshots__/List.test.tsx.snap +110 -8
  166. package/src/components/Logo/Logo.stories.mdx +30 -6
  167. package/src/components/Logo/Logo.test.tsx +17 -0
  168. package/src/components/Logo/Logo.tsx +18 -6
  169. package/src/components/Logo/LogoSvgs.tsx +4 -0
  170. package/src/components/Logo/LogoTypes.tsx +2 -0
  171. package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +73 -2
  172. package/src/components/Modal/Modal.stories.mdx +13 -0
  173. package/src/components/Notification/Notification.stories.mdx +25 -1
  174. package/src/components/Notification/Notification.test.tsx +23 -0
  175. package/src/components/Notification/Notification.tsx +46 -44
  176. package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +158 -29
  177. package/src/components/Pagination/Pagination.stories.mdx +24 -4
  178. package/src/components/Pagination/Pagination.test.tsx +25 -0
  179. package/src/components/Pagination/Pagination.tsx +6 -6
  180. package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +244 -27
  181. package/src/components/Placeholder/Placeholder.tsx +3 -1
  182. package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +76 -10
  183. package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +81 -11
  184. package/src/components/ProgressIndicator/ProgressIndicator.tsx +17 -9
  185. package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +101 -14
  186. package/src/components/Radio/Radio.stories.mdx +64 -12
  187. package/src/components/Radio/Radio.test.tsx +28 -8
  188. package/src/components/Radio/Radio.tsx +66 -63
  189. package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +103 -6
  190. package/src/components/RadioGroup/RadioGroup.stories.mdx +224 -89
  191. package/src/components/RadioGroup/RadioGroup.test.tsx +122 -62
  192. package/src/components/RadioGroup/RadioGroup.tsx +106 -100
  193. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +1236 -1020
  194. package/src/components/SearchBar/SearchBar.stories.mdx +101 -36
  195. package/src/components/SearchBar/{SearchBar.Test.tsx → SearchBar.test.tsx} +46 -4
  196. package/src/components/SearchBar/SearchBar.tsx +17 -8
  197. package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +1039 -0
  198. package/src/components/Select/Select.stories.mdx +128 -49
  199. package/src/components/Select/Select.test.tsx +63 -16
  200. package/src/components/Select/Select.tsx +125 -92
  201. package/src/components/Select/SelectTypes.tsx +5 -0
  202. package/src/components/Select/__snapshots__/Select.test.tsx.snap +749 -409
  203. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +42 -10
  204. package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +8 -0
  205. package/src/components/SkeletonLoader/SkeletonLoader.tsx +76 -72
  206. package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +169 -10
  207. package/src/components/Slider/Slider.stories.mdx +91 -42
  208. package/src/components/Slider/Slider.test.tsx +65 -17
  209. package/src/components/Slider/Slider.tsx +26 -19
  210. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +403 -226
  211. package/src/components/StatusBadge/StatusBadge.stories.mdx +19 -1
  212. package/src/components/StatusBadge/StatusBadge.test.tsx +16 -0
  213. package/src/components/StatusBadge/StatusBadge.tsx +25 -20
  214. package/src/components/StatusBadge/__snapshots__/StatusBadge.test.tsx.snap +22 -3
  215. package/src/components/StructuredContent/StructuredContent.stories.mdx +131 -12
  216. package/src/components/StructuredContent/StructuredContent.test.tsx +34 -0
  217. package/src/components/StructuredContent/StructuredContent.tsx +80 -75
  218. package/src/components/StructuredContent/__snapshots__/StructuredContent.test.tsx.snap +102 -17
  219. package/src/components/StyleGuide/Bidirectionality.stories.mdx +5 -5
  220. package/src/components/StyleGuide/Breakpoints.stories.mdx +6 -6
  221. package/src/components/StyleGuide/Buttons.stories.mdx +2 -12
  222. package/src/components/StyleGuide/ColorCard.tsx +1 -1
  223. package/src/components/StyleGuide/Colors.stories.mdx +1 -2
  224. package/src/components/StyleGuide/DesignTokens.stories.mdx +56 -26
  225. package/src/components/StyleGuide/Forms.stories.mdx +27 -12
  226. package/src/components/StyleGuide/Iconography.stories.mdx +2 -12
  227. package/src/components/StyleGuide/Spacing.stories.mdx +80 -41
  228. package/src/components/StyleGuide/Typography.stories.mdx +30 -21
  229. package/src/components/Table/Table.stories.mdx +38 -11
  230. package/src/components/Table/Table.test.tsx +15 -0
  231. package/src/components/Table/Table.tsx +7 -7
  232. package/src/components/Table/__snapshots__/Table.test.tsx.snap +408 -5
  233. package/src/components/Tabs/Tabs.stories.mdx +52 -3
  234. package/src/components/Tabs/Tabs.test.tsx +16 -0
  235. package/src/components/Tabs/Tabs.tsx +10 -6
  236. package/src/components/Tabs/__snapshots__/Tabs.test.tsx.snap +394 -5
  237. package/src/components/Template/Template.stories.mdx +47 -43
  238. package/src/components/Template/Template.test.tsx +33 -0
  239. package/src/components/Template/Template.tsx +65 -60
  240. package/src/components/Template/__snapshots__/Template.test.tsx.snap +191 -20
  241. package/src/components/Text/Text.stories.mdx +20 -1
  242. package/src/components/Text/Text.test.tsx +12 -0
  243. package/src/components/Text/Text.tsx +6 -4
  244. package/src/components/Text/__snapshots__/Text.test.tsx.snap +21 -4
  245. package/src/components/TextInput/TextInput.stories.mdx +65 -19
  246. package/src/components/TextInput/TextInput.test.tsx +42 -28
  247. package/src/components/TextInput/TextInput.tsx +121 -113
  248. package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +96 -73
  249. package/src/components/Toggle/Toggle.stories.mdx +80 -22
  250. package/src/components/Toggle/Toggle.test.tsx +27 -9
  251. package/src/components/Toggle/Toggle.tsx +22 -18
  252. package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +128 -5
  253. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +52 -4
  254. package/src/components/VideoPlayer/VideoPlayer.test.tsx +23 -0
  255. package/src/components/VideoPlayer/VideoPlayer.tsx +133 -126
  256. package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +81 -39
  257. package/src/docs/Chakra.stories.mdx +50 -9
  258. package/src/docs/Welcome.stories.mdx +160 -41
  259. package/src/hooks/useCarouselStyles.stories.mdx +22 -2
  260. package/src/hooks/useCarouselStyles.ts +3 -2
  261. package/src/hooks/useNYPLTheme.stories.mdx +101 -0
  262. package/src/hooks/useNYPLTheme.ts +30 -6
  263. package/src/hooks/useWindowSize.stories.mdx +23 -0
  264. package/src/index.ts +4 -1
  265. package/src/styles/base/_place-holder.scss +1 -1
  266. package/src/theme/components/button.ts +15 -7
  267. package/src/theme/components/card.ts +30 -19
  268. package/src/theme/components/checkbox.ts +10 -8
  269. package/src/theme/components/checkboxGroup.ts +1 -1
  270. package/src/theme/components/componentWrapper.ts +2 -2
  271. package/src/theme/components/customTable.ts +39 -31
  272. package/src/theme/components/fieldset.ts +1 -2
  273. package/src/theme/components/global.ts +25 -20
  274. package/src/theme/components/heading.ts +1 -1
  275. package/src/theme/components/helperErrorText.ts +1 -0
  276. package/src/theme/components/hero.ts +13 -15
  277. package/src/theme/components/label.ts +4 -3
  278. package/src/theme/components/list.ts +73 -66
  279. package/src/theme/components/notification.ts +2 -2
  280. package/src/theme/components/radio.ts +9 -9
  281. package/src/theme/components/radioGroup.ts +1 -1
  282. package/src/theme/components/select.ts +35 -22
  283. package/src/theme/components/skeletonLoader.ts +3 -3
  284. package/src/theme/components/slider.ts +8 -7
  285. package/src/theme/components/statusBadge.ts +2 -2
  286. package/src/theme/components/structuredContent.ts +66 -1
  287. package/src/theme/components/tabs.ts +2 -2
  288. package/src/theme/components/template.ts +9 -9
  289. package/src/theme/components/textInput.ts +13 -12
  290. package/src/theme/components/toggle.ts +17 -10
  291. package/src/theme/components/videoPlayer.ts +1 -1
  292. package/src/theme/foundations/colors.ts +1 -1
  293. package/src/theme/foundations/radii.ts +1 -0
  294. package/src/theme/foundations/spacing.ts +70 -22
  295. package/src/theme/foundations/typography.ts +2 -2
  296. package/src/utils/componentCategories.ts +1 -2
  297. package/dist/components/SearchBar/SearchBar.Test.d.ts +0 -1
  298. package/dist/helpers/generateUUID.d.ts +0 -1
  299. 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.25.13` |
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
- # Card Placeholders in a Grid
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
- border
143
+ isBordered
112
144
  />
113
145
  <SkeletonLoader
114
146
  imageAspectRatio={SkeletonLoaderImageRatios.Landscape}
115
- border
147
+ isBordered
116
148
  />
117
149
  <SkeletonLoader
118
150
  imageAspectRatio={SkeletonLoaderImageRatios.Landscape}
119
- border
151
+ isBordered
120
152
  />
121
153
  <SkeletonLoader
122
154
  imageAspectRatio={SkeletonLoaderImageRatios.Landscape}
123
- border
155
+ isBordered
124
156
  />
125
157
  <SkeletonLoader
126
158
  imageAspectRatio={SkeletonLoaderImageRatios.Landscape}
127
- border
159
+ isBordered
128
160
  />
129
161
  <SkeletonLoader
130
162
  imageAspectRatio={SkeletonLoaderImageRatios.Landscape}
131
- border
163
+ isBordered
132
164
  />
133
165
  </SimpleGrid>
134
166
  </Story>
135
167
  </Canvas>
136
168
 
137
- # Text Placeholders in a List
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 default function SkeletonLoader(
47
- props: React.PropsWithChildren<SkeletonLoaderProps>
48
- ) {
49
- const {
50
- border = false,
51
- className,
52
- contentSize = 3,
53
- headingSize = 1,
54
- imageAspectRatio = SkeletonLoaderImageRatios.Square,
55
- layout = LayoutTypes.Column,
56
- showButton = false,
57
- showContent = true,
58
- showHeading = true,
59
- showImage = true,
60
- width,
61
- } = props;
62
- const styles = useMultiStyleConfig("SkeletonLoader", {
63
- border,
64
- imageAspectRatio,
65
- showImage,
66
- variant: layout,
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
- return (
91
- <Box className={className} __css={styles} style={{ width: width }}>
92
- {showImage && (
93
- <ChakraSkeleton>
94
- <Box __css={{ ...styles.element, ...styles.image }} />
95
- </ChakraSkeleton>
96
- )}
97
- <Box className={layout} __css={styles.container}>
98
- {showHeading && (
99
- <Box __css={styles.section}>
100
- {getSkeletonElements("heading", headingSize, "80%")}
101
- </Box>
102
- )}
103
- {showContent && (
104
- <Box __css={styles.section}>
105
- {getSkeletonElements("content", contentSize, "30%")}
106
- </Box>
107
- )}
108
- {showButton && (
109
- <Box __css={{ ...styles.section, ...styles.button }}>
110
- <ChakraSkeleton borderRadius="16px">
111
- <Box __css={styles.button} />
112
- </ChakraSkeleton>
113
- </Box>
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
- </Box>
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-0"
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-0"
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-0"
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-0"
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-0"
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-0"
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-0"
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-0"
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-0"
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-0"
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,