@nypl/design-system-react-components 0.26.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/dist/components/Accordion/Accordion.d.ts +1 -1
  3. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -5
  4. package/dist/components/Button/Button.d.ts +2 -10
  5. package/dist/components/ButtonGroup/ButtonGroup.d.ts +22 -0
  6. package/dist/components/Card/Card.d.ts +2 -2
  7. package/dist/components/Checkbox/Checkbox.d.ts +10 -8
  8. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
  9. package/dist/components/DatePicker/DatePicker.d.ts +1 -1
  10. package/dist/components/Form/Form.d.ts +2 -2
  11. package/dist/components/Grid/SimpleGrid.d.ts +6 -3
  12. package/dist/components/Heading/Heading.d.ts +2 -5
  13. package/dist/components/HelperErrorText/HelperErrorText.d.ts +1 -5
  14. package/dist/components/Hero/Hero.d.ts +13 -9
  15. package/dist/components/Icons/Icon.d.ts +6 -5
  16. package/dist/components/Icons/IconSvgs.d.ts +21 -21
  17. package/dist/components/Image/Image.d.ts +8 -5
  18. package/dist/components/Link/Link.d.ts +1 -9
  19. package/dist/components/List/List.d.ts +7 -11
  20. package/dist/components/Logo/Logo.d.ts +2 -5
  21. package/dist/components/Logo/LogoSvgs.d.ts +39 -39
  22. package/dist/components/Modal/Modal.d.ts +28 -8
  23. package/dist/components/Notification/Notification.d.ts +1 -1
  24. package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +2 -1
  25. package/dist/components/RadioGroup/RadioGroup.d.ts +1 -1
  26. package/dist/components/SearchBar/SearchBar.d.ts +3 -2
  27. package/dist/components/Select/Select.d.ts +2 -5
  28. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -4
  29. package/dist/components/SkipNavigation/SkipNavigation.d.ts +17 -0
  30. package/dist/components/StatusBadge/StatusBadge.d.ts +2 -3
  31. package/dist/components/StructuredContent/StructuredContent.d.ts +2 -2
  32. package/dist/components/Table/Table.d.ts +1 -1
  33. package/dist/components/Template/Template.d.ts +2 -0
  34. package/dist/components/Text/Text.d.ts +1 -1
  35. package/dist/components/TextInput/TextInput.d.ts +21 -9
  36. package/dist/components/Toggle/Toggle.d.ts +1 -5
  37. package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
  38. package/dist/design-system-react-components.cjs.development.js +977 -1213
  39. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  40. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  41. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  42. package/dist/design-system-react-components.esm.js +976 -1276
  43. package/dist/design-system-react-components.esm.js.map +1 -1
  44. package/dist/helpers/types.d.ts +1 -0
  45. package/dist/index.d.ts +27 -48
  46. package/dist/styles.css +1 -1
  47. package/dist/theme/components/buttonGroup.d.ts +11 -0
  48. package/dist/theme/components/card.d.ts +104 -8
  49. package/dist/theme/components/componentWrapper.d.ts +4 -3
  50. package/dist/theme/components/customTable.d.ts +11 -14
  51. package/dist/theme/components/fieldset.d.ts +4 -3
  52. package/dist/theme/components/helperErrorText.d.ts +4 -3
  53. package/dist/theme/components/hero.d.ts +1 -1
  54. package/dist/theme/components/horizontalRule.d.ts +4 -3
  55. package/dist/theme/components/icon.d.ts +47743 -1
  56. package/dist/theme/components/image.d.ts +563 -10
  57. package/dist/theme/components/label.d.ts +4 -3
  58. package/dist/theme/components/list.d.ts +6 -7
  59. package/dist/theme/components/logo.d.ts +474 -1
  60. package/dist/theme/components/notification.d.ts +20 -16
  61. package/dist/theme/components/progressIndicator.d.ts +6 -4
  62. package/dist/theme/components/select.d.ts +4 -10
  63. package/dist/theme/components/skeletonLoader.d.ts +14 -10
  64. package/dist/theme/components/skipNavigation.d.ts +22 -0
  65. package/dist/theme/components/slider.d.ts +7 -6
  66. package/dist/theme/components/structuredContent.d.ts +10 -9
  67. package/dist/theme/components/text.d.ts +7 -1
  68. package/dist/theme/components/toggle.d.ts +6 -4
  69. package/dist/theme/provider.d.ts +2 -4
  70. package/dist/utils/componentCategories.d.ts +1 -1
  71. package/dist/utils/interfaces.d.ts +5 -0
  72. package/dist/utils/utils.d.ts +2 -18
  73. package/package.json +15 -16
  74. package/src/__tests__/setup.ts +3 -3
  75. package/src/__tests__/utils/utils.test.ts +1 -23
  76. package/src/components/AccessibilityGuide/SkipNavigation.stories.mdx +22 -14
  77. package/src/components/Accordion/Accordion.stories.mdx +43 -44
  78. package/src/components/Accordion/Accordion.test.tsx +5 -13
  79. package/src/components/Accordion/Accordion.tsx +14 -18
  80. package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +6 -6
  81. package/src/components/Autosuggest/Autosuggest.stories.mdx +1 -1
  82. package/src/components/Autosuggest/Autosuggest.stories.tsx +23 -25
  83. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +21 -37
  84. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +4 -17
  85. package/src/components/Breadcrumbs/Breadcrumbs.tsx +18 -21
  86. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +1 -100
  87. package/src/components/Button/Button.stories.mdx +89 -126
  88. package/src/components/Button/Button.test.tsx +16 -30
  89. package/src/components/Button/Button.tsx +14 -20
  90. package/src/components/ButtonGroup/ButtonGroup.stories.mdx +147 -0
  91. package/src/components/ButtonGroup/ButtonGroup.test.tsx +141 -0
  92. package/src/components/ButtonGroup/ButtonGroup.tsx +99 -0
  93. package/src/components/ButtonGroup/__snapshots__/ButtonGroup.test.tsx.snap +117 -0
  94. package/src/components/Card/Card.stories.mdx +143 -177
  95. package/src/components/Card/Card.test.tsx +36 -97
  96. package/src/components/Card/Card.tsx +78 -74
  97. package/src/components/Card/__snapshots__/Card.test.tsx.snap +1 -1
  98. package/src/components/Chakra/Box.stories.mdx +2 -6
  99. package/src/components/Chakra/Center.stories.mdx +5 -23
  100. package/src/components/Chakra/Flex.stories.mdx +4 -6
  101. package/src/components/Chakra/Stack.stories.mdx +9 -10
  102. package/src/components/Checkbox/Checkbox.stories.mdx +1 -1
  103. package/src/components/Checkbox/Checkbox.test.tsx +2 -2
  104. package/src/components/Checkbox/Checkbox.tsx +20 -13
  105. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +9 -9
  106. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +6 -17
  107. package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +1 -7
  108. package/src/components/CheckboxGroup/CheckboxGroup.tsx +33 -29
  109. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +24 -35
  110. package/src/components/ComponentWrapper/ComponentWrapper.tsx +3 -10
  111. package/src/components/DatePicker/DatePicker.stories.mdx +23 -37
  112. package/src/components/DatePicker/DatePicker.test.tsx +21 -19
  113. package/src/components/DatePicker/DatePicker.tsx +57 -49
  114. package/src/components/Form/Form.stories.mdx +46 -31
  115. package/src/components/Form/Form.test.tsx +1 -18
  116. package/src/components/Form/Form.tsx +7 -7
  117. package/src/components/Grid/SimpleGrid.stories.mdx +73 -49
  118. package/src/components/Grid/SimpleGrid.test.tsx +7 -9
  119. package/src/components/Grid/SimpleGrid.tsx +14 -11
  120. package/src/components/Heading/Heading.stories.mdx +27 -72
  121. package/src/components/Heading/Heading.test.tsx +18 -44
  122. package/src/components/Heading/Heading.tsx +7 -10
  123. package/src/components/HelperErrorText/HelperErrorText.stories.mdx +1 -3
  124. package/src/components/HelperErrorText/HelperErrorText.tsx +1 -5
  125. package/src/components/Hero/Hero.stories.mdx +219 -216
  126. package/src/components/Hero/Hero.test.tsx +107 -223
  127. package/src/components/Hero/Hero.tsx +63 -61
  128. package/src/components/Icons/Icon.stories.mdx +172 -118
  129. package/src/components/Icons/Icon.test.tsx +8 -16
  130. package/src/components/Icons/Icon.tsx +75 -29
  131. package/src/components/Icons/IconSvgs.tsx +42 -42
  132. package/src/components/Image/Image.stories.mdx +45 -132
  133. package/src/components/Image/Image.test.tsx +16 -31
  134. package/src/components/Image/Image.tsx +28 -12
  135. package/src/components/Link/Link.stories.mdx +30 -94
  136. package/src/components/Link/Link.test.tsx +25 -75
  137. package/src/components/Link/Link.tsx +43 -56
  138. package/src/components/Link/__snapshots__/Link.test.tsx.snap +1 -2
  139. package/src/components/List/List.stories.mdx +20 -31
  140. package/src/components/List/List.test.tsx +24 -43
  141. package/src/components/List/List.tsx +25 -36
  142. package/src/components/Logo/Logo.stories.mdx +94 -50
  143. package/src/components/Logo/Logo.test.tsx +10 -19
  144. package/src/components/Logo/Logo.tsx +50 -17
  145. package/src/components/Logo/LogoSvgs.tsx +78 -78
  146. package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +4 -4
  147. package/src/components/Modal/Modal.stories.mdx +245 -139
  148. package/src/components/Modal/Modal.test.tsx +147 -10
  149. package/src/components/Modal/Modal.tsx +140 -20
  150. package/src/components/Modal/__snapshots__/Modal.test.tsx.snap +25 -0
  151. package/src/components/Notification/Notification.stories.mdx +10 -28
  152. package/src/components/Notification/Notification.test.tsx +9 -12
  153. package/src/components/Notification/Notification.tsx +34 -37
  154. package/src/components/Pagination/Pagination.stories.mdx +3 -4
  155. package/src/components/Pagination/Pagination.tsx +15 -10
  156. package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +27 -53
  157. package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +9 -10
  158. package/src/components/ProgressIndicator/ProgressIndicator.tsx +17 -21
  159. package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +0 -10
  160. package/src/components/Radio/Radio.stories.mdx +1 -1
  161. package/src/components/Radio/Radio.tsx +9 -6
  162. package/src/components/RadioGroup/RadioGroup.stories.mdx +15 -16
  163. package/src/components/RadioGroup/RadioGroup.test.tsx +2 -8
  164. package/src/components/RadioGroup/RadioGroup.tsx +28 -24
  165. package/src/components/SearchBar/SearchBar.stories.mdx +1 -1
  166. package/src/components/SearchBar/SearchBar.test.tsx +1 -1
  167. package/src/components/SearchBar/SearchBar.tsx +14 -22
  168. package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +1 -13
  169. package/src/components/Select/Select.stories.mdx +10 -25
  170. package/src/components/Select/Select.test.tsx +6 -7
  171. package/src/components/Select/Select.tsx +28 -35
  172. package/src/components/Select/__snapshots__/Select.test.tsx.snap +24 -24
  173. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +17 -56
  174. package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +7 -21
  175. package/src/components/SkeletonLoader/SkeletonLoader.tsx +9 -8
  176. package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +33 -33
  177. package/src/components/SkipNavigation/SkipNavigation.stories.mdx +90 -0
  178. package/src/components/SkipNavigation/SkipNavigation.test.tsx +63 -0
  179. package/src/components/SkipNavigation/SkipNavigation.tsx +51 -0
  180. package/src/components/SkipNavigation/__snapshots__/SkipNavigation.test.tsx.snap +130 -0
  181. package/src/components/Slider/Slider.stories.mdx +19 -53
  182. package/src/components/Slider/Slider.test.tsx +2 -2
  183. package/src/components/Slider/Slider.tsx +10 -12
  184. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +2 -9
  185. package/src/components/StatusBadge/StatusBadge.stories.mdx +6 -21
  186. package/src/components/StatusBadge/StatusBadge.test.tsx +2 -3
  187. package/src/components/StatusBadge/StatusBadge.tsx +3 -10
  188. package/src/components/StructuredContent/StructuredContent.stories.mdx +30 -58
  189. package/src/components/StructuredContent/StructuredContent.test.tsx +42 -44
  190. package/src/components/StructuredContent/StructuredContent.tsx +9 -18
  191. package/src/components/StyleGuide/Bidirectionality.stories.mdx +9 -23
  192. package/src/components/StyleGuide/Buttons.stories.mdx +62 -62
  193. package/src/components/StyleGuide/ColorCard.tsx +2 -4
  194. package/src/components/StyleGuide/Colors.stories.mdx +7 -8
  195. package/src/components/StyleGuide/DesignTokens.stories.mdx +5 -7
  196. package/src/components/StyleGuide/Forms.stories.mdx +0 -1
  197. package/src/components/StyleGuide/Iconography.stories.mdx +59 -77
  198. package/src/components/StyleGuide/Spacing.stories.mdx +0 -1
  199. package/src/components/StyleGuide/Typography.stories.mdx +15 -18
  200. package/src/components/Table/Table.stories.mdx +85 -1
  201. package/src/components/Table/Table.test.tsx +57 -1
  202. package/src/components/Table/Table.tsx +7 -4
  203. package/src/components/Table/__snapshots__/Table.test.tsx.snap +121 -0
  204. package/src/components/Tabs/Tabs.stories.mdx +1 -1
  205. package/src/components/Tabs/Tabs.test.tsx +2 -2
  206. package/src/components/Tabs/Tabs.tsx +26 -27
  207. package/src/components/Template/Template.stories.mdx +49 -54
  208. package/src/components/Template/Template.tsx +9 -3
  209. package/src/components/Text/Text.stories.mdx +5 -11
  210. package/src/components/Text/Text.test.tsx +3 -6
  211. package/src/components/Text/Text.tsx +3 -5
  212. package/src/components/TextInput/TextInput.stories.mdx +10 -22
  213. package/src/components/TextInput/TextInput.test.tsx +32 -62
  214. package/src/components/TextInput/TextInput.tsx +61 -30
  215. package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +1 -0
  216. package/src/components/Toggle/Toggle.stories.mdx +5 -16
  217. package/src/components/Toggle/Toggle.test.tsx +2 -3
  218. package/src/components/Toggle/Toggle.tsx +9 -10
  219. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +13 -29
  220. package/src/components/VideoPlayer/VideoPlayer.test.tsx +18 -23
  221. package/src/components/VideoPlayer/VideoPlayer.tsx +13 -10
  222. package/src/docs/Chakra.stories.mdx +14 -11
  223. package/src/docs/Welcome.stories.mdx +23 -43
  224. package/src/helpers/types.ts +1 -0
  225. package/src/hooks/tests/useNYPLTheme.test.tsx +1 -1
  226. package/src/hooks/useNYPLTheme.stories.mdx +3 -6
  227. package/src/index.ts +52 -46
  228. package/src/styles.scss +0 -1
  229. package/src/theme/components/buttonGroup.ts +10 -0
  230. package/src/theme/components/card.ts +50 -15
  231. package/src/theme/components/componentWrapper.ts +5 -1
  232. package/src/theme/components/customTable.ts +8 -2
  233. package/src/theme/components/fieldset.ts +5 -1
  234. package/src/theme/components/helperErrorText.ts +5 -1
  235. package/src/theme/components/hero.ts +2 -2
  236. package/src/theme/components/horizontalRule.ts +5 -1
  237. package/src/theme/components/icon.ts +7 -1
  238. package/src/theme/components/image.ts +14 -3
  239. package/src/theme/components/label.ts +5 -1
  240. package/src/theme/components/list.ts +8 -2
  241. package/src/theme/components/logo.ts +5 -1
  242. package/src/theme/components/notification.ts +38 -14
  243. package/src/theme/components/progressIndicator.ts +10 -5
  244. package/src/theme/components/select.ts +5 -6
  245. package/src/theme/components/skeletonLoader.ts +8 -2
  246. package/src/theme/components/skipNavigation.ts +26 -0
  247. package/src/theme/components/slider.ts +13 -1
  248. package/src/theme/components/structuredContent.ts +11 -1
  249. package/src/theme/components/text.ts +12 -5
  250. package/src/theme/components/toggle.ts +9 -3
  251. package/src/theme/index.ts +4 -0
  252. package/src/theme/provider.tsx +1 -1
  253. package/src/utils/componentCategories.ts +13 -5
  254. package/src/utils/interfaces.ts +5 -0
  255. package/src/utils/utils.ts +2 -32
  256. package/dist/components/Accordion/AccordionTypes.d.ts +0 -5
  257. package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +0 -8
  258. package/dist/components/Button/ButtonTypes.d.ts +0 -8
  259. package/dist/components/DatePicker/DatePickerTypes.d.ts +0 -5
  260. package/dist/components/Form/FormTypes.d.ts +0 -2
  261. package/dist/components/Grid/GridTypes.d.ts +0 -9
  262. package/dist/components/Heading/HeadingTypes.d.ts +0 -14
  263. package/dist/components/Hero/HeroTypes.d.ts +0 -12
  264. package/dist/components/Icons/IconTypes.d.ts +0 -77
  265. package/dist/components/Image/ImageTypes.d.ts +0 -22
  266. package/dist/components/Link/LinkTypes.d.ts +0 -8
  267. package/dist/components/List/ListTypes.d.ts +0 -5
  268. package/dist/components/Logo/LogoTypes.d.ts +0 -54
  269. package/dist/components/Notification/NotificationTypes.d.ts +0 -5
  270. package/dist/components/ProgressIndicator/ProgressIndicatorTypes.d.ts +0 -8
  271. package/dist/components/Select/SelectTypes.d.ts +0 -8
  272. package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +0 -5
  273. package/dist/components/StatusBadge/StatusBadgeTypes.d.ts +0 -5
  274. package/dist/components/StructuredContent/StructuredContentTypes.d.ts +0 -5
  275. package/dist/components/Text/TextTypes.d.ts +0 -6
  276. package/dist/components/TextInput/TextInputTypes.d.ts +0 -25
  277. package/dist/components/Toggle/ToggleTypes.d.ts +0 -4
  278. package/dist/components/VideoPlayer/VideoPlayerTypes.d.ts +0 -9
  279. package/dist/helpers/enums.d.ts +0 -4
  280. package/dist/utils/siteSections.d.ts +0 -2
  281. package/src/components/Accordion/AccordionTypes.tsx +0 -5
  282. package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +0 -8
  283. package/src/components/Button/ButtonTypes.tsx +0 -8
  284. package/src/components/DatePicker/DatePickerTypes.tsx +0 -5
  285. package/src/components/Form/FormTypes.tsx +0 -3
  286. package/src/components/Grid/GridTypes.tsx +0 -9
  287. package/src/components/Heading/HeadingTypes.tsx +0 -15
  288. package/src/components/Hero/HeroTypes.tsx +0 -20
  289. package/src/components/Icons/IconTypes.tsx +0 -83
  290. package/src/components/Image/ImageTypes.ts +0 -24
  291. package/src/components/Link/LinkTypes.tsx +0 -8
  292. package/src/components/List/ListTypes.tsx +0 -5
  293. package/src/components/Logo/LogoTypes.tsx +0 -56
  294. package/src/components/Modal/_Modal.scss +0 -18
  295. package/src/components/Notification/NotificationTypes.tsx +0 -5
  296. package/src/components/ProgressIndicator/ProgressIndicatorTypes.ts +0 -8
  297. package/src/components/Select/SelectTypes.tsx +0 -10
  298. package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +0 -5
  299. package/src/components/StatusBadge/StatusBadgeTypes.tsx +0 -5
  300. package/src/components/StructuredContent/StructuredContentTypes.tsx +0 -5
  301. package/src/components/Text/TextTypes.tsx +0 -6
  302. package/src/components/TextInput/TextInputTypes.tsx +0 -48
  303. package/src/components/Toggle/ToggleTypes.tsx +0 -4
  304. package/src/components/VideoPlayer/VideoPlayerTypes.tsx +0 -10
  305. package/src/helpers/enums.ts +0 -4
  306. package/src/utils/siteSections.ts +0 -10
