@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
@@ -3,30 +3,31 @@
3
3
  exports[`Form Snapshot Renders the UI snapshot correctly 1`] = `
4
4
  <form
5
5
  aria-label="form"
6
+ className="css-0"
6
7
  id="snapshot-form"
7
8
  >
8
9
  <div
9
- className="css-aq1pyb"
10
+ className="css-fadkce"
10
11
  id="snapshot-form-parent"
11
12
  >
12
13
  <div
13
- className="css-1ao258g"
14
+ className="css-dofnwd"
14
15
  id="snapshot-form-child0"
15
16
  >
16
17
  <div
17
- className="css-aq1pyb"
18
+ className="css-7ajbp2"
18
19
  id="snapshot-form-child0-grandchild0"
19
20
  >
20
21
  Form Field 1
21
22
  </div>
22
23
  <div
23
- className="css-aq1pyb"
24
+ className="css-7ajbp2"
24
25
  id="snapshot-form-child0-grandchild1"
25
26
  >
26
27
  Form Field 2
27
28
  </div>
28
29
  <div
29
- className="css-aq1pyb"
30
+ className="css-7ajbp2"
30
31
  id="snapshot-form-child0-grandchild2"
31
32
  >
32
33
  Form Field 3
@@ -35,3 +36,80 @@ exports[`Form Snapshot Renders the UI snapshot correctly 1`] = `
35
36
  </div>
36
37
  </form>
