@nypl/design-system-react-components 0.26.0 → 0.28.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 (306) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/dist/components/Accordion/Accordion.d.ts +1 -1
  3. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -5
  4. package/dist/components/Button/Button.d.ts +2 -10
  5. package/dist/components/ButtonGroup/ButtonGroup.d.ts +22 -0
  6. package/dist/components/Card/Card.d.ts +2 -2
  7. package/dist/components/Checkbox/Checkbox.d.ts +10 -8
  8. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
  9. package/dist/components/DatePicker/DatePicker.d.ts +1 -1
  10. package/dist/components/Form/Form.d.ts +2 -2
  11. package/dist/components/Grid/SimpleGrid.d.ts +6 -3
  12. package/dist/components/Heading/Heading.d.ts +2 -5
  13. package/dist/components/HelperErrorText/HelperErrorText.d.ts +1 -5
  14. package/dist/components/Hero/Hero.d.ts +13 -9
  15. package/dist/components/Icons/Icon.d.ts +6 -5
  16. package/dist/components/Icons/IconSvgs.d.ts +21 -21
  17. package/dist/components/Image/Image.d.ts +8 -5
  18. package/dist/components/Link/Link.d.ts +1 -9
  19. package/dist/components/List/List.d.ts +7 -11
  20. package/dist/components/Logo/Logo.d.ts +2 -5
  21. package/dist/components/Logo/LogoSvgs.d.ts +39 -39
  22. package/dist/components/Modal/Modal.d.ts +28 -8
  23. package/dist/components/Notification/Notification.d.ts +1 -1
  24. package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +2 -1
  25. package/dist/components/RadioGroup/RadioGroup.d.ts +1 -1
  26. package/dist/components/SearchBar/SearchBar.d.ts +3 -2
  27. package/dist/components/Select/Select.d.ts +2 -5
  28. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -4
  29. package/dist/components/SkipNavigation/SkipNavigation.d.ts +17 -0
  30. package/dist/components/StatusBadge/StatusBadge.d.ts +2 -3
  31. package/dist/components/StructuredContent/StructuredContent.d.ts +2 -2
  32. package/dist/components/Table/Table.d.ts +1 -1
  33. package/dist/components/Template/Template.d.ts +2 -0
  34. package/dist/components/Text/Text.d.ts +1 -1
  35. package/dist/components/TextInput/TextInput.d.ts +21 -9
  36. package/dist/components/Toggle/Toggle.d.ts +1 -5
  37. package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
  38. package/dist/design-system-react-components.cjs.development.js +977 -1213
  39. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  40. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  41. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  42. package/dist/design-system-react-components.esm.js +976 -1276
  43. package/dist/design-system-react-components.esm.js.map +1 -1
  44. package/dist/helpers/types.d.ts +1 -0
  45. package/dist/index.d.ts +27 -48
  46. package/dist/styles.css +1 -1
  47. package/dist/theme/components/buttonGroup.d.ts +11 -0
  48. package/dist/theme/components/card.d.ts +104 -8
  49. package/dist/theme/components/componentWrapper.d.ts +4 -3
  50. package/dist/theme/components/customTable.d.ts +11 -14
  51. package/dist/theme/components/fieldset.d.ts +4 -3
  52. package/dist/theme/components/helperErrorText.d.ts +4 -3
  53. package/dist/theme/components/hero.d.ts +1 -1
  54. package/dist/theme/components/horizontalRule.d.ts +4 -3
  55. package/dist/theme/components/icon.d.ts +47743 -1
  56. package/dist/theme/components/image.d.ts +563 -10
  57. package/dist/theme/components/label.d.ts +4 -3
  58. package/dist/theme/components/list.d.ts +6 -7
  59. package/dist/theme/components/logo.d.ts +474 -1
  60. package/dist/theme/components/notification.d.ts +20 -16
  61. package/dist/theme/components/progressIndicator.d.ts +6 -4
  62. package/dist/theme/components/select.d.ts +4 -10
  63. package/dist/theme/components/skeletonLoader.d.ts +14 -10
  64. package/dist/theme/components/skipNavigation.d.ts +22 -0
  65. package/dist/theme/components/slider.d.ts +7 -6
  66. package/dist/theme/components/structuredContent.d.ts +10 -9
  67. package/dist/theme/components/text.d.ts +7 -1
  68. package/dist/theme/components/toggle.d.ts +6 -4
  69. package/dist/theme/provider.d.ts +2 -4
  70. package/dist/utils/componentCategories.d.ts +1 -1
  71. package/dist/utils/interfaces.d.ts +5 -0
  72. package/dist/utils/utils.d.ts +2 -18
  73. package/package.json +15 -16
  74. package/src/__tests__/setup.ts +3 -3
  75. package/src/__tests__/utils/utils.test.ts +1 -23
  76. package/src/components/AccessibilityGuide/SkipNavigation.stories.mdx +22 -14
  77. package/src/components/Accordion/Accordion.stories.mdx +43 -44
  78. package/src/components/Accordion/Accordion.test.tsx +5 -13
  79. package/src/components/Accordion/Accordion.tsx +14 -18
  80. package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +6 -6
  81. package/src/components/Autosuggest/Autosuggest.stories.mdx +1 -1
  82. package/src/components/Autosuggest/Autosuggest.stories.tsx +23 -25
  83. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +21 -37
  84. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +4 -17
  85. package/src/components/Breadcrumbs/Breadcrumbs.tsx +18 -21
  86. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +1 -100
  87. package/src/components/Button/Button.stories.mdx +89 -126
  88. package/src/components/Button/Button.test.tsx +16 -30
  89. package/src/components/Button/Button.tsx +14 -20
  90. package/src/components/ButtonGroup/ButtonGroup.stories.mdx +147 -0
  91. package/src/components/ButtonGroup/ButtonGroup.test.tsx +141 -0
  92. package/src/components/ButtonGroup/ButtonGroup.tsx +99 -0
  93. package/src/components/ButtonGroup/__snapshots__/ButtonGroup.test.tsx.snap +117 -0
  94. package/src/components/Card/Card.stories.mdx +143 -177
  95. package/src/components/Card/Card.test.tsx +36 -97
  96. package/src/components/Card/Card.tsx +78 -74
  97. package/src/components/Card/__snapshots__/Card.test.tsx.snap +1 -1
  98. package/src/components/Chakra/Box.stories.mdx +2 -6
  99. package/src/components/Chakra/Center.stories.mdx +5 -23
  100. package/src/components/Chakra/Flex.stories.mdx +4 -6
  101. package/src/components/Chakra/Stack.stories.mdx +9 -10
  102. package/src/components/Checkbox/Checkbox.stories.mdx +1 -1
  103. package/src/components/Checkbox/Checkbox.test.tsx +2 -2
  104. package/src/components/Checkbox/Checkbox.tsx +20 -13
  105. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +9 -9
  106. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +6 -17
  107. package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +1 -7
  108. package/src/components/CheckboxGroup/CheckboxGroup.tsx +33 -29
  109. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +24 -35
  110. package/src/components/ComponentWrapper/ComponentWrapper.tsx +3 -10
  111. package/src/components/DatePicker/DatePicker.stories.mdx +23 -37
  112. package/src/components/DatePicker/DatePicker.test.tsx +21 -19
  113. package/src/components/DatePicker/DatePicker.tsx +57 -49
  114. package/src/components/Form/Form.stories.mdx +46 -31
  115. package/src/components/Form/Form.test.tsx +1 -18
  116. package/src/components/Form/Form.tsx +7 -7
  117. package/src/components/Grid/SimpleGrid.stories.mdx +73 -49
  118. package/src/components/Grid/SimpleGrid.test.tsx +7 -9
  119. package/src/components/Grid/SimpleGrid.tsx +14 -11
  120. package/src/components/Heading/Heading.stories.mdx +27 -72
  121. package/src/components/Heading/Heading.test.tsx +18 -44
  122. package/src/components/Heading/Heading.tsx +7 -10
  123. package/src/components/HelperErrorText/HelperErrorText.stories.mdx +1 -3
  124. package/src/components/HelperErrorText/HelperErrorText.tsx +1 -5
  125. package/src/components/Hero/Hero.stories.mdx +219 -216
  126. package/src/components/Hero/Hero.test.tsx +107 -223
  127. package/src/components/Hero/Hero.tsx +63 -61
  128. package/src/components/Icons/Icon.stories.mdx +172 -118
  129. package/src/components/Icons/Icon.test.tsx +8 -16
  130. package/src/components/Icons/Icon.tsx +75 -29
  131. package/src/components/Icons/IconSvgs.tsx +42 -42
  132. package/src/components/Image/Image.stories.mdx +45 -132
  133. package/src/components/Image/Image.test.tsx +16 -31
  134. package/src/components/Image/Image.tsx +28 -12
  135. package/src/components/Link/Link.stories.mdx +30 -94
  136. package/src/components/Link/Link.test.tsx +25 -75
  137. package/src/components/Link/Link.tsx +43 -56
  138. package/src/components/Link/__snapshots__/Link.test.tsx.snap +1 -2
  139. package/src/components/List/List.stories.mdx +20 -31
  140. package/src/components/List/List.test.tsx +24 -43
  141. package/src/components/List/List.tsx +25 -36
  142. package/src/components/Logo/Logo.stories.mdx +94 -50
  143. package/src/components/Logo/Logo.test.tsx +10 -19
  144. package/src/components/Logo/Logo.tsx +50 -17
  145. package/src/components/Logo/LogoSvgs.tsx +78 -78
  146. package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +4 -4
  147. package/src/components/Modal/Modal.stories.mdx +245 -139
  148. package/src/components/Modal/Modal.test.tsx +147 -10
  149. package/src/components/Modal/Modal.tsx +140 -20
  150. package/src/components/Modal/__snapshots__/Modal.test.tsx.snap +25 -0
  151. package/src/components/Notification/Notification.stories.mdx +10 -28
  152. package/src/components/Notification/Notification.test.tsx +9 -12
  153. package/src/components/Notification/Notification.tsx +34 -37
  154. package/src/components/Pagination/Pagination.stories.mdx +3 -4
  155. package/src/components/Pagination/Pagination.tsx +15 -10
  156. package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +27 -53
  157. package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +9 -10
  158. package/src/components/ProgressIndicator/ProgressIndicator.tsx +17 -21
  159. package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +0 -10
  160. package/src/components/Radio/Radio.stories.mdx +1 -1
  161. package/src/components/Radio/Radio.tsx +9 -6
  162. package/src/components/RadioGroup/RadioGroup.stories.mdx +15 -16
  163. package/src/components/RadioGroup/RadioGroup.test.tsx +2 -8
  164. package/src/components/RadioGroup/RadioGroup.tsx +28 -24
  165. package/src/components/SearchBar/SearchBar.stories.mdx +1 -1
  166. package/src/components/SearchBar/SearchBar.test.tsx +1 -1
  167. package/src/components/SearchBar/SearchBar.tsx +14 -22
  168. package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +1 -13
  169. package/src/components/Select/Select.stories.mdx +10 -25
  170. package/src/components/Select/Select.test.tsx +6 -7
  171. package/src/components/Select/Select.tsx +28 -35
  172. package/src/components/Select/__snapshots__/Select.test.tsx.snap +24 -24
  173. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +17 -56
  174. package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +7 -21
  175. package/src/components/SkeletonLoader/SkeletonLoader.tsx +9 -8
  176. package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +33 -33
  177. package/src/components/SkipNavigation/SkipNavigation.stories.mdx +90 -0
  178. package/src/components/SkipNavigation/SkipNavigation.test.tsx +63 -0
  179. package/src/components/SkipNavigation/SkipNavigation.tsx +51 -0
  180. package/src/components/SkipNavigation/__snapshots__/SkipNavigation.test.tsx.snap +130 -0
  181. package/src/components/Slider/Slider.stories.mdx +19 -53
  182. package/src/components/Slider/Slider.test.tsx +2 -2
  183. package/src/components/Slider/Slider.tsx +10 -12
  184. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +2 -9
  185. package/src/components/StatusBadge/StatusBadge.stories.mdx +6 -21
  186. package/src/components/StatusBadge/StatusBadge.test.tsx +2 -3
  187. package/src/components/StatusBadge/StatusBadge.tsx +3 -10
  188. package/src/components/StructuredContent/StructuredContent.stories.mdx +30 -58
  189. package/src/components/StructuredContent/StructuredContent.test.tsx +42 -44
  190. package/src/components/StructuredContent/StructuredContent.tsx +9 -18
  191. package/src/components/StyleGuide/Bidirectionality.stories.mdx +9 -23
  192. package/src/components/StyleGuide/Buttons.stories.mdx +62 -62
  193. package/src/components/StyleGuide/ColorCard.tsx +2 -4
  194. package/src/components/StyleGuide/Colors.stories.mdx +7 -8
  195. package/src/components/StyleGuide/DesignTokens.stories.mdx +5 -7
  196. package/src/components/StyleGuide/Forms.stories.mdx +0 -1
  197. package/src/components/StyleGuide/Iconography.stories.mdx +59 -77
  198. package/src/components/StyleGuide/Spacing.stories.mdx +0 -1
  199. package/src/components/StyleGuide/Typography.stories.mdx +15 -18
  200. package/src/components/Table/Table.stories.mdx +85 -1
  201. package/src/components/Table/Table.test.tsx +57 -1
  202. package/src/components/Table/Table.tsx +7 -4
  203. package/src/components/Table/__snapshots__/Table.test.tsx.snap +121 -0
  204. package/src/components/Tabs/Tabs.stories.mdx +1 -1
  205. package/src/components/Tabs/Tabs.test.tsx +2 -2
  206. package/src/components/Tabs/Tabs.tsx +26 -27
  207. package/src/components/Template/Template.stories.mdx +49 -54
  208. package/src/components/Template/Template.tsx +9 -3
  209. package/src/components/Text/Text.stories.mdx +5 -11
  210. package/src/components/Text/Text.test.tsx +3 -6
  211. package/src/components/Text/Text.tsx +3 -5
  212. package/src/components/TextInput/TextInput.stories.mdx +10 -22
  213. package/src/components/TextInput/TextInput.test.tsx +32 -62
  214. package/src/components/TextInput/TextInput.tsx +61 -30
  215. package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +1 -0
  216. package/src/components/Toggle/Toggle.stories.mdx +5 -16
  217. package/src/components/Toggle/Toggle.test.tsx +2 -3
  218. package/src/components/Toggle/Toggle.tsx +9 -10
  219. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +13 -29
  220. package/src/components/VideoPlayer/VideoPlayer.test.tsx +18 -23
  221. package/src/components/VideoPlayer/VideoPlayer.tsx +13 -10
  222. package/src/docs/Chakra.stories.mdx +14 -11
  223. package/src/docs/Welcome.stories.mdx +23 -43
  224. package/src/helpers/types.ts +1 -0
  225. package/src/hooks/tests/useNYPLTheme.test.tsx +1 -1
  226. package/src/hooks/useNYPLTheme.stories.mdx +3 -6
  227. package/src/index.ts +52 -46
  228. package/src/styles.scss +0 -1
  229. package/src/theme/components/buttonGroup.ts +10 -0
  230. package/src/theme/components/card.ts +50 -15
  231. package/src/theme/components/componentWrapper.ts +5 -1
  232. package/src/theme/components/customTable.ts +8 -2
  233. package/src/theme/components/fieldset.ts +5 -1
  234. package/src/theme/components/helperErrorText.ts +5 -1
  235. package/src/theme/components/hero.ts +2 -2
  236. package/src/theme/components/horizontalRule.ts +5 -1
  237. package/src/theme/components/icon.ts +7 -1
  238. package/src/theme/components/image.ts +14 -3
  239. package/src/theme/components/label.ts +5 -1
  240. package/src/theme/components/list.ts +8 -2
  241. package/src/theme/components/logo.ts +5 -1
  242. package/src/theme/components/notification.ts +38 -14
  243. package/src/theme/components/progressIndicator.ts +10 -5
  244. package/src/theme/components/select.ts +5 -6
  245. package/src/theme/components/skeletonLoader.ts +8 -2
  246. package/src/theme/components/skipNavigation.ts +26 -0
  247. package/src/theme/components/slider.ts +13 -1
  248. package/src/theme/components/structuredContent.ts +11 -1
  249. package/src/theme/components/text.ts +12 -5
  250. package/src/theme/components/toggle.ts +9 -3
  251. package/src/theme/index.ts +4 -0
  252. package/src/theme/provider.tsx +1 -1
  253. package/src/utils/componentCategories.ts +13 -5
  254. package/src/utils/interfaces.ts +5 -0
  255. package/src/utils/utils.ts +2 -32
  256. package/dist/components/Accordion/AccordionTypes.d.ts +0 -5
  257. package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +0 -8
  258. package/dist/components/Button/ButtonTypes.d.ts +0 -8
  259. package/dist/components/DatePicker/DatePickerTypes.d.ts +0 -5
  260. package/dist/components/Form/FormTypes.d.ts +0 -2
  261. package/dist/components/Grid/GridTypes.d.ts +0 -9
  262. package/dist/components/Heading/HeadingTypes.d.ts +0 -14
  263. package/dist/components/Hero/HeroTypes.d.ts +0 -12
  264. package/dist/components/Icons/IconTypes.d.ts +0 -77
  265. package/dist/components/Image/ImageTypes.d.ts +0 -22
  266. package/dist/components/Link/LinkTypes.d.ts +0 -8
  267. package/dist/components/List/ListTypes.d.ts +0 -5
  268. package/dist/components/Logo/LogoTypes.d.ts +0 -54
  269. package/dist/components/Notification/NotificationTypes.d.ts +0 -5
  270. package/dist/components/ProgressIndicator/ProgressIndicatorTypes.d.ts +0 -8
  271. package/dist/components/Select/SelectTypes.d.ts +0 -8
  272. package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +0 -5
  273. package/dist/components/StatusBadge/StatusBadgeTypes.d.ts +0 -5
  274. package/dist/components/StructuredContent/StructuredContentTypes.d.ts +0 -5
  275. package/dist/components/Text/TextTypes.d.ts +0 -6
  276. package/dist/components/TextInput/TextInputTypes.d.ts +0 -25
  277. package/dist/components/Toggle/ToggleTypes.d.ts +0 -4
  278. package/dist/components/VideoPlayer/VideoPlayerTypes.d.ts +0 -9
  279. package/dist/helpers/enums.d.ts +0 -4
  280. package/dist/utils/siteSections.d.ts +0 -2
  281. package/src/components/Accordion/AccordionTypes.tsx +0 -5
  282. package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +0 -8
  283. package/src/components/Button/ButtonTypes.tsx +0 -8
  284. package/src/components/DatePicker/DatePickerTypes.tsx +0 -5
  285. package/src/components/Form/FormTypes.tsx +0 -3
  286. package/src/components/Grid/GridTypes.tsx +0 -9
  287. package/src/components/Heading/HeadingTypes.tsx +0 -15
  288. package/src/components/Hero/HeroTypes.tsx +0 -20
  289. package/src/components/Icons/IconTypes.tsx +0 -83
  290. package/src/components/Image/ImageTypes.ts +0 -24
  291. package/src/components/Link/LinkTypes.tsx +0 -8
  292. package/src/components/List/ListTypes.tsx +0 -5
  293. package/src/components/Logo/LogoTypes.tsx +0 -56
  294. package/src/components/Modal/_Modal.scss +0 -18
  295. package/src/components/Notification/NotificationTypes.tsx +0 -5
  296. package/src/components/ProgressIndicator/ProgressIndicatorTypes.ts +0 -8
  297. package/src/components/Select/SelectTypes.tsx +0 -10
  298. package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +0 -5
  299. package/src/components/StatusBadge/StatusBadgeTypes.tsx +0 -5
  300. package/src/components/StructuredContent/StructuredContentTypes.tsx +0 -5
  301. package/src/components/Text/TextTypes.tsx +0 -6
  302. package/src/components/TextInput/TextInputTypes.tsx +0 -48
  303. package/src/components/Toggle/ToggleTypes.tsx +0 -4
  304. package/src/components/VideoPlayer/VideoPlayerTypes.tsx +0 -10
  305. package/src/helpers/enums.ts +0 -4
  306. package/src/utils/siteSections.ts +0 -10
