@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
@@ -49,10 +49,21 @@ export const enumValues = getStorybookEnumValues(
49
49
  | Component Version | DS Version |
50
50
  | ----------------- | ---------- |
51
51
  | Added | `0.18.7` |
52
- | Latest | `0.25.1` |
52
+ | Latest | `0.26.0` |
53
+
54
+ ## Table of Contents
55
+
56
+ - [Overview](#overview)
57
+ - [Component Props](#component-props)
58
+ - [Accessibility](#accessibility)
59
+ - [Patterns](#patterns)
60
+
61
+ ## Overview
53
62
 
54
63
  <Description of={StatusBadge} />
55
64
 
65
+ ## Component Props
66
+
56
67
  <Canvas withToolbar>
57
68
  <Story
58
69
  name="StatusBadge"
@@ -73,6 +84,13 @@ export const enumValues = getStorybookEnumValues(
73
84
 
74
85
  <ArgsTable story="StatusBadge" />
75
86
 
87
+ ## Accessibility
88
+
89
+ The visual aspect of the `StatusBadge` component displays three different status
90
+ levels through the use of three different colors. It is important to assign
91
+ the appropriate text so that the user can understand the priority level of the
92
+ `StatusBadge`, and not rely just on the color.
93
+
76
94
  ## Patterns
77
95
 
78
96
  ### Higher Barrier
@@ -47,9 +47,25 @@ describe("StatusBadge", () => {
47
47
  </StatusBadge>
48
48
  )
49
49
  .toJSON();
50
+ const withChakraProps = renderer
51
+ .create(
52
+ <StatusBadge id="chakra" p="20px" color="ui.error.primary">
53
+ Registration Required
54
+ </StatusBadge>
55
+ )
56
+ .toJSON();
57
+ const withOtherProps = renderer
58
+ .create(
59
+ <StatusBadge id="props" data-testid="props">
60
+ Registration Required
61
+ </StatusBadge>
62
+ )
63
+ .toJSON();
50
64
 
51
65
  expect(low).toMatchSnapshot();
52
66
  expect(medium).toMatchSnapshot();
53
67
  expect(high).toMatchSnapshot();
68
+ expect(withChakraProps).toMatchSnapshot();
69
+ expect(withOtherProps).toMatchSnapshot();
54
70
  });
55
71
  });
@@ -1,9 +1,7 @@
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
3
 
4
4
  import { StatusBadgeTypes } from "./StatusBadgeTypes";
5
- import generateUUID from "../../helpers/generateUUID";
6
-
7
5
  export interface StatusBadgeProps {
8
6
  /** Additional class for the component */
9
7
  className?: string;
@@ -14,24 +12,31 @@ export interface StatusBadgeProps {
14
12
  level?: StatusBadgeTypes;
15
13
  }
16
14
 
17
- function StatusBadge(props: React.PropsWithChildren<StatusBadgeProps>) {
18
- const {
19
- children,
20
- className,
21
- id = generateUUID(),
22
- level = StatusBadgeTypes.Low,
23
- } = props;
24
- const styles = useStyleConfig("StatusBadge", { variant: level });
15
+ /**
16
+ * The `StatusBadge` component is used to display a visual badge for three
17
+ * different status levels.
18
+ */
19
+ export const StatusBadge = chakra(
20
+ (props: React.PropsWithChildren<StatusBadgeProps>) => {
21
+ const {
22
+ children,
23
+ className,
24
+ id,
25
+ level = StatusBadgeTypes.Low,
26
+ ...rest
27
+ } = props;
28
+ const styles = useStyleConfig("StatusBadge", { variant: level });
25
29
 
26
- if (!children) {
27
- console.warn("NYPL Reservoir StatusBadge: No children were passed.");
28
- }
30
+ if (!children) {
31
+ console.warn("NYPL Reservoir StatusBadge: No children were passed.");
32
+ }
29
33
 
30
- return (
31
- <Box id={id} className={className} __css={styles}>
32
- {children}
33
- </Box>
34
- );
35
- }
34
+ return (
35
+ <Box id={id} className={className} __css={styles} {...rest}>
36
+ {children}
37
+ </Box>
38
+ );
39
+ }
40
+ );
36
41
 
37
42
  export default StatusBadge;
@@ -2,7 +2,7 @@
2
2
 
3
3
  exports[`StatusBadge renders the UI snapshot correctly 1`] = `
4
4
  <div
5
- className="css-0"
5
+ className="css-1xdhyk6"
6
6
  id="low"
7
7
  >
8
8
  Registration Required
@@ -11,7 +11,7 @@ exports[`StatusBadge renders the UI snapshot correctly 1`] = `
11
11
 
12
12
  exports[`StatusBadge renders the UI snapshot correctly 2`] = `
13
13
  <div
14
- className="css-0"
14
+ className="css-1xdhyk6"
15
15
  id="medium"
16
16
  >
17
17
  Registration Required
@@ -20,9 +20,28 @@ exports[`StatusBadge renders the UI snapshot correctly 2`] = `
20
20
 
21
21
  exports[`StatusBadge renders the UI snapshot correctly 3`] = `
22
22
  <div
23
- className="css-0"
23
+ className="css-1xdhyk6"
24
24
  id="high"
25
25
  >
26
26
  Registration Required
27
27
  </div>
28
28
  `;
29
+
30
+ exports[`StatusBadge renders the UI snapshot correctly 4`] = `
31
+ <div
32
+ className="css-kle7zy"
33
+ id="chakra"
34
+ >
35
+ Registration Required
36
+ </div>
37
+ `;
38
+
39
+ exports[`StatusBadge renders the UI snapshot correctly 5`] = `
40
+ <div
41
+ className="css-1xdhyk6"
42
+ data-testid="props"
43
+ id="props"
44
+ >
45
+ Registration Required
46
+ </div>
47
+ `;
@@ -77,7 +77,7 @@ export const imageSizeEnumValues = getStorybookEnumValues(
77
77
  | Component Version | DS Version |
78
78
  | ----------------- | ---------- |
79
79
  | Added | `0.25.9` |
80
- | Latest | `0.25.13` |
80
+ | Latest | `0.26.0` |
81
81
 
82
82
  ## Table of Contents
83
83
 
@@ -161,10 +161,18 @@ export const imageSizeEnumValues = getStorybookEnumValues(
161
161
 
162
162
  ## Accessibility
163
163
 
164
- - Containers should allow font-size to be scaled to 200% without content overlapping.
165
- - Images should have descriptive (but not too lengthy) alt text.
166
- - Headings levels should not be skipped. Meaning, a `<h2>` should not be followed
167
- by a `<h4>`.
164
+ The `StructuredContent` component is a structured container around a specific
165
+ set of content. While the main image can be controlled through the `imageProps`
166
+ prop, the content will not always be controlled. If the content that is being
167
+ passed is coming from a CMS, the content can contain any set of HTML elements that
168
+ are _not_ controlled through Reservoir DS components. While this component
169
+ attempts to style the added elements, we cannot guarantee that the content will
170
+ be accessible. Please review your content and make sure that:
171
+
172
+ - The content's font-size to be scaled to 200% without content overlapping.
173
+ - Any additional images have descriptive (but not too lengthy) alt text.
174
+ - Any additional heading levels should not be skipped. Meaning, a `<h2>` should
175
+ not be followed by a `<h4>`.
168
176
  - Any links or text with colors should have a 4.5:1 contrast ratio.
169
177
 
170
178
  ## With HTML String Text Content
@@ -173,7 +181,7 @@ The following body content is passed as a string to the `bodyContent` prop. It
173
181
  includes HTML tags in the string.
174
182
 
175
183
  <Canvas>
176
- <Story name="With HTMl String Text Content">
184
+ <Story name="With HTML String Text Content">
177
185
  <StructuredContent
178
186
  calloutText="This is the callout text"
179
187
  headingText="Heading text"
@@ -261,12 +269,69 @@ The following content is passed as HTML DOM elements to the `bodyContent` prop.
261
269
  Feugiat nisl pretium fusce id velit ut tortor. Porttitor leo a diam
262
270
  sollicitudin tempor id eu nisl nunc.
263
271
  </p>
264
- <ul>
265
- <li>one</li>
266
- <li>two</li>
267
- <li>three</li>
268
- <li>four</li>
269
- </ul>
272
+ <h3 id="dates-times">Dates and Times</h3>
273
+ <table role="table" id="times-table">
274
+ <thead>
275
+ <tr role="row">
276
+ <th scope="col">Day</th>
277
+ <th scope="col">Time</th>
278
+ <th scope="col">Presentation</th>
279
+ <th scope="col">Topic</th>
280
+ </tr>
281
+ </thead>
282
+ <tbody>
283
+ <tr role="row">
284
+ <td>Sunday</td>
285
+ <td>7:00 PM</td>
286
+ <td>Tom Nook</td>
287
+ <td>Manhattan</td>
288
+ </tr>
289
+ <tr role="row">
290
+ <td>Monday</td>
291
+ <td>7:00 PM</td>
292
+ <td>Tom Nook</td>
293
+ <td>The Bronx</td>
294
+ </tr>
295
+ <tr role="row">
296
+ <td>Tuesday</td>
297
+ <td>7:00 PM</td>
298
+ <td>Tom Nook</td>
299
+ <td>Queens</td>
300
+ </tr>
301
+ <tr role="row">
302
+ <td>Wednesday</td>
303
+ <td>7:00 PM</td>
304
+ <td>Tom Nook</td>
305
+ <td>Staten Island</td>
306
+ </tr>
307
+ <tr role="row">
308
+ <td>Thursday</td>
309
+ <td>7:00 PM</td>
310
+ <td>Tom Nook</td>
311
+ <td>Brooklyn</td>
312
+ </tr>
313
+ <tr role="row">
314
+ <td>Friday</td>
315
+ <td>7:00 PM</td>
316
+ <td>Tom Nook</td>
317
+ <td>Long Island</td>
318
+ </tr>
319
+ <tr role="row">
320
+ <td>Saturday</td>
321
+ <td>7:00 PM</td>
322
+ <td>Tom Nook</td>
323
+ <td>Upstate</td>
324
+ </tr>
325
+ </tbody>
326
+ </table>
327
+ <h3 id="parting-thoughts">Parting Thoughts</h3>
328
+ <ol id="thoughts-list">
329
+ <li>All text was read</li>
330
+ <li>The two videos were watched</li>
331
+ <li>All images were reviewed</li>
332
+ <li>Notes were taken on a small notepad</li>
333
+ <li>You enjoyed yourself</li>
334
+ </ol>
270
335
  <p>
271
336
  <i>
272
337
  Mauris nunc congue nisi vitae suscipit tellus mauris a diam. Purus
@@ -283,6 +348,60 @@ The following content is passed as HTML DOM elements to the `bodyContent` prop.
283
348
  pharetra.
284
349
  </i>
285
350
  </p>
351
+ <section id="definition-doc-list">
352
+ <h2>Episode Forty-Two: Readings and Resources</h2>
353
+ <dl>
354
+ <dt>Hillary Ballon and Kenneth T. Jackson, eds.</dt>
355
+ <dd>
356
+ <em>
357
+ <a
358
+ id="link-10"
359
+ href="https://www.nypl.org/research/research-catalog/bib/b22154388"
360
+ >
361
+ Robert Moses and the Modern City: The Transformation of New
362
+ York
363
+ </a>
364
+ </em>{" "}
365
+ (W.W. Norton &amp; Co., 2007).
366
+ </dd>
367
+ <dt>The Brooklyn Battery Bridge</dt>
368
+ <dd>
369
+ "
370
+ <a
371
+ id="link-11"
372
+ href="https://www.nypap.org/preservation-history/brooklyn-battery-bridge/"
373
+ >
374
+ The Brooklyn Battery Bridge
375
+ </a>
376
+ ," New York Preservation Archives Project.
377
+ </dd>
378
+ <dt>Robert Caro</dt>
379
+ <dd>
380
+ <em>
381
+ <a
382
+ id="link-12"
383
+ href="https://www.nypl.org/research/research-catalog/bib/b21586756"
384
+ >
385
+ The Power Broker: Robert Moses and the Fall of New York
386
+ </a>
387
+ </em>{" "}
388
+ (Vintage Books, 1975).&nbsp;
389
+ </dd>
390
+ <dt>Anthony Flint</dt>
391
+ <dd>
392
+ <em>
393
+ <a
394
+ id="link-13"
395
+ href="https://www.nypl.org/research/research-catalog/bib/b20538453"
396
+ >
397
+ Wrestling with Moses: How Jane Jacobs Took on New York's
398
+ Master Builder and Transformed the American City
399
+ </a>
400
+ </em>{" "}
401
+ (Random House, 2009).
402
+ </dd>
403
+ </dl>
404
+ </section>
286
405
  </>
287
406
  }
288
407
  />
@@ -380,6 +380,15 @@ describe("StructuredContent", () => {
380
380
  bodyContent={htmlStringBodyContent}
381
381
  headingText="Heading text"
382
382
  id="withoutCalloutText"
383
+ />
384
+ )
385
+ .toJSON();
386
+ const withChakraProps = renderer
387
+ .create(
388
+ <StructuredContent
389
+ calloutText="This is the callout text"
390
+ headingText="Heading text"
391
+ id="withChakraProps"
383
392
  imageProps={{
384
393
  alt: "Image alt text",
385
394
  aspectRatio: ImageRatios.Original,
@@ -389,6 +398,29 @@ describe("StructuredContent", () => {
389
398
  size: ImageSizes.Medium,
390
399
  src: "https://placeimg.com/400/300/animals",
391
400
  }}
401
+ bodyContent={htmlStringBodyContent}
402
+ p="20px"
403
+ color="ui.error.primary"
404
+ />
405
+ )
406
+ .toJSON();
407
+ const withOtherProps = renderer
408
+ .create(
409
+ <StructuredContent
410
+ calloutText="This is the callout text"
411
+ headingText="Heading text"
412
+ id="withOtherProps"
413
+ imageProps={{
414
+ alt: "Image alt text",
415
+ aspectRatio: ImageRatios.Original,
416
+ caption: "Image caption",
417
+ credit: "Image credit",
418
+ position: StructuredContentImagePosition.Left,
419
+ size: ImageSizes.Medium,
420
+ src: "https://placeimg.com/400/300/animals",
421
+ }}
422
+ bodyContent={htmlStringBodyContent}
423
+ data-testid="props"
392
424
  />
393
425
  )
394
426
  .toJSON();
@@ -399,5 +431,7 @@ describe("StructuredContent", () => {
399
431
  expect(withImageWithoutCaptionOrCredit).toMatchSnapshot();
400
432
  expect(withoutHeading).toMatchSnapshot();
401
433
  expect(withoutCalloutText).toMatchSnapshot();
434
+ expect(withChakraProps).toMatchSnapshot();
435
+ expect(withOtherProps).toMatchSnapshot();
402
436
  });
403
437
  });
@@ -1,12 +1,11 @@
1
+ import { Box, chakra, useMultiStyleConfig } from "@chakra-ui/react";
1
2
  import * as React from "react";
2
- import { Box, useMultiStyleConfig } from "@chakra-ui/react";
3
3
 
4
4
  import Heading from "../Heading/Heading";
5
5
  import { HeadingSizes, HeadingLevels } from "../Heading/HeadingTypes";
6
6
  import Image, { ComponentImageProps, ImageProps } from "../Image/Image";
7
7
  import { ImageRatios, ImageSizes } from "../Image/ImageTypes";
8
8
  import { StructuredContentImagePosition } from "./StructuredContentTypes";
9
- import generateUUID from "../../helpers/generateUUID";
10
9
 
11
10
  interface StructuredContentImageProps extends ComponentImageProps {
12
11
  /** Optional value to control the positioning of the internal `Image` component.
@@ -33,7 +32,7 @@ export interface StructuredContentProps {
33
32
  * Internal component used in the `StructuredContent` component
34
33
  * that renders the DS `Image` component.
35
34
  */
36
- function StructuredContentImage(props: ImageProps) {
35
+ const StructuredContentImage = chakra((props: ImageProps) => {
37
36
  const {
38
37
  additionalFigureStyles,
39
38
  additionalImageStyles,
@@ -60,84 +59,90 @@ function StructuredContentImage(props: ImageProps) {
60
59
  src={src}
61
60
  />
62
61
  );
63
- }
62
+ });
64
63
 
65
64
  /**
66
65
  * The `StructuredContent` component that displays a heading, callout content,
67
66
  * an image, and body content. All are optional except for body content.
68
67
  */
69
- export default function StructuredContent(
70
- props: React.PropsWithChildren<StructuredContentProps>
71
- ) {
72
- const {
73
- calloutText,
74
- className,
75
- headingText,
76
- id = generateUUID(),
77
- imageProps = {
78
- alt: "",
79
- aspectRatio: ImageRatios.Square,
80
- caption: undefined,
81
- component: undefined,
82
- credit: undefined,
83
- position: StructuredContentImagePosition.Left,
84
- size: ImageSizes.Medium,
85
- src: "",
86
- },
87
- bodyContent,
88
- } = props;
89
- const hasImage = imageProps.src || imageProps.component;
90
- const hasFigureImage = imageProps.caption || imageProps.credit;
91
- const styles = useMultiStyleConfig("StructuredContent", {
92
- hasFigureImage,
93
- imageAspectRatio: imageProps.aspectRatio,
94
- imagePosition: imageProps.position,
95
- });
96
- const finalBodyContent =
97
- typeof bodyContent === "string" ? (
98
- <div dangerouslySetInnerHTML={{ __html: bodyContent }} />
99
- ) : (
100
- <Box>{bodyContent}</Box>
101
- );
68
+ export const StructuredContent = chakra(
69
+ (props: React.PropsWithChildren<StructuredContentProps>) => {
70
+ const {
71
+ calloutText,
72
+ className,
73
+ headingText,
74
+ id,
75
+ imageProps = {
76
+ alt: "",
77
+ aspectRatio: ImageRatios.Square,
78
+ caption: undefined,
79
+ component: undefined,
80
+ credit: undefined,
81
+ position: StructuredContentImagePosition.Left,
82
+ size: ImageSizes.Medium,
83
+ src: "",
84
+ },
85
+ bodyContent,
86
+ ...rest
87
+ } = props;
88
+ const hasImage = imageProps.src || imageProps.component;
89
+ const hasFigureImage = imageProps.caption || imageProps.credit;
90
+ const styles = useMultiStyleConfig("StructuredContent", {
91
+ hasFigureImage,
92
+ imageAspectRatio: imageProps.aspectRatio,
93
+ imagePosition: imageProps.position,
94
+ });
95
+ const finalBodyContent =
96
+ typeof bodyContent === "string" ? (
97
+ <div
98
+ className="structuredcontent-body"
99
+ dangerouslySetInnerHTML={{ __html: bodyContent }}
100
+ />
101
+ ) : (
102
+ <Box className="structuredcontent-body">{bodyContent}</Box>
103
+ );
102
104
 
103
- if (hasImage && !imageProps.alt) {
104
- console.warn(
105
- "NYPL Reservoir StructuredContent: The `imageProps.alt` prop is required " +
106
- "when using an image."
105
+ if (hasImage && !imageProps.alt) {
106
+ console.warn(
107
+ "NYPL Reservoir StructuredContent: The `imageProps.alt` prop is required " +
108
+ "when using an image."
109
+ );
110
+ }
111
+
112
+ return (
113
+ <Box id={id} className={className} __css={styles} {...rest}>
114
+ {headingText && (
115
+ <Heading id={`${id}-heading`} level={HeadingLevels.Two}>
116
+ {headingText}
117
+ </Heading>
118
+ )}
119
+ {calloutText && (
120
+ <Heading
121
+ id={`${id}-callout`}
122
+ level={HeadingLevels.Three}
123
+ size={HeadingSizes.Callout}
124
+ >
125
+ {calloutText}
126
+ </Heading>
127
+ )}
128
+ {hasImage && (
129
+ <StructuredContentImage
130
+ additionalFigureStyles={styles.imageFigure}
131
+ additionalImageStyles={styles.image}
132
+ additionalWrapperStyles={styles.imageWrapper}
133
+ alt={imageProps.alt}
134
+ component={imageProps.component}
135
+ aspectRatio={imageProps.aspectRatio}
136
+ caption={imageProps.caption}
137
+ credit={imageProps.credit}
138
+ size={imageProps.size}
139
+ src={imageProps.src ? imageProps.src : null}
140
+ />
141
+ )}
142
+ {finalBodyContent}
143
+ </Box>
107
144
  );
108
145
  }
146
+ );
109
147
 
110
- return (
111
- <Box id={id} className={className} __css={styles}>
112
- {headingText && (
113
- <Heading id={`${id}-heading`} level={HeadingLevels.Two}>
114
- {headingText}
115
- </Heading>
116
- )}
117
- {calloutText && (
118
- <Heading
119
- id={`${id}-callout`}
120
- level={HeadingLevels.Three}
121
- size={HeadingSizes.Callout}
122
- >
123
- {calloutText}
124
- </Heading>
125
- )}
126
- {hasImage && (
127
- <StructuredContentImage
128
- additionalFigureStyles={styles.imageFigure}
129
- additionalImageStyles={styles.image}
130
- additionalWrapperStyles={styles.imageWrapper}
131
- alt={imageProps.alt}
132
- component={imageProps.component}
133
- aspectRatio={imageProps.aspectRatio}
134
- caption={imageProps.caption}
135
- credit={imageProps.credit}
136
- size={imageProps.size}
137
- src={imageProps.src ? imageProps.src : null}
138
- />
139
- )}
140
- {finalBodyContent}
141
- </Box>
142
- );
143
- }
148
+ export default StructuredContent;