37
38
  `;
39
+
40
+ exports[`Form Snapshot Renders the UI snapshot correctly 2`] = `
41
+ <form
42
+ aria-label="form"
43
+ className="css-qvgr6z"
44
+ color="ui.error.primary"
45
+ id="chakra"
46
+ p="20px"
47
+ >
48
+ <div
49
+ className="css-fadkce"
50
+ id="chakra-parent"
51
+ >
52
+ <div
53
+ className="css-dofnwd"
54
+ id="chakra-child0"
55
+ >
56
+ <div
57
+ className="css-7ajbp2"
58
+ id="chakra-child0-grandchild0"
59
+ >
60
+ Form Field 1
61
+ </div>
62
+ <div
63
+ className="css-7ajbp2"
64
+ id="chakra-child0-grandchild1"
65
+ >
66
+ Form Field 2
67
+ </div>
68
+ <div
69
+ className="css-7ajbp2"
70
+ id="chakra-child0-grandchild2"
71
+ >
72
+ Form Field 3
73
+ </div>
74
+ </div>
75
+ </div>
76
+ </form>
77
+ `;
78
+
79
+ exports[`Form Snapshot Renders the UI snapshot correctly 3`] = `
80
+ <form
81
+ aria-label="form"
82
+ className="css-0"
83
+ data-testid="props"
84
+ id="props"
85
+ >
86
+ <div
87
+ className="css-fadkce"
88
+ id="props-parent"
89
+ >
90
+ <div
91
+ className="css-dofnwd"
92
+ id="props-child0"
93
+ >
94
+ <div
95
+ className="css-7ajbp2"
96
+ id="props-child0-grandchild0"
97
+ >
98
+ Form Field 1
99
+ </div>
100
+ <div
101
+ className="css-7ajbp2"
102
+ id="props-child0-grandchild1"
103
+ >
104
+ Form Field 2
105
+ </div>
106
+ <div
107
+ className="css-7ajbp2"
108
+ id="props-child0-grandchild2"
109
+ >
110
+ Form Field 3
111
+ </div>
112
+ </div>
113
+ </div>
114
+ </form>
115
+ `;
@@ -1,9 +1,9 @@
1
1
  export enum GridGaps {
2
- ExtraExtraSmall = "xxs",
3
- ExtraSmall = "xs",
4
- Small = "s",
5
- Medium = "m",
6
- Large = "l",
7
- ExtraLarge = "xl",
8
- ExtraExtraLarge = "xxl",
2
+ ExtraExtraSmall = "grid.xxs",
3
+ ExtraSmall = "grid.xs",
4
+ Small = "grid.s",
5
+ Medium = "grid.m",
6
+ Large = "grid.l",
7
+ ExtraLarge = "grid.xl",
8
+ ExtraExtraLarge = "grid.xxl",
9
9
  }
@@ -57,13 +57,29 @@ export const enumValues = getStorybookEnumValues(GridGaps, "GridGaps");
57
57
  | Component Version | DS Version |
58
58
  | ----------------- | ---------- |
59
59
  | Added | `0.25.1` |
60
- | Latest | `0.25.1` |
60
+ | Latest | `0.26.0` |
61
+
62
+ ## Table of Contents
63
+
64
+ - [Overview](#overview)
65
+ - [Component Props](#component-props)
66
+ - [Accessibility](#accessibility)
67
+ - [Other SimpleGrid Examples](#other-simplegrid-examples)
68
+
69
+ ## Overview
61
70
 
62
71
  <Description of={SimpleGrid} />
63
72
 
64
- The `SimpleGrid` component is used to render UI elements in a uniform grid layout, with the column widths and grid spacing fixed throughout the grid.
73
+ The `SimpleGrid` component is used to render UI elements in a uniform grid layout,
74
+ with the column widths and grid spacing fixed throughout the grid.
75
+
76
+ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for
77
+ tablet and `1` for mobile. By default, the `SimpleGrid` component uses these
78
+ standards and the `columns` prop is optional. If the `columns` prop is used, the
79
+ tablet breakpoint will be dropped and only the mobile breakpoint (1 item per row)
80
+ will be triggered.
65
81
 
66
- The NYPL standards for the items per row in a grid is `3` for desktop, `2` for tablet and `1` for mobile. By default, the `SimpleGrid` component uses these standards and the `columns` prop is optional. If the `columns` prop is used, the tablet breakpoint will be dropped and only the mobile breakpoint (1 item per row) will be triggered.
82
+ ## Component Props
67
83
 
68
84
  <Canvas withToolbar>
69
85
  <Story
@@ -162,6 +178,18 @@ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for t
162
178
 
163
179
  <ArgsTable story="SimpleGrid with Controls" />
164
180
 
181
+ ## Accessibility
182
+
183
+ The CSS grid layout properties are used for the `SimpleGrid` component. We don't
184
+ recommend using property rules that change the visual order of elements on the
185
+ page that don't match with its DOM order. This is because a screenreader won't
186
+ pick up `SimpleGrid` CSS rules and will read the page in the expected DOM order
187
+ rather than the visual order.
188
+
189
+ Resources:
190
+
191
+ - [MDN CSS Grid Layout and Accessibility](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/CSS_Grid_Layout_and_Accessibility)
192
+
165
193
  ## Other SimpleGrid Examples
166
194
 
167
195
  ### Icons
@@ -225,12 +253,12 @@ This example is rendering horizontal `Card` components with the `columns` prop s
225
253
  <DSProvider>
226
254
  <SimpleGrid columns={1}>
227
255
  <Card
228
- border
229
256
  imageProps={{
230
257
  alt: "Alt text",
231
258
  aspectRatio: ImageRatios.FourByThree,
232
259
  src: "https://placeimg.com/400/200/animals",
233
260
  }}
261
+ isBordered
234
262
  isCentered
235
263
  layout={LayoutTypes.Row}
236
264
  >
@@ -244,12 +272,12 @@ This example is rendering horizontal `Card` components with the `columns` prop s
244
272
  </CardContent>
245
273
  </Card>
246
274
  <Card
247
- border
248
275
  imageProps={{
249
276
  alt: "Alt text",
250
277
  aspectRatio: ImageRatios.FourByThree,
251
278
  src: "https://placeimg.com/410/210/animals",
252
279
  }}
280
+ isBordered
253
281
  isCentered
254
282
  layout={LayoutTypes.Row}
255
283
  >
@@ -263,12 +291,12 @@ This example is rendering horizontal `Card` components with the `columns` prop s
263
291
  </CardContent>
264
292
  </Card>
265
293
  <Card
266
- border
267
294
  imageProps={{
268
295
  alt: "Alt text",
269
296
  aspectRatio: ImageRatios.FourByThree,
270
297
  src: "https://placeimg.com/320/320/animals",
271
298
  }}
299
+ isBordered
272
300
  isCentered
273
301
  layout={LayoutTypes.Row}
274
302
  >
@@ -60,7 +60,16 @@ describe("Grid Accessibility", () => {
60
60
  describe("SimpleGrid", () => {
61
61
  it("Renders the SimpleGrid UI snapshot correctly", () => {
62
62
  const tree = renderer.create(<SimpleGrid id="test-grid" />).toJSON();
63
+ const withChakraProps = renderer
64
+ .create(<SimpleGrid id="chakra" p="20px" color="ui.error.primary" />)
65
+ .toJSON();
66
+ const withOtherProps = renderer
67
+ .create(<SimpleGrid id="props" data-testid="props" />)
68
+ .toJSON();
69
+
63
70
  expect(tree).toMatchSnapshot();
71
+ expect(withChakraProps).toMatchSnapshot();
72
+ expect(withOtherProps).toMatchSnapshot();
64
73
  });
65
74
 
66
75
  it("Renders SimpleGrid component", () => {
@@ -1,9 +1,7 @@
1
+ import { chakra, SimpleGrid as ChakraSimpleGrid } from "@chakra-ui/react";
1
2
  import * as React from "react";
2
- import { SimpleGrid as ChakraSimpleGrid } from "@chakra-ui/react";
3
- import { GridGaps } from "./GridTypes";
4
-
5
- import generateUUID from "../../helpers/generateUUID";
6
3
 
4
+ import { GridGaps } from "./GridTypes";
7
5
  export interface SimpleGridProps {
8
6
  /** Additional class name. */
9
7
  className?: string;
@@ -15,23 +13,34 @@ export interface SimpleGridProps {
15
13
  id?: string;
16
14
  }
17
15
 
18
- function SimpleGrid(props: React.PropsWithChildren<SimpleGridProps>) {
19
- const { children, columns, className, gap = GridGaps.Large, id } = props;
16
+ export const SimpleGrid = chakra(
17
+ (props: React.PropsWithChildren<SimpleGridProps>) => {
18
+ const {
19
+ children,
20
+ columns,
21
+ className,
22
+ gap = GridGaps.Large,
23
+ id,
24
+ ...rest
25
+ } = props;
20
26
 
21
- const responsiveCols = columns
22
- ? { base: 1, md: columns }
23
- : { base: 1, md: 2, lg: 3 };
27
+ const responsiveCols = columns
28
+ ? { base: 1, md: columns }
29
+ : { base: 1, md: 2, lg: 3 };
24
30
 
25
- return (
26
- <ChakraSimpleGrid
27
- columns={responsiveCols}
28
- gap={gap}
29
- id={id || generateUUID()}
30
- className={className}
31
- >
32
- {children}
33
- </ChakraSimpleGrid>
34
- );
35
- }
31
+ return (
32
+ <ChakraSimpleGrid
33
+ columns={responsiveCols}
34
+ gap={gap}
35
+ id={id}
36
+ className={className}
37
+ {...rest}
38
+ >
39
+ {children}
40
+ </ChakraSimpleGrid>
41
+ );
42
+ },
43
+ { shouldForwardProp: () => true }
44
+ );
36
45
 
37
46
  export default SimpleGrid;
@@ -2,7 +2,22 @@
2
2
 
3
3
  exports[`SimpleGrid Renders the SimpleGrid UI snapshot correctly 1`] = `
