@nypl/design-system-react-components 0.26.1 → 1.0.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 (307) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/README.md +7 -7
  3. package/dist/components/Accordion/Accordion.d.ts +1 -1
  4. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -5
  5. package/dist/components/Button/Button.d.ts +2 -10
  6. package/dist/components/ButtonGroup/ButtonGroup.d.ts +22 -0
  7. package/dist/components/Card/Card.d.ts +2 -2
  8. package/dist/components/Checkbox/Checkbox.d.ts +10 -8
  9. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
  10. package/dist/components/DatePicker/DatePicker.d.ts +1 -1
  11. package/dist/components/Form/Form.d.ts +2 -2
  12. package/dist/components/Grid/SimpleGrid.d.ts +6 -3
  13. package/dist/components/Heading/Heading.d.ts +2 -5
  14. package/dist/components/HelperErrorText/HelperErrorText.d.ts +1 -5
  15. package/dist/components/Hero/Hero.d.ts +13 -9
  16. package/dist/components/Icons/Icon.d.ts +6 -5
  17. package/dist/components/Icons/IconSvgs.d.ts +21 -21
  18. package/dist/components/Image/Image.d.ts +8 -5
  19. package/dist/components/Link/Link.d.ts +1 -9
  20. package/dist/components/List/List.d.ts +7 -11
  21. package/dist/components/Logo/Logo.d.ts +2 -5
  22. package/dist/components/Logo/LogoSvgs.d.ts +39 -39
  23. package/dist/components/Modal/Modal.d.ts +28 -8
  24. package/dist/components/Notification/Notification.d.ts +1 -1
  25. package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +2 -1
  26. package/dist/components/RadioGroup/RadioGroup.d.ts +1 -1
  27. package/dist/components/SearchBar/SearchBar.d.ts +3 -2
  28. package/dist/components/Select/Select.d.ts +2 -5
  29. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -4
  30. package/dist/components/SkipNavigation/SkipNavigation.d.ts +17 -0
  31. package/dist/components/StatusBadge/StatusBadge.d.ts +2 -3
  32. package/dist/components/StructuredContent/StructuredContent.d.ts +2 -2
  33. package/dist/components/Table/Table.d.ts +1 -1
  34. package/dist/components/Template/Template.d.ts +2 -0
  35. package/dist/components/Text/Text.d.ts +1 -1
  36. package/dist/components/TextInput/TextInput.d.ts +21 -9
  37. package/dist/components/Toggle/Toggle.d.ts +1 -5
  38. package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
  39. package/dist/design-system-react-components.cjs.development.js +983 -1222
  40. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  41. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  42. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  43. package/dist/design-system-react-components.esm.js +982 -1285
  44. package/dist/design-system-react-components.esm.js.map +1 -1
  45. package/dist/helpers/types.d.ts +1 -0
  46. package/dist/index.d.ts +27 -48
  47. package/dist/styles.css +1 -1
  48. package/dist/theme/components/buttonGroup.d.ts +11 -0
  49. package/dist/theme/components/card.d.ts +104 -8
  50. package/dist/theme/components/componentWrapper.d.ts +4 -3
  51. package/dist/theme/components/customTable.d.ts +11 -14
  52. package/dist/theme/components/fieldset.d.ts +4 -3
  53. package/dist/theme/components/helperErrorText.d.ts +4 -3
  54. package/dist/theme/components/hero.d.ts +1 -1
  55. package/dist/theme/components/horizontalRule.d.ts +4 -3
  56. package/dist/theme/components/icon.d.ts +47743 -1
  57. package/dist/theme/components/image.d.ts +563 -10
  58. package/dist/theme/components/label.d.ts +4 -3
  59. package/dist/theme/components/list.d.ts +6 -7
  60. package/dist/theme/components/logo.d.ts +474 -1
  61. package/dist/theme/components/notification.d.ts +20 -16
  62. package/dist/theme/components/progressIndicator.d.ts +6 -4
  63. package/dist/theme/components/select.d.ts +4 -10
  64. package/dist/theme/components/skeletonLoader.d.ts +14 -10
  65. package/dist/theme/components/skipNavigation.d.ts +22 -0
  66. package/dist/theme/components/slider.d.ts +7 -6
  67. package/dist/theme/components/structuredContent.d.ts +10 -9
  68. package/dist/theme/components/text.d.ts +7 -1
  69. package/dist/theme/components/toggle.d.ts +6 -4
  70. package/dist/theme/provider.d.ts +2 -4
  71. package/dist/utils/componentCategories.d.ts +1 -1
  72. package/dist/utils/interfaces.d.ts +5 -0
  73. package/dist/utils/utils.d.ts +2 -18
  74. package/package.json +15 -16
  75. package/src/__tests__/setup.ts +3 -3
  76. package/src/__tests__/utils/utils.test.ts +1 -23
  77. package/src/components/AccessibilityGuide/SkipNavigation.stories.mdx +22 -14
  78. package/src/components/Accordion/Accordion.stories.mdx +43 -44
  79. package/src/components/Accordion/Accordion.test.tsx +5 -13
  80. package/src/components/Accordion/Accordion.tsx +14 -18
  81. package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +6 -6
  82. package/src/components/Autosuggest/Autosuggest.stories.mdx +1 -1
  83. package/src/components/Autosuggest/Autosuggest.stories.tsx +23 -25
  84. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +21 -37
  85. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +4 -17
  86. package/src/components/Breadcrumbs/Breadcrumbs.tsx +18 -21
  87. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +1 -100
  88. package/src/components/Button/Button.stories.mdx +89 -126
  89. package/src/components/Button/Button.test.tsx +16 -30
  90. package/src/components/Button/Button.tsx +14 -20
  91. package/src/components/ButtonGroup/ButtonGroup.stories.mdx +147 -0
  92. package/src/components/ButtonGroup/ButtonGroup.test.tsx +141 -0
  93. package/src/components/ButtonGroup/ButtonGroup.tsx +99 -0
  94. package/src/components/ButtonGroup/__snapshots__/ButtonGroup.test.tsx.snap +117 -0
  95. package/src/components/Card/Card.stories.mdx +144 -178
  96. package/src/components/Card/Card.test.tsx +36 -97
  97. package/src/components/Card/Card.tsx +78 -74
  98. package/src/components/Chakra/Box.stories.mdx +3 -7
  99. package/src/components/Chakra/Center.stories.mdx +6 -24
  100. package/src/components/Chakra/Flex.stories.mdx +5 -7
  101. package/src/components/Chakra/Grid.stories.mdx +1 -1
  102. package/src/components/Chakra/Stack.stories.mdx +10 -11
  103. package/src/components/Checkbox/Checkbox.stories.mdx +1 -1
  104. package/src/components/Checkbox/Checkbox.test.tsx +2 -2
  105. package/src/components/Checkbox/Checkbox.tsx +20 -13
  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 +0 -11
  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 +4 -4
  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 +63 -63
  193. package/src/components/StyleGuide/ColorCard.tsx +2 -4
  194. package/src/components/StyleGuide/Colors.stories.mdx +9 -10
  195. package/src/components/StyleGuide/DesignTokens.stories.mdx +5 -7
  196. package/src/components/StyleGuide/Forms.stories.mdx +2 -2
  197. package/src/components/StyleGuide/Iconography.stories.mdx +60 -78
  198. package/src/components/StyleGuide/Spacing.stories.mdx +1 -2
  199. package/src/components/StyleGuide/Typography.stories.mdx +16 -19
  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/foundations/colors.ts +6 -9
  252. package/src/theme/index.ts +4 -0
  253. package/src/theme/provider.tsx +1 -1
  254. package/src/utils/componentCategories.ts +13 -5
  255. package/src/utils/interfaces.ts +5 -0
  256. package/src/utils/utils.ts +2 -32
  257. package/dist/components/Accordion/AccordionTypes.d.ts +0 -5
  258. package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +0 -8
  259. package/dist/components/Button/ButtonTypes.d.ts +0 -8
  260. package/dist/components/DatePicker/DatePickerTypes.d.ts +0 -5
  261. package/dist/components/Form/FormTypes.d.ts +0 -2
  262. package/dist/components/Grid/GridTypes.d.ts +0 -9
  263. package/dist/components/Heading/HeadingTypes.d.ts +0 -14
  264. package/dist/components/Hero/HeroTypes.d.ts +0 -12
  265. package/dist/components/Icons/IconTypes.d.ts +0 -77
  266. package/dist/components/Image/ImageTypes.d.ts +0 -22
  267. package/dist/components/Link/LinkTypes.d.ts +0 -8
  268. package/dist/components/List/ListTypes.d.ts +0 -5
  269. package/dist/components/Logo/LogoTypes.d.ts +0 -54
  270. package/dist/components/Notification/NotificationTypes.d.ts +0 -5
  271. package/dist/components/ProgressIndicator/ProgressIndicatorTypes.d.ts +0 -8
  272. package/dist/components/Select/SelectTypes.d.ts +0 -8
  273. package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +0 -5
  274. package/dist/components/StatusBadge/StatusBadgeTypes.d.ts +0 -5
  275. package/dist/components/StructuredContent/StructuredContentTypes.d.ts +0 -5
  276. package/dist/components/Text/TextTypes.d.ts +0 -6
  277. package/dist/components/TextInput/TextInputTypes.d.ts +0 -25
  278. package/dist/components/Toggle/ToggleTypes.d.ts +0 -4
  279. package/dist/components/VideoPlayer/VideoPlayerTypes.d.ts +0 -9
  280. package/dist/helpers/enums.d.ts +0 -4
  281. package/dist/utils/siteSections.d.ts +0 -2
  282. package/src/components/Accordion/AccordionTypes.tsx +0 -5
  283. package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +0 -8
  284. package/src/components/Button/ButtonTypes.tsx +0 -8
  285. package/src/components/DatePicker/DatePickerTypes.tsx +0 -5
  286. package/src/components/Form/FormTypes.tsx +0 -3
  287. package/src/components/Grid/GridTypes.tsx +0 -9
  288. package/src/components/Heading/HeadingTypes.tsx +0 -15
  289. package/src/components/Hero/HeroTypes.tsx +0 -20
  290. package/src/components/Icons/IconTypes.tsx +0 -83
  291. package/src/components/Image/ImageTypes.ts +0 -24
  292. package/src/components/Link/LinkTypes.tsx +0 -8
  293. package/src/components/List/ListTypes.tsx +0 -5
  294. package/src/components/Logo/LogoTypes.tsx +0 -56
  295. package/src/components/Modal/_Modal.scss +0 -18
  296. package/src/components/Notification/NotificationTypes.tsx +0 -5
  297. package/src/components/ProgressIndicator/ProgressIndicatorTypes.ts +0 -8
  298. package/src/components/Select/SelectTypes.tsx +0 -10
  299. package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +0 -5
  300. package/src/components/StatusBadge/StatusBadgeTypes.tsx +0 -5
  301. package/src/components/StructuredContent/StructuredContentTypes.tsx +0 -5
  302. package/src/components/Text/TextTypes.tsx +0 -6
  303. package/src/components/TextInput/TextInputTypes.tsx +0 -48
  304. package/src/components/Toggle/ToggleTypes.tsx +0 -4
  305. package/src/components/VideoPlayer/VideoPlayerTypes.tsx +0 -10
  306. package/src/helpers/enums.ts +0 -4
  307. package/src/utils/siteSections.ts +0 -10
