@nypl/design-system-react-components 0.27.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 (298) hide show
  1. package/CHANGELOG.md +29 -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/Notification/Notification.d.ts +1 -1
  23. package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +2 -1
  24. package/dist/components/RadioGroup/RadioGroup.d.ts +1 -1
  25. package/dist/components/SearchBar/SearchBar.d.ts +3 -2
  26. package/dist/components/Select/Select.d.ts +2 -5
  27. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -4
  28. package/dist/components/SkipNavigation/SkipNavigation.d.ts +17 -0
  29. package/dist/components/StatusBadge/StatusBadge.d.ts +2 -3
  30. package/dist/components/StructuredContent/StructuredContent.d.ts +2 -2
  31. package/dist/components/Table/Table.d.ts +1 -1
  32. package/dist/components/Template/Template.d.ts +2 -0
  33. package/dist/components/Text/Text.d.ts +1 -1
  34. package/dist/components/TextInput/TextInput.d.ts +21 -9
  35. package/dist/components/Toggle/Toggle.d.ts +1 -5
  36. package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
  37. package/dist/design-system-react-components.cjs.development.js +856 -1155
  38. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  39. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  40. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  41. package/dist/design-system-react-components.esm.js +858 -1220
  42. package/dist/design-system-react-components.esm.js.map +1 -1
  43. package/dist/helpers/types.d.ts +1 -0
  44. package/dist/index.d.ts +26 -47
  45. package/dist/theme/components/buttonGroup.d.ts +11 -0
  46. package/dist/theme/components/card.d.ts +104 -8
  47. package/dist/theme/components/componentWrapper.d.ts +4 -3
  48. package/dist/theme/components/customTable.d.ts +11 -14
  49. package/dist/theme/components/fieldset.d.ts +4 -3
  50. package/dist/theme/components/helperErrorText.d.ts +4 -3
  51. package/dist/theme/components/hero.d.ts +1 -1
  52. package/dist/theme/components/horizontalRule.d.ts +4 -3
  53. package/dist/theme/components/icon.d.ts +47743 -1
  54. package/dist/theme/components/image.d.ts +563 -10
  55. package/dist/theme/components/label.d.ts +4 -3
  56. package/dist/theme/components/list.d.ts +6 -7
  57. package/dist/theme/components/logo.d.ts +474 -1
  58. package/dist/theme/components/notification.d.ts +20 -16
  59. package/dist/theme/components/progressIndicator.d.ts +6 -4
  60. package/dist/theme/components/select.d.ts +4 -4
  61. package/dist/theme/components/skeletonLoader.d.ts +14 -10
  62. package/dist/theme/components/skipNavigation.d.ts +22 -0
  63. package/dist/theme/components/slider.d.ts +7 -6
  64. package/dist/theme/components/structuredContent.d.ts +10 -9
  65. package/dist/theme/components/text.d.ts +7 -1
  66. package/dist/theme/components/toggle.d.ts +6 -4
  67. package/dist/theme/provider.d.ts +2 -4
  68. package/dist/utils/componentCategories.d.ts +1 -1
  69. package/dist/utils/interfaces.d.ts +5 -0
  70. package/dist/utils/utils.d.ts +2 -18
  71. package/package.json +2 -2
  72. package/src/__tests__/setup.ts +3 -3
  73. package/src/__tests__/utils/utils.test.ts +1 -23
  74. package/src/components/AccessibilityGuide/SkipNavigation.stories.mdx +22 -14
  75. package/src/components/Accordion/Accordion.stories.mdx +43 -44
  76. package/src/components/Accordion/Accordion.test.tsx +5 -13
  77. package/src/components/Accordion/Accordion.tsx +14 -18
  78. package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +6 -6
  79. package/src/components/Autosuggest/Autosuggest.stories.mdx +1 -1
  80. package/src/components/Autosuggest/Autosuggest.stories.tsx +23 -25
  81. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +21 -37
  82. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +4 -17
  83. package/src/components/Breadcrumbs/Breadcrumbs.tsx +18 -21
  84. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +1 -100
  85. package/src/components/Button/Button.stories.mdx +89 -126
  86. package/src/components/Button/Button.test.tsx +16 -30
  87. package/src/components/Button/Button.tsx +14 -20
  88. package/src/components/ButtonGroup/ButtonGroup.stories.mdx +147 -0
  89. package/src/components/ButtonGroup/ButtonGroup.test.tsx +141 -0
  90. package/src/components/ButtonGroup/ButtonGroup.tsx +99 -0
  91. package/src/components/ButtonGroup/__snapshots__/ButtonGroup.test.tsx.snap +117 -0
  92. package/src/components/Card/Card.stories.mdx +143 -177
  93. package/src/components/Card/Card.test.tsx +36 -97
  94. package/src/components/Card/Card.tsx +78 -74
  95. package/src/components/Chakra/Box.stories.mdx +2 -6
  96. package/src/components/Chakra/Center.stories.mdx +5 -23
  97. package/src/components/Chakra/Flex.stories.mdx +4 -6
  98. package/src/components/Chakra/Stack.stories.mdx +9 -10
  99. package/src/components/Checkbox/Checkbox.stories.mdx +1 -1
  100. package/src/components/Checkbox/Checkbox.test.tsx +2 -2
  101. package/src/components/Checkbox/Checkbox.tsx +20 -13
  102. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +6 -17
  103. package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +1 -7
  104. package/src/components/CheckboxGroup/CheckboxGroup.tsx +33 -29
  105. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +0 -11
  106. package/src/components/ComponentWrapper/ComponentWrapper.tsx +3 -10
  107. package/src/components/DatePicker/DatePicker.stories.mdx +23 -37
  108. package/src/components/DatePicker/DatePicker.test.tsx +21 -19
  109. package/src/components/DatePicker/DatePicker.tsx +57 -49
  110. package/src/components/Form/Form.stories.mdx +46 -31
  111. package/src/components/Form/Form.test.tsx +1 -18
  112. package/src/components/Form/Form.tsx +7 -7
  113. package/src/components/Grid/SimpleGrid.stories.mdx +73 -49
  114. package/src/components/Grid/SimpleGrid.test.tsx +7 -9
  115. package/src/components/Grid/SimpleGrid.tsx +14 -11
  116. package/src/components/Heading/Heading.stories.mdx +27 -72
  117. package/src/components/Heading/Heading.test.tsx +18 -44
  118. package/src/components/Heading/Heading.tsx +7 -10
  119. package/src/components/HelperErrorText/HelperErrorText.stories.mdx +1 -3
  120. package/src/components/HelperErrorText/HelperErrorText.tsx +1 -5
  121. package/src/components/Hero/Hero.stories.mdx +219 -216
  122. package/src/components/Hero/Hero.test.tsx +107 -223
  123. package/src/components/Hero/Hero.tsx +63 -61
  124. package/src/components/Icons/Icon.stories.mdx +172 -118
  125. package/src/components/Icons/Icon.test.tsx +8 -16
  126. package/src/components/Icons/Icon.tsx +75 -29
  127. package/src/components/Icons/IconSvgs.tsx +42 -42
  128. package/src/components/Image/Image.stories.mdx +45 -132
  129. package/src/components/Image/Image.test.tsx +16 -31
  130. package/src/components/Image/Image.tsx +28 -12
  131. package/src/components/Link/Link.stories.mdx +30 -80
  132. package/src/components/Link/Link.test.tsx +25 -53
  133. package/src/components/Link/Link.tsx +43 -56
  134. package/src/components/Link/__snapshots__/Link.test.tsx.snap +1 -2
  135. package/src/components/List/List.stories.mdx +20 -31
  136. package/src/components/List/List.test.tsx +24 -43
  137. package/src/components/List/List.tsx +25 -36
  138. package/src/components/Logo/Logo.stories.mdx +94 -50
  139. package/src/components/Logo/Logo.test.tsx +10 -19
  140. package/src/components/Logo/Logo.tsx +50 -17
  141. package/src/components/Logo/LogoSvgs.tsx +78 -78
  142. package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +4 -4
  143. package/src/components/Modal/Modal.stories.mdx +8 -9
  144. package/src/components/Modal/Modal.test.tsx +5 -10
  145. package/src/components/Modal/Modal.tsx +1 -1
  146. package/src/components/Notification/Notification.stories.mdx +10 -28
  147. package/src/components/Notification/Notification.test.tsx +9 -12
  148. package/src/components/Notification/Notification.tsx +34 -37
  149. package/src/components/Pagination/Pagination.stories.mdx +2 -2
  150. package/src/components/Pagination/Pagination.tsx +15 -10
  151. package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +27 -53
  152. package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +9 -10
  153. package/src/components/ProgressIndicator/ProgressIndicator.tsx +17 -21
  154. package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +0 -10
  155. package/src/components/Radio/Radio.stories.mdx +1 -1
  156. package/src/components/Radio/Radio.tsx +9 -6
  157. package/src/components/RadioGroup/RadioGroup.stories.mdx +15 -16
  158. package/src/components/RadioGroup/RadioGroup.test.tsx +2 -8
  159. package/src/components/RadioGroup/RadioGroup.tsx +28 -24
  160. package/src/components/SearchBar/SearchBar.stories.mdx +1 -1
  161. package/src/components/SearchBar/SearchBar.test.tsx +1 -1
  162. package/src/components/SearchBar/SearchBar.tsx +14 -22
  163. package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +0 -12
  164. package/src/components/Select/Select.stories.mdx +8 -23
  165. package/src/components/Select/Select.test.tsx +6 -7
  166. package/src/components/Select/Select.tsx +13 -26
  167. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +17 -56
  168. package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +7 -21
  169. package/src/components/SkeletonLoader/SkeletonLoader.tsx +9 -8
  170. package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +33 -33
  171. package/src/components/SkipNavigation/SkipNavigation.stories.mdx +90 -0
  172. package/src/components/SkipNavigation/SkipNavigation.test.tsx +63 -0
  173. package/src/components/SkipNavigation/SkipNavigation.tsx +51 -0
  174. package/src/components/SkipNavigation/__snapshots__/SkipNavigation.test.tsx.snap +130 -0
  175. package/src/components/Slider/Slider.stories.mdx +19 -53
  176. package/src/components/Slider/Slider.test.tsx +2 -2
  177. package/src/components/Slider/Slider.tsx +10 -12
  178. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +2 -9
  179. package/src/components/StatusBadge/StatusBadge.stories.mdx +6 -21
  180. package/src/components/StatusBadge/StatusBadge.test.tsx +2 -3
  181. package/src/components/StatusBadge/StatusBadge.tsx +3 -10
  182. package/src/components/StructuredContent/StructuredContent.stories.mdx +30 -58
  183. package/src/components/StructuredContent/StructuredContent.test.tsx +42 -44
  184. package/src/components/StructuredContent/StructuredContent.tsx +9 -18
  185. package/src/components/StyleGuide/Bidirectionality.stories.mdx +9 -23
  186. package/src/components/StyleGuide/Buttons.stories.mdx +62 -62
  187. package/src/components/StyleGuide/ColorCard.tsx +2 -4
  188. package/src/components/StyleGuide/Colors.stories.mdx +7 -8
  189. package/src/components/StyleGuide/DesignTokens.stories.mdx +5 -7
  190. package/src/components/StyleGuide/Forms.stories.mdx +0 -1
  191. package/src/components/StyleGuide/Iconography.stories.mdx +59 -77
  192. package/src/components/StyleGuide/Spacing.stories.mdx +0 -1
  193. package/src/components/StyleGuide/Typography.stories.mdx +15 -18
  194. package/src/components/Table/Table.stories.mdx +85 -1
  195. package/src/components/Table/Table.test.tsx +57 -1
  196. package/src/components/Table/Table.tsx +7 -4
  197. package/src/components/Table/__snapshots__/Table.test.tsx.snap +121 -0
  198. package/src/components/Tabs/Tabs.stories.mdx +1 -1
  199. package/src/components/Tabs/Tabs.test.tsx +2 -2
  200. package/src/components/Tabs/Tabs.tsx +26 -27
  201. package/src/components/Template/Template.stories.mdx +49 -54
  202. package/src/components/Template/Template.tsx +9 -3
  203. package/src/components/Text/Text.stories.mdx +5 -11
  204. package/src/components/Text/Text.test.tsx +3 -6
  205. package/src/components/Text/Text.tsx +3 -5
  206. package/src/components/TextInput/TextInput.stories.mdx +10 -22
  207. package/src/components/TextInput/TextInput.test.tsx +32 -62
  208. package/src/components/TextInput/TextInput.tsx +61 -30
  209. package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +1 -0
  210. package/src/components/Toggle/Toggle.stories.mdx +5 -16
  211. package/src/components/Toggle/Toggle.test.tsx +2 -3
  212. package/src/components/Toggle/Toggle.tsx +9 -10
  213. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +13 -29
  214. package/src/components/VideoPlayer/VideoPlayer.test.tsx +18 -23
  215. package/src/components/VideoPlayer/VideoPlayer.tsx +13 -10
  216. package/src/docs/Chakra.stories.mdx +14 -11
  217. package/src/docs/Welcome.stories.mdx +23 -43
  218. package/src/helpers/types.ts +1 -0
  219. package/src/hooks/tests/useNYPLTheme.test.tsx +1 -1
  220. package/src/hooks/useNYPLTheme.stories.mdx +3 -6
  221. package/src/index.ts +51 -45
  222. package/src/theme/components/buttonGroup.ts +10 -0
  223. package/src/theme/components/card.ts +50 -15
  224. package/src/theme/components/componentWrapper.ts +5 -1
  225. package/src/theme/components/customTable.ts +8 -2
  226. package/src/theme/components/fieldset.ts +5 -1
  227. package/src/theme/components/helperErrorText.ts +5 -1
  228. package/src/theme/components/hero.ts +2 -2
  229. package/src/theme/components/horizontalRule.ts +5 -1
  230. package/src/theme/components/icon.ts +7 -1
  231. package/src/theme/components/image.ts +14 -3
  232. package/src/theme/components/label.ts +5 -1
  233. package/src/theme/components/list.ts +8 -2
  234. package/src/theme/components/logo.ts +5 -1
  235. package/src/theme/components/notification.ts +38 -14
  236. package/src/theme/components/progressIndicator.ts +10 -5
  237. package/src/theme/components/select.ts +5 -2
  238. package/src/theme/components/skeletonLoader.ts +8 -2
  239. package/src/theme/components/skipNavigation.ts +26 -0
  240. package/src/theme/components/slider.ts +13 -1
  241. package/src/theme/components/structuredContent.ts +11 -1
  242. package/src/theme/components/text.ts +12 -5
  243. package/src/theme/components/toggle.ts +9 -3
  244. package/src/theme/index.ts +4 -0
  245. package/src/theme/provider.tsx +1 -1
  246. package/src/utils/componentCategories.ts +13 -5
  247. package/src/utils/interfaces.ts +5 -0
  248. package/src/utils/utils.ts +2 -32
  249. package/dist/components/Accordion/AccordionTypes.d.ts +0 -5
  250. package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +0 -8
  251. package/dist/components/Button/ButtonTypes.d.ts +0 -8
  252. package/dist/components/DatePicker/DatePickerTypes.d.ts +0 -5
  253. package/dist/components/Form/FormTypes.d.ts +0 -2
  254. package/dist/components/Grid/GridTypes.d.ts +0 -9
  255. package/dist/components/Heading/HeadingTypes.d.ts +0 -14
  256. package/dist/components/Hero/HeroTypes.d.ts +0 -12
  257. package/dist/components/Icons/IconTypes.d.ts +0 -77
  258. package/dist/components/Image/ImageTypes.d.ts +0 -22
  259. package/dist/components/Link/LinkTypes.d.ts +0 -8
  260. package/dist/components/List/ListTypes.d.ts +0 -5
  261. package/dist/components/Logo/LogoTypes.d.ts +0 -54
  262. package/dist/components/Notification/NotificationTypes.d.ts +0 -5
  263. package/dist/components/ProgressIndicator/ProgressIndicatorTypes.d.ts +0 -8
  264. package/dist/components/Select/SelectTypes.d.ts +0 -8
  265. package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +0 -5
  266. package/dist/components/StatusBadge/StatusBadgeTypes.d.ts +0 -5
  267. package/dist/components/StructuredContent/StructuredContentTypes.d.ts +0 -5
  268. package/dist/components/Text/TextTypes.d.ts +0 -6
  269. package/dist/components/TextInput/TextInputTypes.d.ts +0 -25
  270. package/dist/components/Toggle/ToggleTypes.d.ts +0 -4
  271. package/dist/components/VideoPlayer/VideoPlayerTypes.d.ts +0 -9
  272. package/dist/helpers/enums.d.ts +0 -4
  273. package/dist/utils/siteSections.d.ts +0 -2
  274. package/src/components/Accordion/AccordionTypes.tsx +0 -5
  275. package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +0 -8
  276. package/src/components/Button/ButtonTypes.tsx +0 -8
  277. package/src/components/DatePicker/DatePickerTypes.tsx +0 -5
  278. package/src/components/Form/FormTypes.tsx +0 -3
  279. package/src/components/Grid/GridTypes.tsx +0 -9
  280. package/src/components/Heading/HeadingTypes.tsx +0 -15
  281. package/src/components/Hero/HeroTypes.tsx +0 -20
  282. package/src/components/Icons/IconTypes.tsx +0 -83
  283. package/src/components/Image/ImageTypes.ts +0 -24
  284. package/src/components/Link/LinkTypes.tsx +0 -8
  285. package/src/components/List/ListTypes.tsx +0 -5
  286. package/src/components/Logo/LogoTypes.tsx +0 -56
  287. package/src/components/Notification/NotificationTypes.tsx +0 -5
  288. package/src/components/ProgressIndicator/ProgressIndicatorTypes.ts +0 -8
  289. package/src/components/Select/SelectTypes.tsx +0 -10
  290. package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +0 -5
  291. package/src/components/StatusBadge/StatusBadgeTypes.tsx +0 -5
  292. package/src/components/StructuredContent/StructuredContentTypes.tsx +0 -5
  293. package/src/components/Text/TextTypes.tsx +0 -6
  294. package/src/components/TextInput/TextInputTypes.tsx +0 -48
  295. package/src/components/Toggle/ToggleTypes.tsx +0 -4
  296. package/src/components/VideoPlayer/VideoPlayerTypes.tsx +0 -10
  297. package/src/helpers/enums.ts +0 -4
  298. package/src/utils/siteSections.ts +0 -10