@@ -1,4 +1,4 @@
1
- import { ButtonGroup, VStack } from "@chakra-ui/react";
1
+ import { VStack } from "@chakra-ui/react";
2
2
  import {
3
3
  ArgsTable,
4
4
  Canvas,
@@ -9,19 +9,43 @@ import {
9
9
  import { withDesign } from "storybook-addon-designs";
10
10
 
11
11
  import Button, { ButtonElementType } from "./Button";
12
- import { ButtonTypes } from "./ButtonTypes";
12
+ import ButtonGroup from "../ButtonGroup/ButtonGroup";
13
13
  import Icon from "../Icons/Icon";
14
- import {
15
- IconAlign,
16
- IconNames,
17
- IconRotationTypes,
18
- IconSizes,
19
- } from "../Icons/IconTypes";
20
14
  import { getCategory } from "../../utils/componentCategories";
21
15
  import DSProvider from "../../theme/provider";
22
- import { getStorybookEnumValues } from "../../utils/utils";
23
16
 
24
- export const enumValues = getStorybookEnumValues(ButtonTypes, "ButtonTypes");
17
+ export const iconNames = [
18
+ "accessibilityFull",
19
+ "accessibilityPartial",
20
+ "actionCheckCircle",
21
+ "actionHelpDefault",
22
+ "actionHelpOutline",
23
+ "alertNotificationImportant",
24
+ "actionLaunch",
25
+ "arrow",
26
+ "check",
27
+ "clock",
28
+ "close",
29
+ "download",
30
+ "errorFilled",
31
+ "errorOutline",
32
+ "fileTypeAudio",
33
+ "fileTypeDoc",
34
+ "fileTypeGenericDoc",
35
+ "fileTypeImage",
36
+ "fileTypePdf",
37
+ "fileTypeSpreadsheet",
38
+ "fileTypeVideo",
39
+ "headset",
40
+ "minus",
41
+ "plus",
42
+ "search",
43
+ "speakerNotes",
44
+ "utilityAccountFilled",
45
+ "utilityAccountUnfilled",
46
+ "utilityHamburger",
47
+ "utilitySearch",
48
+ ];
25
49
 
26
50
  <Meta
27
51
  title={getCategory("Button")}
@@ -35,13 +59,9 @@ export const enumValues = getStorybookEnumValues(ButtonTypes, "ButtonTypes");
35
59
  jest: ["Button.test.tsx"],
36
60
  }}
