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