@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.
Files changed (305) hide show
  1. package/CHANGELOG.md +85 -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/Modal/Modal.d.ts +28 -8
  29. package/dist/components/Notification/Notification.d.ts +4 -4
  30. package/dist/components/Pagination/Pagination.d.ts +2 -2
  31. package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +3 -3
  32. package/dist/components/Radio/Radio.d.ts +4 -6
  33. package/dist/components/RadioGroup/RadioGroup.d.ts +12 -6
  34. package/dist/components/SearchBar/SearchBar.d.ts +4 -4
  35. package/dist/components/Select/Select.d.ts +10 -6
  36. package/dist/components/Select/SelectTypes.d.ts +4 -0
  37. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -3
  38. package/dist/components/Slider/Slider.d.ts +6 -4
  39. package/dist/components/StatusBadge/StatusBadge.d.ts +5 -1
  40. package/dist/components/StructuredContent/StructuredContent.d.ts +2 -2
  41. package/dist/components/Table/Table.d.ts +1 -1
  42. package/dist/components/Tabs/Tabs.d.ts +4 -3
  43. package/dist/components/Template/Template.d.ts +4 -3
  44. package/dist/components/Text/Text.d.ts +1 -1
  45. package/dist/components/TextInput/TextInput.d.ts +5 -5
  46. package/dist/components/Toggle/Toggle.d.ts +3 -4
  47. package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
  48. package/dist/design-system-react-components.cjs.development.js +1767 -1180
  49. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  50. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  51. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  52. package/dist/design-system-react-components.esm.js +1774 -1188
  53. package/dist/design-system-react-components.esm.js.map +1 -1
  54. package/dist/hooks/useCarouselStyles.d.ts +3 -2
  55. package/dist/hooks/useNYPLTheme.d.ts +12 -0
  56. package/dist/index.d.ts +5 -2
  57. package/dist/styles.css +1 -1
  58. package/dist/theme/components/button.d.ts +10 -2
  59. package/dist/theme/components/card.d.ts +42 -22
  60. package/dist/theme/components/checkbox.d.ts +5 -4
  61. package/dist/theme/components/checkboxGroup.d.ts +1 -1
  62. package/dist/theme/components/componentWrapper.d.ts +2 -2
  63. package/dist/theme/components/customTable.d.ts +84 -1
  64. package/dist/theme/components/fieldset.d.ts +4 -14
  65. package/dist/theme/components/global.d.ts +23 -17
  66. package/dist/theme/components/heading.d.ts +53 -0
  67. package/dist/theme/components/helperErrorText.d.ts +1 -0
  68. package/dist/theme/components/hero.d.ts +20 -14
  69. package/dist/theme/components/label.d.ts +9 -10
  70. package/dist/theme/components/list.d.ts +99 -9
  71. package/dist/theme/components/radio.d.ts +6 -4
  72. package/dist/theme/components/radioGroup.d.ts +1 -1
  73. package/dist/theme/components/select.d.ts +28 -5
  74. package/dist/theme/components/skeletonLoader.d.ts +2 -2
  75. package/dist/theme/components/slider.d.ts +6 -3
  76. package/dist/theme/components/structuredContent.d.ts +197 -0
  77. package/dist/theme/components/textInput.d.ts +18 -6
  78. package/dist/theme/components/toggle.d.ts +7 -4
  79. package/dist/theme/foundations/global.d.ts +2 -0
  80. package/dist/theme/foundations/radii.d.ts +1 -0
  81. package/dist/theme/foundations/spacing.d.ts +46 -43
  82. package/package.json +17 -19
  83. package/src/components/Accordion/Accordion.stories.mdx +9 -9
  84. package/src/components/Accordion/Accordion.test.tsx +21 -0
  85. package/src/components/Accordion/Accordion.tsx +13 -9
  86. package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +276 -27
  87. package/src/components/Autosuggest/Autosuggest.stories.mdx +4 -3
  88. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +21 -5
  89. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +52 -31
  90. package/src/components/Breadcrumbs/Breadcrumbs.tsx +8 -7
  91. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +211 -12
  92. package/src/components/Button/Button.stories.mdx +87 -23
  93. package/src/components/Button/Button.test.tsx +25 -0
  94. package/src/components/Button/Button.tsx +18 -7
  95. package/src/components/Button/__snapshots__/Button.test.tsx.snap +27 -7
  96. package/src/components/Card/Card.stories.mdx +287 -194
  97. package/src/components/Card/Card.test.tsx +102 -0
  98. package/src/components/Card/Card.tsx +73 -32
  99. package/src/components/Card/__snapshots__/Card.test.tsx.snap +196 -36
  100. package/src/components/Chakra/Grid.stories.mdx +4 -4
  101. package/src/components/Checkbox/Checkbox.stories.mdx +62 -10
  102. package/src/components/Checkbox/Checkbox.test.tsx +32 -9
  103. package/src/components/Checkbox/Checkbox.tsx +20 -15
  104. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +134 -7
  105. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +65 -17
  106. package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +137 -81
  107. package/src/components/CheckboxGroup/CheckboxGroup.tsx +31 -21
  108. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +332 -97
  109. package/src/components/ComponentWrapper/ComponentWrapper.test.tsx +12 -0
  110. package/src/components/ComponentWrapper/ComponentWrapper.tsx +39 -41
  111. package/src/components/ComponentWrapper/__snapshots__/ComponentWrapper.test.tsx.snap +47 -34
  112. package/src/components/DatePicker/DatePicker.stories.mdx +63 -27
  113. package/src/components/DatePicker/DatePicker.test.tsx +89 -13
  114. package/src/components/DatePicker/DatePicker.tsx +62 -56
  115. package/src/components/DatePicker/_DatePicker.scss +71 -13
  116. package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +250 -206
  117. package/src/components/Fieldset/Fieldset.stories.mdx +33 -3
  118. package/src/components/Fieldset/Fieldset.test.tsx +58 -28
  119. package/src/components/Fieldset/Fieldset.tsx +35 -30
  120. package/src/components/Fieldset/__snapshots__/Fieldset.test.tsx.snap +40 -19
  121. package/src/components/Form/Form.stories.mdx +72 -39
  122. package/src/components/Form/Form.test.tsx +58 -15
  123. package/src/components/Form/Form.tsx +89 -67
  124. package/src/components/Form/__snapshots__/Form.test.tsx.snap +83 -5
  125. package/src/components/Grid/GridTypes.tsx +7 -7
  126. package/src/components/Grid/SimpleGrid.stories.mdx +34 -6
  127. package/src/components/Grid/SimpleGrid.test.tsx +9 -0
  128. package/src/components/Grid/SimpleGrid.tsx +29 -20
  129. package/src/components/Grid/__snapshots__/SimpleGrid.test.tsx.snap +16 -1
  130. package/src/components/Heading/Heading.stories.mdx +36 -3
  131. package/src/components/Heading/Heading.test.tsx +10 -0
  132. package/src/components/Heading/Heading.tsx +56 -50
  133. package/src/components/Heading/__snapshots__/Heading.test.tsx.snap +26 -7
  134. package/src/components/HelperErrorText/HelperErrorText.stories.mdx +64 -42
  135. package/src/components/HelperErrorText/HelperErrorText.test.tsx +15 -0
  136. package/src/components/HelperErrorText/HelperErrorText.tsx +40 -35
  137. package/src/components/HelperErrorText/__snapshots__/HelperErrorText.test.tsx.snap +35 -4
  138. package/src/components/Hero/Hero.stories.mdx +125 -95
  139. package/src/components/Hero/Hero.test.tsx +33 -0
  140. package/src/components/Hero/Hero.tsx +135 -126
  141. package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +89 -17
  142. package/src/components/HorizontalRule/HorizontalRule.stories.mdx +26 -4
  143. package/src/components/HorizontalRule/HorizontalRule.test.tsx +9 -19
  144. package/src/components/HorizontalRule/HorizontalRule.tsx +9 -26
  145. package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +18 -5
  146. package/src/components/Icons/Icon.stories.mdx +31 -6
  147. package/src/components/Icons/Icon.test.tsx +38 -0
  148. package/src/components/Icons/Icon.tsx +93 -76
  149. package/src/components/Icons/__snapshots__/Icon.test.tsx.snap +129 -0
  150. package/src/components/Image/Image.stories.mdx +29 -5
  151. package/src/components/Image/Image.test.tsx +8 -0
  152. package/src/components/Image/Image.tsx +38 -26
  153. package/src/components/Image/__snapshots__/Image.test.tsx.snap +24 -8
  154. package/src/components/Label/Label.stories.mdx +42 -20
  155. package/src/components/Label/Label.test.tsx +42 -17
  156. package/src/components/Label/Label.tsx +22 -13
  157. package/src/components/Label/__snapshots__/Label.test.tsx.snap +19 -15
  158. package/src/components/Link/Link.stories.mdx +25 -15
  159. package/src/components/Link/Link.test.tsx +21 -22
  160. package/src/components/Link/Link.tsx +8 -8
  161. package/src/components/Link/__snapshots__/Link.test.tsx.snap +37 -11
  162. package/src/components/List/List.stories.mdx +75 -40
  163. package/src/components/List/List.test.tsx +67 -19
  164. package/src/components/List/List.tsx +38 -25
  165. package/src/components/List/ListTypes.tsx +1 -1
  166. package/src/components/List/__snapshots__/List.test.tsx.snap +110 -8
  167. package/src/components/Logo/Logo.stories.mdx +30 -6
  168. package/src/components/Logo/Logo.test.tsx +17 -0
  169. package/src/components/Logo/Logo.tsx +18 -6
  170. package/src/components/Logo/LogoSvgs.tsx +4 -0
  171. package/src/components/Logo/LogoTypes.tsx +2 -0
  172. package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +73 -2
  173. package/src/components/Modal/Modal.stories.mdx +256 -136
  174. package/src/components/Modal/Modal.test.tsx +151 -9
  175. package/src/components/Modal/Modal.tsx +140 -20
  176. package/src/components/Modal/__snapshots__/Modal.test.tsx.snap +25 -0
  177. package/src/components/Notification/Notification.stories.mdx +25 -1
  178. package/src/components/Notification/Notification.test.tsx +23 -0
  179. package/src/components/Notification/Notification.tsx +46 -44
  180. package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +158 -29
  181. package/src/components/Pagination/Pagination.stories.mdx +25 -6
  182. package/src/components/Pagination/Pagination.test.tsx +25 -0
  183. package/src/components/Pagination/Pagination.tsx +6 -6
  184. package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +244 -27
  185. package/src/components/Placeholder/Placeholder.tsx +3 -1
  186. package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +76 -10
  187. package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +81 -11
  188. package/src/components/ProgressIndicator/ProgressIndicator.tsx +17 -9
  189. package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +101 -14
  190. package/src/components/Radio/Radio.stories.mdx +64 -12
  191. package/src/components/Radio/Radio.test.tsx +28 -8
  192. package/src/components/Radio/Radio.tsx +66 -63
  193. package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +103 -6
  194. package/src/components/RadioGroup/RadioGroup.stories.mdx +224 -89
  195. package/src/components/RadioGroup/RadioGroup.test.tsx +122 -62
  196. package/src/components/RadioGroup/RadioGroup.tsx +106 -100
  197. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +1236 -1020
  198. package/src/components/SearchBar/SearchBar.stories.mdx +101 -36
  199. package/src/components/SearchBar/{SearchBar.Test.tsx → SearchBar.test.tsx} +46 -4
  200. package/src/components/SearchBar/SearchBar.tsx +17 -8
  201. package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +1039 -0
  202. package/src/components/Select/Select.stories.mdx +128 -49
  203. package/src/components/Select/Select.test.tsx +63 -16
  204. package/src/components/Select/Select.tsx +131 -92
  205. package/src/components/Select/SelectTypes.tsx +5 -0
  206. package/src/components/Select/__snapshots__/Select.test.tsx.snap +765 -425
  207. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +42 -10
  208. package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +8 -0
  209. package/src/components/SkeletonLoader/SkeletonLoader.tsx +76 -72
  210. package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +169 -10
  211. package/src/components/Slider/Slider.stories.mdx +91 -42
  212. package/src/components/Slider/Slider.test.tsx +65 -17
  213. package/src/components/Slider/Slider.tsx +26 -19
  214. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +403 -226
  215. package/src/components/StatusBadge/StatusBadge.stories.mdx +19 -1
  216. package/src/components/StatusBadge/StatusBadge.test.tsx +16 -0
  217. package/src/components/StatusBadge/StatusBadge.tsx +25 -20
  218. package/src/components/StatusBadge/__snapshots__/StatusBadge.test.tsx.snap +22 -3
  219. package/src/components/StructuredContent/StructuredContent.stories.mdx +131 -12
  220. package/src/components/StructuredContent/StructuredContent.test.tsx +34 -0
  221. package/src/components/StructuredContent/StructuredContent.tsx +80 -75
  222. package/src/components/StructuredContent/__snapshots__/StructuredContent.test.tsx.snap +102 -17
  223. package/src/components/StyleGuide/Bidirectionality.stories.mdx +5 -5
  224. package/src/components/StyleGuide/Breakpoints.stories.mdx +6 -6
  225. package/src/components/StyleGuide/Buttons.stories.mdx +2 -12
  226. package/src/components/StyleGuide/ColorCard.tsx +1 -1
  227. package/src/components/StyleGuide/Colors.stories.mdx +1 -2
  228. package/src/components/StyleGuide/DesignTokens.stories.mdx +56 -26
  229. package/src/components/StyleGuide/Forms.stories.mdx +27 -12
  230. package/src/components/StyleGuide/Iconography.stories.mdx +2 -12
  231. package/src/components/StyleGuide/Spacing.stories.mdx +80 -41
  232. package/src/components/StyleGuide/Typography.stories.mdx +30 -21
  233. package/src/components/Table/Table.stories.mdx +38 -11
  234. package/src/components/Table/Table.test.tsx +15 -0
  235. package/src/components/Table/Table.tsx +7 -7
  236. package/src/components/Table/__snapshots__/Table.test.tsx.snap +408 -5
  237. package/src/components/Tabs/Tabs.stories.mdx +52 -3
  238. package/src/components/Tabs/Tabs.test.tsx +16 -0
  239. package/src/components/Tabs/Tabs.tsx +10 -6
  240. package/src/components/Tabs/__snapshots__/Tabs.test.tsx.snap +394 -5
  241. package/src/components/Template/Template.stories.mdx +47 -43
  242. package/src/components/Template/Template.test.tsx +33 -0
  243. package/src/components/Template/Template.tsx +65 -60
  244. package/src/components/Template/__snapshots__/Template.test.tsx.snap +191 -20
  245. package/src/components/Text/Text.stories.mdx +20 -1
  246. package/src/components/Text/Text.test.tsx +12 -0
  247. package/src/components/Text/Text.tsx +6 -4
  248. package/src/components/Text/__snapshots__/Text.test.tsx.snap +21 -4
  249. package/src/components/TextInput/TextInput.stories.mdx +65 -19
  250. package/src/components/TextInput/TextInput.test.tsx +42 -28
  251. package/src/components/TextInput/TextInput.tsx +121 -113
  252. package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +96 -73
  253. package/src/components/Toggle/Toggle.stories.mdx +80 -22
  254. package/src/components/Toggle/Toggle.test.tsx +27 -9
  255. package/src/components/Toggle/Toggle.tsx +22 -18
  256. package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +128 -5
  257. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +52 -4
  258. package/src/components/VideoPlayer/VideoPlayer.test.tsx +23 -0
  259. package/src/components/VideoPlayer/VideoPlayer.tsx +133 -126
  260. package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +81 -39
  261. package/src/docs/Chakra.stories.mdx +50 -9
  262. package/src/docs/Welcome.stories.mdx +160 -41
  263. package/src/hooks/useCarouselStyles.stories.mdx +22 -2
  264. package/src/hooks/useCarouselStyles.ts +3 -2
  265. package/src/hooks/useNYPLTheme.stories.mdx +101 -0
  266. package/src/hooks/useNYPLTheme.ts +30 -6
  267. package/src/hooks/useWindowSize.stories.mdx +23 -0
  268. package/src/index.ts +5 -2
  269. package/src/styles/base/_place-holder.scss +1 -1
  270. package/src/styles.scss +0 -1
  271. package/src/theme/components/button.ts +15 -7
  272. package/src/theme/components/card.ts +30 -19
  273. package/src/theme/components/checkbox.ts +10 -8
  274. package/src/theme/components/checkboxGroup.ts +1 -1
  275. package/src/theme/components/componentWrapper.ts +2 -2
  276. package/src/theme/components/customTable.ts +39 -31
  277. package/src/theme/components/fieldset.ts +1 -2
  278. package/src/theme/components/global.ts +25 -20
  279. package/src/theme/components/heading.ts +1 -1
  280. package/src/theme/components/helperErrorText.ts +1 -0
  281. package/src/theme/components/hero.ts +13 -15
  282. package/src/theme/components/label.ts +4 -3
  283. package/src/theme/components/list.ts +73 -66
  284. package/src/theme/components/notification.ts +2 -2
  285. package/src/theme/components/radio.ts +9 -9
  286. package/src/theme/components/radioGroup.ts +1 -1
  287. package/src/theme/components/select.ts +31 -22
  288. package/src/theme/components/skeletonLoader.ts +3 -3
  289. package/src/theme/components/slider.ts +8 -7
  290. package/src/theme/components/statusBadge.ts +2 -2
  291. package/src/theme/components/structuredContent.ts +66 -1
  292. package/src/theme/components/tabs.ts +2 -2
  293. package/src/theme/components/template.ts +9 -9
  294. package/src/theme/components/textInput.ts +13 -12
  295. package/src/theme/components/toggle.ts +17 -10
  296. package/src/theme/components/videoPlayer.ts +1 -1
  297. package/src/theme/foundations/colors.ts +1 -1
  298. package/src/theme/foundations/radii.ts +1 -0
  299. package/src/theme/foundations/spacing.ts +70 -22
  300. package/src/theme/foundations/typography.ts +2 -2
  301. package/src/utils/componentCategories.ts +1 -2
  302. package/dist/components/SearchBar/SearchBar.Test.d.ts +0 -1
  303. package/dist/helpers/generateUUID.d.ts +0 -1
  304. package/src/components/Modal/_Modal.scss +0 -18
  305. package/src/helpers/generateUUID.tsx +0 -5
