@nypl/design-system-react-components 1.0.2 → 1.0.3-beta

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 (282) hide show
  1. package/README.md +0 -2
  2. package/dist/components/Slider/Slider.d.ts +1 -2
  3. package/dist/components/TextInput/TextInput.d.ts +2 -1
  4. package/dist/design-system-react-components.cjs.development.js +33 -10
  5. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  6. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  7. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  8. package/dist/design-system-react-components.esm.js +33 -10
  9. package/dist/design-system-react-components.esm.js.map +1 -1
  10. package/dist/hooks/{tests → __tests__}/useCarouselStyles.test.d.ts +0 -0
  11. package/dist/theme/components/global.d.ts +1 -1
  12. package/dist/theme/components/radio.d.ts +8 -0
  13. package/dist/theme/components/template.d.ts +4 -1
  14. package/package.json +2 -3
  15. package/CHANGELOG.md +0 -1430
  16. package/src/__tests__/fileMock.ts +0 -6
  17. package/src/__tests__/setup.ts +0 -27
  18. package/src/__tests__/utils/utils.test.ts +0 -18
  19. package/src/components/AccessibilityGuide/SkipNavigation.stories.mdx +0 -42
  20. package/src/components/Accordion/Accordion.stories.mdx +0 -333
  21. package/src/components/Accordion/Accordion.test.tsx +0 -237
  22. package/src/components/Accordion/Accordion.tsx +0 -137
  23. package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +0 -734
  24. package/src/components/Autosuggest/Autosuggest.stories.mdx +0 -75
  25. package/src/components/Autosuggest/Autosuggest.stories.tsx +0 -211
  26. package/src/components/Autosuggest/_Autosuggest.scss +0 -51
  27. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +0 -231
  28. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +0 -144
  29. package/src/components/Breadcrumbs/Breadcrumbs.tsx +0 -98
  30. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +0 -695
  31. package/src/components/Button/Button.stories.mdx +0 -320
  32. package/src/components/Button/Button.test.tsx +0 -184
  33. package/src/components/Button/Button.tsx +0 -95
  34. package/src/components/Button/__snapshots__/Button.test.tsx.snap +0 -106
  35. package/src/components/ButtonGroup/ButtonGroup.stories.mdx +0 -178
  36. package/src/components/ButtonGroup/ButtonGroup.test.tsx +0 -141
  37. package/src/components/ButtonGroup/ButtonGroup.tsx +0 -100
  38. package/src/components/ButtonGroup/__snapshots__/ButtonGroup.test.tsx.snap +0 -117
  39. package/src/components/Card/Card.stories.mdx +0 -1041
  40. package/src/components/Card/Card.test.tsx +0 -388
  41. package/src/components/Card/Card.tsx +0 -346
  42. package/src/components/Card/__snapshots__/Card.test.tsx.snap +0 -568
  43. package/src/components/Chakra/Box.stories.mdx +0 -52
  44. package/src/components/Chakra/Center.stories.mdx +0 -96
  45. package/src/components/Chakra/Flex.stories.mdx +0 -111
  46. package/src/components/Chakra/Grid.stories.mdx +0 -89
  47. package/src/components/Chakra/Stack.stories.mdx +0 -109
  48. package/src/components/Checkbox/Checkbox.stories.mdx +0 -243
  49. package/src/components/Checkbox/Checkbox.test.tsx +0 -350
  50. package/src/components/Checkbox/Checkbox.tsx +0 -152
  51. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +0 -661
  52. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +0 -462
  53. package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +0 -492
  54. package/src/components/CheckboxGroup/CheckboxGroup.tsx +0 -173
  55. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +0 -1842
  56. package/src/components/ComponentWrapper/ComponentWrapper.test.tsx +0 -163
  57. package/src/components/ComponentWrapper/ComponentWrapper.tsx +0 -76
  58. package/src/components/ComponentWrapper/__snapshots__/ComponentWrapper.test.tsx.snap +0 -103
  59. package/src/components/DatePicker/DatePicker.stories.mdx +0 -452
  60. package/src/components/DatePicker/DatePicker.test.tsx +0 -940
  61. package/src/components/DatePicker/DatePicker.tsx +0 -450
  62. package/src/components/DatePicker/_DatePicker.scss +0 -100
  63. package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +0 -908
  64. package/src/components/Fieldset/Fieldset.stories.mdx +0 -96
  65. package/src/components/Fieldset/Fieldset.test.tsx +0 -155
  66. package/src/components/Fieldset/Fieldset.tsx +0 -55
  67. package/src/components/Fieldset/__snapshots__/Fieldset.test.tsx.snap +0 -89
  68. package/src/components/Form/Form.stories.mdx +0 -426
  69. package/src/components/Form/Form.test.tsx +0 -234
  70. package/src/components/Form/Form.tsx +0 -124
  71. package/src/components/Form/__snapshots__/Form.test.tsx.snap +0 -115
  72. package/src/components/Grid/SimpleGrid.stories.mdx +0 -336
  73. package/src/components/Grid/SimpleGrid.test.tsx +0 -79
  74. package/src/components/Grid/SimpleGrid.tsx +0 -49
  75. package/src/components/Grid/__snapshots__/SimpleGrid.test.tsx.snap +0 -23
  76. package/src/components/Heading/Heading.stories.mdx +0 -187
  77. package/src/components/Heading/Heading.test.tsx +0 -171
  78. package/src/components/Heading/Heading.tsx +0 -104
  79. package/src/components/Heading/__snapshots__/Heading.test.tsx.snap +0 -90
  80. package/src/components/HelperErrorText/HelperErrorText.stories.mdx +0 -172
  81. package/src/components/HelperErrorText/HelperErrorText.test.tsx +0 -114
  82. package/src/components/HelperErrorText/HelperErrorText.tsx +0 -62
  83. package/src/components/HelperErrorText/__snapshots__/HelperErrorText.test.tsx.snap +0 -93
  84. package/src/components/Hero/Hero.stories.mdx +0 -378
  85. package/src/components/Hero/Hero.test.tsx +0 -611
  86. package/src/components/Hero/Hero.tsx +0 -203
  87. package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +0 -379
  88. package/src/components/HorizontalRule/HorizontalRule.stories.mdx +0 -73
  89. package/src/components/HorizontalRule/HorizontalRule.test.tsx +0 -54
  90. package/src/components/HorizontalRule/HorizontalRule.tsx +0 -27
  91. package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +0 -44
  92. package/src/components/Icons/Icon.stories.mdx +0 -413
  93. package/src/components/Icons/Icon.test.tsx +0 -120
  94. package/src/components/Icons/Icon.tsx +0 -187
  95. package/src/components/Icons/IconSvgs.tsx +0 -64
  96. package/src/components/Icons/__snapshots__/Icon.test.tsx.snap +0 -129
  97. package/src/components/Image/Image.stories.mdx +0 -332
  98. package/src/components/Image/Image.test.tsx +0 -155
  99. package/src/components/Image/Image.tsx +0 -171
  100. package/src/components/Image/__snapshots__/Image.test.tsx.snap +0 -269
  101. package/src/components/Label/Label.stories.mdx +0 -100
  102. package/src/components/Label/Label.test.tsx +0 -116
  103. package/src/components/Label/Label.tsx +0 -55
  104. package/src/components/Label/__snapshots__/Label.test.tsx.snap +0 -45
  105. package/src/components/Link/Link.stories.mdx +0 -249
  106. package/src/components/Link/Link.test.tsx +0 -224
  107. package/src/components/Link/Link.tsx +0 -178
  108. package/src/components/Link/__snapshots__/Link.test.tsx.snap +0 -286
  109. package/src/components/List/List.stories.mdx +0 -393
  110. package/src/components/List/List.test.tsx +0 -265
  111. package/src/components/List/List.tsx +0 -156
  112. package/src/components/List/__snapshots__/List.test.tsx.snap +0 -213
  113. package/src/components/Logo/Logo.stories.mdx +0 -295
  114. package/src/components/Logo/Logo.test.tsx +0 -116
  115. package/src/components/Logo/Logo.tsx +0 -151
  116. package/src/components/Logo/LogoSvgs.tsx +0 -90
  117. package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +0 -142
  118. package/src/components/Modal/Modal.stories.mdx +0 -294
  119. package/src/components/Modal/Modal.test.tsx +0 -157
  120. package/src/components/Modal/Modal.tsx +0 -154
  121. package/src/components/Modal/__snapshots__/Modal.test.tsx.snap +0 -25
  122. package/src/components/Notification/Notification.stories.mdx +0 -358
  123. package/src/components/Notification/Notification.test.tsx +0 -279
  124. package/src/components/Notification/Notification.tsx +0 -224
  125. package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +0 -525
  126. package/src/components/Pagination/Pagination.stories.mdx +0 -184
  127. package/src/components/Pagination/Pagination.test.tsx +0 -419
  128. package/src/components/Pagination/Pagination.tsx +0 -269
  129. package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +0 -544
  130. package/src/components/Placeholder/Placeholder.tsx +0 -19
  131. package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +0 -360
  132. package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +0 -298
  133. package/src/components/ProgressIndicator/ProgressIndicator.tsx +0 -132
  134. package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +0 -434
  135. package/src/components/Radio/Radio.stories.mdx +0 -216
  136. package/src/components/Radio/Radio.test.tsx +0 -247
  137. package/src/components/Radio/Radio.tsx +0 -119
  138. package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +0 -451
  139. package/src/components/RadioGroup/RadioGroup.stories.mdx +0 -479
  140. package/src/components/RadioGroup/RadioGroup.test.tsx +0 -471
  141. package/src/components/RadioGroup/RadioGroup.tsx +0 -171
  142. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +0 -1550
  143. package/src/components/SearchBar/SearchBar.stories.mdx +0 -518
  144. package/src/components/SearchBar/SearchBar.test.tsx +0 -435
  145. package/src/components/SearchBar/SearchBar.tsx +0 -210
  146. package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +0 -1049
  147. package/src/components/Select/Select.stories.mdx +0 -439
  148. package/src/components/Select/Select.test.tsx +0 -358
  149. package/src/components/Select/Select.tsx +0 -183
  150. package/src/components/Select/__snapshots__/Select.test.tsx.snap +0 -895
  151. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +0 -142
  152. package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +0 -116
  153. package/src/components/SkeletonLoader/SkeletonLoader.tsx +0 -123
  154. package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +0 -898
  155. package/src/components/SkipNavigation/SkipNavigation.stories.mdx +0 -90
  156. package/src/components/SkipNavigation/SkipNavigation.test.tsx +0 -63
  157. package/src/components/SkipNavigation/SkipNavigation.tsx +0 -51
  158. package/src/components/SkipNavigation/__snapshots__/SkipNavigation.test.tsx.snap +0 -130
  159. package/src/components/Slider/Slider.stories.mdx +0 -628
  160. package/src/components/Slider/Slider.test.tsx +0 -736
  161. package/src/components/Slider/Slider.tsx +0 -322
  162. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +0 -2186
  163. package/src/components/StatusBadge/StatusBadge.stories.mdx +0 -109
  164. package/src/components/StatusBadge/StatusBadge.test.tsx +0 -70
  165. package/src/components/StatusBadge/StatusBadge.tsx +0 -35
  166. package/src/components/StatusBadge/__snapshots__/StatusBadge.test.tsx.snap +0 -47
  167. package/src/components/StructuredContent/StructuredContent.stories.mdx +0 -567
  168. package/src/components/StructuredContent/StructuredContent.test.tsx +0 -435
  169. package/src/components/StructuredContent/StructuredContent.tsx +0 -139
  170. package/src/components/StructuredContent/__snapshots__/StructuredContent.test.tsx.snap +0 -368
  171. package/src/components/StyleGuide/Bidirectionality.stories.mdx +0 -206
  172. package/src/components/StyleGuide/Breakpoints.stories.mdx +0 -55
  173. package/src/components/StyleGuide/Buttons.stories.mdx +0 -194
  174. package/src/components/StyleGuide/ColorCard.tsx +0 -43
  175. package/src/components/StyleGuide/Colors.stories.mdx +0 -201
  176. package/src/components/StyleGuide/DesignTokens.stories.mdx +0 -193
  177. package/src/components/StyleGuide/Forms.stories.mdx +0 -94
  178. package/src/components/StyleGuide/Iconography.stories.mdx +0 -142
  179. package/src/components/StyleGuide/Spacing.stories.mdx +0 -116
  180. package/src/components/StyleGuide/Typography.stories.mdx +0 -419
  181. package/src/components/Table/Table.stories.mdx +0 -272
  182. package/src/components/Table/Table.test.tsx +0 -241
  183. package/src/components/Table/Table.tsx +0 -152
  184. package/src/components/Table/__snapshots__/Table.test.tsx.snap +0 -1703
  185. package/src/components/Tabs/Tabs.stories.mdx +0 -338
  186. package/src/components/Tabs/Tabs.test.tsx +0 -298
  187. package/src/components/Tabs/Tabs.tsx +0 -264
  188. package/src/components/Tabs/__snapshots__/Tabs.test.tsx.snap +0 -584
  189. package/src/components/Template/Template.stories.mdx +0 -695
  190. package/src/components/Template/Template.test.tsx +0 -309
  191. package/src/components/Template/Template.tsx +0 -326
  192. package/src/components/Template/__snapshots__/Template.test.tsx.snap +0 -342
  193. package/src/components/Text/Text.stories.mdx +0 -103
  194. package/src/components/Text/Text.test.tsx +0 -63
  195. package/src/components/Text/Text.tsx +0 -50
  196. package/src/components/Text/__snapshots__/Text.test.tsx.snap +0 -50
  197. package/src/components/TextInput/TextInput.stories.mdx +0 -268
  198. package/src/components/TextInput/TextInput.test.tsx +0 -451
  199. package/src/components/TextInput/TextInput.tsx +0 -240
  200. package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +0 -274
  201. package/src/components/Toggle/Toggle.stories.mdx +0 -237
  202. package/src/components/Toggle/Toggle.test.tsx +0 -170
  203. package/src/components/Toggle/Toggle.tsx +0 -128
  204. package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +0 -470
  205. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +0 -212
  206. package/src/components/VideoPlayer/VideoPlayer.test.tsx +0 -308
  207. package/src/components/VideoPlayer/VideoPlayer.tsx +0 -188
  208. package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +0 -192
  209. package/src/docs/Chakra.stories.mdx +0 -563
  210. package/src/docs/Welcome.stories.mdx +0 -148
  211. package/src/helpers/types.ts +0 -1
  212. package/src/hooks/tests/useCarouselStyles.test.ts +0 -140
  213. package/src/hooks/tests/useNYPLTheme.test.tsx +0 -36
  214. package/src/hooks/useCarouselStyles.stories.mdx +0 -30
  215. package/src/hooks/useCarouselStyles.ts +0 -35
  216. package/src/hooks/useNYPLTheme.stories.mdx +0 -98
  217. package/src/hooks/useNYPLTheme.ts +0 -91
  218. package/src/hooks/useWindowSize.stories.mdx +0 -23
  219. package/src/hooks/useWindowSize.ts +0 -40
  220. package/src/index.ts +0 -136
  221. package/src/resources.scss +0 -6
  222. package/src/styles/base/_01-breakpoints.scss +0 -27
  223. package/src/styles/base/_02-mixins.scss +0 -103
  224. package/src/styles/base/_place-holder.scss +0 -33
  225. package/src/styles/space/_space-inline.scss +0 -79
  226. package/src/styles/space/_space-inset.scss +0 -57
  227. package/src/styles/space/_space-stack.scss +0 -116
  228. package/src/styles.scss +0 -23
  229. package/src/theme/components/accordion.ts +0 -25
  230. package/src/theme/components/breadcrumb.ts +0 -94
  231. package/src/theme/components/button.ts +0 -133
  232. package/src/theme/components/buttonGroup.ts +0 -10
  233. package/src/theme/components/card.ts +0 -237
  234. package/src/theme/components/checkbox.ts +0 -110
  235. package/src/theme/components/checkboxGroup.ts +0 -10
  236. package/src/theme/components/componentWrapper.ts +0 -14
  237. package/src/theme/components/customTable.ts +0 -77
  238. package/src/theme/components/datePicker.ts +0 -17
  239. package/src/theme/components/fieldset.ts +0 -23
  240. package/src/theme/components/global.ts +0 -91
  241. package/src/theme/components/globalMixins.ts +0 -24
  242. package/src/theme/components/heading.ts +0 -79
  243. package/src/theme/components/helperErrorText.ts +0 -14
  244. package/src/theme/components/hero.ts +0 -238
  245. package/src/theme/components/horizontalRule.ts +0 -17
  246. package/src/theme/components/icon.ts +0 -88
  247. package/src/theme/components/image.ts +0 -136
  248. package/src/theme/components/label.ts +0 -15
  249. package/src/theme/components/link.ts +0 -63
  250. package/src/theme/components/list.ts +0 -88
  251. package/src/theme/components/logo.ts +0 -58
  252. package/src/theme/components/notification.ts +0 -132
  253. package/src/theme/components/pagination.ts +0 -17
  254. package/src/theme/components/progressIndicator.ts +0 -67
  255. package/src/theme/components/radio.ts +0 -103
  256. package/src/theme/components/radioGroup.ts +0 -10
  257. package/src/theme/components/searchBar.ts +0 -19
  258. package/src/theme/components/select.ts +0 -72
  259. package/src/theme/components/skeletonLoader.ts +0 -113
  260. package/src/theme/components/skipNavigation.ts +0 -29
  261. package/src/theme/components/slider.ts +0 -95
  262. package/src/theme/components/statusBadge.ts +0 -26
  263. package/src/theme/components/structuredContent.ts +0 -149
  264. package/src/theme/components/tabs.ts +0 -109
  265. package/src/theme/components/template.ts +0 -114
  266. package/src/theme/components/text.ts +0 -38
  267. package/src/theme/components/textInput.ts +0 -65
  268. package/src/theme/components/toggle.ts +0 -109
  269. package/src/theme/components/videoPlayer.ts +0 -47
  270. package/src/theme/foundations/breakpoints.ts +0 -24
  271. package/src/theme/foundations/colors.ts +0 -212
  272. package/src/theme/foundations/global.ts +0 -43
  273. package/src/theme/foundations/radii.ts +0 -7
  274. package/src/theme/foundations/shadows.ts +0 -5
  275. package/src/theme/foundations/spacing.ts +0 -136
  276. package/src/theme/foundations/typography.ts +0 -107
  277. package/src/theme/index.ts +0 -131
  278. package/src/theme/provider.tsx +0 -9
  279. package/src/theme/types.ts +0 -1
  280. package/src/utils/componentCategories.ts +0 -152
  281. package/src/utils/interfaces.ts +0 -5
  282. package/src/utils/utils.ts +0 -84
