@nypl/design-system-react-components 0.25.13 → 0.27.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 (305) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/README.md +10 -10
  3. package/dist/components/Accordion/Accordion.d.ts +1 -1
  4. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  5. package/dist/components/Button/Button.d.ts +2 -2
  6. package/dist/components/Card/Card.d.ts +11 -9
  7. package/dist/components/Checkbox/Checkbox.d.ts +2 -2
  8. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +5 -4
  9. package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +1 -1
  10. package/dist/components/DatePicker/DatePicker.d.ts +5 -6
  11. package/dist/components/Fieldset/Fieldset.d.ts +5 -6
  12. package/dist/components/Form/Form.d.ts +6 -6
  13. package/dist/components/Grid/GridTypes.d.ts +7 -7
  14. package/dist/components/Grid/SimpleGrid.d.ts +1 -1
  15. package/dist/components/Heading/Heading.d.ts +1 -1
  16. package/dist/components/HelperErrorText/HelperErrorText.d.ts +9 -8
  17. package/dist/components/Hero/Hero.d.ts +2 -1
  18. package/dist/components/HorizontalRule/HorizontalRule.d.ts +2 -10
  19. package/dist/components/Icons/Icon.d.ts +2 -1
  20. package/dist/components/Image/Image.d.ts +2 -2
  21. package/dist/components/Label/Label.d.ts +7 -4
  22. package/dist/components/Link/Link.d.ts +1 -1
  23. package/dist/components/List/List.d.ts +11 -11
  24. package/dist/components/List/ListTypes.d.ts +1 -1
  25. package/dist/components/Logo/Logo.d.ts +2 -1
  26. package/dist/components/Logo/LogoSvgs.d.ts +2 -0
  27. package/dist/components/Logo/LogoTypes.d.ts +2 -0
  28. package/dist/components/Modal/Modal.d.ts +28 -8
  29. package/dist/components/Notification/Notification.d.ts +4 -4
  30. package/dist/components/Pagination/Pagination.d.ts +2 -2
  31. package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +3 -3
  32. package/dist/components/Radio/Radio.d.ts +4 -6
  33. package/dist/components/RadioGroup/RadioGroup.d.ts +12 -6
  34. package/dist/components/SearchBar/SearchBar.d.ts +4 -4
  35. package/dist/components/Select/Select.d.ts +10 -6
  36. package/dist/components/Select/SelectTypes.d.ts +4 -0
  37. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -3
  38. package/dist/components/Slider/Slider.d.ts +6 -4
  39. package/dist/components/StatusBadge/StatusBadge.d.ts +5 -1
  40. package/dist/components/StructuredContent/StructuredContent.d.ts +2 -2
  41. package/dist/components/Table/Table.d.ts +1 -1
  42. package/dist/components/Tabs/Tabs.d.ts +4 -3
  43. package/dist/components/Template/Template.d.ts +4 -3
  44. package/dist/components/Text/Text.d.ts +1 -1
  45. package/dist/components/TextInput/TextInput.d.ts +5 -5
  46. package/dist/components/Toggle/Toggle.d.ts +3 -4
  47. package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
  48. package/dist/design-system-react-components.cjs.development.js +1767 -1180
  49. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  50. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  51. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  52. package/dist/design-system-react-components.esm.js +1774 -1188
  53. package/dist/design-system-react-components.esm.js.map +1 -1
  54. package/dist/hooks/useCarouselStyles.d.ts +3 -2
  55. package/dist/hooks/useNYPLTheme.d.ts +12 -0
  56. package/dist/index.d.ts +5 -2
  57. package/dist/styles.css +1 -1
  58. package/dist/theme/components/button.d.ts +10 -2
  59. package/dist/theme/components/card.d.ts +42 -22
  60. package/dist/theme/components/checkbox.d.ts +5 -4
  61. package/dist/theme/components/checkboxGroup.d.ts +1 -1
  62. package/dist/theme/components/componentWrapper.d.ts +2 -2
  63. package/dist/theme/components/customTable.d.ts +84 -1
  64. package/dist/theme/components/fieldset.d.ts +4 -14
  65. package/dist/theme/components/global.d.ts +23 -17
  66. package/dist/theme/components/heading.d.ts +53 -0
  67. package/dist/theme/components/helperErrorText.d.ts +1 -0
  68. package/dist/theme/components/hero.d.ts +20 -14
  69. package/dist/theme/components/label.d.ts +9 -10
  70. package/dist/theme/components/list.d.ts +99 -9
  71. package/dist/theme/components/radio.d.ts +6 -4
  72. package/dist/theme/components/radioGroup.d.ts +1 -1
  73. package/dist/theme/components/select.d.ts +28 -5
  74. package/dist/theme/components/skeletonLoader.d.ts +2 -2
  75. package/dist/theme/components/slider.d.ts +6 -3
  76. package/dist/theme/components/structuredContent.d.ts +197 -0
  77. package/dist/theme/components/textInput.d.ts +18 -6
  78. package/dist/theme/components/toggle.d.ts +7 -4
  79. package/dist/theme/foundations/global.d.ts +2 -0
  80. package/dist/theme/foundations/radii.d.ts +1 -0
  81. package/dist/theme/foundations/spacing.d.ts +46 -43
  82. package/package.json +17 -19
  83. package/src/components/Accordion/Accordion.stories.mdx +9 -9
  84. package/src/components/Accordion/Accordion.test.tsx +21 -0
  85. package/src/components/Accordion/Accordion.tsx +13 -9
  86. package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +276 -27
  87. package/src/components/Autosuggest/Autosuggest.stories.mdx +4 -3
  88. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +21 -5
  89. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +52 -31
  90. package/src/components/Breadcrumbs/Breadcrumbs.tsx +8 -7
  91. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +211 -12
  92. package/src/components/Button/Button.stories.mdx +87 -23
  93. package/src/components/Button/Button.test.tsx +25 -0
  94. package/src/components/Button/Button.tsx +18 -7
  95. package/src/components/Button/__snapshots__/Button.test.tsx.snap +27 -7
  96. package/src/components/Card/Card.stories.mdx +287 -194
  97. package/src/components/Card/Card.test.tsx +102 -0
  98. package/src/components/Card/Card.tsx +73 -32
  99. package/src/components/Card/__snapshots__/Card.test.tsx.snap +196 -36
  100. package/src/components/Chakra/Grid.stories.mdx +4 -4
  101. package/src/components/Checkbox/Checkbox.stories.mdx +62 -10
  102. package/src/components/Checkbox/Checkbox.test.tsx +32 -9
  103. package/src/components/Checkbox/Checkbox.tsx +20 -15
  104. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +134 -7
  105. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +65 -17
  106. package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +137 -81
  107. package/src/components/CheckboxGroup/CheckboxGroup.tsx +31 -21
  108. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +332 -97
  109. package/src/components/ComponentWrapper/ComponentWrapper.test.tsx +12 -0
  110. package/src/components/ComponentWrapper/ComponentWrapper.tsx +39 -41
  111. package/src/components/ComponentWrapper/__snapshots__/ComponentWrapper.test.tsx.snap +47 -34
  112. package/src/components/DatePicker/DatePicker.stories.mdx +63 -27
  113. package/src/components/DatePicker/DatePicker.test.tsx +89 -13
  114. package/src/components/DatePicker/DatePicker.tsx +62 -56
  115. package/src/components/DatePicker/_DatePicker.scss +71 -13
  116. package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +250 -206
  117. package/src/components/Fieldset/Fieldset.stories.mdx +33 -3
  118. package/src/components/Fieldset/Fieldset.test.tsx +58 -28
  119. package/src/components/Fieldset/Fieldset.tsx +35 -30
  120. package/src/components/Fieldset/__snapshots__/Fieldset.test.tsx.snap +40 -19
  121. package/src/components/Form/Form.stories.mdx +72 -39
  122. package/src/components/Form/Form.test.tsx +58 -15
  123. package/src/components/Form/Form.tsx +89 -67
  124. package/src/components/Form/__snapshots__/Form.test.tsx.snap +83 -5
  125. package/src/components/Grid/GridTypes.tsx +7 -7
  126. package/src/components/Grid/SimpleGrid.stories.mdx +34 -6
  127. package/src/components/Grid/SimpleGrid.test.tsx +9 -0
  128. package/src/components/Grid/SimpleGrid.tsx +29 -20
  129. package/src/components/Grid/__snapshots__/SimpleGrid.test.tsx.snap +16 -1
  130. package/src/components/Heading/Heading.stories.mdx +36 -3
  131. package/src/components/Heading/Heading.test.tsx +10 -0
  132. package/src/components/Heading/Heading.tsx +56 -50
  133. package/src/components/Heading/__snapshots__/Heading.test.tsx.snap +26 -7
  134. package/src/components/HelperErrorText/HelperErrorText.stories.mdx +64 -42
  135. package/src/components/HelperErrorText/HelperErrorText.test.tsx +15 -0
  136. package/src/components/HelperErrorText/HelperErrorText.tsx +40 -35
  137. package/src/components/HelperErrorText/__snapshots__/HelperErrorText.test.tsx.snap +35 -4
  138. package/src/components/Hero/Hero.stories.mdx +125 -95
  139. package/src/components/Hero/Hero.test.tsx +33 -0
  140. package/src/components/Hero/Hero.tsx +135 -126
  141. package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +89 -17
  142. package/src/components/HorizontalRule/HorizontalRule.stories.mdx +26 -4
  143. package/src/components/HorizontalRule/HorizontalRule.test.tsx +9 -19
  144. package/src/components/HorizontalRule/HorizontalRule.tsx +9 -26
  145. package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +18 -5
  146. package/src/components/Icons/Icon.stories.mdx +31 -6
  147. package/src/components/Icons/Icon.test.tsx +38 -0
  148. package/src/components/Icons/Icon.tsx +93 -76
  149. package/src/components/Icons/__snapshots__/Icon.test.tsx.snap +129 -0
  150. package/src/components/Image/Image.stories.mdx +29 -5
  151. package/src/components/Image/Image.test.tsx +8 -0
  152. package/src/components/Image/Image.tsx +38 -26
  153. package/src/components/Image/__snapshots__/Image.test.tsx.snap +24 -8
  154. package/src/components/Label/Label.stories.mdx +42 -20
  155. package/src/components/Label/Label.test.tsx +42 -17
  156. package/src/components/Label/Label.tsx +22 -13
  157. package/src/components/Label/__snapshots__/Label.test.tsx.snap +19 -15
  158. package/src/components/Link/Link.stories.mdx +25 -15
  159. package/src/components/Link/Link.test.tsx +21 -22
  160. package/src/components/Link/Link.tsx +8 -8
  161. package/src/components/Link/__snapshots__/Link.test.tsx.snap +37 -11
  162. package/src/components/List/List.stories.mdx +75 -40
  163. package/src/components/List/List.test.tsx +67 -19
  164. package/src/components/List/List.tsx +38 -25
  165. package/src/components/List/ListTypes.tsx +1 -1
  166. package/src/components/List/__snapshots__/List.test.tsx.snap +110 -8
  167. package/src/components/Logo/Logo.stories.mdx +30 -6
  168. package/src/components/Logo/Logo.test.tsx +17 -0
  169. package/src/components/Logo/Logo.tsx +18 -6
  170. package/src/components/Logo/LogoSvgs.tsx +4 -0
  171. package/src/components/Logo/LogoTypes.tsx +2 -0
  172. package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +73 -2
  173. package/src/components/Modal/Modal.stories.mdx +256 -136
  174. package/src/components/Modal/Modal.test.tsx +151 -9
  175. package/src/components/Modal/Modal.tsx +140 -20
  176. package/src/components/Modal/__snapshots__/Modal.test.tsx.snap +25 -0
  177. package/src/components/Notification/Notification.stories.mdx +25 -1
  178. package/src/components/Notification/Notification.test.tsx +23 -0
  179. package/src/components/Notification/Notification.tsx +46 -44
  180. package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +158 -29
  181. package/src/components/Pagination/Pagination.stories.mdx +25 -6
  182. package/src/components/Pagination/Pagination.test.tsx +25 -0
  183. package/src/components/Pagination/Pagination.tsx +6 -6
  184. package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +244 -27
  185. package/src/components/Placeholder/Placeholder.tsx +3 -1
  186. package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +76 -10
  187. package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +81 -11
  188. package/src/components/ProgressIndicator/ProgressIndicator.tsx +17 -9
  189. package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +101 -14
  190. package/src/components/Radio/Radio.stories.mdx +64 -12
  191. package/src/components/Radio/Radio.test.tsx +28 -8
  192. package/src/components/Radio/Radio.tsx +66 -63
  193. package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +103 -6
  194. package/src/components/RadioGroup/RadioGroup.stories.mdx +224 -89
  195. package/src/components/RadioGroup/RadioGroup.test.tsx +122 -62
  196. package/src/components/RadioGroup/RadioGroup.tsx +106 -100
  197. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +1236 -1020
  198. package/src/components/SearchBar/SearchBar.stories.mdx +101 -36
  199. package/src/components/SearchBar/{SearchBar.Test.tsx → SearchBar.test.tsx} +46 -4
  200. package/src/components/SearchBar/SearchBar.tsx +17 -8
  201. package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +1039 -0
  202. package/src/components/Select/Select.stories.mdx +128 -49
  203. package/src/components/Select/Select.test.tsx +63 -16
  204. package/src/components/Select/Select.tsx +131 -92
  205. package/src/components/Select/SelectTypes.tsx +5 -0
  206. package/src/components/Select/__snapshots__/Select.test.tsx.snap +765 -425
  207. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +42 -10
  208. package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +8 -0
  209. package/src/components/SkeletonLoader/SkeletonLoader.tsx +76 -72
  210. package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +169 -10
  211. package/src/components/Slider/Slider.stories.mdx +91 -42
  212. package/src/components/Slider/Slider.test.tsx +65 -17
  213. package/src/components/Slider/Slider.tsx +26 -19
  214. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +403 -226
  215. package/src/components/StatusBadge/StatusBadge.stories.mdx +19 -1
  216. package/src/components/StatusBadge/StatusBadge.test.tsx +16 -0
  217. package/src/components/StatusBadge/StatusBadge.tsx +25 -20
  218. package/src/components/StatusBadge/__snapshots__/StatusBadge.test.tsx.snap +22 -3
  219. package/src/components/StructuredContent/StructuredContent.stories.mdx +131 -12
  220. package/src/components/StructuredContent/StructuredContent.test.tsx +34 -0
  221. package/src/components/StructuredContent/StructuredContent.tsx +80 -75
  222. package/src/components/StructuredContent/__snapshots__/StructuredContent.test.tsx.snap +102 -17
  223. package/src/components/StyleGuide/Bidirectionality.stories.mdx +5 -5
  224. package/src/components/StyleGuide/Breakpoints.stories.mdx +6 -6
  225. package/src/components/StyleGuide/Buttons.stories.mdx +2 -12
  226. package/src/components/StyleGuide/ColorCard.tsx +1 -1
  227. package/src/components/StyleGuide/Colors.stories.mdx +1 -2
  228. package/src/components/StyleGuide/DesignTokens.stories.mdx +56 -26
  229. package/src/components/StyleGuide/Forms.stories.mdx +27 -12
  230. package/src/components/StyleGuide/Iconography.stories.mdx +2 -12
  231. package/src/components/StyleGuide/Spacing.stories.mdx +80 -41
  232. package/src/components/StyleGuide/Typography.stories.mdx +30 -21
  233. package/src/components/Table/Table.stories.mdx +38 -11
  234. package/src/components/Table/Table.test.tsx +15 -0
  235. package/src/components/Table/Table.tsx +7 -7
  236. package/src/components/Table/__snapshots__/Table.test.tsx.snap +408 -5
  237. package/src/components/Tabs/Tabs.stories.mdx +52 -3
  238. package/src/components/Tabs/Tabs.test.tsx +16 -0
  239. package/src/components/Tabs/Tabs.tsx +10 -6
  240. package/src/components/Tabs/__snapshots__/Tabs.test.tsx.snap +394 -5
  241. package/src/components/Template/Template.stories.mdx +47 -43
  242. package/src/components/Template/Template.test.tsx +33 -0
  243. package/src/components/Template/Template.tsx +65 -60
  244. package/src/components/Template/__snapshots__/Template.test.tsx.snap +191 -20
  245. package/src/components/Text/Text.stories.mdx +20 -1
  246. package/src/components/Text/Text.test.tsx +12 -0
  247. package/src/components/Text/Text.tsx +6 -4
  248. package/src/components/Text/__snapshots__/Text.test.tsx.snap +21 -4
  249. package/src/components/TextInput/TextInput.stories.mdx +65 -19
  250. package/src/components/TextInput/TextInput.test.tsx +42 -28
  251. package/src/components/TextInput/TextInput.tsx +121 -113
  252. package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +96 -73
  253. package/src/components/Toggle/Toggle.stories.mdx +80 -22
  254. package/src/components/Toggle/Toggle.test.tsx +27 -9
  255. package/src/components/Toggle/Toggle.tsx +22 -18
  256. package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +128 -5
  257. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +52 -4
  258. package/src/components/VideoPlayer/VideoPlayer.test.tsx +23 -0
  259. package/src/components/VideoPlayer/VideoPlayer.tsx +133 -126
  260. package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +81 -39
  261. package/src/docs/Chakra.stories.mdx +50 -9
  262. package/src/docs/Welcome.stories.mdx +160 -41
  263. package/src/hooks/useCarouselStyles.stories.mdx +22 -2
  264. package/src/hooks/useCarouselStyles.ts +3 -2
  265. package/src/hooks/useNYPLTheme.stories.mdx +101 -0
  266. package/src/hooks/useNYPLTheme.ts +30 -6
  267. package/src/hooks/useWindowSize.stories.mdx +23 -0
  268. package/src/index.ts +5 -2
  269. package/src/styles/base/_place-holder.scss +1 -1
  270. package/src/styles.scss +0 -1
  271. package/src/theme/components/button.ts +15 -7
  272. package/src/theme/components/card.ts +30 -19
  273. package/src/theme/components/checkbox.ts +10 -8
  274. package/src/theme/components/checkboxGroup.ts +1 -1
  275. package/src/theme/components/componentWrapper.ts +2 -2
  276. package/src/theme/components/customTable.ts +39 -31
  277. package/src/theme/components/fieldset.ts +1 -2
  278. package/src/theme/components/global.ts +25 -20
  279. package/src/theme/components/heading.ts +1 -1
  280. package/src/theme/components/helperErrorText.ts +1 -0
  281. package/src/theme/components/hero.ts +13 -15
  282. package/src/theme/components/label.ts +4 -3
  283. package/src/theme/components/list.ts +73 -66
  284. package/src/theme/components/notification.ts +2 -2
  285. package/src/theme/components/radio.ts +9 -9
  286. package/src/theme/components/radioGroup.ts +1 -1
  287. package/src/theme/components/select.ts +31 -22
  288. package/src/theme/components/skeletonLoader.ts +3 -3
  289. package/src/theme/components/slider.ts +8 -7
  290. package/src/theme/components/statusBadge.ts +2 -2
  291. package/src/theme/components/structuredContent.ts +66 -1
  292. package/src/theme/components/tabs.ts +2 -2
  293. package/src/theme/components/template.ts +9 -9
  294. package/src/theme/components/textInput.ts +13 -12
  295. package/src/theme/components/toggle.ts +17 -10
  296. package/src/theme/components/videoPlayer.ts +1 -1
  297. package/src/theme/foundations/colors.ts +1 -1
  298. package/src/theme/foundations/radii.ts +1 -0
  299. package/src/theme/foundations/spacing.ts +70 -22
  300. package/src/theme/foundations/typography.ts +2 -2
  301. package/src/utils/componentCategories.ts +1 -2
  302. package/dist/components/SearchBar/SearchBar.Test.d.ts +0 -1
  303. package/dist/helpers/generateUUID.d.ts +0 -1
  304. package/src/components/Modal/_Modal.scss +0 -18
  305. package/src/helpers/generateUUID.tsx +0 -5