@@ -2,30 +2,43 @@
2
2
 
3
3
  exports[`HorizontalRule renders the UI snapshot correctly 1`] = `
4
4
  <hr
5
- className="css-1bhbd2a"
5
+ className="css-mvtkpx"
6
6
  />
7
7
  `;
8
8
 
9
9
  exports[`HorizontalRule renders the UI snapshot correctly 2`] = `
10
10
  <hr
11
- className="css-154goob"
11
+ className="css-j99tgf"
12
12
  />
13
13
  `;
14
14
 
15
15
  exports[`HorizontalRule renders the UI snapshot correctly 3`] = `
16
16
  <hr
17
- className="css-gj8znx"
17
+ className="css-21sffo"
18
18
  />
19
19
  `;
20
20
 
21
21
  exports[`HorizontalRule renders the UI snapshot correctly 4`] = `
22
22
  <hr
23
- className="css-1bhbd2a"
23
+ className="css-mvtkpx"
24
24
  />
25
25
  `;
26
26
 
27
27
  exports[`HorizontalRule renders the UI snapshot correctly 5`] = `
28
28
  <hr
29
- className="css-1bhbd2a"
29
+ className="css-mvtkpx"
30
+ />
31
+ `;
32
+
33
+ exports[`HorizontalRule renders the UI snapshot correctly 6`] = `
34
+ <hr
35
+ className="css-1pg2j4r"
36
+ />
37
+ `;
38
+
39
+ exports[`HorizontalRule renders the UI snapshot correctly 7`] = `
40
+ <hr
41
+ className="css-mvtkpx"
42
+ data-testid="props"
30
43
  />
31
44
  `;