@@ -0,0 +1,90 @@
1
+ import { Box, VStack } from "@chakra-ui/react";
2
+ import {
3
+ ArgsTable,
4
+ Canvas,
5
+ Description,
6
+ Meta,
7
+ Story,
8
+ } from "@storybook/addon-docs";
9
+
10
+ import Button from "../Button/Button";
11
+ import SkipNavigation from "./SkipNavigation";
12
+ import { getCategory } from "../../utils/componentCategories";
13
+
14
+ <Meta
15
+ title={getCategory("SkipNavigation")}
16
+ component={SkipNavigation}
17
+ parameters={{
18
+ jest: ["SkipNavigation.test.tsx"],
19
+ }}
20
+ argTypes={{
21
+ className: { control: false },
22
+ id: { control: false },
23
+ target: { control: false },
24
+ }}
25
+ />
26
+
27
+ # SkipNavigation
28
+
29
+ | Component Version | DS Version |
30
+ | ----------------- | ---------- |
31
+ | Added | `0.28.0` |
32
+ | Latest | `0.28.0` |
33
+
34
+ ## Table of Contents
35
+
36
+ - [Overview](#overview)
37
+ - [Component Props](#component-props)
38
+ - [Accessibility](#accessibility)
39
+
40
+ ## Overview
41
+
42
+ <Description of={SkipNavigation} />
43
+
44
+ **NOTE: In order to see the links in the `SkipNavigation` component, start by focusing
45
+ on the button below by tabbing or clicking on it. Then press "tab" to see the
46
+ first link and press "tab" again to see the second link. Hiding the links
47
+ intentional as the links should initially be visually hidden.**
48
+
49
+ ## Component Props
50
+
51
+ <Canvas>
52
+ <Story
53
+ name="SkipNavigation with Controls"
54
+ args={{
55
+ className: undefined,
56
+ id: "skip-nav",
57
+ target: "mainContent",
58
+ }}
59
+ >
60
+ {(args) => (
61
+ <>
62
+ <Button>Focus on me and then press "tab"</Button>
63
+ <SkipNavigation {...args} />
64
+ </>
65
+ )}
66
+ </Story>
67
+ </Canvas>
68
+
69
+ <ArgsTable story="SkipNavigation with Controls" />
70
+
71
+ ## Accessibility
72
+
73
+ To create a useable page for screen readers, a link or a navigational list of
74
+ links should be added before all the content on a page. The Reservoir Design
75
+ System (DS) achieves this through the `SkipNavigation` component which renders
76
+ a `<nav>` element with an `aria-label` of "Skip Navigation". Inside the `<nav>`
77
+ element, an unordered list is rendered.
78
+
79
+ The reason this is a navigation list of links is because the first main link
80
+ points to the anchor of the main content, in this case `"#mainContent"`. The
81
+ second link points to accessibility information on [NYPL.org/accessibility](https://nypl.org/accessibility).
82
+
83
+ See the [Skip Navigation accessibility guide](https://nypl.github.io/nypl-design-system/storybook-static/?path=/story/accessibility-guide-skip-navigation--page)
84
+ for more information on how to use this component with other DS components.
85
+
86
+ Resources:
87
+
88
+ - [WebAIM Skip Navigation Links](https://webaim.org/techniques/skipnav/)
89
+ - [WebAIM CSS in Action "Skip" links](https://webaim.org/techniques/css/invisiblecontent/#skipnavlinks)
90
+ - [CSS-Tricks A Deep Dive on Skipping to Content](https://css-tricks.com/a-deep-dive-on-skipping-to-content/)
@@ -0,0 +1,63 @@
1
+ import * as React from "react";
2
+ import { render, screen, within } from "@testing-library/react";
3
+ import { axe } from "jest-axe";
4
+ import renderer from "react-test-renderer";
5
+
6
+ import SkipNavigation from "./SkipNavigation";
7
+
8
+ describe("SkipNavigation Accessibility", () => {
9
+ it("passes axe accessibility test", async () => {
10
+ const { container } = render(<SkipNavigation />);
11
+ expect(await axe(container)).toHaveNoViolations();
12
+ });
13
+ });
14
+
15
+ describe("Label", () => {
16
+ it("renders a nav element with an unordered list", () => {
17
+ render(<SkipNavigation />);
18
+ const nav = screen.getByRole("navigation");
19
+
20
+ expect(nav).toBeInTheDocument();
21
+ expect(nav).toHaveAttribute("aria-label", "Skip Navigation");
22
+ // Chakra renders other lists so we only want the list we
23
+ // created within the nav element.
24
+ const { getByRole } = within(nav);
25
+ expect(getByRole("list")).toBeInTheDocument();
26
+ });
27
+
28
+ it("renders two links", () => {
29
+ render(<SkipNavigation />);
30
+ const links = screen.getAllByRole("link");
31
+
32
+ expect(links[0]).toHaveAttribute("href", "#mainContent");
33
+ expect(links[1]).toHaveAttribute(
34
+ "href",
35
+ "https://www.nypl.org/accessibility"
36
+ );
37
+ });
38
+
39
+ it("renders a custom main link target", () => {
40
+ render(<SkipNavigation target="customId" />);
41
+ const links = screen.getAllByRole("link");
42
+
43
+ expect(links[0]).toHaveAttribute("href", "customId");
44
+ });
45
+
46
+ it("Renders the UI snapshot correctly", () => {
47
+ const simple = renderer.create(<SkipNavigation />).toJSON();
48
+ const customTarget = renderer
49
+ .create(<SkipNavigation target="customId" />)
50
+ .toJSON();
51
+ const withChakraProps = renderer
52
+ .create(<SkipNavigation p="20px" color="ui.error.primary" />)
53
+ .toJSON();
54
+ const withOtherProps = renderer
55
+ .create(<SkipNavigation data-testid="props" />)
56
+ .toJSON();
57
+
58
+ expect(simple).toMatchSnapshot();
59
+ expect(customTarget).toMatchSnapshot();
60
+ expect(withChakraProps).toMatchSnapshot();
61
+ expect(withOtherProps).toMatchSnapshot();
62
+ });
63
+ });
@@ -0,0 +1,51 @@
1
+ import { Box, chakra, useStyleConfig } from "@chakra-ui/react";
2
+ import * as React from "react";
3
+
4
+ import Link from "../Link/Link";
5
+ import List from "../List/List";
6
+
7
+ interface SkipNavigationProps {
8
+ /** Additional CSS class name to render in the `nav` element. */
9
+ className?: string;
10
+ /** ID that other components can cross reference for accessibility purposes */
11
+ id?: string;
12
+ /** The anchor target for the main skip link. The default is "#mainContent". */
13
+ target?: string;
14
+ }
15
+
16
+ /**
17
+ * SkipNavigation is a component that is used to provide a navigational list of
18
+ * links. The first link is used to skip to the main content of the page using
19
+ * the `#mainContent` id, and the second link points to accessibility information
20
+ * on NYPL.org. These links are visually hidden but can be read by screenreaders.
21
+ */
22
+ export const SkipNavigation = chakra(
23
+ (props: React.PropsWithChildren<SkipNavigationProps>) => {
24
+ const { className, id, target = "#mainContent", ...rest } = props;
25
+ const styles = useStyleConfig("SkipNavigation");
26
+
27
+ return (
28
+ <Box
29
+ as="nav"
30
+ aria-label="Skip Navigation"
31
+ className={className}
32
+ id={id}
33
+ __css={styles}
34
+ {...rest}
35
+ >
36
+ <List inline noStyling type="ul">
37
+ <li>
38
+ <Link href={target}>Skip to Main Content</Link>
39
+ </li>
40
+ <li>
41
+ <Link href="https://www.nypl.org/accessibility">
42
+ Click to learn about accessibility at the Library
43
+ </Link>
44
+ </li>
45
+ </List>
46
+ </Box>
47
+ );
48
+ }
49
+ );
50
+
51
+ export default SkipNavigation;
@@ -0,0 +1,130 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Label Renders the UI snapshot correctly 1`] = `
4
+ <nav
5
+ aria-label="Skip Navigation"
6
+ className="css-1xdhyk6"
7
+ >
8
+ <ul
9
+ className="css-1xdhyk6"
10
+ >
11
+ <li>
12
+ <a
13
+ className="css-1xdhyk6"
14
+ href="#mainContent"
15
+ rel={null}
16
+ target={null}
17
+ >
18
+ Skip to Main Content
19
+ </a>
20
+ </li>
21
+ <li>
22
+ <a
23
+ className="css-1xdhyk6"
24
+ href="https://www.nypl.org/accessibility"
25
+ rel={null}
26
+ target={null}
27
+ >
28
+ Click to learn about accessibility at the Library
29
+ </a>
30
+ </li>
31
+ </ul>
32
+ </nav>
33
+ `;
34
+
35
+ exports[`Label Renders the UI snapshot correctly 2`] = `
36
+ <nav
37
+ aria-label="Skip Navigation"
38
+ className="css-1xdhyk6"
39
+ >
40
+ <ul
41
+ className="css-1xdhyk6"
42
+ >
43
+ <li>
44
+ <a
45
+ className="css-1xdhyk6"
46
+ href="customId"
47
+ rel={null}
48
+ target={null}
49
+ >
50
+ Skip to Main Content
51
+ </a>
52
+ </li>
53
+ <li>
54
+ <a
55
+ className="css-1xdhyk6"
56
+ href="https://www.nypl.org/accessibility"
57
+ rel={null}
58
+ target={null}
59
+ >
60
+ Click to learn about accessibility at the Library
61
+ </a>
62
+ </li>
63
+ </ul>
64
+ </nav>
65
+ `;
66
+
67
+ exports[`Label Renders the UI snapshot correctly 3`] = `
68
+ <nav
69
+ aria-label="Skip Navigation"
70
+ className="css-kle7zy"
71
+ >
72
+ <ul
73
+ className="css-1xdhyk6"
74
+ >
75
+ <li>
76
+ <a
77
+ className="css-1xdhyk6"
78
+ href="#mainContent"
79
+ rel={null}
80
+ target={null}
81
+ >
82
+ Skip to Main Content
83
+ </a>
84
+ </li>
85
+ <li>
86
+ <a
87
+ className="css-1xdhyk6"
88
+ href="https://www.nypl.org/accessibility"
89
+ rel={null}
90
+ target={null}
91
+ >
92
+ Click to learn about accessibility at the Library
93
+ </a>
94
+ </li>
95
+ </ul>
96
+ </nav>
97
+ `;
98
+
99
+ exports[`Label Renders the UI snapshot correctly 4`] = `
100
+ <nav
101
+ aria-label="Skip Navigation"
102
+ className="css-1xdhyk6"
103
+ data-testid="props"
104
+ >
105
+ <ul
106
+ className="css-1xdhyk6"
107
+ >
108
+ <li>
109
+ <a
110
+ className="css-1xdhyk6"
111
+ href="#mainContent"
112
+ rel={null}
113
+ target={null}
114
+ >
115
+ Skip to Main Content
116
+ </a>
117
+ </li>
118
+ <li>
119
+ <a
120
+ className="css-1xdhyk6"
121
+ href="https://www.nypl.org/accessibility"
122
+ rel={null}
123
+ target={null}
124
+ >
125
+ Click to learn about accessibility at the Library
126
+ </a>
127
+ </li>
128
+ </ul>
129
+ </nav>
130
+ `;
@@ -8,8 +8,6 @@ import {
8
8
  import { withDesign } from "storybook-addon-designs";
9
9
 
10
10
  import Heading from "../Heading/Heading";
11
- import { HeadingLevels } from "../Heading/HeadingTypes";
12
- import { GridGaps } from "../Grid/GridTypes";
13
11
  import SimpleGrid from "../Grid/SimpleGrid";
14
12
  import Slider from "./Slider";
15
13
  import { getCategory } from "../../utils/componentCategories";
@@ -76,7 +74,7 @@ import DSProvider from "../../theme/provider";
76
74
  | Component Version | DS Version |
77
75
  | ----------------- | ---------- |
78
76
  | Added | `0.25.4` |
79
- | Latest | `0.26.0` |
77
+ | Latest | `0.28.0` |
80
78
 
81
79
  ## Table of Contents
82
80
 
@@ -160,10 +158,10 @@ Resources:
160
158
  ### Slider Accessibility Implementation
161
159
 
162
160
  Chakra's `Slider` component is accessible and, as recommended, we pass in an
163
- `aria-label` to their `Slider` component. On top of that, the Reservoir Design
164
- System (DS) `Slider` component's `<label>` points to the `<input>` element
165
- which shows the current value. This `input` element also has its own
166
- `aria-label`. When the input box is hidden, the `for` attribute in the `label`
161
+ `aria-label` to their `Slider` component. On top of that, the Reservoir Design
162
+ System (DS) `Slider` component's `<label>` points to the `<input>` element
163
+ which shows the current value. This `input` element also has its own
164
+ `aria-label`. When the input box is hidden, the `for` attribute in the `label`
167
165
  element is removed.
168
166
 
169
167
  Note that Chakra handles its single slider thumb aria attributes: `aria-valuemin`,
@@ -233,11 +231,7 @@ Note that Chakra handles its two slider thumbs aria attributes: `aria-valuemin`,
233
231
 
234
232
  <Canvas>
235
233
  <DSProvider>
236
- <Heading
237
- id="heading-single-default"
238
- level={HeadingLevels.Four}
239
- text="Default State"
240
- />
234
+ <Heading id="heading-single-default" level="four" text="Default State" />
241
235
  <Slider
242
236
  defaultValue={50}
243
237
  helperText="Component helper text."
@@ -250,11 +244,7 @@ Note that Chakra handles its two slider thumbs aria attributes: `aria-valuemin`,
250
244
 
251
245
  <Canvas>
252
246
  <DSProvider>
253
- <Heading
254
- id="heading-single-errored"
255
- level={HeadingLevels.Four}
256
- text="Errored State"
257
- />
247
+ <Heading id="heading-single-errored" level="four" text="Errored State" />
258
248
  <Slider
259
249
  defaultValue={50}
260
250
  helperText="Component helper text."
@@ -268,11 +258,7 @@ Note that Chakra handles its two slider thumbs aria attributes: `aria-valuemin`,
268
258
 
269
259
  <Canvas>
270
260
  <DSProvider>
271
- <Heading
272
- id="heading-single-required"
273
- level={HeadingLevels.Four}
274
- text="Required State"
275
- />
261
+ <Heading id="heading-single-required" level="four" text="Required State" />
276
262
  <Slider
277
263
  defaultValue={50}
278
264
  helperText="Component helper text."
@@ -286,11 +272,7 @@ Note that Chakra handles its two slider thumbs aria attributes: `aria-valuemin`,
286
272
 
287
273
  <Canvas>
288
274
  <DSProvider>
289
- <Heading
290
- id="heading-single-disabled"
291
- level={HeadingLevels.Four}
292
- text="Disabled State"
293
- />
275
+ <Heading id="heading-single-disabled" level="four" text="Disabled State" />
294
276
  <Slider
295
277
  defaultValue={50}
296
278
  helperText="Component helper text."
@@ -308,11 +290,7 @@ To enable the Range Slider, set the `isRangeSlider` prop to true.
308
290
 
309
291
  <Canvas>
310
292
  <DSProvider>
311
- <Heading
312
- id="heading-range-default"
313
- level={HeadingLevels.Four}
314
- text="Default State"
315
- />
293
+ <Heading id="heading-range-default" level="four" text="Default State" />
316
294
  <Slider
317
295
  defaultValue={[25, 75]}
318
296
  helperText="Component helper text."
@@ -326,12 +304,8 @@ To enable the Range Slider, set the `isRangeSlider` prop to true.
326
304
 
327
305
  <Canvas>
328
306
  <DSProvider>
329
- <Heading
330
- id="heading-range-errored"
331
- level={HeadingLevels.Four}
332
- text="Errored State"
333
- />
334
- <SimpleGrid columns={1} gap={GridGaps.Large}>
307
+ <Heading id="heading-range-errored" level="four" text="Errored State" />
308
+ <SimpleGrid columns={1} gap="grid.l">
335
309
  <Slider
336
310
  defaultValue={[25, 75]}
337
311
  helperText="Component helper text."
@@ -364,11 +338,7 @@ To enable the Range Slider, set the `isRangeSlider` prop to true.
364
338
 
365
339
  <Canvas>
366
340
  <DSProvider>
367
- <Heading
368
- id="heading-range-required"
369
- level={HeadingLevels.Four}
370
- text="Required State"
371
- />
341
+ <Heading id="heading-range-required" level="four" text="Required State" />
372
342
  <Slider
373
343
  defaultValue={[25, 75]}
374
344
  helperText="Component helper text."
@@ -383,11 +353,7 @@ To enable the Range Slider, set the `isRangeSlider` prop to true.
383
353
 
384
354
  <Canvas>
385
355
  <DSProvider>
386
- <Heading
387
- id="heading-range-disabled"
388
- level={HeadingLevels.Four}
389
- text="Disabled State"
390
- />
356
+ <Heading id="heading-range-disabled" level="four" text="Disabled State" />
391
357
  <Slider
392
358
  defaultValue={[25, 75]}
393
359
  helperText="Component helper text."
@@ -409,10 +375,10 @@ input are hidden.
409
375
  <DSProvider>
410
376
  <Heading
411
377
  id="heading-single-labels"
412
- level={HeadingLevels.Four}
378
+ level="four"
413
379
  text="With and Without Component Labels"
414
380
  />
415
- <SimpleGrid columns={1} gap={GridGaps.ExtraLarge}>
381
+ <SimpleGrid columns={1} gap="grid.xl">
416
382
  <Slider
417
383
  defaultValue={50}
418
384
  helperText="Component helper text."
@@ -466,10 +432,10 @@ For the following examples, all labels are hidden.
466
432
  <DSProvider>
467
433
  <Heading
468
434
  id="heading-single-labels-inputs"
469
- level={HeadingLevels.Four}
435
+ level="four"
470
436
  text="With and Without Internal Inputs and Labels"
471
437
  />
472
- <SimpleGrid columns={1} gap={GridGaps.ExtraLarge}>
438
+ <SimpleGrid columns={1} gap="grid.xl">
473
439
  <Slider
474
440
  defaultValue={50}
475
441
  helperText="Component helper text."
@@ -516,7 +482,7 @@ In the following examples, all the labels are hidden.
516
482
 
517
483
  <Canvas>
518
484
  <DSProvider>
519
- <SimpleGrid columns={1} gap={GridGaps.ExtraLarge}>
485
+ <SimpleGrid columns={1} gap="grid.xl">
520
486
  <Slider
521
487
  defaultValue={[15, 75]}
522
488
  helperText="Component helper text."
@@ -320,8 +320,8 @@ describe("Slider", () => {
320
320
 
321
321
  it("gets the current value through the onChange callback function", () => {
322
322
  let currentValue = 0;
323
- function onChange(value) {
324
- currentValue = value;
323
+ function onChange(value: number | number[]) {
324
+ currentValue = value as number;
325
325
  }
326
326
 
327
327
  render(
@@ -17,8 +17,7 @@ import Label from "../Label/Label";
17
17
  import HelperErrorText, {
18
18
  HelperErrorTextType,
19
19
  } from "../HelperErrorText/HelperErrorText";
20
- import TextInput from "../TextInput/TextInput";
21
- import { TextInputTypes } from "../TextInput/TextInputTypes";
20
+ import TextInput, { TextInputTypes } from "../TextInput/TextInput";
22
21
 
23
22
  export interface SliderProps {
24
23
  /** Additional class name for the Slider component. */
@@ -121,9 +120,7 @@ export const Slider = chakra((props: React.PropsWithChildren<SliderProps>) => {
121
120
  if (isRangeSlider && currentValue[0] > currentValue[1]) {
122
121
  finalIsInvalid = true;
123
122
  }
124
- const footnote: HelperErrorTextType = finalIsInvalid
125
- ? invalidText
126
- : helperText;
123
+ const footnote = finalIsInvalid ? invalidText : helperText;
127
124
  const styles = useMultiStyleConfig("CustomSlider", {
128
125
  isDisabled,
129
126
  isInvalid: finalIsInvalid,
@@ -151,15 +148,16 @@ export const Slider = chakra((props: React.PropsWithChildren<SliderProps>) => {
151
148
  };
152
149
  // Props that the two `TextInput` components use.
153
150
  const textInputSharedProps = {
154
- attributes: { max, min },
155
151
  isDisabled,
156
152
  isInvalid: finalIsInvalid,
157
153
  isRequired,
154
+ max,
155
+ min,
158
156
  // Never show the label or helper text for the `TextInput` component.
159
157
  showHelperInvalidText: false,
160
158
  showLabel: false,
161
159
  step,
162
- type: TextInputTypes.number,
160
+ type: "number" as TextInputTypes,
163
161
  };
164
162
  /**
165
163
  * This returns either the "start" or "end" `TextInput` component. Note that
@@ -222,7 +220,7 @@ export const Slider = chakra((props: React.PropsWithChildren<SliderProps>) => {
222
220
  <TextInput
223
221
  id={`${id}-textInput-${type}`}
224
222
  labelText={updatedLabel}
225
- additionalStyles={{
223
+ __css={{
226
224
  ...styles.textInput,
227
225
  // Specific margins for each text input to
228
226
  // push the elements inside.
@@ -244,11 +242,11 @@ export const Slider = chakra((props: React.PropsWithChildren<SliderProps>) => {
244
242
  aria-label={
245
243
  !showLabel
246
244
  ? [`${labelText} - start value`, `${labelText} - end value`]
247
- : null
245
+ : undefined
248
246
  }
249
247
  // Both slider thumbs need values and should be in an array,
250
248
  // even if it's the same label.
251
- aria-labelledby={showLabel ? [`${id}-label`, `${id}-label`] : null}
249
+ aria-labelledby={showLabel ? [`${id}-label`, `${id}-label`] : undefined}
252
250
  value={currentValue as number[]}
253
251
  // Make the thumbs larger.
254
252
  size="lg"
@@ -262,7 +260,7 @@ export const Slider = chakra((props: React.PropsWithChildren<SliderProps>) => {
262
260
  </ChakraRangeSlider>
263
261
  ) : (
264
262
  <ChakraSlider
265
- aria-label={!showLabel ? labelText : null}
263
+ aria-label={!showLabel ? labelText : undefined}
266
264
  aria-labelledby={`${id}-label`}
267
265
  value={currentValue as number}
268
266
  // Make the thumb larger.
@@ -289,7 +287,7 @@ export const Slider = chakra((props: React.PropsWithChildren<SliderProps>) => {
289
287
  htmlFor={
290
288
  showBoxes
291
289
  ? `${id}-textInput-${isRangeSlider ? "start" : "end"}`
292
- : null
290
+ : ""
293
291
  }
294
292
  isRequired={showRequiredLabel && isRequired}
295
293
  >
@@ -856,7 +856,7 @@ exports[`Slider Range Slider renders the UI snapshot correctly 6`] = `
856
856
  >
857
857
  <label
858
858
  className="css-1xdhyk6"
859
- htmlFor={null}
859
+ htmlFor=""
860
860
  id="noVisibleValues-label"
861
861
  >
862
862
  Label
@@ -1139,7 +1139,6 @@ exports[`Slider Single Slider renders the UI snapshot correctly 1`] = `
1139
1139
  />
1140
1140
  </div>
1141
1141
  <div
1142
- aria-label={null}
1143
1142
  aria-labelledby="defaultSlider-label"
1144
1143
  aria-orientation="horizontal"
1145
1144
  aria-valuemax={100}
@@ -1269,7 +1268,6 @@ exports[`Slider Single Slider renders the UI snapshot correctly 2`] = `
1269
1268
  />
1270
1269
  </div>
1271
1270
  <div
1272
- aria-label={null}
1273
1271
  aria-labelledby="errored-label"
1274
1272
  aria-orientation="horizontal"
1275
1273
  aria-valuemax={100}
@@ -1403,7 +1401,6 @@ exports[`Slider Single Slider renders the UI snapshot correctly 3`] = `
1403
1401
  />
1404
1402
  </div>
1405
1403
  <div
1406
- aria-label={null}
1407
1404
  aria-labelledby="required-label"
1408
1405
  aria-orientation="horizontal"
1409
1406
  aria-valuemax={100}
@@ -1537,7 +1534,6 @@ exports[`Slider Single Slider renders the UI snapshot correctly 4`] = `
1537
1534
  </div>
1538
1535
  <div
1539
1536
  aria-disabled={true}
1540
- aria-label={null}
1541
1537
  aria-labelledby="disabled-label"
1542
1538
  aria-orientation="horizontal"
1543
1539
  aria-valuemax={100}
@@ -1722,7 +1718,7 @@ exports[`Slider Single Slider renders the UI snapshot correctly 6`] = `
1722
1718
  >
1723
1719
  <label
1724
1720
  className="css-1xdhyk6"
1725
- htmlFor={null}
1721
+ htmlFor=""
1726
1722
  id="noVisibleValues-label"
1727
1723
  >
1728
1724
  Label
@@ -1771,7 +1767,6 @@ exports[`Slider Single Slider renders the UI snapshot correctly 6`] = `
1771
1767
  />
1772
1768
  </div>
1773
1769
  <div
1774
- aria-label={null}
1775
1770
  aria-labelledby="noVisibleValues-label"
1776
1771
  aria-orientation="horizontal"
1777
1772
  aria-valuemax={100}
@@ -1958,7 +1953,6 @@ exports[`Slider Single Slider renders the UI snapshot correctly 8`] = `
1958
1953
  />
1959
1954
  </div>
1960
1955
  <div
1961
- aria-label={null}
1962
1956
  aria-labelledby="chakra-label"
1963
1957
  aria-orientation="horizontal"
1964
1958
  aria-valuemax={100}
@@ -2089,7 +2083,6 @@ exports[`Slider Single Slider renders the UI snapshot correctly 9`] = `
2089
2083
  />
2090
2084
  </div>
2091
2085
  <div
2092
- aria-label={null}
2093
2086
  aria-labelledby="props-label"
2094
2087
  aria-orientation="horizontal"
2095
2088
  aria-valuemax={100}