@nypl/design-system-react-components 0.25.13 → 0.26.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.
- package/CHANGELOG.md +58 -0
- package/README.md +10 -10
- package/dist/components/Accordion/Accordion.d.ts +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/dist/components/Button/Button.d.ts +2 -2
- package/dist/components/Card/Card.d.ts +11 -9
- package/dist/components/Checkbox/Checkbox.d.ts +2 -2
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +5 -4
- package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +1 -1
- package/dist/components/DatePicker/DatePicker.d.ts +5 -6
- package/dist/components/Fieldset/Fieldset.d.ts +5 -6
- package/dist/components/Form/Form.d.ts +6 -6
- package/dist/components/Grid/GridTypes.d.ts +7 -7
- package/dist/components/Grid/SimpleGrid.d.ts +1 -1
- package/dist/components/Heading/Heading.d.ts +1 -1
- package/dist/components/HelperErrorText/HelperErrorText.d.ts +9 -8
- package/dist/components/Hero/Hero.d.ts +2 -1
- package/dist/components/HorizontalRule/HorizontalRule.d.ts +2 -10
- package/dist/components/Icons/Icon.d.ts +2 -1
- package/dist/components/Image/Image.d.ts +2 -2
- package/dist/components/Label/Label.d.ts +7 -4
- package/dist/components/Link/Link.d.ts +1 -1
- package/dist/components/List/List.d.ts +11 -11
- package/dist/components/List/ListTypes.d.ts +1 -1
- package/dist/components/Logo/Logo.d.ts +2 -1
- package/dist/components/Logo/LogoSvgs.d.ts +2 -0
- package/dist/components/Logo/LogoTypes.d.ts +2 -0
- package/dist/components/Notification/Notification.d.ts +4 -4
- package/dist/components/Pagination/Pagination.d.ts +2 -2
- package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +3 -3
- package/dist/components/Radio/Radio.d.ts +4 -6
- package/dist/components/RadioGroup/RadioGroup.d.ts +12 -6
- package/dist/components/SearchBar/SearchBar.d.ts +4 -4
- package/dist/components/Select/Select.d.ts +10 -6
- package/dist/components/Select/SelectTypes.d.ts +4 -0
- package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -3
- package/dist/components/Slider/Slider.d.ts +6 -4
- package/dist/components/StatusBadge/StatusBadge.d.ts +5 -1
- package/dist/components/StructuredContent/StructuredContent.d.ts +2 -2
- package/dist/components/Table/Table.d.ts +1 -1
- package/dist/components/Tabs/Tabs.d.ts +4 -3
- package/dist/components/Template/Template.d.ts +4 -3
- package/dist/components/Text/Text.d.ts +1 -1
- package/dist/components/TextInput/TextInput.d.ts +5 -5
- package/dist/components/Toggle/Toggle.d.ts +3 -4
- package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
- package/dist/design-system-react-components.cjs.development.js +1663 -1139
- package/dist/design-system-react-components.cjs.development.js.map +1 -1
- package/dist/design-system-react-components.cjs.production.min.js +1 -1
- package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
- package/dist/design-system-react-components.esm.js +1667 -1143
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/hooks/useCarouselStyles.d.ts +3 -2
- package/dist/hooks/useNYPLTheme.d.ts +12 -0
- package/dist/index.d.ts +4 -1
- package/dist/styles.css +1 -1
- package/dist/theme/components/button.d.ts +10 -2
- package/dist/theme/components/card.d.ts +42 -22
- package/dist/theme/components/checkbox.d.ts +5 -4
- package/dist/theme/components/checkboxGroup.d.ts +1 -1
- package/dist/theme/components/componentWrapper.d.ts +2 -2
- package/dist/theme/components/customTable.d.ts +84 -1
- package/dist/theme/components/fieldset.d.ts +4 -14
- package/dist/theme/components/global.d.ts +23 -17
- package/dist/theme/components/heading.d.ts +53 -0
- package/dist/theme/components/helperErrorText.d.ts +1 -0
- package/dist/theme/components/hero.d.ts +20 -14
- package/dist/theme/components/label.d.ts +9 -10
- package/dist/theme/components/list.d.ts +99 -9
- package/dist/theme/components/radio.d.ts +6 -4
- package/dist/theme/components/radioGroup.d.ts +1 -1
- package/dist/theme/components/select.d.ts +34 -5
- package/dist/theme/components/skeletonLoader.d.ts +2 -2
- package/dist/theme/components/slider.d.ts +6 -3
- package/dist/theme/components/structuredContent.d.ts +197 -0
- package/dist/theme/components/textInput.d.ts +18 -6
- package/dist/theme/components/toggle.d.ts +7 -4
- package/dist/theme/foundations/global.d.ts +2 -0
- package/dist/theme/foundations/radii.d.ts +1 -0
- package/dist/theme/foundations/spacing.d.ts +46 -43
- package/package.json +5 -6
- package/src/components/Accordion/Accordion.stories.mdx +9 -9
- package/src/components/Accordion/Accordion.test.tsx +21 -0
- package/src/components/Accordion/Accordion.tsx +13 -9
- package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +276 -27
- package/src/components/Autosuggest/Autosuggest.stories.mdx +4 -3
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +21 -5
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +52 -31
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +8 -7
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +211 -12
- package/src/components/Button/Button.stories.mdx +87 -23
- package/src/components/Button/Button.test.tsx +25 -0
- package/src/components/Button/Button.tsx +18 -7
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +27 -7
- package/src/components/Card/Card.stories.mdx +287 -194
- package/src/components/Card/Card.test.tsx +102 -0
- package/src/components/Card/Card.tsx +73 -32
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +195 -35
- package/src/components/Chakra/Grid.stories.mdx +4 -4
- package/src/components/Checkbox/Checkbox.stories.mdx +62 -10
- package/src/components/Checkbox/Checkbox.test.tsx +32 -9
- package/src/components/Checkbox/Checkbox.tsx +20 -15
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +134 -7
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +65 -17
- package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +137 -81
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +31 -21
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +332 -97
- package/src/components/ComponentWrapper/ComponentWrapper.test.tsx +12 -0
- package/src/components/ComponentWrapper/ComponentWrapper.tsx +39 -41
- package/src/components/ComponentWrapper/__snapshots__/ComponentWrapper.test.tsx.snap +47 -34
- package/src/components/DatePicker/DatePicker.stories.mdx +63 -27
- package/src/components/DatePicker/DatePicker.test.tsx +89 -13
- package/src/components/DatePicker/DatePicker.tsx +62 -56
- package/src/components/DatePicker/_DatePicker.scss +71 -13
- package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +250 -206
- package/src/components/Fieldset/Fieldset.stories.mdx +33 -3
- package/src/components/Fieldset/Fieldset.test.tsx +58 -28
- package/src/components/Fieldset/Fieldset.tsx +35 -30
- package/src/components/Fieldset/__snapshots__/Fieldset.test.tsx.snap +40 -19
- package/src/components/Form/Form.stories.mdx +72 -39
- package/src/components/Form/Form.test.tsx +58 -15
- package/src/components/Form/Form.tsx +89 -67
- package/src/components/Form/__snapshots__/Form.test.tsx.snap +83 -5
- package/src/components/Grid/GridTypes.tsx +7 -7
- package/src/components/Grid/SimpleGrid.stories.mdx +34 -6
- package/src/components/Grid/SimpleGrid.test.tsx +9 -0
- package/src/components/Grid/SimpleGrid.tsx +29 -20
- package/src/components/Grid/__snapshots__/SimpleGrid.test.tsx.snap +16 -1
- package/src/components/Heading/Heading.stories.mdx +36 -3
- package/src/components/Heading/Heading.test.tsx +10 -0
- package/src/components/Heading/Heading.tsx +56 -50
- package/src/components/Heading/__snapshots__/Heading.test.tsx.snap +26 -7
- package/src/components/HelperErrorText/HelperErrorText.stories.mdx +64 -42
- package/src/components/HelperErrorText/HelperErrorText.test.tsx +15 -0
- package/src/components/HelperErrorText/HelperErrorText.tsx +40 -35
- package/src/components/HelperErrorText/__snapshots__/HelperErrorText.test.tsx.snap +35 -4
- package/src/components/Hero/Hero.stories.mdx +125 -95
- package/src/components/Hero/Hero.test.tsx +33 -0
- package/src/components/Hero/Hero.tsx +135 -126
- package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +89 -17
- package/src/components/HorizontalRule/HorizontalRule.stories.mdx +26 -4
- package/src/components/HorizontalRule/HorizontalRule.test.tsx +9 -19
- package/src/components/HorizontalRule/HorizontalRule.tsx +9 -26
- package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +18 -5
- package/src/components/Icons/Icon.stories.mdx +31 -6
- package/src/components/Icons/Icon.test.tsx +38 -0
- package/src/components/Icons/Icon.tsx +93 -76
- package/src/components/Icons/__snapshots__/Icon.test.tsx.snap +129 -0
- package/src/components/Image/Image.stories.mdx +29 -5
- package/src/components/Image/Image.test.tsx +8 -0
- package/src/components/Image/Image.tsx +38 -26
- package/src/components/Image/__snapshots__/Image.test.tsx.snap +24 -8
- package/src/components/Label/Label.stories.mdx +42 -20
- package/src/components/Label/Label.test.tsx +42 -17
- package/src/components/Label/Label.tsx +22 -13
- package/src/components/Label/__snapshots__/Label.test.tsx.snap +19 -15
- package/src/components/Link/Link.stories.mdx +25 -1
- package/src/components/Link/Link.test.tsx +21 -0
- package/src/components/Link/Link.tsx +8 -8
- package/src/components/Link/__snapshots__/Link.test.tsx.snap +37 -11
- package/src/components/List/List.stories.mdx +75 -40
- package/src/components/List/List.test.tsx +67 -19
- package/src/components/List/List.tsx +38 -25
- package/src/components/List/ListTypes.tsx +1 -1
- package/src/components/List/__snapshots__/List.test.tsx.snap +110 -8
- package/src/components/Logo/Logo.stories.mdx +30 -6
- package/src/components/Logo/Logo.test.tsx +17 -0
- package/src/components/Logo/Logo.tsx +18 -6
- package/src/components/Logo/LogoSvgs.tsx +4 -0
- package/src/components/Logo/LogoTypes.tsx +2 -0
- package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +73 -2
- package/src/components/Modal/Modal.stories.mdx +13 -0
- package/src/components/Notification/Notification.stories.mdx +25 -1
- package/src/components/Notification/Notification.test.tsx +23 -0
- package/src/components/Notification/Notification.tsx +46 -44
- package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +158 -29
- package/src/components/Pagination/Pagination.stories.mdx +24 -4
- package/src/components/Pagination/Pagination.test.tsx +25 -0
- package/src/components/Pagination/Pagination.tsx +6 -6
- package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +244 -27
- package/src/components/Placeholder/Placeholder.tsx +3 -1
- package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +76 -10
- package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +81 -11
- package/src/components/ProgressIndicator/ProgressIndicator.tsx +17 -9
- package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +101 -14
- package/src/components/Radio/Radio.stories.mdx +64 -12
- package/src/components/Radio/Radio.test.tsx +28 -8
- package/src/components/Radio/Radio.tsx +66 -63
- package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +103 -6
- package/src/components/RadioGroup/RadioGroup.stories.mdx +224 -89
- package/src/components/RadioGroup/RadioGroup.test.tsx +122 -62
- package/src/components/RadioGroup/RadioGroup.tsx +106 -100
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +1236 -1020
- package/src/components/SearchBar/SearchBar.stories.mdx +101 -36
- package/src/components/SearchBar/{SearchBar.Test.tsx → SearchBar.test.tsx} +46 -4
- package/src/components/SearchBar/SearchBar.tsx +17 -8
- package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +1039 -0
- package/src/components/Select/Select.stories.mdx +128 -49
- package/src/components/Select/Select.test.tsx +63 -16
- package/src/components/Select/Select.tsx +125 -92
- package/src/components/Select/SelectTypes.tsx +5 -0
- package/src/components/Select/__snapshots__/Select.test.tsx.snap +749 -409
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +42 -10
- package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +8 -0
- package/src/components/SkeletonLoader/SkeletonLoader.tsx +76 -72
- package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +169 -10
- package/src/components/Slider/Slider.stories.mdx +91 -42
- package/src/components/Slider/Slider.test.tsx +65 -17
- package/src/components/Slider/Slider.tsx +26 -19
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +403 -226
- package/src/components/StatusBadge/StatusBadge.stories.mdx +19 -1
- package/src/components/StatusBadge/StatusBadge.test.tsx +16 -0
- package/src/components/StatusBadge/StatusBadge.tsx +25 -20
- package/src/components/StatusBadge/__snapshots__/StatusBadge.test.tsx.snap +22 -3
- package/src/components/StructuredContent/StructuredContent.stories.mdx +131 -12
- package/src/components/StructuredContent/StructuredContent.test.tsx +34 -0
- package/src/components/StructuredContent/StructuredContent.tsx +80 -75
- package/src/components/StructuredContent/__snapshots__/StructuredContent.test.tsx.snap +102 -17
- package/src/components/StyleGuide/Bidirectionality.stories.mdx +5 -5
- package/src/components/StyleGuide/Breakpoints.stories.mdx +6 -6
- package/src/components/StyleGuide/Buttons.stories.mdx +2 -12
- package/src/components/StyleGuide/ColorCard.tsx +1 -1
- package/src/components/StyleGuide/Colors.stories.mdx +1 -2
- package/src/components/StyleGuide/DesignTokens.stories.mdx +56 -26
- package/src/components/StyleGuide/Forms.stories.mdx +27 -12
- package/src/components/StyleGuide/Iconography.stories.mdx +2 -12
- package/src/components/StyleGuide/Spacing.stories.mdx +80 -41
- package/src/components/StyleGuide/Typography.stories.mdx +30 -21
- package/src/components/Table/Table.stories.mdx +38 -11
- package/src/components/Table/Table.test.tsx +15 -0
- package/src/components/Table/Table.tsx +7 -7
- package/src/components/Table/__snapshots__/Table.test.tsx.snap +408 -5
- package/src/components/Tabs/Tabs.stories.mdx +52 -3
- package/src/components/Tabs/Tabs.test.tsx +16 -0
- package/src/components/Tabs/Tabs.tsx +10 -6
- package/src/components/Tabs/__snapshots__/Tabs.test.tsx.snap +394 -5
- package/src/components/Template/Template.stories.mdx +47 -43
- package/src/components/Template/Template.test.tsx +33 -0
- package/src/components/Template/Template.tsx +65 -60
- package/src/components/Template/__snapshots__/Template.test.tsx.snap +191 -20
- package/src/components/Text/Text.stories.mdx +20 -1
- package/src/components/Text/Text.test.tsx +12 -0
- package/src/components/Text/Text.tsx +6 -4
- package/src/components/Text/__snapshots__/Text.test.tsx.snap +21 -4
- package/src/components/TextInput/TextInput.stories.mdx +65 -19
- package/src/components/TextInput/TextInput.test.tsx +42 -28
- package/src/components/TextInput/TextInput.tsx +121 -113
- package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +96 -73
- package/src/components/Toggle/Toggle.stories.mdx +80 -22
- package/src/components/Toggle/Toggle.test.tsx +27 -9
- package/src/components/Toggle/Toggle.tsx +22 -18
- package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +128 -5
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +52 -4
- package/src/components/VideoPlayer/VideoPlayer.test.tsx +23 -0
- package/src/components/VideoPlayer/VideoPlayer.tsx +133 -126
- package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +81 -39
- package/src/docs/Chakra.stories.mdx +50 -9
- package/src/docs/Welcome.stories.mdx +160 -41
- package/src/hooks/useCarouselStyles.stories.mdx +22 -2
- package/src/hooks/useCarouselStyles.ts +3 -2
- package/src/hooks/useNYPLTheme.stories.mdx +101 -0
- package/src/hooks/useNYPLTheme.ts +30 -6
- package/src/hooks/useWindowSize.stories.mdx +23 -0
- package/src/index.ts +4 -1
- package/src/styles/base/_place-holder.scss +1 -1
- package/src/theme/components/button.ts +15 -7
- package/src/theme/components/card.ts +30 -19
- package/src/theme/components/checkbox.ts +10 -8
- package/src/theme/components/checkboxGroup.ts +1 -1
- package/src/theme/components/componentWrapper.ts +2 -2
- package/src/theme/components/customTable.ts +39 -31
- package/src/theme/components/fieldset.ts +1 -2
- package/src/theme/components/global.ts +25 -20
- package/src/theme/components/heading.ts +1 -1
- package/src/theme/components/helperErrorText.ts +1 -0
- package/src/theme/components/hero.ts +13 -15
- package/src/theme/components/label.ts +4 -3
- package/src/theme/components/list.ts +73 -66
- package/src/theme/components/notification.ts +2 -2
- package/src/theme/components/radio.ts +9 -9
- package/src/theme/components/radioGroup.ts +1 -1
- package/src/theme/components/select.ts +35 -22
- package/src/theme/components/skeletonLoader.ts +3 -3
- package/src/theme/components/slider.ts +8 -7
- package/src/theme/components/statusBadge.ts +2 -2
- package/src/theme/components/structuredContent.ts +66 -1
- package/src/theme/components/tabs.ts +2 -2
- package/src/theme/components/template.ts +9 -9
- package/src/theme/components/textInput.ts +13 -12
- package/src/theme/components/toggle.ts +17 -10
- package/src/theme/components/videoPlayer.ts +1 -1
- package/src/theme/foundations/colors.ts +1 -1
- package/src/theme/foundations/radii.ts +1 -0
- package/src/theme/foundations/spacing.ts +70 -22
- package/src/theme/foundations/typography.ts +2 -2
- package/src/utils/componentCategories.ts +1 -2
- package/dist/components/SearchBar/SearchBar.Test.d.ts +0 -1
- package/dist/helpers/generateUUID.d.ts +0 -1
- 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
|
|
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
|
|
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
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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;
|