@@ -8,18 +8,7 @@ import {
8
8
  import { withDesign } from "storybook-addon-designs";
9
9
 
10
10
  import Heading from "./Heading";
11
- import { HeadingSizes, HeadingLevels } from "./HeadingTypes";
12
11
  import { getCategory } from "../../utils/componentCategories";
13
- import { getStorybookEnumValues } from "../../utils/utils";
14
-
15
- export const sizesEnumValues = getStorybookEnumValues(
16
- HeadingSizes,
17
- "HeadingSizes"
18
- );
19
- export const levelsEnumValues = getStorybookEnumValues(
20
- HeadingLevels,
21
- "HeadingLevels"
22
- );
23
12
 
24
13
  <Meta
25
14
  title={getCategory("Heading")}
@@ -33,17 +22,10 @@ export const levelsEnumValues = getStorybookEnumValues(
33
22
  jest: ["Heading.test.tsx"],
34
23
  }}
35
24
  argTypes={{
36
- additionalStyles: { control: false },
37
25
  className: { control: false },
38
26
  id: { control: false },
39
27
  level: {
40
- control: { type: "select" },
41
- options: levelsEnumValues.options,
42
- table: { defaultValue: { summary: "HeadingLevels.Two" } },
43
- },
44
- size: {
45
- control: { type: "select" },
46
- options: sizesEnumValues.options,
28
+ table: { defaultValue: { summary: "two" } },
47
29
  },
48
30
  }}