@@ -4,12 +4,11 @@ import { axe } from "jest-axe";
4
4
  import renderer from "react-test-renderer";
5
5
 
6
6
  import Heading from "./Heading";
7
- import { HeadingSizes, HeadingLevels } from "./HeadingTypes";
8
7
 
9
8
  describe("Heading Accessibility", () => {
10
9
  it("passes axe accessibility test", async () => {
11
10
  const { container } = render(
12
- <Heading id="h1" level={HeadingLevels.One} text="Heading 1" />
11
+ <Heading id="h1" level="one" text="Heading 1" />
13
12
  );
14
13
  expect(await axe(container)).toHaveNoViolations();
15
14
  });
@@ -17,17 +16,13 @@ describe("Heading Accessibility", () => {
17
16
 
18
17
  describe("Heading", () => {
19
18
  it("renders and HTML heading element with the correct level", () => {
20
- render(<Heading id="h1" level={HeadingLevels.One} text="Heading 1" />);
19
+ render(<Heading id="h1" level="one" text="Heading 1" />);
21
20
  expect(screen.getByRole("heading", { level: 1 })).toBeInTheDocument();
22
21
  expect(screen.getByText("Heading 1")).toBeInTheDocument();
23
22
  });
24
23
 
25
24
  it("can pass heading content as child", () => {
26
- render(
27
- <Heading id="h1" level={HeadingLevels.Two}>
28
- Heading 2
29
- </Heading>
30
- );
25
+ render(<Heading id="h1">Heading 2</Heading>);
31
26
  expect(screen.getByRole("heading", { level: 2 })).toBeInTheDocument();
32
27
  expect(screen.getByText("Heading 2")).toBeInTheDocument();
33
28
  });
@@ -37,15 +32,9 @@ describe("Heading", () => {
37
32
  expect(screen.getByRole("heading", { level: 2 })).toBeInTheDocument();
38
33
  });
39
34
 
40
- // TODO: check that header children are links
41
- // it("Throws error when invalid heading is passed as child", () => {
42
- // expect(() => render(<Heading id="h1" level={HeadingLevels.Three}><span>oh no</span></Heading>))
43
- // .to.throw("Headings can only be plain text or bold");
44
- // });
45
-
46
35
  it("can pass a span element as a child", () => {
47
36
  render(
48
- <Heading id="h1" level={HeadingLevels.One}>
37
+ <Heading id="h1" level="one">
49
38
  <span>
50
39
  Text <b>hi</b>
51
40
  </span>
@@ -56,7 +45,7 @@ describe("Heading", () => {
56
45
 
57
46
  it("prioritizes the child when both child and the text prop are passed", () => {
58
47
  render(
59
- <Heading id="h1" level={HeadingLevels.One} text="prop text">
48
+ <Heading id="h1" level="one" text="prop text">
60
49
  child text
61
50
  </Heading>
62
51
  );
@@ -64,14 +53,7 @@ describe("Heading", () => {
64
53
  });
65
54
 
66
55
  it("renders an anchor element when the `url` prop is passed", () => {
67
- render(
68
- <Heading
69
- id="h1"
70
- level={HeadingLevels.One}
71
- text="Heading 1"
72
- url="fake-url"
73
- />
74
- );
56
+ render(<Heading id="h1" level="one" text="Heading 1" url="fake-url" />);
75
57
 
76
58
  expect(screen.getByRole("link")).toBeInTheDocument();
77
59
  });
@@ -80,7 +62,7 @@ describe("Heading", () => {
80
62
  render(
81
63
  <Heading
82
64
  id="h1"
83
- level={HeadingLevels.One}
65
+ level="one"
84
66
  url="fake-url"
85
67
  urlClass="fake-class"
86
68
  text="Heading 1"
@@ -92,7 +74,7 @@ describe("Heading", () => {
92
74
  });
93
75
 
94
76
  it("throws error when neither child nor text is passed", () => {
95
- expect(() => render(<Heading id="h1" level={HeadingLevels.One} />)).toThrow(
77
+ expect(() => render(<Heading id="h1" level="one" />)).toThrow(
96
78
  "NYPL Reservoir Heading: No children or value was passed to the `text` prop."
97
79
  );
98
80
  });
@@ -100,7 +82,7 @@ describe("Heading", () => {
100
82
  it("throws error when heading with many children is passed", () => {
101
83
  expect(() =>
102
84
  render(
103
- <Heading id="h1" level={HeadingLevels.Four}>
85
+ <Heading id="h1" level="four">
104
86
  <span>too</span>
105
87
  <span>many</span>
106
88
  </Heading>
@@ -112,8 +94,8 @@ describe("Heading", () => {
112
94
  render(
113
95
  <Heading
114
96
  id="h1"
115
- level={HeadingLevels.One}
116
- size={HeadingSizes.Secondary}
97
+ level="one"
98
+ size="secondary"
117
99
  text="Heading with Secondary size"
118
100
  />
119
101
  );
@@ -124,13 +106,11 @@ describe("Heading", () => {
124
106
 
125
107
  it("renders the UI snapshot correctly", () => {
126
108
  const basic = renderer
127
- .create(
128
- <Heading id="basic" level={HeadingLevels.One} text="Heading text" />
129
- )
109
+ .create(<Heading id="basic" level="one" text="Heading text" />)
130
110
  .toJSON();
131
111
  const basicWithChildText = renderer
132
112
  .create(
133
- <Heading id="basicWithChildText" level={HeadingLevels.One}>
113
+ <Heading id="basicWithChildText" level="one">
134
114
  Heading text
135
115
  </Heading>
136
116
  )
@@ -139,26 +119,20 @@ describe("Heading", () => {
139
119
  .create(
140
120
  <Heading
141
121
  id="customDisplaySize"
142
- level={HeadingLevels.One}
143
- size={HeadingSizes.Secondary}
122
+ level="one"
123
+ size="secondary"
144
124
  text="Heading with Secondary size"
145
125
  />
146
126
  )
147
127
  .toJSON();
148
128
  const otherLevel = renderer
149
- .create(
150
- <Heading
151
- id="otherLevel"
152
- level={HeadingLevels.Six}
153
- text="Heading level six"
154
- />
155
- )
129
+ .create(<Heading id="otherLevel" level="six" text="Heading level six" />)
156
130
  .toJSON();
157
131
  const withLink = renderer
158
132
  .create(
159
133
  <Heading
160
134
  id="withLink"
161
- level={HeadingLevels.One}
135
+ level="one"
162
136
  text="Heading text is a link"
163
137
  url="fake-url"
164
138
  />
@@ -166,7 +140,7 @@ describe("Heading", () => {
166
140
  .toJSON();
167
141
  const withCustomLink = renderer
168
142
  .create(
169
- <Heading id="withCustomLink" level={HeadingLevels.One}>
143
+ <Heading id="withCustomLink" level="one">
170
144
  <>
171
145
  Part of the heading text is
172
146
  <a href="fake-url" className="custom-link">
@@ -5,12 +5,11 @@ import {
5
5
  } from "@chakra-ui/react";
6
6
  import * as React from "react";
7
7
 
8
- import { HeadingSizes, HeadingLevels } from "./HeadingTypes";
9
8
  import Link from "../Link/Link";
10
- import { getVariant } from "../../utils/utils";
9
+
10
+ export type HeadingSizes = "primary" | "secondary" | "tertiary" | "callout";
11
+ export type HeadingLevels = "one" | "two" | "three" | "four" | "five" | "six";
11
12
  export interface HeadingProps {
12
- /** Optionally pass in additional Chakra-based styles. */
13
- additionalStyles?: { [key: string]: any };
14
13
  /** Optional className that appears in addition to `heading` */
15
14
  className?: string;
16
15
  /** Optional ID that other components can cross reference for accessibility purposes */
@@ -32,7 +31,7 @@ export interface HeadingProps {
32
31
  }
33
32
 
34
33
  /** Map the word heading level to the number heading level. The default is 2. */
35
- const getMappedLevel = (level = HeadingLevels.Two) => {
34
+ const getMappedLevel = (level = "two") => {
36
35
  const levelMap = {
37
36
  one: 1,
38
37
  two: 2,
@@ -47,10 +46,9 @@ const getMappedLevel = (level = HeadingLevels.Two) => {
47
46
  export const Heading = chakra(
48
47
  (props: React.PropsWithChildren<HeadingProps>) => {
49
48
  const {
50
- additionalStyles = {},
51
49
  className,
52
50
  id,
53
- level = HeadingLevels.Two,
51
+ level = "two",
54
52
  size,
55
53
  text,
56
54
  url,
@@ -58,11 +56,10 @@ export const Heading = chakra(
58
56
  ...rest
59
57
  } = props;
60
58
  const finalLevel = getMappedLevel(level);
61
- const variant = size ? getVariant(size, HeadingSizes) : `h${finalLevel}`;
59
+ const variant = size ? size : `h${finalLevel}`;
62
60
  const styles = useStyleConfig("Heading", { variant });
63
61
  // Combine native base styles with any additional styles.
64
62
  // This is used in the `Hero` and `Notification` components.
65
- const finalStyles = { ...styles, ...additionalStyles };
66
63
  const asHeading: any = `h${finalLevel}`;
67
64
 
68
65
  if (!props.children && !text) {
@@ -92,7 +89,7 @@ export const Heading = chakra(
92
89
  as={asHeading}
93
90
  className={className}
94
91
  id={id}
95
- sx={finalStyles}
92
+ sx={styles}
96
93
  {...rest}
97
94
  >
98
95
  {content}
@@ -25,7 +25,6 @@ import DSProvider from "../../theme/provider";
25
25
  jest: ["HelperErrorText.test.tsx"],
26
26
  }}
27
27
  argTypes={{
28
- additionalStyles: { control: false },
29
28
  ariaAtomic: {
30
29
  control: false,
31
30
  table: { defaultValue: { summary: true } },
@@ -47,7 +46,7 @@ import DSProvider from "../../theme/provider";
47
46
  | Component Version | DS Version |
48
47
  | ----------------- | ---------- |
49
48
  | Added | `0.0.10` |
50
- | Latest | `0.26.0` |
49
+ | Latest | `0.28.0` |
51
50
 
52
51
  ## Table of Contents
53
52
 
@@ -67,7 +66,6 @@ import DSProvider from "../../theme/provider";
67
66
  <Story
68
67
  name="HelperErrorText with Controls"
69
68
  args={{
70
- additionalStyles: undefined,
71
69
  ariaAtomic: undefined,
72
70
  ariaLive: "polite",
73
71
  className: undefined,
@@ -5,8 +5,6 @@ export type AriaLiveValues = "assertive" | "off" | "polite";
5
5
  export type HelperErrorTextType = string | JSX.Element;
6
6
 
7
7
  interface HelperErrorTextProps {
8
- /** Optionally pass in additional Chakra-based styles. */
9
- additionalStyles?: { [key: string]: any };
10
8
  /** Aria attribute. When true, assistive technologies will
11
9
  * read the entire DOM element. When false, only changes (additionals or
12
10
  * removals) will be read. True by default. */
@@ -33,7 +31,6 @@ interface HelperErrorTextProps {
33
31
  */
34
32
  export const HelperErrorText = chakra(
35
33
  ({
36
- additionalStyles = {},
37
34
  ariaAtomic = true,
38
35
  ariaLive = "polite",
39
36
  className = "",
@@ -45,14 +42,13 @@ export const HelperErrorText = chakra(
45
42
  // Only announce the text in the invalid state.
46
43
  const announceAriaLive = isInvalid;
47
44
  const styles = useStyleConfig("HelperErrorText", { isInvalid });
48
- const finalStyles = { ...styles, ...additionalStyles };
49
45
  const props = {
50
46
  "aria-atomic": ariaAtomic,
51
47
  "aria-live": announceAriaLive ? ariaLive : "off",
52
48
  className,
53
49
  "data-isinvalid": isInvalid,
54
50
  id,
55
- __css: finalStyles,
51
+ __css: styles,
56
52
  ...rest,
57
53
  };
58
54
  return typeof text === "string" ? (