@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
@@ -47,10 +47,22 @@ import DSProvider from "../../theme/provider";
47
47
  | Component Version | DS Version |
48
48
  | ----------------- | ---------- |
49
49
  | Added | `0.0.10` |
50
- | Latest | `0.25.11` |
50
+ | Latest | `0.26.0` |
51
+
52
+ ## Table of Contents
53
+
54
+ - [Overview](#overview)
55
+ - [Component Props](#component-props)
56
+ - [Accessibility](#accessibility)
57
+ - [With HTML Children](#with-html-children)
58
+ - [Invalid State](#invalid-state)
59
+
60
+ ## Overview
51
61
 
52
62
  <Description of={HelperErrorText} />
53
63
 
64
+ ## Component Props
65
+
54
66
  <Canvas withToolbar>
55
67
  <Story
56
68
  name="HelperErrorText with Controls"
@@ -75,6 +87,54 @@ import DSProvider from "../../theme/provider";
75
87
 
76
88
  <ArgsTable story="HelperErrorText with Controls" />
77
89
 
90
+ ## Accessibility
91
+
92
+ In the "invalid" state when `isInvalid` is set to true, the text passed to the
93
+ `invalidText` prop will be presented to screen readers be default. If you need
94
+ to turn this off, set the `ariaLive` prop to `"off"`. This is used in DS "form"
95
+ components for invalid form submissions or incorrect values entered.
96
+
97
+ ### ariaAtomic
98
+
99
+ The `ariaAtomic` prop sets the `aria-atomic` attribute and it is set to `true`
100
+ by default. This allows the entire DOM element to be presented to assistive
101
+ technologies. When it is set to `false`, only additionals or removals will be
102
+ read by assistive technologies.
103
+
104
+ ### ariaLive
105
+
106
+ The `ariaLive` prop sets the `aria-live` attribute; `"polite"` is set by default
107
+ in the "invalid" state and `"off"` otherwise. This sets the priority of when the
108
+ text in this component should be read to users by assistive technologies. The
109
+ `"off"` value indicates that the content should not be presented, `"polite"` that
110
+ it will be announced at the next available time slot, and `"assertive"` that it
111
+ should be announced immediately.
112
+
113
+ <Canvas>
114
+ <Story
115
+ name="With Aria Controls"
116
+ args={{
117
+ ariaAtomic: true,
118
+ ariaLive: "polite",
119
+ isInvalid: true,
120
+ }}
121
+ >
122
+ {(args) => (
123
+ <HelperErrorText
124
+ {...args}
125
+ text="Only invalid text can be read to screen readers with the appropriate aria-atomic and aria-live props."
126
+ />
127
+ )}
128
+ </Story>
129
+ </Canvas>
130
+
131
+ Resources:
132
+
133
+ - [MDN ARIA live regions](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions)
134
+ - [W3C WAI-ARIA 1.1 - aria-live (property)](https://www.w3.org/TR/wai-aria-1.1/#aria-live)
135
+ - [W3C ARIA19: Using ARIA role=alert or Live Regions to Identify Errors](https://www.w3.org/TR/WCAG20-TECHS/ARIA19.html)
136
+ - [DigitalA11y WAI-ARIA:aria-live (Property)](https://www.digitala11y.com/aria-live-properties/)
137
+
78
138
  ## With HTML Children
79
139
 
80
140
  The `HelperErrorText` component can render any React component or HTML element
@@ -93,8 +153,9 @@ through the `text` prop.
93
153
  <HelperErrorText
94
154
  text={
95
155
  <Text>
96
- This second example uses DS components, such as the{" "}
97
- <Link href="#">`Link`</Link> component, and the `Text` component.
156
+ This second example uses Reservoir Design System (DS) components, such
157
+ as the <Link href="#">`Link`</Link> component, and the `Text`
158
+ component.
98
159
  </Text>
99
160
  }
100
161
  />
@@ -111,42 +172,3 @@ NYPL "invalid" styling.
111
172
  <HelperErrorText isInvalid text="This is the error text :(" />
112
173
  </Story>
113
174
  </Canvas>
114
-
115
- ## With Aria Props
116
-
117
- In the "invalid" state when `isInvalid` is set to true, the rendered text can be
118
- presented to screen readers if `ariaAtomic` and `ariaLive` are set appropriately.
119
-
120
- ### ariaAtomic
121
-
122
- The `ariaAtomic` prop sets the `aria-atomic` attribute; `true` by default. This
123
- allows the entire DOM element to be presented to assistive technologies. When it
124
- is set to `false`, only additionals or removals will be read by assistive
125
- technologies.
126
-
127
- ### ariaLive
128
-
129
- The `ariaLive` prop sets the `aria-live` attribute; `polite` by default in the
130
- "invalid" state and `off` otherwise. This sets the priority of when the text in
131
- this component should be read to users by assistive technologies. The `off` value
132
- indicates that the content should not be presented, `polite` that it will be
133
- announced at the next available time slot, and `assertive` that it should be
134
- announced immediately.
135
-
136
- <Canvas>
137
- <Story
138
- name="With Aria Controls"
139
- args={{
140
- ariaAtomic: true,
141
- ariaLive: "polite",
142
- isInvalid: true,
143
- }}
144
- >
145
- {(args) => (
146
- <HelperErrorText
147
- {...args}
148
- text="Only invalid text can be read to screen readers with the appropriate aria-atomic and aria-live props."
149
- />
150
- )}
151
- </Story>
152
- </Canvas>
@@ -90,10 +90,25 @@ describe("HelperErrorText", () => {
90
90
  />
91
91
  )
92
92
  .toJSON();
93
+ const withChakraProps = renderer
94
+ .create(
95
+ <HelperErrorText
96
+ id="chakra"
97
+ text="Text"
98
+ p="20px"
99
+ color="ui.red.primary"
100
+ />
101
+ )
102
+ .toJSON();
103
+ const withOtherProps = renderer
104
+ .create(<HelperErrorText id="props" text="Text" data-testid="props" />)
105
+ .toJSON();
93
106
 
94
107
  expect(basic).toMatchSnapshot();
95
108
  expect(invalid).toMatchSnapshot();
96
109
  expect(withHTMLString).toMatchSnapshot();
97
110
  expect(withHTMLElement).toMatchSnapshot();
111
+ expect(withChakraProps).toMatchSnapshot();
112
+ expect(withOtherProps).toMatchSnapshot();
98
113
  });
99
114
  });
@@ -1,7 +1,5 @@
1
+ import { Box, chakra, useStyleConfig } from "@chakra-ui/react";
1
2
  import * as React from "react";
2
- import { Box, useStyleConfig } from "@chakra-ui/react";
3
-
4
- import generateUUID from "../../helpers/generateUUID";
5
3
 
6
4
  export type AriaLiveValues = "assertive" | "off" | "polite";
7
5
  export type HelperErrorTextType = string | JSX.Element;
@@ -13,11 +11,12 @@ interface HelperErrorTextProps {
13
11
  * read the entire DOM element. When false, only changes (additionals or
14
12
  * removals) will be read. True by default. */
15
13
  ariaAtomic?: boolean;
16
- /** Aria attribute only used in the invalid state to read error text. This
17
- * indicates the priority of the text and when it should be presented to users
18
- * using screen readers; "off" indicates that the content should not be presented,
19
- * "polite" that it will be announced at the next available time slot, and
20
- * "assertive" that it should be announced immediately. "polite" by default. */
14
+ /** Aria attribute used in the invalid state to read error text by default.
15
+ * This indicates the priority of the text and when it should be presented to
16
+ * users using screen readers; "off" indicates that the content should not be
17
+ * presented, "polite" that it will be announced at the next available time
18
+ * slot, and "assertive" that it should be announced immediately. This is set
19
+ * to "off" by default and to "polite" by when `isInvalid` is true. */
21
20
  ariaLive?: AriaLiveValues;
22
21
  /** Additional className to add. */
23
22
  className?: string;
@@ -30,32 +29,38 @@ interface HelperErrorTextProps {
30
29
  }
31
30
 
32
31
  /**
33
- * Helper or Error text for forms
32
+ * Helper or error text for forms components.
34
33
  */
35
- export default function HelperErrorText({
36
- additionalStyles = {},
37
- ariaAtomic = true,
38
- ariaLive = "polite",
39
- className = "",
40
- id = generateUUID(),
41
- isInvalid = false,
42
- text,
43
- }: HelperErrorTextProps) {
44
- // Only announce the text in the invalid state.
45
- const announceAriaLive = isInvalid;
46
- const styles = useStyleConfig("HelperErrorText", { isInvalid });
47
- const finalStyles = { ...styles, ...additionalStyles };
48
- const props = {
49
- "aria-atomic": ariaAtomic,
50
- "aria-live": announceAriaLive ? ariaLive : "off",
51
- className,
52
- "data-isinvalid": isInvalid,
34
+ export const HelperErrorText = chakra(
35
+ ({
36
+ additionalStyles = {},
37
+ ariaAtomic = true,
38
+ ariaLive = "polite",
39
+ className = "",
53
40
  id,
54
- __css: finalStyles,
55
- };
56
- return typeof text === "string" ? (
57
- <Box {...props} dangerouslySetInnerHTML={{ __html: text }} />
58
- ) : (
59
- <Box {...props}>{text}</Box>
60
- );
61
- }
41
+ isInvalid = false,
42
+ text,
43
+ ...rest
44
+ }: HelperErrorTextProps) => {
45
+ // Only announce the text in the invalid state.
46
+ const announceAriaLive = isInvalid;
47
+ const styles = useStyleConfig("HelperErrorText", { isInvalid });
48
+ const finalStyles = { ...styles, ...additionalStyles };
49
+ const props = {
50
+ "aria-atomic": ariaAtomic,
51
+ "aria-live": announceAriaLive ? ariaLive : "off",
52
+ className,
53
+ "data-isinvalid": isInvalid,
54
+ id,
55
+ __css: finalStyles,
56
+ ...rest,
57
+ };
58
+ return typeof text === "string" ? (
59
+ <Box {...props} dangerouslySetInnerHTML={{ __html: text }} />
60
+ ) : (
61
+ <Box {...props}>{text}</Box>
62
+ );
63
+ }
64
+ );
65
+
66
+ export default HelperErrorText;
@@ -4,7 +4,7 @@ exports[`HelperErrorText Renders the UI snapshot correctly 1`] = `
4
4
  <div
5
5
  aria-atomic={true}
6
6
  aria-live="off"
7
- className=" css-0"
7
+ className="css-1xdhyk6"
8
8
  dangerouslySetInnerHTML={
9
9
  Object {
10
10
  "__html": "Text",
@@ -19,7 +19,7 @@ exports[`HelperErrorText Renders the UI snapshot correctly 2`] = `
19
19
  <div
20
20
  aria-atomic={true}
21
21
  aria-live="polite"
22
- className=" css-0"
22
+ className="css-1xdhyk6"
23
23
  dangerouslySetInnerHTML={
24
24
  Object {
25
25
  "__html": "Text",
@@ -34,7 +34,7 @@ exports[`HelperErrorText Renders the UI snapshot correctly 3`] = `
34
34
  <div
35
35
  aria-atomic={true}
36
36
  aria-live="polite"
37
- className=" css-0"
37
+ className="css-1xdhyk6"
38
38
  dangerouslySetInnerHTML={
39
39
  Object {
40
40
  "__html": "This helper text <b>contains HTML in the string</b>.",
@@ -49,7 +49,7 @@ exports[`HelperErrorText Renders the UI snapshot correctly 4`] = `
49
49
  <div
50
50
  aria-atomic={true}
51
51
  aria-live="polite"
52
- className=" css-0"
52
+ className="css-1xdhyk6"
53
53
  data-isinvalid={true}
54
54
  id="invalid"
55
55
  >
@@ -60,3 +60,34 @@ exports[`HelperErrorText Renders the UI snapshot correctly 4`] = `
60
60
  .
61
61
  </div>
62
62
  `;
63
+
64
+ exports[`HelperErrorText Renders the UI snapshot correctly 5`] = `
65
+ <div
66
+ aria-atomic={true}
67
+ aria-live="off"
68
+ className="css-10g9ftz"
69
+ dangerouslySetInnerHTML={
70
+ Object {
71
+ "__html": "Text",
72
+ }
73
+ }
74
+ data-isinvalid={false}
75
+ id="chakra"
76
+ />
77
+ `;
78
+
79
+ exports[`HelperErrorText Renders the UI snapshot correctly 6`] = `
80
+ <div
81
+ aria-atomic={true}
82
+ aria-live="off"
83
+ className="css-1xdhyk6"
84
+ dangerouslySetInnerHTML={
85
+ Object {
86
+ "__html": "Text",
87
+ }
88
+ }
89
+ data-isinvalid={false}
90
+ data-testid="props"
91
+ id="props"
92
+ />
93
+ `;
@@ -63,7 +63,17 @@ const imageSrc = "https://placeimg.com/800/400/animals";
63
63
  | Component Version | DS Version |
64
64
  | ----------------- | ---------- |
65
65
  | Added | `0.2.0` |
66
- | 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
+ - [All Variations](#all-variations)
74
+ - [Color Variations for Secondary Hero](#color-variations-for-secondary-hero)
75
+
76
+ ## Overview
67
77
 
68
78
  <Description of={Hero} />
69
79
 
@@ -71,6 +81,8 @@ The `Hero` component is used to display a full width banner at the top of a page
71
81
  The `Hero` will contain a required `h1` page title and may also include optional
72
82
  descriptive text and images.
73
83
 
84
+ ## Component Props
85
+
74
86
  <Canvas withToolbar>
75
87
  <Story
76
88
  name="Hero with Controls"
@@ -150,101 +162,12 @@ descriptive text and images.
150
162
 
151
163
  <ArgsTable story="Hero with Controls" />
152
164
 
153
- ## Color Variations for Secondary Hero
154
-
155
- The background color for the title bar in "Secondary" types changes based on
156
- variants for the `Secondary` main variant. Before, components relied on the
157
- parent wrapper's CSS class name for background color updates. Now, the proper
158
- `HeroType` must be passed in.
165
+ ## Accessibility
159
166
 
160
- ```jsx
161
- // Before
162
- <div className="nypl--books-and-more">
163
- <Hero {...props} />
164
- </div>
165
-
166
- // Now
167
- <Hero heroType={HeroTypes.SecondaryBooksAndMore} {...props} />
168
- ```
169
-
170
- <Canvas>
171
- <Story name="Color Variations for Secondary Hero">
172
- <VStack spacing={10} align="stretch">
173
- <Heading
174
- id="books-heading"
175
- level={HeadingLevels.Two}
176
- text="HeroTypes.SecondaryBooksAndMore"
177
- />
178
- <Hero
179
- heading={
180
- <Heading
181
- level={HeadingLevels.One}
182
- id="books-hero"
183
- text="Books and More"
184
- />
185
- }
186
- heroType={HeroTypes.SecondaryBooksAndMore}
187
- imageAlt={imageAlt}
188
- imageSrc={imageSrc}
189
- subHeaderText={secondarySubHeaderText}
190
- />
191
- <Heading
192
- id="location-heading"
193
- level={HeadingLevels.Two}
194
- text="HeroTypes.SecondaryLocations"
195
- />
196
- <Hero
197
- heading={
198
- <Heading
199
- level={HeadingLevels.One}
200
- id="locations-hero"
201
- text="Locations"
202
- />
203
- }
204
- heroType={HeroTypes.SecondaryLocations}
205
- imageAlt={imageAlt}
206
- imageSrc={imageSrc}
207
- subHeaderText={secondarySubHeaderText}
208
- />
209
- <Heading
210
- id="research-heading"
211
- level={HeadingLevels.Two}
212
- text="HeroTypes.SecondaryResearch"
213
- />
214
- <Hero
215
- heading={
216
- <Heading
217
- level={HeadingLevels.One}
218
- id="research-hero"
219
- text="Research"
220
- />
221
- }
222
- heroType={HeroTypes.SecondaryResearch}
223
- imageAlt={imageAlt}
224
- imageSrc={imageSrc}
225
- subHeaderText={secondarySubHeaderText}
226
- />
227
- <Heading
228
- id="whats-on-heading"
229
- level={HeadingLevels.Two}
230
- text="HeroTypes.SecondaryWhatsOn"
231
- />
232
- <Hero
233
- heading={
234
- <Heading
235
- level={HeadingLevels.One}
236
- id="whats-on-hero"
237
- text="What's On"
238
- />
239
- }
240
- heroType={HeroTypes.SecondaryWhatsOn}
241
- imageAlt={imageAlt}
242
- imageSrc={imageSrc}
243
- subHeaderText={secondarySubHeaderText}
244
- />
245
- </VStack>
246
- </Story>
247
- </Canvas>
167
+ The `Hero` component is commonly used as a banner below the page's header and
168
+ breadcrumbs and above the main content. This means that if the `Hero` displays
169
+ a heading element, it should be the first on the page and an `h1` element set
170
+ through `Heading`'s `level={HeadingLevels.One}`.
248
171
 
249
172
  ## All Variations
250
173
 
@@ -343,3 +266,110 @@ parent wrapper's CSS class name for background color updates. Now, the proper
343
266
  </VStack>
344
267
  </DSProvider>
345
268
  </Canvas>
269
+
270
+ ## Color Variations for Secondary Hero
271
+
272
+ The background color for the title bar in the "Secondary" `Hero` changes based
273
+ on the `HeroTypes` variants for the `Secondary` main variant.
274
+
275
+ ```jsx
276
+ // Example `HeroTypes` "Secondary" variant.
277
+ <Hero heroType={HeroTypes.SecondaryBooksAndMore} {...props} />
278
+ ```
279
+
280
+ <Canvas>
281
+ <Story name="Color Variations for Secondary Hero">
282
+ <VStack spacing={10} align="stretch">
283
+ <Heading
284
+ id="main-secondary-heading"
285
+ level={HeadingLevels.Two}
286
+ text="HeroTypes.Secondary"
287
+ />
288
+ <Hero
289
+ heading={
290
+ <Heading
291
+ level={HeadingLevels.One}
292
+ id="main-secondary-hero"
293
+ text="Secondary"
294
+ />
295
+ }
296
+ heroType={HeroTypes.Secondary}
297
+ imageAlt={imageAlt}
298
+ imageSrc={imageSrc}
299
+ subHeaderText={secondarySubHeaderText}
300
+ />
301
+ <Heading
302
+ id="books-heading"
303
+ level={HeadingLevels.Two}
304
+ text="HeroTypes.SecondaryBooksAndMore"
305
+ />
306
+ <Hero
307
+ heading={
308
+ <Heading
309
+ level={HeadingLevels.One}
310
+ id="books-hero"
311
+ text="Books and More"
312
+ />
313
+ }
314
+ heroType={HeroTypes.SecondaryBooksAndMore}
315
+ imageAlt={imageAlt}
316
+ imageSrc={imageSrc}
317
+ subHeaderText={secondarySubHeaderText}
318
+ />
319
+ <Heading
320
+ id="location-heading"
321
+ level={HeadingLevels.Two}
322
+ text="HeroTypes.SecondaryLocations"
323
+ />
324
+ <Hero
325
+ heading={
326
+ <Heading
327
+ level={HeadingLevels.One}
328
+ id="locations-hero"
329
+ text="Locations"
330
+ />
331
+ }
332
+ heroType={HeroTypes.SecondaryLocations}
333
+ imageAlt={imageAlt}
334
+ imageSrc={imageSrc}
335
+ subHeaderText={secondarySubHeaderText}
336
+ />
337
+ <Heading
338
+ id="research-heading"
339
+ level={HeadingLevels.Two}
340
+ text="HeroTypes.SecondaryResearch"
341
+ />
342
+ <Hero
343
+ heading={
344
+ <Heading
345
+ level={HeadingLevels.One}
346
+ id="research-hero"
347
+ text="Research"
348
+ />
349
+ }
350
+ heroType={HeroTypes.SecondaryResearch}
351
+ imageAlt={imageAlt}
352
+ imageSrc={imageSrc}
353
+ subHeaderText={secondarySubHeaderText}
354
+ />
355
+ <Heading
356
+ id="whats-on-heading"
357
+ level={HeadingLevels.Two}
358
+ text="HeroTypes.SecondaryWhatsOn"
359
+ />
360
+ <Hero
361
+ heading={
362
+ <Heading
363
+ level={HeadingLevels.One}
364
+ id="whats-on-hero"
365
+ text="What's On"
366
+ />
367
+ }
368
+ heroType={HeroTypes.SecondaryWhatsOn}
369
+ imageAlt={imageAlt}
370
+ imageSrc={imageSrc}
371
+ subHeaderText={secondarySubHeaderText}
372
+ />
373
+ </VStack>
374
+ </Story>
375
+ </Canvas>
@@ -680,6 +680,37 @@ describe("Hero", () => {
680
680
  />
681
681
  )
682
682
  .toJSON();
683
+ const withChakraProps = renderer
684
+ .create(
685
+ <Hero
686
+ heroType={HeroTypes.Primary}
687
+ heading={
688
+ <Heading
689
+ level={HeadingLevels.One}
690
+ id="chakra"
691
+ text="Hero Primary"
692
+ />
693
+ }
694
+ subHeaderText="Example Subtitle"
695
+ backgroundImageSrc="https://placeimg.com/1600/800/arch"
696
+ p="20px"
697
+ color="ui.error.primary"
698
+ />
699
+ )
700
+ .toJSON();
701
+ const withOtherProps = renderer
702
+ .create(
703
+ <Hero
704
+ heroType={HeroTypes.Primary}
705
+ heading={
706
+ <Heading level={HeadingLevels.One} id="props" text="Hero Primary" />
707
+ }
708
+ subHeaderText="Example Subtitle"
709
+ backgroundImageSrc="https://placeimg.com/1600/800/arch"
710
+ data-testid="props"
711
+ />
712
+ )
713
+ .toJSON();
683
714
 
684
715
  expect(primary).toMatchSnapshot();
685
716
  expect(secondary).toMatchSnapshot();
@@ -690,5 +721,7 @@ describe("Hero", () => {
690
721
  expect(tertiary).toMatchSnapshot();
691
722
  expect(campaign).toMatchSnapshot();
692
723
  expect(fiftyFifty).toMatchSnapshot();
724
+ expect(withChakraProps).toMatchSnapshot();
725
+ expect(withOtherProps).toMatchSnapshot();
693
726
  });
694
727
  });