@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
@@ -250,6 +250,102 @@ describe("Card", () => {
250
250
  <CardContent>middle column content</CardContent>
251
251
  </Card>
252
252
  );
253
+ const cardWithRightActions = () => (
254
+ <Card
255
+ id="cardID"
256
+ imageProps={{
257
+ alt: "Alt text",
258
+ src: "https://placeimg.com/400/200/arch",
259
+ }}
260
+ isAlignedRightActions
261
+ >
262
+ <CardHeading level={HeadingLevels.Three} id="heading1">
263
+ The Card Heading
264
+ </CardHeading>
265
+ <CardContent>middle column content</CardContent>
266
+ <CardActions>
267
+ <Button
268
+ onClick={() => {}}
269
+ id="button1"
270
+ buttonType={ButtonTypes.Primary}
271
+ type="submit"
272
+ >
273
+ Example CTA
274
+ </Button>
275
+ </CardActions>
276
+ <CardActions>
277
+ <Button
278
+ onClick={() => {}}
279
+ id="button2"
280
+ buttonType={ButtonTypes.Primary}
281
+ type="submit"
282
+ >
283
+ Example CTA
284
+ </Button>
285
+ </CardActions>
286
+ </Card>
287
+ );
288
+ const cardWithChakraProps = (
289
+ <Card
290
+ id="chakraProps"
291
+ imageProps={{
292
+ alt: "Alt text",
293
+ src: "https://placeimg.com/400/200/arch",
294
+ }}
295
+ p="s"
296
+ color="ui.error.primary"
297
+ >
298
+ <CardHeading
299
+ level={HeadingLevels.Three}
300
+ id="heading1"
301
+ color="ui.error.secondary"
302
+ >
303
+ The Card Heading
304
+ </CardHeading>
305
+ <CardContent p="20px">middle column content</CardContent>
306
+ <CardActions m="20px">
307
+ <Button
308
+ onClick={() => {}}
309
+ id="button1"
310
+ buttonType={ButtonTypes.Primary}
311
+ type="submit"
312
+ >
313
+ Example CTA
314
+ </Button>
315
+ </CardActions>
316
+ </Card>
317
+ );
318
+ const cardWithOtherProps = (
319
+ <Card
320
+ id="otherProps"
321
+ imageProps={{
322
+ alt: "Alt text",
323
+ src: "https://placeimg.com/400/200/arch",
324
+ }}
325
+ data-testid="card-testid"
326
+ >
327
+ <CardHeading
328
+ level={HeadingLevels.Three}
329
+ id="heading1"
330
+ color="ui.error.secondary"
331
+ >
332
+ The Card Heading
333
+ </CardHeading>
334
+ <CardContent data-testid="cardcontent-testid">
335
+ middle column content
336
+ </CardContent>
337
+ <CardActions data-testid="cardaction-testid">
338
+ <Button
339
+ onClick={() => {}}
340
+ id="button1"
341
+ buttonType={ButtonTypes.Primary}
342
+ type="submit"
343
+ >
344
+ Example CTA
345
+ </Button>
346
+ </CardActions>
347
+ </Card>
348
+ );
253
349
  let container;
254
350
 
255
351
  it("renders a Card with a header, image, content, and CTAs", () => {
@@ -336,6 +432,9 @@ describe("Card", () => {
336
432
  const withNoContent = renderer.create(cardWithNoContent).toJSON();
337
433
  const withNoImage = renderer.create(cardWithNoImage).toJSON();
338
434
  const withFullClick = renderer.create(cardFullClick()).toJSON();
435
+ const withRightActions = renderer.create(cardWithRightActions()).toJSON();
436
+ const withChakraProps = renderer.create(cardWithChakraProps).toJSON();
437
+ const withOtherProps = renderer.create(cardWithOtherProps).toJSON();
339
438
 
340
439
  expect(regular).toMatchSnapshot();
341
440
  expect(withExtendedStyles).toMatchSnapshot();
@@ -343,5 +442,8 @@ describe("Card", () => {
343
442
  expect(withNoContent).toMatchSnapshot();
344
443
  expect(withNoImage).toMatchSnapshot();
345
444
  expect(withFullClick).toMatchSnapshot();
445
+ expect(withRightActions).toMatchSnapshot();
446
+ expect(withChakraProps).toMatchSnapshot();
447
+ expect(withOtherProps).toMatchSnapshot();
346
448
  });
347
449
  });
@@ -1,19 +1,18 @@
1
- import * as React from "react";
2
1
  import {
3
2
  Box,
3
+ chakra,
4
4
  LinkBox as ChakraLinkBox,
5
5
  LinkOverlay as ChakraLinkOverlay,
6
6
  useMultiStyleConfig,
7
7
  useStyleConfig,
8
8
  } from "@chakra-ui/react";
9
+ import * as React from "react";
9
10
 
10
11
  import { LayoutTypes } from "../../helpers/enums";
11
12
  import Heading from "../Heading/Heading";
12
13
  import Image, { ComponentImageProps, ImageProps } from "../Image/Image";
13
14
  import { ImageRatios, ImageSizes } from "../Image/ImageTypes";
14
15
  import useWindowSize from "../../hooks/useWindowSize";
15
- import generateUUID from "../../helpers/generateUUID";
16
-
17
16
  interface CardBaseProps {
18
17
  /** Optional value to control the alignment of the text and elements. */
19
18
  isCentered?: boolean;
@@ -51,17 +50,20 @@ interface CardImageComponentProps extends CardBaseProps, ImageProps {
51
50
  export interface CardProps extends CardBaseProps, CardLinkBoxProps {
52
51
  /** Optional hex color value used to set the card background color. */
53
52
  backgroundColor?: string;
54
- /** Optional boolean value to control the visibility of a border around
55
- * the card. */
56
- border?: boolean;
57
53
  /** Optional CSS class name to add. */
58
54
  className?: string;
59
55
  /** Optional hex color value used to override the default text color. */
60
56
  foregroundColor?: string;
61
57
  /** ID that other components can cross reference for accessibility purposes. */
62
58
  id?: string;
59
+ /** Optional boolean value to control the visibility of a border around
60
+ * the card. */
61
+ isBordered?: boolean;
63
62
  /** Object used to create and render the `Image` component. */
64
63
  imageProps?: CardImageProps;
64
+ /** Set CardActions to the right content side. This only works in
65
+ * the row layout. */
66
+ isAlignedRightActions?: boolean;
65
67
  }
66
68
 
67
69
  /**
@@ -88,8 +90,8 @@ function CardImage(
88
90
  const styles = useStyleConfig("CardImage", {
89
91
  imageIsAtEnd: isAtEnd,
90
92
  isCentered,
91
- size,
92
93
  layout,
94
+ size,
93
95
  });
94
96
  return (
95
97
  <Box __css={styles}>
@@ -107,27 +109,42 @@ function CardImage(
107
109
  }
108
110
 
109
111
  // CardHeading child-component
110
- export const CardHeading = Heading;
112
+ export const CardHeading = chakra(Heading);
111
113
 
112
114
  // CardContent child-component
113
- export function CardContent(props: React.PropsWithChildren<{}>) {
114
- const { children } = props;
115
+ export const CardContent = chakra((props: React.PropsWithChildren<{}>) => {
116
+ const { children, ...rest } = props;
115
117
  const styles = useStyleConfig("CardContent");
116
- return children && <Box __css={styles}>{children}</Box>;
117
- }
118
+ return (
119
+ children && (
120
+ <Box __css={styles} {...rest}>
121
+ {children}
122
+ </Box>
123
+ )
124
+ );
125
+ });
118
126
 
119
127
  // CardActions child-component
120
- export function CardActions(props: React.PropsWithChildren<CardActionsProps>) {
121
- const { bottomBorder, children, isCentered, layout, topBorder } = props;
122
- const styles = useStyleConfig("CardActions", {
123
- bottomBorder,
124
- isCentered,
125
- layout,
126
- topBorder,
127
- });
128
+ export const CardActions = chakra(
129
+ (props: React.PropsWithChildren<CardActionsProps>) => {
130
+ const { bottomBorder, children, isCentered, layout, topBorder, ...rest } =
131
+ props;
132
+ const styles = useStyleConfig("CardActions", {
133
+ bottomBorder,
134
+ isCentered,
135
+ layout,
136
+ topBorder,
137
+ });
128
138
 
129
- return children && <Box __css={styles}>{children}</Box>;
130
- }
139
+ return (
140
+ children && (
141
+ <Box __css={styles} {...rest}>
142
+ {children}
143
+ </Box>
144
+ )
145
+ );
146
+ }
147
+ );
131
148
 
132
149
  /**
133
150
  * If `mainActionLink` is passed, then this adds Chakra's `LinkBox` wrapper
@@ -163,14 +180,13 @@ function CardLinkOverlay({
163
180
  );
164
181
  }
165
182
 
166
- export default function Card(props: React.PropsWithChildren<CardProps>) {
183
+ export const Card = chakra((props: React.PropsWithChildren<CardProps>) => {
167
184
  const {
168
185
  backgroundColor,
169
- border,
170
186
  children,
171
187
  className,
172
188
  foregroundColor,
173
- id = generateUUID(),
189
+ id,
174
190
  imageProps = {
175
191
  alt: "",
176
192
  aspectRatio: ImageRatios.Square,
@@ -181,9 +197,12 @@ export default function Card(props: React.PropsWithChildren<CardProps>) {
181
197
  size: ImageSizes.Default,
182
198
  src: "",
183
199
  },
200
+ isAlignedRightActions = false,
201
+ isBordered,
184
202
  isCentered = false,
185
203
  layout = LayoutTypes.Column,
186
204
  mainActionLink,
205
+ ...rest
187
206
  } = props;
188
207
  const hasImage = imageProps.src || imageProps.component;
189
208
  const [finalImageSize, setFinalImageSize] = React.useState<ImageSizes>(
@@ -194,6 +213,7 @@ export default function Card(props: React.PropsWithChildren<CardProps>) {
194
213
  : imageProps.aspectRatio;
195
214
  const customColors = {};
196
215
  const cardContents = [];
216
+ const cardRightContents = [];
197
217
  const windowDimensions = useWindowSize();
198
218
  let cardHeadingCount = 0;
199
219
 
@@ -221,15 +241,18 @@ export default function Card(props: React.PropsWithChildren<CardProps>) {
221
241
  foregroundColor && (customColors["color"] = foregroundColor);
222
242
 
223
243
  const styles = useMultiStyleConfig("Card", {
224
- border,
225
244
  hasImage,
226
245
  imageIsAtEnd: imageProps.isAtEnd,
246
+ isBordered,
227
247
  isCentered,
228
248
  layout,
229
249
  mainActionLink,
230
250
  });
231
251
 
232
252
  React.Children.map(children, (child: React.ReactElement, key) => {
253
+ const isCardActions =
254
+ child.type === CardActions || child.props.mdxType === "CardActions";
255
+
233
256
  if (child.type === CardHeading || child.props.mdxType === "CardHeading") {
234
257
  // If the child is a `CardHeading` component, then we add the
235
258
  // `CardLinkOverlay` inside of the `Heading` component and wrap its text.
@@ -250,7 +273,6 @@ export default function Card(props: React.PropsWithChildren<CardProps>) {
250
273
  ...child.props.additionalStyles,
251
274
  },
252
275
  key,
253
- isCentered,
254
276
  // Override the child text with the potential `CardLinkOverlay`.
255
277
  children: newChildren,
256
278
  layout,
@@ -259,12 +281,20 @@ export default function Card(props: React.PropsWithChildren<CardProps>) {
259
281
  cardHeadingCount++;
260
282
  } else if (
261
283
  child.type === CardContent ||
262
- child.props.mdxType === "CardContent" ||
263
- child.type === CardActions ||
264
- child.props.mdxType === "CardActions"
284
+ child.props.mdxType === "CardContent"
265
285
  ) {
266
- const elem = React.cloneElement(child, { key, isCentered, layout });
286
+ const elem = React.cloneElement(child, { key });
267
287
  cardContents.push(elem);
288
+ } else if (isCardActions) {
289
+ const elem = React.cloneElement(child, { key, isCentered, layout });
290
+
291
+ // Only allow `CardActions` to align to the right of the main
292
+ // `CardContent` component when in the row layout.
293
+ if (isAlignedRightActions && layout === LayoutTypes.Row) {
294
+ cardRightContents.push(elem);
295
+ } else {
296
+ cardContents.push(elem);
297
+ }
268
298
  }
269
299
  });
270
300
 
@@ -277,6 +307,7 @@ export default function Card(props: React.PropsWithChildren<CardProps>) {
277
307
  ...styles,
278
308
  ...customColors,
279
309
  }}
310
+ {...rest}
280
311
  >
281
312
  {hasImage && (
282
313
  <CardImage
@@ -294,7 +325,17 @@ export default function Card(props: React.PropsWithChildren<CardProps>) {
294
325
  <Box className="card-body" __css={styles.body}>
295
326
  {cardContents}
296
327
  </Box>
328
+ {cardRightContents.length ? (
329
+ <Box
330
+ className="card-right"
331
+ __css={{ ...styles.body, ...styles.actions }}
332
+ >
333
+ {cardRightContents}
334
+ </Box>
335
+ ) : null}
297
336
  </Box>
298
337
  </CardLinkBox>
299
338
  );
300
- }
339
+ });
340
+
341
+ export default Card;