4
4
  <div
5
- className="css-1tep0ti"
5
+ className="css-bjq6jk"
6
6
  id="test-grid"
7
7
  />
8
8
  `;
9
+
10
+ exports[`SimpleGrid Renders the SimpleGrid UI snapshot correctly 2`] = `
11
+ <div
12
+ className="css-161u8yz"
13
+ id="chakra"
14
+ />
15
+ `;
16
+
17
+ exports[`SimpleGrid Renders the SimpleGrid UI snapshot correctly 3`] = `
18
+ <div
19
+ className="css-bjq6jk"
20
+ data-testid="props"
21
+ id="props"
22
+ />
23
+ `;
@@ -53,7 +53,19 @@ export const levelsEnumValues = getStorybookEnumValues(
53
53
  | Component Version | DS Version |
54
54
  | ----------------- | ---------- |
55
55
  | Added | `0.0.4` |
56
- | Latest | `0.25.13` |
56
+ | Latest | `0.26.0` |
57
+
58
+ ## Table of Contents
59
+
60
+ - [Overview](#overview)
61
+ - [Component Props](#component-props)
62
+ - [Accessibility](#accessibility)
63
+ - [Default Heading Styles](#default-heading-styles)
64
+ - [Size Styles](#size-styles)
65
+ - [Heading with Bold Text](#heading-with-bold-text)
66
+ - [Headings with Links](#headings-with-links)
67
+
68
+ ## Overview
57
69
 
58
70
  <Description of={Heading} />
59
71
 
@@ -61,6 +73,8 @@ A `Heading` component will render a standard HTML `<h>` tag (1-6). The heading's
61
73
  text can be passed in through a `text` prop or as a child. Default styles for
62
74
  semantic elements can be overwritten using the `size` prop.
63
75
 
76
+ ## Component Props
77
+
64
78
  <Canvas withToolbar>
65
79
  <Story
66
80
  name="Heading with Controls"
@@ -87,6 +101,25 @@ semantic elements can be overwritten using the `size` prop.
87
101
 
88
102
  <ArgsTable story="Heading with Controls" />
89
103
 
104
+ ## Accessibility
105
+
106
+ When adding headings to a webpage, it is important to ensure that the heading
107
+ hierarchy is consistent. This means they should start with only one `h1` for the
108
+ page title and then proceed with `h2`s, `h3`s, `h4`s, `h5`s and `h6`s in the
109
+ proper order and not skipping any. For example, the following is invalid HTML:
110
+
111
+ ```html
112
+ <h1>Page Title</h1>
113
+ <h2>Subtitle</h2>
114
+ <h4>Sub-subtitle</h4>
115
+ ```
116
+
117
+ Resources:
118
+
119
+ - [W3C WAI Headings](https://www.w3.org/WAI/tutorials/page-structure/headings/)
120
+ - [A11y Project Accessible heading structure](https://www.a11yproject.com/posts/how-to-accessible-heading-structure/)
121
+ - [Chakra UI Heading](https://chakra-ui.com/docs/components/typography/heading)
122
+
90
123
  ## Default Heading Styles
91
124
 
92
125
  <Canvas>
@@ -162,10 +195,10 @@ Note: The `level` prop for the `Heading`s in the next example are all set to
162
195
  </Story>
163
196
  </Canvas>
164
197
 
165
- ## Heading with Bold
198
+ ## Heading with Bold Text
166
199
 
167
200
  <Canvas>
168
- <Story name="Heading with Bold">
201
+ <Story name="Heading with Bold Text">
169
202
  <Heading id="headingWithBold" level={HeadingLevels.One}>
170
203
  <>
171
204
  Heading with a <b>Bold</b> Word
@@ -176,6 +176,14 @@ describe("Heading", () => {
176
176
  </Heading>
177
177
  )
178
178
  .toJSON();
179
+ const withChakraProps = renderer
180
+ .create(
181
+ <Heading id="chakra" text="Heading" p="20px" color="ui.red.primary" />
182
+ )
183
+ .toJSON();
184
+ const withOtherProps = renderer
185
+ .create(<Heading id="props" text="Heading" data-testid="props" />)
186
+ .toJSON();
179
187
 
180
188
  expect(basic).toMatchSnapshot();
181
189
  expect(basicWithChildText).toMatchSnapshot();
@@ -183,5 +191,7 @@ describe("Heading", () => {
183
191
  expect(otherLevel).toMatchSnapshot();
184
192
  expect(withLink).toMatchSnapshot();
185
193
  expect(withCustomLink).toMatchSnapshot();
194
+ expect(withChakraProps).toMatchSnapshot();
195
+ expect(withOtherProps).toMatchSnapshot();
186
196
  });
187
197
  });
@@ -1,11 +1,13 @@
1
- import { Heading as ChakraHeading, useStyleConfig } from "@chakra-ui/react";
1
+ import {
2
+ chakra,
3
+ Heading as ChakraHeading,
4
+ useStyleConfig,
5
+ } from "@chakra-ui/react";
2
6
  import * as React from "react";
3
7
 
4
8
  import { HeadingSizes, HeadingLevels } from "./HeadingTypes";
5
9
  import Link from "../Link/Link";
6
10
  import { getVariant } from "../../utils/utils";
7
- import generateUUID from "../../helpers/generateUUID";
8
-
9
11
  export interface HeadingProps {
10
12
  /** Optionally pass in additional Chakra-based styles. */
11
13
  additionalStyles?: { [key: string]: any };
@@ -42,57 +44,61 @@ const getMappedLevel = (level = HeadingLevels.Two) => {
42
44
  return levelMap[level] || 2;
43
45
  };
44
46
 
45
- function Heading(props: React.PropsWithChildren<HeadingProps>) {
46
- const {
47
- additionalStyles = {},
48
- className,
49
- id = generateUUID(),
50
- level = HeadingLevels.Two,
51
- size,
52
- text,
53
- url,
54
- urlClass,
55
- } = props;
56
- const finalLevel = getMappedLevel(level);
57
- const variant = size ? getVariant(size, HeadingSizes) : `h${finalLevel}`;
58
- const styles = useStyleConfig("Heading", { variant });
59
- // Combine native base styles with any additional styles.
60
- // This is used in the `Hero` and `Notification` components.
61
- const finalStyles = { ...styles, ...additionalStyles };
62
- const asHeading: any = `h${finalLevel}`;
47
+ export const Heading = chakra(
48
+ (props: React.PropsWithChildren<HeadingProps>) => {
49
+ const {
50
+ additionalStyles = {},
51
+ className,
52
+ id,
53
+ level = HeadingLevels.Two,
54
+ size,
55
+ text,
56
+ url,
57
+ urlClass,
58
+ ...rest
59
+ } = props;
60
+ const finalLevel = getMappedLevel(level);
61
+ const variant = size ? getVariant(size, HeadingSizes) : `h${finalLevel}`;
62
+ const styles = useStyleConfig("Heading", { variant });
63
+ // Combine native base styles with any additional styles.
64
+ // This is used in the `Hero` and `Notification` components.
65
+ const finalStyles = { ...styles, ...additionalStyles };
66
+ const asHeading: any = `h${finalLevel}`;
67
+
68
+ if (!props.children && !text) {
69
+ throw new Error(
70
+ "NYPL Reservoir Heading: No children or value was passed to the `text` prop."
71
+ );
72
+ }
63
73
 
64
- if (!props.children && !text) {
65
- throw new Error(
66
- "NYPL Reservoir Heading: No children or value was passed to the `text` prop."
74
+ if (React.Children.count(props.children) > 1) {
75
+ // Catching the error because React's error isn't as helpful.
76
+ throw new Error(
77
+ "NYPL Reservoir Heading: Only pass one child into Heading."
78
+ );
79
+ }
80
+
81
+ const contentToRender = props.children ? props.children : text;
82
+ const content = url ? (
83
+ <Link className={urlClass} href={url} id={`${id}-link`}>
84
+ {contentToRender}
85
+ </Link>
86
+ ) : (
87
+ contentToRender
67
88
  );
68
- }
69
89
 
70
- if (React.Children.count(props.children) > 1) {
71
- // Catching the error because React's error isn't as helpful.
72
- throw new Error(
73
- "NYPL Reservoir Heading: Only pass one child into Heading."
90
+ return (
91
+ <ChakraHeading
92
+ as={asHeading}
93
+ className={className}
94
+ id={id}
95
+ sx={finalStyles}
96
+ {...rest}
97
+ >
98
+ {content}
99
+ </ChakraHeading>
74
100
  );
75
101
  }
76
-
77
- const contentToRender = props.children ? props.children : text;
78
- const content = url ? (
79
- <Link className={urlClass} href={url} id={`${id}-link`}>
80
- {contentToRender}
81
- </Link>
82
- ) : (
83
- contentToRender
84
- );
85
-
86
- return (
87
- <ChakraHeading
88
- id={id}
89
- as={asHeading}
90
- sx={finalStyles}
91
- className={className}
92
- >
93
- {content}
94
- </ChakraHeading>
95
- );
96
- }
102
+ );
97
103
 
98
104
  export default Heading;
@@ -2,7 +2,7 @@
2
2
 
3
3
  exports[`Heading renders the UI snapshot correctly 1`] = `