@@ -91,10 +91,25 @@ export const rotationEnumValues = getStorybookEnumValues(
91
91
  | Component Version | DS Version |
92
92
  | ----------------- | ---------- |
93
93
  | Added | `0.0.4` |
94
- | Latest | `0.25.13` |
94
+ | Latest | `0.26.0` |
95
+
96
+ ## Table of Contents
97
+
98
+ - [Overview](#overview)
99
+ - [Component Props](#component-props)
100
+ - [Accessibility](#accessibility)
101
+ - [Rotation Types](#rotation-types)
102
+ - [IconColors Types](#icon-colors-types)
103
+ - [IconSizes Types](#icon-sizes-types)
104
+ - [All Display Icons](#all-display-icons)
105
+ - [Custom Icons](#custom-icons)
106
+
107
+ ## Overview
95
108
 
96
109
  <Description of={Icon} />
97
110
 
111
+ ## Component Props
112
+
98
113
  <Canvas withToolbar>
99
114
  <Story
100
115
  name="Icon with Controls"
@@ -214,11 +229,21 @@ export const allIconsType = (list) => (
214
229
 
215
230
  ## Accessibility
216
231
 
217
- For accessibility purposes, every DS `Icon` will render the `svg` element with
218
- its icon name in the `title` element. The default text in the `title` element
219
- is the icon's code name. Pass in better descriptive text in the `title` prop
220
- when using the `Icon` component in your application. This will give screenreaders
221
- a better descriptive title for the `svg` graphic.
232
+ For accessibility purposes, every Reservoir Design System (DS) `Icon` will
233
+ render the `svg` element with its icon name in the `title` element. The default
234
+ text in the `title` element is the icon's code name. Pass in better descriptive
235
+ text in the `title` prop when using the `Icon` component in your application.
236
+ This will give screenreaders a better descriptive title for the `svg` graphic.
237
+
238
+ `Icon`s are decorative by default. This means that they are presentational and
239
+ screenreaders will not read them because the `aria-hidden` attribute is set to
240
+ `true`.
241
+
242
+ Resources:
243
+
244
+ - [W3C Design System SVG Icons](https://design-system.w3.org/styles/svg-icons.html)
245
+ - [CSS-Tricks Accessible SVG Icons](https://css-tricks.com/accessible-svg-icons/)
246
+ - [Chakra UI Icon](https://chakra-ui.com/docs/components/media-and-icons/icon)
222
247
 
223
248
  ## Rotation Types
224
249
 
@@ -1,6 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { render } from "@testing-library/react";
3
3
  import { axe } from "jest-axe";
4
+ import renderer from "react-test-renderer";
4
5
 
5
6
  import Icon from "./Icon";
6
7
  import { IconNames } from "./IconTypes";
@@ -87,4 +88,41 @@ describe("Icon", () => {
87
88
  );
88
89
  expect(container.querySelector("svg")).toBeInTheDocument();
89
90
  });
91
+
92
+ it("renders the UI snapshot correctly", () => {
93
+ const basic = renderer
94
+ .create(<Icon id="basic" name={IconNames.Download} />)
95
+ .toJSON();
96
+ const customIcon = renderer
97
+ .create(
98
+ <Icon id="customIcon">
99
+ <svg viewBox="0 0 24 14" xmlns="http://www.w3.org/2000/svg">
100
+ <path
101
+ fillRule="evenodd"
102
+ clipRule="evenodd"
103
+ d="M10.526 12.871L.263 1.676 1.737.324 12 11.52 22.263.324l1.474 1.352L13.474 12.87a2 2 0 01-2.948 0z"
104
+ />
105
+ </svg>
106
+ </Icon>
107
+ )
108
+ .toJSON();
109
+ const withChakraProps = renderer
110
+ .create(
111
+ <Icon
112
+ id="chakra"
113
+ name={IconNames.Download}
114
+ p="20px"
115
+ color="ui.error.primary"
116
+ />
117
+ )
118
+ .toJSON();
119
+ const withOtherProps = renderer
120
+ .create(<Icon id="props" name={IconNames.Download} data-testid="props" />)
121
+ .toJSON();
122
+
123
+ expect(basic).toMatchSnapshot();
124
+ expect(customIcon).toMatchSnapshot();
125
+ expect(withChakraProps).toMatchSnapshot();
126
+ expect(withOtherProps).toMatchSnapshot();
127
+ });
90
128
  });
@@ -1,7 +1,11 @@
1
+ import {
2
+ Icon as ChakraIcon,
3
+ Box,
4
+ chakra,
5
+ useStyleConfig,
6
+ } from "@chakra-ui/react";
1
7
  import * as React from "react";
2
- import { Icon as ChakraIcon, Box, useStyleConfig } from "@chakra-ui/react";
3
8
 
4
- import generateUUID from "../../helpers/generateUUID";
5
9
  import {
6
10
  IconAlign,
7
11
  IconColors,
@@ -43,82 +47,95 @@ export interface IconProps {
43
47
  /**
44
48
  * Renders SVG-based icons.
45
49
  */
46
- export default function Icon(props: React.PropsWithChildren<IconProps>) {
47
- const {
48
- additionalStyles = {},
49
- align = IconAlign.None,
50
- children,
51
- className,
52
- color = IconColors.UiBlack,
53
- decorative = true,
54
- iconRotation = IconRotationTypes.Rotate0,
55
- id = generateUUID(),
56
- name,
57
- size = IconSizes.Default,
58
- title = `${name} icon`,
59
- type = IconTypes.Default,
60
- } = props;
61
- const styles = useStyleConfig("Icon", {
62
- align,
63
- color,
64
- iconRotation,
65
- size,
66
- variant: type,
67
- });
68
- const iconProps = {
69
- "aria-hidden": decorative,
70
- className,
71
- id,
72
- role: "img",
73
- title,
74
- };
75
- let childSVG = null;
50
+ export const Icon = chakra(
51
+ (props: React.PropsWithChildren<IconProps>) => {
52
+ const {
53
+ additionalStyles = {},
54
+ align = IconAlign.None,
55
+ children,
56
+ className,
57
+ color = IconColors.UiBlack,
58
+ decorative = true,
59
+ iconRotation = IconRotationTypes.Rotate0,
60
+ id,
61
+ name,
62
+ size = IconSizes.Default,
63
+ title = `${name} icon`,
64
+ type = IconTypes.Default,
65
+ ...rest
66
+ } = props;
67
+ const styles = useStyleConfig("Icon", {
68
+ align,
69
+ color,
70
+ iconRotation,
71
+ size,
72
+ variant: type,
73
+ });
74
+ const iconProps = {
75
+ "aria-hidden": decorative,
76
+ className,
77
+ id,
78
+ role: "img",
79
+ title,
80
+ ...rest,
81
+ };
82
+ let childSVG = null;
76
83
 
77
- // Component prop validation
78
- if (name && children) {
79
- console.warn(
80
- "NYPL Reservoir Icon: Pass in either a `name` prop or an `svg` element " +
81
- "child. Do not pass both."
82
- );
83
- return null;
84
- } else if (!name && !children) {
85
- console.warn(
86
- "NYPL Reservoir Icon: Pass an icon `name` prop or an SVG child to " +
87
- "ensure an icon appears."
88
- );
89
- return null;
90
- }
84
+ // Component prop validation
85
+ if (name && children) {
86
+ console.warn(
87
+ "NYPL Reservoir Icon: Pass in either a `name` prop or an `svg` element " +
88
+ "child. Do not pass both."
89
+ );
90
+ return null;
91
+ } else if (!name && !children) {
92
+ console.warn(
93
+ "NYPL Reservoir Icon: Pass an icon `name` prop or an SVG child to " +
94
+ "ensure an icon appears."
95
+ );
96
+ return null;
97
+ }
91
98
 
92
- // The user wants to render an existing icon. Load the icon and render it
93
- // as a component through Chakra's Icon component. Otherwise, we're going to
94
- // render the SVG child with NYPL-theme styling.
95
- if (name) {
96
- const SvgComponent: any = iconSvgs[name];
97
- return (
98
- <ChakraIcon
99
- as={SvgComponent}
100
- {...iconProps}
101
- __css={{ ...styles, ...additionalStyles }}
102
- />
103
- );
104
- }
99
+ // The user wants to render an existing icon. Load the icon and render it
100
+ // as a component through Chakra's Icon component. Otherwise, we're going to
101
+ // render the SVG child with NYPL-theme styling.
102
+ if (name) {
103
+ const SvgComponent: any = iconSvgs[name];
104
+ return (
105
+ <ChakraIcon
106
+ as={SvgComponent}
107
+ {...iconProps}
108
+ __css={{ ...styles, ...additionalStyles }}
109
+ />
110
+ );
111
+ }
105
112
 
106
- // If no `name` prop was passed, we expect a child SVG element to be passed.
107
- // Apply icon props to the SVG child.
108
- if (
109
- (children as JSX.Element).type === "svg" ||
110
- (children as JSX.Element).props?.type === "svg" ||
111
- (children as JSX.Element).props?.mdxType === "svg"
112
- ) {
113
- childSVG = React.cloneElement(children as JSX.Element, {
114
- ...iconProps,
115
- });
116
- } else {
117
- console.warn(
118
- "NYPL Reservoir Icon: An `svg` element must be passed to the `Icon` " +
119
- "component as its child."
113
+ // If no `name` prop was passed, we expect a child SVG element to be passed.
114
+ // Apply icon props to the SVG child.
115
+ if (
116
+ (children as JSX.Element).type === "svg" ||
117
+ (children as JSX.Element).props?.type === "svg" ||
118
+ (children as JSX.Element).props?.mdxType === "svg"
119
+ ) {
120
+ childSVG = React.cloneElement(children as JSX.Element, {
121
+ ...iconProps,
122
+ });
123
+ } else {
124
+ console.warn(
125
+ "NYPL Reservoir Icon: An `svg` element must be passed to the `Icon` " +
126
+ "component as its child."
127
+ );
128
+ }
129
+
130
+ return (
131
+ <Box __css={styles} {...rest}>
132
+ {childSVG}
133
+ </Box>
120
134
  );
121
- }
135
+ },
136
+ // Pass all custom props to Chakra and override, e.g. we want the
137
+ // DS color prop to use the DS enum and not color strings.
138
+ { shouldForwardProp: () => true }
139
+ );
122
140
 
123
- return <Box __css={styles}>{childSVG}</Box>;
124
- }
141
+ export default Icon;
@@ -0,0 +1,129 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Icon renders the UI snapshot correctly 1`] = `
4
+ <svg
5
+ aria-hidden={true}
6
+ className="chakra-icon css-1grhd2q"
7
+ focusable={false}
8
+ id="basic"
9
+ role="img"
10
+ title="download icon"
11
+ viewBox="0 0 24 24"
12
+ >
13
+ <g
14
+ stroke="currentColor"
15
+ strokeWidth="1.5"
16
+ >
17
+ <path
18
+ d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
19
+ fill="none"
20
+ strokeLinecap="round"
21
+ />
22
+ <path
23
+ d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
24
+ fill="currentColor"
25
+ strokeLinecap="round"
26
+ />
27
+ <circle
28
+ cx="12"
29
+ cy="12"
30
+ fill="none"
31
+ r="11.25"
32
+ strokeMiterlimit="10"
33
+ />
34
+ </g>
35
+ </svg>
36
+ `;
37
+
38
+ exports[`Icon renders the UI snapshot correctly 2`] = `
39
+ <div
40
+ className="css-0"
41
+ >
42
+ <svg
43
+ aria-hidden={true}
44
+ className="css-0"
45
+ id="customIcon"
46
+ role="img"
47
+ title="undefined icon"
48
+ viewBox="0 0 24 14"
49
+ xmlns="http://www.w3.org/2000/svg"
50
+ >
51
+ <path
52
+ clipRule="evenodd"
53
+ d="M10.526 12.871L.263 1.676 1.737.324 12 11.52 22.263.324l1.474 1.352L13.474 12.87a2 2 0 01-2.948 0z"
54
+ fillRule="evenodd"
55
+ />
56
+ </svg>
57
+ </div>
58
+ `;
59
+
60
+ exports[`Icon renders the UI snapshot correctly 3`] = `
61
+ <svg
62
+ aria-hidden={true}
63
+ className="chakra-icon css-7rufou"
64
+ focusable={false}
65
+ id="chakra"
66
+ role="img"
67
+ title="download icon"
68
+ viewBox="0 0 24 24"
69
+ >
70
+ <g
71
+ stroke="currentColor"
72
+ strokeWidth="1.5"
73
+ >
74
+ <path
75
+ d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
76
+ fill="none"
77
+ strokeLinecap="round"
78
+ />
79
+ <path
80
+ d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
81
+ fill="currentColor"
82
+ strokeLinecap="round"
83
+ />
84
+ <circle
85
+ cx="12"
86
+ cy="12"
87
+ fill="none"
88
+ r="11.25"
89
+ strokeMiterlimit="10"
90
+ />
91
+ </g>
92
+ </svg>
93
+ `;
94
+
95
+ exports[`Icon renders the UI snapshot correctly 4`] = `
96
+ <svg
97
+ aria-hidden={true}
98
+ className="chakra-icon css-1grhd2q"
99
+ data-testid="props"
100
+ focusable={false}
101
+ id="props"
102
+ role="img"
103
+ title="download icon"
104
+ viewBox="0 0 24 24"
105
+ >
106
+ <g
107
+ stroke="currentColor"
108
+ strokeWidth="1.5"
109
+ >
110
+ <path
111
+ d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
112
+ fill="none"
113
+ strokeLinecap="round"
114
+ />
115
+ <path
116
+ d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
117
+ fill="currentColor"
118
+ strokeLinecap="round"
119
+ />
120
+ <circle
121
+ cx="12"
122
+ cy="12"
123
+ fill="none"
124
+ r="11.25"
125
+ strokeMiterlimit="10"
126
+ />
127
+ </g>
128
+ </svg>
129
+ `;
@@ -82,14 +82,26 @@ export const imageBlockStyles = {
82
82
  | Component Version | DS Version |
83
83
  | ----------------- | ---------- |
84
84
  | Added | `0.0.6` |
85
- | Latest | `0.25.13` |
85
+ | Latest | `0.26.0` |
86
+
87
+ ## Table of Contents
88
+
89
+ - [Overview](#overview)
90
+ - [Component Props](#component-props)
91
+ - [Accessibility](#accessibility)
92
+ - [Image Figure](#image-figure)
93
+ - [Image Sizes](#image-sizes)
94
+ - [Image Aspect Ratios](#image-aspect-ratios)
95
+ - [Image Types](#image-types)
96
+
97
+ ## Overview
86
98
 
87
99
  <Description of={Image} />
88
100
 
89
- <p>
90
- If you want a simple HTML `img` element then don't pass in values for the
91
- `aspectRatio` or `size` props.
92
- </p>
101
+ If you want a simple HTML `img` element then don't pass in values for the
102
+ `aspectRatio` or `size` props.
103
+
104
+ ## Component Props
93
105
 
94
106
  <Canvas>
95
107
  <Story
@@ -122,6 +134,18 @@ export const imageBlockStyles = {
122
134
 
123
135
  <ArgsTable story="Image with Controls" />
124
136
 
137
+ ## Accessibility
138
+
139
+ All images must have an `alt` attribute, even if it's empty. The `alt` prop should
140
+ be used to concisely describe the image. If the image is decorative, then the
141
+ `alt` prop should be an empty string `""`.
142
+
143
+ Resources:
144
+
145
+ - [W3C WAI Images Tutorial](https://www.w3.org/WAI/tutorials/images/)
146
+ - [WebAIM Accessible Images](https://webaim.org/techniques/images/)
147
+ - [Yale Usability & Web Accessibility](https://usability.yale.edu/web-accessibility/articles/images)
148
+
125
149
  ## Image Figure
126
150
 
127
151
  By passing in `credit` or `caption`, the `Image` component will
@@ -139,6 +139,12 @@ describe("Image", () => {
139
139
  />
140
140
  )
141
141
  .toJSON();
142
+ const withChakraProps = renderer
143
+ .create(<Image src="test.png" alt="" p="20px" color="ui.error.primary" />)
144
+ .toJSON();
145
+ const withOtherProps = renderer
146
+ .create(<Image src="test.png" alt="" data-testid="image" />)
147
+ .toJSON();
142
148
 
143
149
  expect(basic).toMatchSnapshot();
144
150
  expect(figCaption).toMatchSnapshot();
@@ -158,5 +164,7 @@ describe("Image", () => {
158
164
  expect(ratioThreeByTwo).toMatchSnapshot();
159
165
  expect(ratioTwoByOne).toMatchSnapshot();
160
166
  expect(typeCircle).toMatchSnapshot();
167
+ expect(withChakraProps).toMatchSnapshot();
168
+ expect(withOtherProps).toMatchSnapshot();
161
169
  });
162
170
  });
@@ -1,4 +1,4 @@
1
- import { Box, useMultiStyleConfig } from "@chakra-ui/react";
1
+ import { Box, chakra, useMultiStyleConfig } from "@chakra-ui/react";
2
2
  import * as React from "react";
3
3
 
4
4
  import { ImageRatios, ImageSizes, ImageTypes } from "./ImageTypes";
@@ -55,31 +55,35 @@ export interface ImageProps extends ImageWrapperProps {
55
55
  src: string;
56
56
  }
57
57
 
58
- function ImageWrapper(props: React.PropsWithChildren<ImageWrapperProps>) {
59
- const {
60
- additionalWrapperStyles = {},
61
- className = "",
62
- children,
63
- aspectRatio = ImageRatios.Original,
64
- size = ImageSizes.Default,
65
- } = props;
66
- const styles = useMultiStyleConfig("CustomImageWrapper", {
67
- ratio: aspectRatio,
68
- size,
69
- });
70
- return (
71
- <Box
72
- className={`the-wrap ${className}`}
73
- __css={{ ...styles, ...additionalWrapperStyles }}
74
- >
75
- <Box className="the-crop" __css={styles.crop}>
76
- {children}
58
+ const ImageWrapper = chakra(
59
+ (props: React.PropsWithChildren<ImageWrapperProps>) => {
60
+ const {
61
+ additionalWrapperStyles = {},
62
+ className = "",
63
+ children,
64
+ aspectRatio = ImageRatios.Original,
65
+ size = ImageSizes.Default,
66
+ ...rest
67
+ } = props;
68
+ const styles = useMultiStyleConfig("CustomImageWrapper", {
69
+ ratio: aspectRatio,
70
+ size,
71
+ });
72
+ return (
73
+ <Box
74
+ className={`the-wrap ${className}`}
75
+ __css={{ ...styles, ...additionalWrapperStyles }}
76
+ {...rest}
77
+ >
78
+ <Box className="the-crop" __css={styles.crop}>
79
+ {children}
80
+ </Box>
77
81
  </Box>
78
- </Box>
79
- );
80
- }
82
+ );
83
+ }
84
+ );
81
85
 
82
- export default function Image(props: ImageProps) {
86
+ export const Image = chakra((props: ImageProps) => {
83
87
  const {
84
88
  additionalFigureStyles = {},
85
89
  additionalImageStyles = {},
@@ -93,6 +97,7 @@ export default function Image(props: ImageProps) {
93
97
  imageType = ImageTypes.Default,
94
98
  size = ImageSizes.Default,
95
99
  src,
100
+ ...rest
96
101
  } = props;
97
102
  const useImageWrapper = aspectRatio !== ImageRatios.Original;
98
103
  const styles = useMultiStyleConfig("CustomImage", {
@@ -122,6 +127,7 @@ export default function Image(props: ImageProps) {
122
127
  aspectRatio={aspectRatio}
123
128
  className={className}
124
129
  size={size}
130
+ {...(caption || credit ? {} : rest)}
125
131
  >
126
132
  {imageComponent}
127
133
  </ImageWrapper>
@@ -130,7 +136,11 @@ export default function Image(props: ImageProps) {
130
136
  );
131
137
 
132
138
  return caption || credit ? (
133
- <Box as="figure" __css={{ ...styles.figure, ...additionalFigureStyles }}>
139
+ <Box
140
+ as="figure"
141
+ __css={{ ...styles.figure, ...additionalFigureStyles }}
142
+ {...rest}
143
+ >
134
144
  {finalImage}
135
145
  <Box as="figcaption" __css={styles.figcaption}>
136
146
  {caption && <Box __css={styles.captionWrappers}>{caption}</Box>}
@@ -140,4 +150,6 @@ export default function Image(props: ImageProps) {
140
150
  ) : (
141
151
  finalImage
142
152
  );
143
- }
153
+ });
154
+
155
+ export default Image;