@@ -1,10 +1,11 @@
1
- import * as React from "react";
2
1
  import {
3
2
  Breadcrumb as ChakraBreadcrumb,
4
3
  BreadcrumbItem,
5
4
  BreadcrumbLink,
5
+ chakra,
6
6
  useStyleConfig,
7
7
  } from "@chakra-ui/react";
8
+ import * as React from "react";
8
9
 
9
10
  import Icon from "../Icons/Icon";
10
11
  import {
@@ -13,7 +14,6 @@ import {
13
14
  IconSizes,
14
15
  IconTypes,
15
16
  } from "../Icons/IconTypes";
16
- import generateUUID from "../../helpers/generateUUID";
17
17
  import { BreadcrumbsTypes } from "./BreadcrumbsTypes";
18
18
  import { getVariant } from "../../utils/utils";
19
19
 
@@ -64,13 +64,14 @@ const getElementsFromData = (data, breadcrumbsID) => {
64
64
  return breadcrumbItems;
65
65
  };
66
66
 
67
- function Breadcrumbs(props: React.PropsWithChildren<BreadcrumbProps>) {
67
+ export const Breadcrumbs = chakra((props: BreadcrumbProps) => {
68
68
  const {
69
69
  additionalStyles = {},
70
70
  breadcrumbsData,
71
71
  breadcrumbsType,
72
72
  className,
73
- id = generateUUID(),
73
+ id,
74
+ ...rest
74
75
  } = props;
75
76
  const variant = getVariant(breadcrumbsType, BreadcrumbsTypes);
76
77
 
@@ -83,18 +84,18 @@ function Breadcrumbs(props: React.PropsWithChildren<BreadcrumbProps>) {
83
84
  const styles = useStyleConfig("Breadcrumb", { variant });
84
85
  const finalStyles = { ...styles, ...additionalStyles };
85
86
  const breadcrumbItems = getElementsFromData(breadcrumbsData, id);
86
- const ariaAttrs = { "aria-label": "Breadcrumb" };
87
87
 
88
88
  return (
89
89
  <ChakraBreadcrumb
90
+ aria-label="Breadcrumb"
90
91
  className={className}
91
92
  id={id}
92
- {...ariaAttrs}
93
93
  __css={finalStyles}
94
+ {...rest}
94
95
  >
95
96
  {breadcrumbItems}
96
97
  </ChakraBreadcrumb>
97
98
  );
98
- }
99
+ });
99
100
 
100
101
  export default Breadcrumbs;
@@ -3,7 +3,7 @@
3
3
  exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 1`] = `
4
4
  <nav
5
5
  aria-label="Breadcrumb"
6
- className="chakra-breadcrumb css-0"
6
+ className="chakra-breadcrumb css-1xdhyk6"
7
7
  id="breadcrumbs-test"
8
8
  >
9
9
  <ol
@@ -38,7 +38,7 @@ exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 1`] = `
38
38
  >
39
39
  <svg
40
40
  aria-hidden={true}
41
- className="chakra-icon breadcrumbs-icon css-onkibi"
41
+ className="chakra-icon breadcrumbs-icon css-1grhd2q"
42
42
  focusable={false}
43
43
  id="breadcrumbs-test__backarrow"
44
44
  role="img"
@@ -102,7 +102,7 @@ exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 1`] = `
102
102
  exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 2`] = `
103
103
  <nav
104
104
  aria-label="Breadcrumb"
105
- className="chakra-breadcrumb css-0"
105
+ className="chakra-breadcrumb css-1xdhyk6"
106
106
  id="breadcrumbs-test"
107
107
  >
108
108
  <ol
@@ -137,7 +137,7 @@ exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 2`] = `
137
137
  >
138
138
  <svg
139
139
  aria-hidden={true}
140
- className="chakra-icon breadcrumbs-icon css-onkibi"
140
+ className="chakra-icon breadcrumbs-icon css-1grhd2q"
141
141
  focusable={false}
142
142
  id="breadcrumbs-test__backarrow"
143
143
  role="img"
@@ -201,7 +201,7 @@ exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 2`] = `
201
201
  exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 3`] = `
202
202
  <nav
203
203
  aria-label="Breadcrumb"
204
- className="chakra-breadcrumb css-0"
204
+ className="chakra-breadcrumb css-1xdhyk6"
205
205
  id="breadcrumbs-test"
206
206
  >
207
207
  <ol
@@ -236,7 +236,7 @@ exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 3`] = `
236
236
  >
237
237
  <svg
238
238
  aria-hidden={true}
239
- className="chakra-icon breadcrumbs-icon css-onkibi"
239
+ className="chakra-icon breadcrumbs-icon css-1grhd2q"
240
240
  focusable={false}
241
241
  id="breadcrumbs-test__backarrow"
242
242
  role="img"
@@ -300,7 +300,7 @@ exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 3`] = `
300
300
  exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 4`] = `
301
301
  <nav
302
302
  aria-label="Breadcrumb"
303
- className="chakra-breadcrumb css-0"
303
+ className="chakra-breadcrumb css-1xdhyk6"
304
304
  id="breadcrumbs-test"
305
305
  >
306
306
  <ol
@@ -335,7 +335,7 @@ exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 4`] = `
335
335
  >
336
336
  <svg
337
337
  aria-hidden={true}
338
- className="chakra-icon breadcrumbs-icon css-onkibi"
338
+ className="chakra-icon breadcrumbs-icon css-1grhd2q"
339
339
  focusable={false}
340
340
  id="breadcrumbs-test__backarrow"
341
341
  role="img"
@@ -399,7 +399,7 @@ exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 4`] = `
399
399
  exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 5`] = `
400
400
  <nav
401
401
  aria-label="Breadcrumb"
402
- className="chakra-breadcrumb css-0"
402
+ className="chakra-breadcrumb css-1xdhyk6"
403
403
  id="breadcrumbs-test"
404
404
  >
405
405
  <ol
@@ -434,7 +434,7 @@ exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 5`] = `
434
434
  >
435
435
  <svg
436
436
  aria-hidden={true}
437
- className="chakra-icon breadcrumbs-icon css-onkibi"
437
+ className="chakra-icon breadcrumbs-icon css-1grhd2q"
438
438
  focusable={false}
439
439
  id="breadcrumbs-test__backarrow"
440
440
  role="img"
@@ -498,7 +498,7 @@ exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 5`] = `
498
498
  exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 6`] = `
499
499
  <nav
500
500
  aria-label="Breadcrumb"
501
- className="chakra-breadcrumb css-1f2fw9u"
501
+ className="chakra-breadcrumb css-ruvqk2"
502
502
  id="breadcrumbs-test"
503
503
  >
504
504
  <ol
@@ -533,7 +533,206 @@ exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 6`] = `
533
533
  >
534
534
  <svg
535
535
  aria-hidden={true}
536
- className="chakra-icon breadcrumbs-icon css-onkibi"
536
+ className="chakra-icon breadcrumbs-icon css-1grhd2q"
537
+ focusable={false}
538
+ id="breadcrumbs-test__backarrow"
539
+ role="img"
540
+ title="arrow icon"
541
+ viewBox="0 0 24 24"
542
+ >
543
+ <g
544
+ stroke="currentColor"
545
+ strokeWidth="1.5"
546
+ >
547
+ <path
548
+ d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
549
+ fill="none"
550
+ strokeLinecap="round"
551
+ />
552
+ <path
553
+ d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
554
+ fill="currentColor"
555
+ strokeLinecap="round"
556
+ />
557
+ <circle
558
+ cx="12"
559
+ cy="12"
560
+ fill="none"
561
+ r="11.25"
562
+ strokeMiterlimit="10"
563
+ />
564
+ </g>
565
+ </svg>
566
+ <span
567
+ className="breadcrumb-label"
568
+ >
569
+ string2
570
+ </span>
571
+ </a>
572
+ <span
573
+ className="css-t4q1nq"
574
+ role="presentation"
575
+ >
576
+ /
577
+ </span>
578
+ </li>
579
+ <li
580
+ className="chakra-breadcrumb__list-item css-18biwo"
581
+ >
582
+ <span
583
+ aria-current="page"
584
+ className="chakra-breadcrumb__link css-0"
585
+ >
586
+ <span
587
+ className="breadcrumb-label"
588
+ >
589
+ string3
590
+ </span>
591
+ </span>
592
+ </li>
593
+ </ol>
594
+ </nav>
595
+ `;
596
+
597
+ exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 7`] = `
598
+ <nav
599
+ aria-label="Breadcrumb"
600
+ className="chakra-breadcrumb css-1t0bvx9"
601
+ id="breadcrumbs-test"
602
+ >
603
+ <ol
604
+ className="chakra-breadcrumb__list css-0"
605
+ >
606
+ <li
607
+ className="chakra-breadcrumb__list-item css-18biwo"
608
+ >
609
+ <a
610
+ className="chakra-breadcrumb__link css-0"
611
+ href="#string1"
612
+ >
613
+ <span
614
+ className="breadcrumb-label"
615
+ >
616
+ string1
617
+ </span>
618
+ </a>
619
+ <span
620
+ className="css-t4q1nq"
621
+ role="presentation"
622
+ >
623
+ /
624
+ </span>
625
+ </li>
626
+ <li
627
+ className="chakra-breadcrumb__list-item css-18biwo"
628
+ >
629
+ <a
630
+ className="chakra-breadcrumb__link css-0"
631
+ href="#string2"
632
+ >
633
+ <svg
634
+ aria-hidden={true}
635
+ className="chakra-icon breadcrumbs-icon css-1grhd2q"
636
+ focusable={false}
637
+ id="breadcrumbs-test__backarrow"
638
+ role="img"
639
+ title="arrow icon"
640
+ viewBox="0 0 24 24"
641
+ >
642
+ <g
643
+ stroke="currentColor"
644
+ strokeWidth="1.5"
645
+ >
646
+ <path
647
+ d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
648
+ fill="none"
649
+ strokeLinecap="round"
650
+ />
651
+ <path
652
+ d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
653
+ fill="currentColor"
654
+ strokeLinecap="round"
655
+ />
656
+ <circle
657
+ cx="12"
658
+ cy="12"
659
+ fill="none"
660
+ r="11.25"
661
+ strokeMiterlimit="10"
662
+ />
663
+ </g>
664
+ </svg>
665
+ <span
666
+ className="breadcrumb-label"
667
+ >
668
+ string2
669
+ </span>
670
+ </a>
671
+ <span
672
+ className="css-t4q1nq"
673
+ role="presentation"
674
+ >
675
+ /
676
+ </span>
677
+ </li>
678
+ <li
679
+ className="chakra-breadcrumb__list-item css-18biwo"
680
+ >
681
+ <span
682
+ aria-current="page"
683
+ className="chakra-breadcrumb__link css-0"
684
+ >
685
+ <span
686
+ className="breadcrumb-label"
687
+ >
688
+ string3
689
+ </span>
690
+ </span>
691
+ </li>
692
+ </ol>
693
+ </nav>
694
+ `;
695
+
696
+ exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 8`] = `
697
+ <nav
698
+ aria-label="Breadcrumb"
699
+ className="chakra-breadcrumb css-1xdhyk6"
700
+ data-testid="testid"
701
+ id="breadcrumbs-test"
702
+ >
703
+ <ol
704
+ className="chakra-breadcrumb__list css-0"
705
+ >
706
+ <li
707
+ className="chakra-breadcrumb__list-item css-18biwo"
708
+ >
709
+ <a
710
+ className="chakra-breadcrumb__link css-0"
711
+ href="#string1"
712
+ >
713
+ <span
714
+ className="breadcrumb-label"
715
+ >
716
+ string1
717
+ </span>
718
+ </a>
719
+ <span
720
+ className="css-t4q1nq"
721
+ role="presentation"
722
+ >
723
+ /
724
+ </span>
725
+ </li>
726
+ <li
727
+ className="chakra-breadcrumb__list-item css-18biwo"
728
+ >
729
+ <a
730
+ className="chakra-breadcrumb__link css-0"
731
+ href="#string2"
732
+ >
733
+ <svg
734
+ aria-hidden={true}
735
+ className="chakra-icon breadcrumbs-icon css-1grhd2q"
537
736
  focusable={false}
538
737
  id="breadcrumbs-test__backarrow"
539
738
  role="img"
@@ -40,7 +40,7 @@ export const enumValues = getStorybookEnumValues(ButtonTypes, "ButtonTypes");
40
40
  buttonText: { description: "Only used for Storybook" },
41
41
  buttonType: {
42
42
  control: { type: "select" },
43
- table: { defaultValue: { summary: "ButtonType.Primary" } },
43
+ table: { defaultValue: { summary: "ButtonTypes.Primary" } },
44
44
  options: enumValues.options,
45
45
  },
46
46
  className: { control: false },
@@ -65,7 +65,19 @@ export const enumValues = getStorybookEnumValues(ButtonTypes, "ButtonTypes");
65
65
  | Component Version | DS Version |
66
66
  | ----------------- | ---------- |
67
67
  | Added | `0.0.4` |
68
- | Latest | `0.25.9` |
68
+ | Latest | `0.26.0` |
69
+
70
+ ## Table of Contents
71
+
72
+ - [Overview](#overview)
73
+ - [Component Props](#component-props)
74
+ - [Accessibility](#accessibility)
75
+ - [Button Groups](#button-groups)
76
+ - [With Icons](#with-icons)
77
+ - [Patterns](#patterns)
78
+ - [Other Examples](#other-examples)
79
+
80
+ ## Overview
69
81
 
70
82
  <Description of={Button} />
71
83
 
@@ -83,6 +95,8 @@ that can be rendered.
83
95
  When one and only one `Icon` component is passed inside a `Button` component with
84
96
  no text, it will automatically be configured to use the `"iconOnly"` type.
85
97
 
98
+ ## Component Props
99
+
86
100
  <Canvas withToolbar>
87
101
  <Story
88
102
  name="Button with Controls"
@@ -103,7 +117,17 @@ no text, it will automatically be configured to use the `"iconOnly"` type.
103
117
  }}
104
118
  >
105
119
  {(args) => (
106
- <Button {...args} buttonType={enumValues.getValue(args.buttonType)}>
120
+ <Button
121
+ additionalStyles={args.additionalStyles}
122
+ attributes={args.attributes}
123
+ buttonType={enumValues.getValue(args.buttonType)}
124
+ className={args.className}
125
+ id={args.id}
126
+ isDisabled={args.isDisabled}
127
+ mouseDown={args.mouseDown}
128
+ onClick={args.onClick}
129
+ type={args.type}
130
+ >
107
131
  {args.displayIcon && args.displayIconLeft && (
108
132
  <Icon
109
133
  name={args.iconType}
@@ -126,6 +150,21 @@ no text, it will automatically be configured to use the `"iconOnly"` type.
126
150
 
127
151
  <ArgsTable story="Button with Controls" />
128
152
 
153
+ ## Accessibility
154
+
155
+ The Reservoir `Button` component renders an HTML `<button>` element that is
156
+ accessible. `Button`s should be used to perform user actions or submit forms,
157
+ never to link and go to another page. For `Button`s without text and only an
158
+ icon, make sure to pass an `aria-label` value to the `Button`. `Button`s cannot
159
+ have images of text.
160
+
161
+ Resources:
162
+
163
+ - [W3C WAI ARIA Button](https://www.w3.org/TR/wai-aria-practices-1.1/#button)
164
+ - [W3C WAI ARIA Button Examples](https://www.w3.org/TR/wai-aria-practices-1.1/examples/button/button.html)
165
+ - [MDN ARIA: button role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role)
166
+ - [Chakra UI Button](https://chakra-ui.com/docs/components/form/button)
167
+
129
168
  ## Button Groups
130
169
 
131
170
  Primary and secondary buttons should be grouped like in the following example.
@@ -135,8 +174,12 @@ be used to wrap the `Button` component.
135
174
  <Canvas>
136
175
  <Story name="Button Groups">
137
176
  <ButtonGroup>
138
- <Button buttonType={ButtonTypes.Secondary}>Button</Button>
139
- <Button buttonType={ButtonTypes.Primary}>Submit</Button>
177
+ <Button buttonType={ButtonTypes.Secondary} id="group-1">
178
+ Button
179
+ </Button>
180
+ <Button buttonType={ButtonTypes.Primary} id="group-2">
181
+ Submit
182
+ </Button>
140
183
  </ButtonGroup>
141
184
  </Story>
142
185
  </Canvas>
@@ -149,8 +192,8 @@ to see the full list of icon and logo names that can be rendered.
149
192
 
150
193
  <Canvas>
151
194
  <Story name="With Icon">
152
- <VStack align="left" width="150px">
153
- <Button>
195
+ <VStack align="left" spacing="input.group.button.vstack" width="150px">
196
+ <Button id="icon-1">
154
197
  <Icon
155
198
  name={IconNames.Search}
156
199
  align={IconAlign.Left}
@@ -158,7 +201,7 @@ to see the full list of icon and logo names that can be rendered.
158
201
  />
159
202
  Button Text
160
203
  </Button>
161
- <Button>
204
+ <Button id="icon-2">
162
205
  Button Text
163
206
  <Icon
164
207
  name={IconNames.Search}
@@ -175,7 +218,7 @@ The icon can be placed to the left or the right of the button text.
175
218
  <Canvas>
176
219
  <DSProvider>
177
220
  <ButtonGroup>
178
- <Button buttonType={ButtonTypes.Secondary}>
221
+ <Button buttonType={ButtonTypes.Secondary} id="icon-left">
179
222
  <Icon
180
223
  name={IconNames.Arrow}
181
224
  iconRotation={IconRotationTypes.Rotate90}
@@ -184,7 +227,7 @@ The icon can be placed to the left or the right of the button text.
184
227
  />
185
228
  Previous
186
229
  </Button>
187
- <Button buttonType={ButtonTypes.Secondary}>
230
+ <Button buttonType={ButtonTypes.Secondary} id="icon-right">
188
231
  Next
189
232
  <Icon
190
233
  name={IconNames.Arrow}
@@ -205,10 +248,11 @@ is an `aria-label` passed to the `Button` component through the `attributes` pro
205
248
  <DSProvider>
206
249
  <ButtonGroup>
207
250
  <Button
208
- buttonType={ButtonTypes.Secondary}
209
251
  attributes={{
210
252
  "aria-label": "Previous",
211
253
  }}
254
+ buttonType={ButtonTypes.Secondary}
255
+ id="prev-btn"
212
256
  >
213
257
  <Icon
214
258
  name={IconNames.Arrow}
@@ -217,10 +261,11 @@ is an `aria-label` passed to the `Button` component through the `attributes` pro
217
261
  />
218
262
  </Button>
219
263
  <Button
220
- buttonType={ButtonTypes.Secondary}
221
264
  attributes={{
222
265
  "aria-label": "Next",
223
266
  }}
267
+ buttonType={ButtonTypes.Secondary}
268
+ id="next-btn"
224
269
  >
225
270
  <Icon
226
271
  name={IconNames.Arrow}
@@ -229,10 +274,11 @@ is an `aria-label` passed to the `Button` component through the `attributes` pro
229
274
  />
230
275
  </Button>
231
276
  <Button
232
- buttonType={ButtonTypes.Secondary}
233
277
  attributes={{
234
278
  "aria-label": "Close",
235
279
  }}
280
+ buttonType={ButtonTypes.Secondary}
281
+ id="close-btn"
236
282
  >
237
283
  <Icon name={IconNames.Close} size={IconSizes.Small} />
238
284
  </Button>
@@ -249,8 +295,10 @@ must include an up arrow icon on the right side.
249
295
  <Canvas>
250
296
  <Story name="Patterns">
251
297
  <ButtonGroup>
252
- <Button buttonType={ButtonTypes.Callout}>Donate to this library</Button>
253
- <Button buttonType={ButtonTypes.Secondary}>
298
+ <Button buttonType={ButtonTypes.Callout} id="donate-btn">
299
+ Donate to this library
300
+ </Button>
301
+ <Button buttonType={ButtonTypes.Secondary} id="top-btn">
254
302
  Back to Top
255
303
  <Icon
256
304
  name={IconNames.Arrow}
@@ -271,12 +319,24 @@ The different `ButtonTypes` modified by the `buttonType` prop:
271
319
  <Canvas>
272
320
  <DSProvider>
273
321
  <ButtonGroup>
274
- <Button buttonType={ButtonTypes.Primary}>Primary</Button>
275
- <Button buttonType={ButtonTypes.Secondary}>Secondary</Button>
276
- <Button buttonType={ButtonTypes.Callout}>Callout</Button>
277
- <Button buttonType={ButtonTypes.Pill}>Pill</Button>
278
- <Button buttonType={ButtonTypes.Link}>Link</Button>
279
- <Button buttonType={ButtonTypes.NoBrand}>NoBrand</Button>
322
+ <Button buttonType={ButtonTypes.Primary} id="primary-btn">
323
+ Primary
324
+ </Button>
325
+ <Button buttonType={ButtonTypes.Secondary} id="secondary-btn">
326
+ Secondary
327
+ </Button>
328
+ <Button buttonType={ButtonTypes.Callout} id="callout-btn">
329
+ Callout
330
+ </Button>
331
+ <Button buttonType={ButtonTypes.Pill} id="pill-btn">
332
+ Pill
333
+ </Button>
334
+ <Button buttonType={ButtonTypes.Link} id="link-btn">
335
+ Link
336
+ </Button>
337
+ <Button buttonType={ButtonTypes.NoBrand} id="nobrand-btn">
338
+ NoBrand
339
+ </Button>
280
340
  </ButtonGroup>
281
341
  </DSProvider>
282
342
  </Canvas>
@@ -286,8 +346,12 @@ Modifying the `isDisabled` prop:
286
346
  <Canvas>
287
347
  <DSProvider>
288
348
  <ButtonGroup>
289
- <Button isDisabled={false}>Enabled</Button>
290
- <Button isDisabled>isDisabled</Button>
349
+ <Button id="enabled-btn" isDisabled={false}>
350
+ Enabled
351
+ </Button>
352
+ <Button id="disabled-btn" isDisabled>
353
+ isDisabled
354
+ </Button>
291
355
  </ButtonGroup>
292
356
  </DSProvider>
293
357
  </Canvas>
@@ -96,6 +96,16 @@ describe("padding for icon only button", () => {
96
96
  );
97
97
  expect(container.querySelector("button svg")).toBeInTheDocument();
98
98
  });
99
+
100
+ it("logs a warning when there is no `id` passed", () => {
101
+ const warn = jest.spyOn(console, "warn");
102
+ // @ts-ignore: Typescript complains when a required prop is not passed, but
103
+ // here we don't want to pass the required prop to make sure the warning appears.
104
+ render(<Button>Submit</Button>);
105
+ expect(warn).toHaveBeenCalledWith(
106
+ "NYPL Reservoir Button: This component's required `id` prop was not passed."
107
+ );
108
+ });
99
109
  });
100
110
 
101
111
  describe("Button Snapshot", () => {
@@ -161,6 +171,19 @@ describe("Button Snapshot", () => {
161
171
  </Button>
162
172
  )
163
173
  .toJSON();
174
+ const withChakraProps = renderer
175
+ .create(
176
+ <Button
177
+ id="button"
178
+ onClick={jest.fn()}
179
+ p="s"
180
+ color="ui.error.primary"
181
+ />
182
+ )
183
+ .toJSON();
184
+ const withOtherProps = renderer
185
+ .create(<Button id="button" onClick={jest.fn()} data-testid="testid" />)
186
+ .toJSON();
164
187
 
165
188
  expect(primary).toMatchSnapshot();
166
189
  expect(disabled).toMatchSnapshot();
@@ -169,5 +192,7 @@ describe("Button Snapshot", () => {
169
192
  expect(pill).toMatchSnapshot();
170
193
  expect(link).toMatchSnapshot();
171
194
  expect(noBrand).toMatchSnapshot();
195
+ expect(withChakraProps).toMatchSnapshot();
196
+ expect(withOtherProps).toMatchSnapshot();
172
197
  });
173
198
  });