@@ -1,178 +0,0 @@
1
- import {
2
- ArgsTable,
3
- Canvas,
4
- Description,
5
- Meta,
6
- Story,
7
- } from "@storybook/addon-docs";
8
- import { withDesign } from "storybook-addon-designs";
9
-
10
- import Button from "../Button/Button";
11
- import ButtonGroup from "./ButtonGroup";
12
- import Heading from "../Heading/Heading";
13
- import SimpleGrid from "../Grid/SimpleGrid";
14
- import { getCategory } from "../../utils/componentCategories";
15
- import DSProvider from "../../theme/provider";
16
-
17
- <Meta
18
- title={getCategory("ButtonGroup")}
19
- component={ButtonGroup}
20
- decorators={[withDesign]}
21
- parameters={{
22
- jest: ["ButtonGroup.test.tsx"],
23
- }}
24
- argTypes={{
25
- buttonWidth: { table: { defaultValue: { summary: "default" } } },
26
- className: { control: false },
27
- id: { control: false },
28
- isDisabled: { table: { defaultValue: { summary: false } } },
29
- layout: { table: { defaultValue: { summary: "row" } } },
30
- }}
31
- />
32
-
33
- # ButtonGroup
34
-
35
- | Component Version | DS Version |
36
- | ----------------- | ---------- |
37
- | Added | `0.28.0` |
38
- | Latest | `1.0.2` |
39
-
40
- ## Table of Contents
41
-
42
- - [Overview](#overview)
43
- - [Component Props](#component-props)
44
- - [Accessibility](#accessibility)
45
- - [Button Width](#button-width)
46
- - [Layout](#layout)
47
- - [isDisabled](#isDisabled)
48
-
49
- ## Overview
50
-
51
- <Description of={ButtonGroup} />
52
-
53
- Note: The `ButtonGroup` component does not come from Chakra because we want to
54
- display the `Button`s in a column layout as an option, as well as control the
55
- width.
56
-
57
- ## Component Props
58
-
59
- <Canvas withToolbar>
60
- <Story
61
- name="ButtonGroup with Controls"
62
- args={{
63
- buttonWidth: "default",
64
- className: undefined,
65
- id: "button-id",
66
- isDisabled: false,
67
- layout: "row",
68
- }}
69
- >
70
- {(args) => (
71
- <ButtonGroup {...args}>
72
- <Button buttonType="secondary" id="group-1">
73
- Button
74
- </Button>
75
- <Button id="group-2">Submit</Button>
76
- </ButtonGroup>
77
- )}
78
- </Story>
79
- </Canvas>
80
-
81
- <ArgsTable story="ButtonGroup with Controls" />
82
-
83
- ## Accessibility
84
-
85
- This component is a wrapper around the `Button` component. For accessibility
86
- information on the `Button` component, see the
87
- [Button Accessibility](https://nypl.github.io/nypl-design-system/reservoir/v1/?path=/docs/components-form-elements-button--button-with-controls#accessibility)
88
- documentation.
89
-
90
- ## Button Width
91
-
92
- The `buttonWidth` prop can be used to set the width of the internal `Button`
93
- components. The default value is `default` and it sets the width to `"fit-content"`
94
- so the buttons will expand to its content. The `"full"` value will set the width
95
- to the parent's width.
96
-
97
- <Canvas>
98
- <DSProvider>
99
- <SimpleGrid columns={1}>
100
- <Heading level="three">default fit-content</Heading>
101
- <ButtonGroup>
102
- <Button buttonType="secondary" id="width-fit-1">
103
- Button
104
- </Button>
105
- <Button id="width-fit-2">Submit</Button>
106
- </ButtonGroup>
107
- <Heading level="three">full width</Heading>
108
- <ButtonGroup buttonWidth="full">
109
- <Button buttonType="secondary" id="width-full-1">
110
- Button
111
- </Button>
112
- <Button id="width-full-2">Submit</Button>
113
- </ButtonGroup>
114
- </SimpleGrid>
115
- </DSProvider>
116
- </Canvas>
117
-
118
- ## Layout
119
-
120
- The `layout` prop can be used to set the layout to either `row` or `column`.
121
-
122
- <Canvas>
123
- <DSProvider>
124
- <SimpleGrid columns={1}>
125
- <Heading level="three">default row</Heading>
126
- <ButtonGroup>
127
- <Button buttonType="secondary" id="row-1">
128
- Button
129
- </Button>
130
- <Button id="row-2">Submit</Button>
131
- </ButtonGroup>
132
- <Heading level="three">column</Heading>
133
- <ButtonGroup layout="column">
134
- <Button buttonType="secondary" id="column-1">
135
- Button
136
- </Button>
137
- <Button id="column-2">Submit</Button>
138
- </ButtonGroup>
139
- <Heading level="three">column layout with full-width</Heading>
140
- <ButtonGroup buttonWidth="full" layout="column">
141
- <Button buttonType="secondary" id="column-full-1">
142
- Button
143
- </Button>
144
- <Button id="column-full-2">Submit</Button>
145
- </ButtonGroup>
146
- </SimpleGrid>
147
- </DSProvider>
148
- </Canvas>
149
-
150
- ## isDisabled
151
-
152
- The `isDisabled` prop can be used to disable all the `Button` children at once.
153
- Individual `Button`s can still be disabled with their own `isDisabled` prop.
154
-
155
- <Canvas>
156
- <DSProvider>
157
- <SimpleGrid columns={1}>
158
- <Heading level="three">ButtonGroup isDisabled</Heading>
159
- <ButtonGroup isDisabled>
160
- <Button buttonType="secondary" id="group-disabled-1">
161
- Button disabled
162
- </Button>
163
- <Button buttonType="secondary" id="group-disabled-2">
164
- Button disabled
165
- </Button>
166
- </ButtonGroup>
167
- <Heading level="three">Individual Button isDisabled</Heading>
168
- <ButtonGroup>
169
- <Button buttonType="secondary" id="individual-disabled-1">
170
- Button not disabled
171
- </Button>
172
- <Button buttonType="secondary" id="individual-disabled-2" isDisabled>
173
- Button disabled
174
- </Button>
175
- </ButtonGroup>
176
- </SimpleGrid>
177
- </DSProvider>
178
- </Canvas>
@@ -1,141 +0,0 @@
1
- import * as React from "react";
2
- import { render, screen } from "@testing-library/react";
3
- import { axe } from "jest-axe";
4
- import renderer from "react-test-renderer";
5
-
6
- import Button from "../Button/Button";
7
- import ButtonGroup from "../ButtonGroup/ButtonGroup";
8
-
9
- describe("ButtonGroup Accessibility", () => {
10
- it("passes axe accessibility test", async () => {
11
- const { container } = render(
12
- <ButtonGroup>
13
- <Button buttonType="secondary" id="btn-1">
14
- Button
15
- </Button>
16
- <Button id="btn-2">Submit</Button>
17
- </ButtonGroup>
18
- );
19
- expect(await axe(container)).toHaveNoViolations();
20
- });
21
- });
22
-
23
- describe("ButtonGroup", () => {
24
- it("renders only Button components", () => {
25
- render(
26
- <ButtonGroup>
27
- <Button buttonType="secondary" id="btn-1">
28
- Button
29
- </Button>
30
- <Button id="btn-2">Submit</Button>
31
- <p data-test="paragraph">This is not a button</p>
32
- </ButtonGroup>
33
- );
34
-
35
- expect(screen.getAllByRole("button")).toHaveLength(2);
36
- expect(screen.queryByTestId("paragraph")).not.toBeInTheDocument();
37
- });
38
-
39
- it("sets all `Button` children as disabled if isDisabled is true", () => {
40
- const { rerender } = render(
41
- <ButtonGroup>
42
- <Button buttonType="secondary" id="btn-1">
43
- Button
44
- </Button>
45
- <Button id="btn-2">Submit</Button>
46
- </ButtonGroup>
47
- );
48
-
49
- expect(screen.getAllByRole("button")[0]).not.toBeDisabled();
50
- expect(screen.getAllByRole("button")[1]).not.toBeDisabled();
51
-
52
- rerender(
53
- <ButtonGroup isDisabled>
54
- <Button buttonType="secondary" id="btn-1">
55
- Button
56
- </Button>
57
- <Button id="btn-2">Submit</Button>
58
- </ButtonGroup>
59
- );
60
-
61
- expect(screen.getAllByRole("button")[0]).toBeDisabled();
62
- expect(screen.getAllByRole("button")[1]).toBeDisabled();
63
- });
64
-
65
- it("logs a warning when any element that is not a Button is passed ", () => {
66
- const warn = jest.spyOn(console, "warn");
67
- render(
68
- <ButtonGroup>
69
- <Button buttonType="secondary" id="btn-1">
70
- Button
71
- </Button>
72
- <Button id="btn-2">Submit</Button>
73
- <p data-test="paragraph">This is not a button</p>
74
- </ButtonGroup>
75
- );
76
- expect(warn).toHaveBeenCalledWith(
77
- "NYPL Reservoir ButtonGroup: Only Button components can be children of ButtonGroup."
78
- );
79
- });
80
- });
81
-
82
- describe("ButtonGroup Snapshot", () => {
83
- it("renders the UI snapshot correctly", () => {
84
- const basic = renderer
85
- .create(
86
- <ButtonGroup>
87
- <Button buttonType="secondary" id="btn-1">
88
- Button
89
- </Button>
90
- <Button id="btn-2">Submit</Button>
91
- </ButtonGroup>
92
- )
93
- .toJSON();
94
- const fullWidth = renderer
95
- .create(
96
- <ButtonGroup buttonWidth="full">
97
- <Button buttonType="secondary" id="btn-1">
98
- Button
99
- </Button>
100
- <Button id="btn-2">Submit</Button>
101
- </ButtonGroup>
102
- )
103
- .toJSON();
104
- const column = renderer
105
- .create(
106
- <ButtonGroup layout="column">
107
- <Button buttonType="secondary" id="btn-1">
108
- Button
109
- </Button>
110
- <Button id="btn-2">Submit</Button>
111
- </ButtonGroup>
112
- )
113
- .toJSON();
114
- const withChakraProps = renderer
115
- .create(
116
- <ButtonGroup p="s" color="ui.error.primary">
117
- <Button buttonType="secondary" id="btn-1">
118
- Button
119
- </Button>
120
- <Button id="btn-2">Submit</Button>
121
- </ButtonGroup>
122
- )
123
- .toJSON();
124
- const withOtherProps = renderer
125
- .create(
126
- <ButtonGroup data-testid="testid">
127
- <Button buttonType="secondary" id="btn-1">
128
- Button
129
- </Button>
130
- <Button id="btn-2">Submit</Button>
131
- </ButtonGroup>
132
- )
133
- .toJSON();
134
-
135
- expect(basic).toMatchSnapshot();
136
- expect(fullWidth).toMatchSnapshot();
137
- expect(column).toMatchSnapshot();
138
- expect(withChakraProps).toMatchSnapshot();
139
- expect(withOtherProps).toMatchSnapshot();
140
- });
141
- });
@@ -1,100 +0,0 @@
1
- import { chakra, Stack, useStyleConfig } from "@chakra-ui/react";
2
- import * as React from "react";
3
-
4
- import Button from "../Button/Button";
5
- import { LayoutTypes } from "../../helpers/types";
6
- import useWindowSize from "../../hooks/useWindowSize";
7
-
8
- export type ButtonGroupWidths = "default" | "full";
9
-
10
- interface ButtonGroupProps {
11
- /** Sets the width to "default" (for "fit-content") or "full". */
12
- buttonWidth?: ButtonGroupWidths;
13
- /** Additional className to use. */
14
- className?: string;
15
- /** ID that other components can cross reference for accessibility purposes. */
16
- id?: string;
17
- /** Set's the disabled state to all the internal `Button` components. */
18
- isDisabled?: boolean;
19
- /** Renders the layout of `Button` components in a row or column. */
20
- layout?: LayoutTypes;
21
- }
22
-
23
- const noop = () => {};
24
-
25
- /**
26
- * A simple wrapper to group `Button` components together. The layout can be set
27
- * to row or column and the width of internal `Button` components can be set to
28
- * the parent's full width or the `Button`'s content width
29
- */
30
- export const ButtonGroup = chakra(
31
- (props: React.PropsWithChildren<ButtonGroupProps>) => {
32
- const {
33
- buttonWidth = "default",
34
- children,
35
- className = "",
36
- id,
37
- isDisabled = false,
38
- layout = "row",
39
- ...rest
40
- } = props;
41
- const newChildren: JSX.Element[] = [];
42
- // Based on --nypl-breakpoint-medium
43
- const breakpointMedium = 600;
44
- const [finalLayout, setFinalLayout] = React.useState<LayoutTypes>(layout);
45
- const [finalButtonWidth, setFinalButtonWidth] =
46
- React.useState<ButtonGroupWidths>(buttonWidth);
47
- const windowDimensions = useWindowSize();
48
- React.useEffect(() => {
49
- // When on a mobile device or narrow window, always set the layout to
50
- // column and the button width to "full".
51
- if (windowDimensions.width <= breakpointMedium) {
52
- setFinalButtonWidth("full");
53
- setFinalLayout("column");
54
- } else {
55
- // Otherwise, set the layout and button width to the values
56
- // passed in via the `buttonWidth` and `layout` props.
57
- setFinalButtonWidth(buttonWidth);
58
- setFinalLayout(layout);
59
- }
60
- }, [buttonWidth, layout, windowDimensions.width]);
61
- const styles = useStyleConfig("ButtonGroup", {
62
- buttonWidth: finalButtonWidth,
63
- });
64
-
65
- React.Children.map(
66
- children as JSX.Element,
67
- (child: React.ReactElement, key: number) => {
68
- if (child.type !== Button) {
69
- // Special case for Storybook MDX documentation.
70
- if (child.props.mdxType && child.props.mdxType === "Button") {
71
- noop();
72
- } else {
73
- console.warn(
74
- "NYPL Reservoir ButtonGroup: Only Button components can be children of ButtonGroup."
75
- );
76
- return;
77
- }
78
- }
79
- const disabledProps = isDisabled ? { isDisabled } : {};
80
- newChildren.push(React.cloneElement(child, { key, ...disabledProps }));
81
- }
82
- );
83
-
84
- return (
85
- <Stack
86
- id={id}
87
- className={className}
88
- direction={finalLayout}
89
- // Always set the spacing to "8px".
90
- spacing="xs"
91
- sx={styles}
92
- {...rest}
93
- >
94
- {newChildren}
95
- </Stack>
96
- );
97
- }
98
- );
99
-
100
- export default ButtonGroup;
@@ -1,117 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`ButtonGroup Snapshot renders the UI snapshot correctly 1`] = `
4
- <div
5
- className="chakra-stack css-ytb711"
6
- >
7
- <button
8
- className="chakra-button css-1xdhyk6"
9
- data-testid="button"
10
- id="btn-1"
11
- type="button"
12
- >
13
- Button
14
- </button>
15
- <button
16
- className="chakra-button css-1xdhyk6"
17
- data-testid="button"
18
- id="btn-2"
19
- type="button"
20
- >
21
- Submit
22
- </button>
23
- </div>
24
- `;
25
-
26
- exports[`ButtonGroup Snapshot renders the UI snapshot correctly 2`] = `
27
- <div
28
- className="chakra-stack css-ytb711"
29
- >
30
- <button
31
- className="chakra-button css-1xdhyk6"
32
- data-testid="button"
33
- id="btn-1"
34
- type="button"
35
- >
36
- Button
37
- </button>
38
- <button
39
- className="chakra-button css-1xdhyk6"
40
- data-testid="button"
41
- id="btn-2"
42
- type="button"
43
- >
44
- Submit
45
- </button>
46
- </div>
47
- `;
48
-
49
- exports[`ButtonGroup Snapshot renders the UI snapshot correctly 3`] = `
50
- <div
51
- className="chakra-stack css-6dfzd0"
52
- >
53
- <button
54
- className="chakra-button css-1xdhyk6"
55
- data-testid="button"
56
- id="btn-1"
57
- type="button"
58
- >
59
- Button
60
- </button>
61
- <button
62
- className="chakra-button css-1xdhyk6"
63
- data-testid="button"
64
- id="btn-2"
65
- type="button"
66
- >
67
- Submit
68
- </button>
69
- </div>
70
- `;
71
-
72
- exports[`ButtonGroup Snapshot renders the UI snapshot correctly 4`] = `
73
- <div
74
- className="chakra-stack css-1pxah8o"
75
- >
76
- <button
77
- className="chakra-button css-1xdhyk6"
78
- data-testid="button"
79
- id="btn-1"
80
- type="button"
81
- >
82
- Button
83
- </button>
84
- <button
85
- className="chakra-button css-1xdhyk6"
86
- data-testid="button"
87
- id="btn-2"
88
- type="button"
89
- >
90
- Submit
91
- </button>
92
- </div>
93
- `;
94
-
95
- exports[`ButtonGroup Snapshot renders the UI snapshot correctly 5`] = `
96
- <div
97
- className="chakra-stack css-ytb711"
98
- data-testid="testid"
99
- >
100
- <button
101
- className="chakra-button css-1xdhyk6"
102
- data-testid="button"
103
- id="btn-1"
104
- type="button"
105
- >
106
- Button
107
- </button>
108
- <button
109
- className="chakra-button css-1xdhyk6"
110
- data-testid="button"
111
- id="btn-2"
112
- type="button"
113
- >
114
- Submit
115
- </button>
116
- </div>
117
- `;