4
4
  <h1
5
- className="chakra-heading css-0"
5
+ className="chakra-heading css-1xdhyk6"
6
6
  id="basic"
7
7
  >
8
8
  Heading text
@@ -11,7 +11,7 @@ exports[`Heading renders the UI snapshot correctly 1`] = `
11
11
 
12
12
  exports[`Heading renders the UI snapshot correctly 2`] = `
13
13
  <h1
14
- className="chakra-heading css-0"
14
+ className="chakra-heading css-1xdhyk6"
15
15
  id="basicWithChildText"
16
16
  >
17
17
  Heading text
@@ -20,7 +20,7 @@ exports[`Heading renders the UI snapshot correctly 2`] = `
20
20
 
21
21
  exports[`Heading renders the UI snapshot correctly 3`] = `
22
22
  <h1
23
- className="chakra-heading css-0"
23
+ className="chakra-heading css-1xdhyk6"
24
24
  id="customDisplaySize"
25
25
  >
26
26
  Heading with Secondary size
@@ -29,7 +29,7 @@ exports[`Heading renders the UI snapshot correctly 3`] = `
29
29
 
30
30
  exports[`Heading renders the UI snapshot correctly 4`] = `
31
31
  <h6
32
- className="chakra-heading css-0"
32
+ className="chakra-heading css-1xdhyk6"
33
33
  id="otherLevel"