49
31
  />
@@ -53,7 +35,7 @@ export const levelsEnumValues = getStorybookEnumValues(
53
35
  | Component Version | DS Version |
54
36
  | ----------------- | ---------- |
55
37
  | Added | `0.0.4` |
56
- | Latest | `0.26.0` |
38
+ | Latest | `0.28.0` |
57
39
 
58
40
  ## Table of Contents
59
41
 
@@ -79,23 +61,16 @@ semantic elements can be overwritten using the `size` prop.
79
61
  <Story
80
62
  name="Heading with Controls"
81
63
  args={{
82
- additionalStyles: undefined,
83
64
  className: undefined,
84
65
  id: "heading-id",
85
- level: "HeadingLevels.Two",
66
+ level: "two",
86
67
  size: undefined,
87
68
  text: "Default Heading",
88
69
  url: undefined,
89
70
  urlClass: undefined,
90
71
  }}
91
72
  >
92
- {(args) => (
93
- <Heading
94
- {...args}
95
- level={levelsEnumValues.getValue(args.level)}
96
- size={args.size && sizesEnumValues.getValue(args.size)}
97
- />
98
- )}
73
+ {(args) => <Heading {...args} />}
99
74
  </Story>
100
75
  </Canvas>
101
76
 
@@ -125,36 +100,16 @@ Resources:
125
100
  <Canvas>
126
101
  <Story name="Default Heading Styles">
127
102
  <div>
128
- <Heading
129
- id="heading-one"
130
- level={HeadingLevels.One}
131
- text="<h1> Heading 1 - HeadingLevels.One"
132
- />
133
- <Heading
134
- id="heading-two"
135
- level={HeadingLevels.Two}
136
- text="<h2> Heading 2 - HeadingLevels.Two"
137
- />
103
+ <Heading id="heading-one" level="one" text="<h1> Heading 1 - 'one'" />
104
+ <Heading id="heading-two" level="two" text="<h2> Heading 2 - 'two'" />
138
105
  <Heading
139
106
  id="heading-three"
140
- level={HeadingLevels.Three}
141
- text="<h3> Heading 3 - HeadingLevels.Three"
142
- />
143
- <Heading
144
- id="heading-four"
145
- level={HeadingLevels.Four}
146
- text="<h4> Heading 4 - HeadingLevels.Four"
147
- />
148
- <Heading
149
- id="heading-five"
150
- level={HeadingLevels.Five}
151
- text="<h5> Heading 5 - HeadingLevels.Five"
152
- />
153
- <Heading
154
- id="heading-six"
155
- level={HeadingLevels.Six}
156
- text="<h6> Heading 6 - HeadingLevels.Six"
107
+ level="three"
108
+ text="<h3> Heading 3 - 'three'"
157
109
  />
110
+ <Heading id="heading-four" level="four" text="<h4> Heading 4 - 'four'" />
111
+ <Heading id="heading-five" level="five" text="<h5> Heading 5 - 'five'" />
112
+ <Heading id="heading-six" level="six" text="<h6> Heading 6 - 'six'" />
158
113
  </div>
159
114
  </Story>
160
115
  </Canvas>
@@ -162,34 +117,34 @@ Resources:
162
117
  ## Size Styles
163
118
 
164
119
  Note: The `level` prop for the `Heading`s in the next example are all set to
165
- `level={HeadingLevels.One}`.
120
+ `level="one"`.
166
121
 
167
122
  <Canvas>
168
123
  <Story name="Size Styles">
169
124
  <div>
170
125
  <Heading
171
126
  id="heading-primary"
172
- level={HeadingLevels.One}
173
- size={HeadingSizes.Primary}
174
- text="<h1> HeadingSizes.Primary"
127
+ level="one"
128
+ size="primary"
129
+ text="<h1> 'primary'"
175
130
  />
176
131
  <Heading
177
132
  id="heading-secondary"
178
- level={HeadingLevels.One}
179
- size={HeadingSizes.Secondary}
180
- text="<h1> HeadingSizes.Secondary"
133
+ level="one"
134
+ size="secondary"
135
+ text="<h1> 'secondary'"
181
136
  />
182
137
  <Heading
183
138
  id="heading-tertiary"
184
- level={HeadingLevels.One}
185
- size={HeadingSizes.Tertiary}
186
- text="<h1> HeadingSizes.Tertiary"
139
+ level="one"
140
+ size="tertiary"
141
+ text="<h1> 'tertiary'"
187
142
  />
188
143
  <Heading
189
144
  id="heading-callout"
190
- level={HeadingLevels.One}
191
- size={HeadingSizes.Callout}
192
- text="<h1> HeadingSizes.Callout"
145
+ level="one"
146
+ size="callout"
147
+ text="<h1> 'callout'"
193
148
  />
194
149
  </div>
195
150
  </Story>
@@ -199,7 +154,7 @@ Note: The `level` prop for the `Heading`s in the next example are all set to
199
154
 
200
155
  <Canvas>
201
156
  <Story name="Heading with Bold Text">
202
- <Heading id="headingWithBold" level={HeadingLevels.One}>
157
+ <Heading id="headingWithBold" level="one">
203
158
  <>
204
159
  Heading with a <b>Bold</b> Word
205
160
  </>
@@ -215,12 +170,12 @@ When the `url` prop is passed to `Heading`, a child `<a>` element is created and
215
170
  <Story name="Headings with Links">
216
171
  <Heading
217
172
  id="heading-with-link-url"
218
- level={HeadingLevels.Two}
173
+ level="two"
219
174
  text="Heading with URL Props"
220
175
  url="http://apple.com"
221
176
  urlClass="special-link"
222
177
  />
223
- <Heading id="heading-with-link-child" level={HeadingLevels.Two}>
178
+ <Heading id="heading-with-link-child">
224
179
  <>
225
180
  Heading with a Word <a href="#hello">Link</a>
226
181
  </>
@@ -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" ? (