37
61
  argTypes={{
38
- additionalStyles: { control: false },
39
- attributes: { control: false },
40
62
  buttonText: { description: "Only used for Storybook" },
41
63
  buttonType: {
42
- control: { type: "select" },
43
- table: { defaultValue: { summary: "ButtonTypes.Primary" } },
44
- options: enumValues.options,
64
+ table: { defaultValue: { summary: "primary" } },
45
65
  },
46
66
  className: { control: false },
47
67
  displayIcon: { description: "Only used for Storybook." },
@@ -50,7 +70,7 @@ export const enumValues = getStorybookEnumValues(ButtonTypes, "ButtonTypes");
50
70
  },
51
71
  iconType: {
52
72
  control: { type: "select" },
53
- options: Object.values(IconNames).map((value) => value),
73
+ options: iconNames,
54
74
  description: "Select the icon. Only used for Storybook.",
55
75
  },
56
76
  id: { control: false },
@@ -65,7 +85,7 @@ export const enumValues = getStorybookEnumValues(ButtonTypes, "ButtonTypes");
65
85
  | Component Version | DS Version |
66
86
  | ----------------- | ---------- |
67
87
  | Added | `0.0.4` |
68
- | Latest | `0.26.0` |
88
+ | Latest | `0.28.0` |
69
89
 
70
90
  ## Table of Contents
71
91
 
@@ -84,13 +104,13 @@ export const enumValues = getStorybookEnumValues(ButtonTypes, "ButtonTypes");
84
104
  Update the `buttonType` in the Controls section to see the types of buttons
85
105
  that can be rendered.
86
106
 
87
- - `ButtonTypes.Primary` is used for actions that move the user forward.
88
- - `ButtonTypes.Secondary` is used for actions that move the user back, such as cancellations.
89
- - `ButtonTypes.Callout` is used for call to action text such as "Donate".
90
- - `ButtonTypes.Pill` is used for equally weighted actions within cards and always in a set.
91
- - `ButtonTypes.Link` is used for equally weighted actions in a text based list.
92
- - `ButtonTypes.NoBrand` is a variant used when there is no brand and will display
93
- the background color as black.
107
+ - `"primary"` is used for actions that move the user forward. This is the default.
108
+ - `"secondary"` is used for actions that move the user back, such as cancellations.
109
+ - `"callout"` is used for call to action text such as "Donate".
110
+ - `"pill"` is used for equally weighted actions within cards and always in a set.
111
+ - `"link"` is used for equally weighted actions in a text based list.
112
+ - `"noBrand"` is a variant used when there is no brand and will display the
113
+ background color as black.
94
114
 
95
115
  When one and only one `Icon` component is passed inside a `Button` component with
96
116
  no text, it will automatically be configured to use the `"iconOnly"` type.
@@ -101,14 +121,12 @@ no text, it will automatically be configured to use the `"iconOnly"` type.
101
121
  <Story
102
122
  name="Button with Controls"
103
123
  args={{
104
- additionalStyles: undefined,
105
- attributes: undefined,
106
124
  buttonText: "Button Text",
107
- buttonType: "ButtonTypes.Primary",
125
+ buttonType: "primary",
108
126
  className: undefined,
109
127
  displayIcon: false,
110
128
  displayIconLeft: true,
111
- iconType: IconNames.Search,
129
+ iconType: "search",
112
130
  id: "button-id",
113
131
  isDisabled: false,
114
132
  mouseDown: undefined,
@@ -118,9 +136,7 @@ no text, it will automatically be configured to use the `"iconOnly"` type.
118
136
  >
119
137
  {(args) => (
120
138
  <Button
121
- additionalStyles={args.additionalStyles}
122
- attributes={args.attributes}
123
- buttonType={enumValues.getValue(args.buttonType)}
139
+ buttonType={args.buttonType}
124
140
  className={args.className}
125
141
  id={args.id}
126
142
  isDisabled={args.isDisabled}
@@ -129,19 +145,11 @@ no text, it will automatically be configured to use the `"iconOnly"` type.
129
145
  type={args.type}
130
146
  >
131
147
  {args.displayIcon && args.displayIconLeft && (
132
- <Icon
133
- name={args.iconType}
134
- align={IconAlign.Left}
135
- size={IconSizes.Small}
136
- />
148
+ <Icon name={args.iconType} align="left" size="small" />
137
149
  )}
138
150
  {args.buttonText}
139
151
  {args.displayIcon && !args.displayIconLeft && (
140
- <Icon
141
- name={args.iconType}
142
- align={IconAlign.Right}
143
- size={IconSizes.Small}
144
- />
152
+ <Icon name={args.iconType} align="right" size="small" />
145
153
  )}
146
154
  </Button>
147
155
  )}
@@ -168,18 +176,15 @@ Resources:
168
176
  ## Button Groups
169
177
 
170
178
  Primary and secondary buttons should be grouped like in the following example.
171
- The `ButtonGroup` component, which is directly exported from Chakra UI, should
172
- be used to wrap the `Button` component.
179
+ The `ButtonGroup` component should be used to wrap the `Button` component.
173
180
 
174
181
  <Canvas>
175
182
  <Story name="Button Groups">
176
183
  <ButtonGroup>
177
- <Button buttonType={ButtonTypes.Secondary} id="group-1">
184
+ <Button buttonType="secondary" id="group-1">
178
185
  Button
179
186
  </Button>
180
- <Button buttonType={ButtonTypes.Primary} id="group-2">
181
- Submit
182
- </Button>
187
+ <Button id="group-2">Submit</Button>
183
188
  </ButtonGroup>
184
189
  </Story>
185
190
  </Canvas>
@@ -187,27 +192,19 @@ be used to wrap the `Button` component.
187
192
  ## With Icons
188
193
 
189
194
  The `Icon` component collaborates great with the `Button` component. Check out
190
- [`src/components/Icons/IconTypes`](https://github.com/NYPL/nypl-design-system/blob/development/src/components/Icons/IconTypes.tsx)
191
- to see the full list of icon and logo names that can be rendered.
195
+ [`src/components/Icons/Icon.tsx`](https://github.com/NYPL/nypl-design-system/blob/development/src/components/Icons/Icon.tsx)
196
+ to see the full list of icon names that can be rendered.
192
197
 
193
198
  <Canvas>
194
199
  <Story name="With Icon">
195
200
  <VStack align="left" spacing="input.group.button.vstack" width="150px">
196
201
  <Button id="icon-1">
197
- <Icon
198
- name={IconNames.Search}
199
- align={IconAlign.Left}
200
- size={IconSizes.Small}
201
- />
202
+ <Icon name="search" align="left" size="small" />
202
203
  Button Text
203
204
  </Button>
204
205
  <Button id="icon-2">
205
206
  Button Text
206
- <Icon
207
- name={IconNames.Search}
208
- align={IconAlign.Right}
209
- size={IconSizes.Small}
210
- />
207
+ <Icon name="search" align="right" size="small" />
211
208
  </Button>
212
209
  </VStack>
213
210
  </Story>
@@ -218,22 +215,17 @@ The icon can be placed to the left or the right of the button text.
218
215
  <Canvas>
219
216
  <DSProvider>
220
217
  <ButtonGroup>
221
- <Button buttonType={ButtonTypes.Secondary} id="icon-left">
222
- <Icon
223
- name={IconNames.Arrow}
224
- iconRotation={IconRotationTypes.Rotate90}
225
- align={IconAlign.Left}
226
- size={IconSizes.Small}
227
- />
218
+ <Button buttonType="secondary" id="icon-left">
219
+ <Icon name="arrow" iconRotation="rotate90" align="left" size="small" />
228
220
  Previous
229
221
  </Button>
230
- <Button buttonType={ButtonTypes.Secondary} id="icon-right">
222
+ <Button buttonType="secondary" id="icon-right">
231
223
  Next
232
224
  <Icon
233
- name={IconNames.Arrow}
234
- iconRotation={IconRotationTypes.Rotate270}
235
- align={IconAlign.Right}
236
- size={IconSizes.Small}
225
+ name="arrow"
226
+ iconRotation="rotate270"
227
+ align="right"
228
+ size="small"
237
229
  />
238
230
  </Button>
239
231
  </ButtonGroup>
@@ -241,46 +233,19 @@ The icon can be placed to the left or the right of the button text.
241
233
  </Canvas>
242
234
 
243
235
  Text in a button is optional if an icon is rendered, but make sure that there
244
- is an `aria-label` passed to the `Button` component through the `attributes` prop:
245
- `attributes={{ "aria-label": "Previous" }}`
236
+ is an `aria-label` passed to the `Button` component `aria-label="Previous"`.
246
237
 
247
238
  <Canvas>
248
239
  <DSProvider>
249
240
  <ButtonGroup>
250
- <Button
251
- attributes={{
252
- "aria-label": "Previous",
253
- }}
254
- buttonType={ButtonTypes.Secondary}
255
- id="prev-btn"
256
- >
257
- <Icon
258
- name={IconNames.Arrow}
259
- iconRotation={IconRotationTypes.Rotate90}
260
- size={IconSizes.Small}
261
- />
241
+ <Button aria-label="Previous" buttonType="secondary" id="prev-btn">
242
+ <Icon name="arrow" iconRotation="rotate90" size="small" />
262
243
  </Button>
263
- <Button
264
- attributes={{
265
- "aria-label": "Next",
266
- }}
267
- buttonType={ButtonTypes.Secondary}
268
- id="next-btn"
269
- >
270
- <Icon
271
- name={IconNames.Arrow}
272
- iconRotation={IconRotationTypes.Rotate270}
273
- size={IconSizes.Small}
274
- />
244
+ <Button aria-label="Next" buttonType="secondary" id="next-btn">
245
+ <Icon name="arrow" iconRotation="rotate270" size="small" />
275
246
  </Button>
276
- <Button
277
- attributes={{
278
- "aria-label": "Close",
279
- }}
280
- buttonType={ButtonTypes.Secondary}
281
- id="close-btn"
282
- >
283
- <Icon name={IconNames.Close} size={IconSizes.Small} />
247
+ <Button aria-label="Close" buttonType="secondary" id="close-btn">
248
+ <Icon name="close" size="small" />
284
249
  </Button>
285
250
  </ButtonGroup>
286
251
  </DSProvider>
@@ -289,23 +254,23 @@ is an `aria-label` passed to the `Button` component through the `attributes` pro
289
254
  ## Patterns
290
255
 
291
256
  Buttons are blue by default but should be red when it is intended to be used as
292
- a call out. The "Back to Top" button must be of `ButtonTypes` `Secondary` and
257
+ a call out. The "Back to Top" button must be of `buttonType="secondary"` and
293
258
  must include an up arrow icon on the right side.
294
259
 
295
260
  <Canvas>
296
261
  <Story name="Patterns">
297
262
  <ButtonGroup>
298
- <Button buttonType={ButtonTypes.Callout} id="donate-btn">
263
+ <Button buttonType="callout" id="donate-btn">
299
264
  Donate to this library
300
265
  </Button>
301
- <Button buttonType={ButtonTypes.Secondary} id="top-btn">
266
+ <Button buttonType="secondary" id="top-btn">
302
267
  Back to Top
303
268
  <Icon
304
- name={IconNames.Arrow}
305
- iconRotation={IconRotationTypes.Rotate180}
306
- size={IconSizes.Small}
269
+ name="arrow"
270
+ iconRotation="rotate180"
271
+ size="small"
307
272
  className="right"
308
- align={IconAlign.Right}
273
+ align="right"
309
274
  />
310
275
  </Button>
311
276
  </ButtonGroup>
@@ -314,28 +279,26 @@ must include an up arrow icon on the right side.
314
279
 
315
280
  ## Other Examples
316
281
 
317
- The different `ButtonTypes` modified by the `buttonType` prop:
282
+ The variations modified by the `buttonType` prop:
318
283
 
319
284
  <Canvas>
320
285
  <DSProvider>
321
286
  <ButtonGroup>
322
- <Button buttonType={ButtonTypes.Primary} id="primary-btn">
323
- Primary
324
- </Button>
325
- <Button buttonType={ButtonTypes.Secondary} id="secondary-btn">
326
- Secondary
287
+ <Button id="primary-btn">primary</Button>
288
+ <Button buttonType="secondary" id="secondary-btn">
289
+ secondary
327
290
  </Button>
328
- <Button buttonType={ButtonTypes.Callout} id="callout-btn">
329
- Callout
291
+ <Button buttonType="callout" id="callout-btn">
292
+ callout
330
293
  </Button>
331
- <Button buttonType={ButtonTypes.Pill} id="pill-btn">
332
- Pill
294
+ <Button buttonType="pill" id="pill-btn">
295
+ pill
333
296
  </Button>
334
- <Button buttonType={ButtonTypes.Link} id="link-btn">
335
- Link
297
+ <Button buttonType="link" id="link-btn">
298
+ link
336
299
  </Button>
337
- <Button buttonType={ButtonTypes.NoBrand} id="nobrand-btn">
338
- NoBrand
300
+ <Button buttonType="noBrand" id="nobrand-btn">
301
+ noBrand
339
302
  </Button>
340
303
  </ButtonGroup>
341
304
  </DSProvider>
@@ -1,13 +1,16 @@
1
1
  import * as React from "react";
2
- import { render, screen, fireEvent } from "@testing-library/react";
2
+ import {
3
+ render,
4
+ RenderResult,
5
+ screen,
6
+ fireEvent,
7
+ } from "@testing-library/react";
3
8
  import { axe } from "jest-axe";
4
9
  import userEvent from "@testing-library/user-event";
5
10
  import renderer from "react-test-renderer";
6
11
 
7
12
  import Button from "./Button";
8
13
  import Icon from "../Icons/Icon";
9
- import { IconAlign, IconNames, IconSizes } from "../Icons/IconTypes";
10
- import { ButtonTypes } from "./ButtonTypes";
11
14
 
12
15
  describe("Button Accessibility", () => {
13
16
  it("passes axe accessibility test", async () => {
@@ -22,17 +25,16 @@ describe("Button Accessibility", () => {
22
25
  });
23
26
 
24
27
  describe("Button", () => {
25
- let onClick;
26
- let rerender;
28
+ let onClick: jest.MockedFunction<() => void>;
29
+ let utils: RenderResult;
27
30
 
28
31
  beforeEach(() => {
29
32
  onClick = jest.fn();
30
- const utils = render(
33
+ utils = render(
31
34
  <Button id="button" onClick={onClick}>
32
35
  Submit
33
36
  </Button>
34
37
  );
35
- rerender = utils.rerender;
36
38
  });
37
39
 
38
40
  it("calls the onClick", () => {
@@ -47,7 +49,7 @@ describe("Button", () => {
47
49
 
48
50
  it("optionally calls the onClick on mouseDown instead of on click", () => {
49
51
  expect(onClick).toHaveBeenCalledTimes(0);
50
- rerender(
52
+ utils.rerender(
51
53
  <Button id="button5" mouseDown={true}>
52
54
  Submit
53
55
  </Button>
@@ -87,11 +89,7 @@ describe("padding for icon only button", () => {
87
89
  const onClick = jest.fn();
88
90
  const { container } = render(
89
91
  <Button id="button" onClick={onClick} type="button">
90
- <Icon
91
- align={IconAlign.Left}
92
- name={IconNames.Check}
93
- size={IconSizes.Small}
94
- />
92
+ <Icon align="left" name="check" size="small" />
95
93
  </Button>
96
94
  );
97
95
  expect(container.querySelector("button svg")).toBeInTheDocument();
@@ -126,47 +124,35 @@ describe("Button Snapshot", () => {
126
124
  .toJSON();
127
125
  const secondary = renderer
128
126
  .create(
129
- <Button
130
- id="button"
131
- onClick={jest.fn()}
132
- buttonType={ButtonTypes.Secondary}
133
- >
127
+ <Button id="button" onClick={jest.fn()} buttonType="secondary">
134
128
  Seconday
135
129
  </Button>
136
130
  )
137
131
  .toJSON();
138
132
  const callout = renderer
139
133
  .create(
140
- <Button
141
- id="button"
142
- onClick={jest.fn()}
143
- buttonType={ButtonTypes.Callout}
144
- >
134
+ <Button id="button" onClick={jest.fn()} buttonType="callout">
145
135
  Callout
146
136
  </Button>
147
137
  )
148
138
  .toJSON();
149
139
  const pill = renderer
150
140
  .create(
151
- <Button id="button" onClick={jest.fn()} buttonType={ButtonTypes.Pill}>
141
+ <Button id="button" onClick={jest.fn()} buttonType="pill">
152
142
  Pill
153
143
  </Button>
154
144
  )
155
145
  .toJSON();
156
146
  const link = renderer
157
147
  .create(
158
- <Button id="button" onClick={jest.fn()} buttonType={ButtonTypes.Link}>
148
+ <Button id="button" onClick={jest.fn()} buttonType="link">
159
149
  Link
160
150
  </Button>
161
151
  )
162
152
  .toJSON();
163
153
  const noBrand = renderer
164
154
  .create(
165
- <Button
166
- id="button"
167
- onClick={jest.fn()}
168
- buttonType={ButtonTypes.NoBrand}
169
- >
155
+ <Button id="button" onClick={jest.fn()} buttonType="noBrand">
170
156
  NoBrand
171
157
  </Button>
172
158
  )
@@ -5,18 +5,19 @@ import {
5
5
  } from "@chakra-ui/react";
6
6
  import * as React from "react";
7
7
 
8
- import { ButtonTypes } from "./ButtonTypes";
9
8
  import Icon from "../Icons/Icon";
10
- import { getVariant } from "../../utils/utils";
11
9
 
12
10
  export type ButtonElementType = "submit" | "button" | "reset";
11
+ export type ButtonTypes =
12
+ | "primary"
13
+ | "secondary"
14
+ | "callout"
15
+ | "pill"
16
+ | "link"
17
+ | "noBrand";
13
18
 
14
19
  interface ButtonProps {
15
- /** Optionally pass in additional Chakra-based styles. */
16
- additionalStyles?: { [key: string]: any };
17
- /** Additional attributes passed to the button. */
18
- attributes?: { [key: string]: any };
19
- /** The kind of button assigned through the `ButtonTypes` enum. */
20
+ /** The button variation to render based on the `ButtonTypes` type.*/
20
21
  buttonType?: ButtonTypes;
21
22
  /** Additional className to use. */
22
23
  className?: string;
@@ -38,9 +39,7 @@ interface ButtonProps {
38
39
  */
39
40
  export const Button = chakra((props: React.PropsWithChildren<ButtonProps>) => {
40
41
  const {
41
- additionalStyles = {},
42
- attributes,
43
- buttonType,
42
+ buttonType = "primary",
44
43
  children,
45
44
  className = "",
46
45
  id,
@@ -53,7 +52,7 @@ export const Button = chakra((props: React.PropsWithChildren<ButtonProps>) => {
53
52
  const btnCallback = mouseDown ? { onMouseDown: onClick } : { onClick };
54
53
  let childCount = 0;
55
54
  let hasIcon = false;
56
- let variant;
55
+ let variant: string | ButtonTypes = buttonType;
57
56
  let styles = {};
58
57
 
59
58
  if (!id) {
@@ -62,13 +61,10 @@ export const Button = chakra((props: React.PropsWithChildren<ButtonProps>) => {
62
61
  );
63
62
  }
64
63
 
65
- React.Children.map(children, (child: React.ReactElement) => {
64
+ React.Children.map(children as JSX.Element, (child: React.ReactElement) => {
66
65
  childCount++;
67
66
  if (child !== undefined && child !== null) {
68
- if (
69
- child.type === Icon ||
70
- (child.props && child.props.mdxType === "Icon")
71
- ) {
67
+ if (child.type === Icon || child?.props?.mdxType === "Icon") {
72
68
  hasIcon = true;
73
69
  }
74
70
  }
@@ -76,11 +72,10 @@ export const Button = chakra((props: React.PropsWithChildren<ButtonProps>) => {
76
72
 
77
73
  if (childCount === 1 && hasIcon) {
78
74
  variant = "iconOnly";
79
- } else {
80
- variant = getVariant(buttonType, ButtonTypes, ButtonTypes.Primary);
81
75
  }
82
76
 
83
77
  styles = useStyleConfig("Button", { variant });
78
+
84
79
  return (
85
80
  <ChakraButton
86
81
  id={id}
@@ -88,9 +83,8 @@ export const Button = chakra((props: React.PropsWithChildren<ButtonProps>) => {
88
83
  className={className}
89
84
  type={type}
90
85
  isDisabled={isDisabled}
91
- {...attributes}
92
86
  {...btnCallback}
93
- __css={{ ...styles, ...additionalStyles }}
87
+ __css={styles}
94
88
  {...rest}
95
89
  >
96
90
  {children}