34
34
  >
35
35
  Heading level six
@@ -38,11 +38,11 @@ exports[`Heading renders the UI snapshot correctly 4`] = `
38
38
 
39
39
  exports[`Heading renders the UI snapshot correctly 5`] = `
40
40
  <h1
41
- className="chakra-heading css-0"
41
+ className="chakra-heading css-1xdhyk6"
42
42
  id="withLink"
43
43
  >
44
44
  <a
45
- className="css-0"
45
+ className="css-1xdhyk6"
46
46
  href="fake-url"
47
47
  id="withLink-link"
48
48
  rel={null}
@@ -55,7 +55,7 @@ exports[`Heading renders the UI snapshot correctly 5`] = `
55
55
 
56
56
  exports[`Heading renders the UI snapshot correctly 6`] = `
57
57
  <h1
58
- className="chakra-heading css-0"
58
+ className="chakra-heading css-1xdhyk6"
59
59
  id="withCustomLink"
60
60
  >
61
61
  Part of the heading text is
@@ -69,3 +69,22 @@ exports[`Heading renders the UI snapshot correctly 6`] = `
69
69
  </a>
70
70
  </h1>
71
71
  `;
72
+
73
+ exports[`Heading renders the UI snapshot correctly 7`] = `
74
+ <h2
75
+ className="chakra-heading css-10g9ftz"
76
+ id="chakra"
77
+ >
78
+ Heading
79
+ </h2>
80
+ `;
81
+
82
+ exports[`Heading renders the UI snapshot correctly 8`] = `
83
+ <h2
84
+ className="chakra-heading css-1xdhyk6"
85
+ data-testid="props"
86
+ id="props"
87
+ >
88
+ Heading
89
+ </h2>
90
+ `;