@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
|
@@ -11,7 +11,7 @@ import { withDesign } from "storybook-addon-designs";
|
|
|
11
11
|
import Heading from "../Heading/Heading";
|
|
12
12
|
import SimpleGrid from "../Grid/SimpleGrid";
|
|
13
13
|
import Toggle from "./Toggle";
|
|
14
|
-
import { ToggleSizes } from "./
|
|
14
|
+
import { ToggleSizes } from "./ToggleTypes";
|
|
15
15
|
import { getCategory } from "../../utils/componentCategories";
|
|
16
16
|
import DSProvider from "../../theme/provider";
|
|
17
17
|
import { getStorybookEnumValues } from "../../utils/utils";
|
|
@@ -43,7 +43,7 @@ export const sizeEnumValues = getStorybookEnumValues(
|
|
|
43
43
|
size: {
|
|
44
44
|
control: {
|
|
45
45
|
type: "select",
|
|
46
|
-
table: { defaultValue: { summary: "ToggleSizes.
|
|
46
|
+
table: { defaultValue: { summary: "ToggleSizes.Default" } },
|
|
47
47
|
options: sizeEnumValues.options,
|
|
48
48
|
},
|
|
49
49
|
},
|
|
@@ -55,17 +55,35 @@ export const sizeEnumValues = getStorybookEnumValues(
|
|
|
55
55
|
| Component Version | DS Version |
|
|
56
56
|
| ----------------- | ---------- |
|
|
57
57
|
| Added | `0.25.8` |
|
|
58
|
-
| Latest | `0.
|
|
58
|
+
| Latest | `0.26.0` |
|
|
59
|
+
|
|
60
|
+
## Table of Contents
|
|
61
|
+
|
|
62
|
+
- [Overview](#overview)
|
|
63
|
+
- [Component Props](#component-props)
|
|
64
|
+
- [Accessibility](#accessibility)
|
|
65
|
+
- [Sizes](#sizes)
|
|
66
|
+
- [Controlled Toggle](#controlled-toggle)
|
|
67
|
+
- [Browser States](#browser-states)
|
|
68
|
+
- [Layouts](#layouts)
|
|
69
|
+
|
|
70
|
+
## Overview
|
|
59
71
|
|
|
60
72
|
<Description of={Toggle} />
|
|
61
73
|
|
|
62
|
-
The Toggle component is used as an alternative for the Checkbox component and
|
|
74
|
+
The `Toggle` component is used as an alternative for the Checkbox component and
|
|
75
|
+
returns a boolean response. Like the Checkbox component, the `Toggle` component
|
|
76
|
+
can display a label to the right of the toggle and helper/error text below the toggle.
|
|
63
77
|
|
|
64
78
|
### Best Practices
|
|
65
79
|
|
|
66
|
-
Toggle components are commonly used for “on/off” switches to perform binary
|
|
80
|
+
`Toggle` components are commonly used for “on/off” switches to perform binary
|
|
81
|
+
actions that occur immediately after a user “flips the switch.”
|
|
67
82
|
|
|
68
|
-
The Toggle component label should clarify the action being performed. Labels
|
|
83
|
+
The Toggle component label should clarify the action being performed. Labels
|
|
84
|
+
should be short and to the point, often three words or less.
|
|
85
|
+
|
|
86
|
+
## Component Props
|
|
69
87
|
|
|
70
88
|
<Canvas>
|
|
71
89
|
<Story
|
|
@@ -92,20 +110,43 @@ The Toggle component label should clarify the action being performed. Labels sho
|
|
|
92
110
|
|
|
93
111
|
<ArgsTable story="Toggle" />
|
|
94
112
|
|
|
113
|
+
## Accessibility
|
|
114
|
+
|
|
115
|
+
The `Toggle` component is implemented using Chakra's `Switch` component. While
|
|
116
|
+
some accessibility resources state that using a `<button>` element is better for
|
|
117
|
+
a toggle or switch component, Chakra UI internally uses a `checkbox` element.
|
|
118
|
+
Because Chakra's `Switch` component handles the internal state so well and its
|
|
119
|
+
styles, we chose this over implementing this component with a `<button>` element.
|
|
120
|
+
|
|
121
|
+
For comparison and reference, resources that build toggle components with the
|
|
122
|
+
`<button>` element are linked below.
|
|
123
|
+
|
|
124
|
+
Resources:
|
|
125
|
+
|
|
126
|
+
- [Chakra UI Switch](https://chakra-ui.com/docs/components/form/switch)
|
|
127
|
+
- [W3C Switch Example Using HTML Button](https://w3c.github.io/aria-practices/examples/switch/switch-button.html)
|
|
128
|
+
- [Inclusive Components Toggle Buttons](https://inclusive-components.design/toggle-button/)
|
|
129
|
+
- [Accessible HTML Toggle Button (Switch)](https://www.erikkroes.nl/blog/accessible-html-toggle-button-switch/)
|
|
130
|
+
|
|
95
131
|
## Sizes
|
|
96
132
|
|
|
97
133
|
<Canvas>
|
|
98
134
|
<DSProvider>
|
|
99
135
|
<SimpleGrid columns="2">
|
|
100
136
|
<VStack align="left" spacing="s">
|
|
101
|
-
<Heading level={3}>
|
|
102
|
-
<Toggle
|
|
103
|
-
<Toggle
|
|
137
|
+
<Heading level={3}>Default</Heading>
|
|
138
|
+
<Toggle defaultChecked={true} id="default-checked" labelText="On" />
|
|
139
|
+
<Toggle id="default" labelText="Off" />
|
|
104
140
|
</VStack>
|
|
105
141
|
<VStack align="left" spacing="s">
|
|
106
142
|
<Heading level={3}>Small</Heading>
|
|
107
|
-
<Toggle
|
|
108
|
-
|
|
143
|
+
<Toggle
|
|
144
|
+
defaultChecked={true}
|
|
145
|
+
id="small-checked"
|
|
146
|
+
size={ToggleSizes.Small}
|
|
147
|
+
labelText="On"
|
|
148
|
+
/>
|
|
149
|
+
<Toggle id="default-small" size={ToggleSizes.Small} labelText="Off" />
|
|
109
150
|
</VStack>
|
|
110
151
|
</SimpleGrid>
|
|
111
152
|
</DSProvider>
|
|
@@ -125,17 +166,23 @@ const onChange = (e) => {
|
|
|
125
166
|
console.log(e.target.value);
|
|
126
167
|
};
|
|
127
168
|
|
|
128
|
-
<Toggle
|
|
169
|
+
<Toggle
|
|
170
|
+
id="toggle"
|
|
171
|
+
isChecked={true}
|
|
172
|
+
labelText="Controlled Toggle"
|
|
173
|
+
onChange={onChange}
|
|
174
|
+
/>;
|
|
129
175
|
```
|
|
130
176
|
|
|
131
177
|
<Canvas>
|
|
132
178
|
<DSProvider>
|
|
133
179
|
<Toggle
|
|
180
|
+
id="toggle"
|
|
134
181
|
isChecked={true}
|
|
182
|
+
labelText="Controlled Toggle"
|
|
135
183
|
onChange={(e) => {
|
|
136
184
|
console.log(e.target.value);
|
|
137
185
|
}}
|
|
138
|
-
labelText="Controlled Toggle"
|
|
139
186
|
/>
|
|
140
187
|
</DSProvider>
|
|
141
188
|
</Canvas>
|
|
@@ -147,28 +194,28 @@ const onChange = (e) => {
|
|
|
147
194
|
<SimpleGrid columns="3">
|
|
148
195
|
<VStack align="left" spacing="s">
|
|
149
196
|
<Heading level={3}>Default</Heading>
|
|
150
|
-
<Toggle
|
|
151
|
-
<Toggle
|
|
197
|
+
<Toggle defaultChecked={true} id="checked-default2" labelText="On" />
|
|
198
|
+
<Toggle id="default2" labelText="Off" />
|
|
152
199
|
</VStack>
|
|
153
200
|
<VStack align="left" spacing="s">
|
|
154
201
|
<Heading level={3}>Disabled</Heading>
|
|
155
202
|
<Toggle
|
|
156
|
-
size={ToggleSizes.Large}
|
|
157
203
|
defaultChecked={true}
|
|
204
|
+
id="disabled-checked"
|
|
158
205
|
isDisabled={true}
|
|
159
206
|
labelText="On"
|
|
160
207
|
/>
|
|
161
|
-
<Toggle
|
|
208
|
+
<Toggle id="disabled2" isDisabled={true} labelText="Off" />
|
|
162
209
|
</VStack>
|
|
163
210
|
<VStack align="left" spacing="s">
|
|
164
211
|
<Heading level={3}>Error</Heading>
|
|
165
212
|
<Toggle
|
|
166
|
-
size={ToggleSizes.Large}
|
|
167
213
|
defaultChecked={true}
|
|
168
|
-
|
|
214
|
+
id="error-default"
|
|
169
215
|
isInvalid={true}
|
|
216
|
+
labelText="On"
|
|
170
217
|
/>
|
|
171
|
-
<Toggle
|
|
218
|
+
<Toggle id="error2" isInvalid={true} labelText="Off" />
|
|
172
219
|
</VStack>
|
|
173
220
|
</SimpleGrid>
|
|
174
221
|
</DSProvider>
|
|
@@ -181,18 +228,19 @@ const onChange = (e) => {
|
|
|
181
228
|
<SimpleGrid columns="2">
|
|
182
229
|
<VStack align="left" spacing="s">
|
|
183
230
|
<Heading level={3}>Grouped</Heading>
|
|
184
|
-
<Toggle defaultChecked={true} labelText="On" />
|
|
185
|
-
<Toggle defaultChecked={true} labelText="On" />
|
|
186
|
-
<Toggle defaultChecked={true} labelText="On" />
|
|
187
|
-
<Toggle defaultChecked={true} labelText="On" />
|
|
188
|
-
<Toggle defaultChecked={true} labelText="On" />
|
|
231
|
+
<Toggle defaultChecked={true} id="layout1" labelText="On" />
|
|
232
|
+
<Toggle defaultChecked={true} id="layout2" labelText="On" />
|
|
233
|
+
<Toggle defaultChecked={true} id="layout3" labelText="On" />
|
|
234
|
+
<Toggle defaultChecked={true} id="layout4" labelText="On" />
|
|
235
|
+
<Toggle defaultChecked={true} id="layout5" labelText="On" />
|
|
189
236
|
</VStack>
|
|
190
237
|
<VStack align="left" spacing="s">
|
|
191
238
|
<Heading level={3}>With Helper Text</Heading>
|
|
192
239
|
<Toggle
|
|
193
240
|
defaultChecked={true}
|
|
194
|
-
labelText="On"
|
|
195
241
|
helperText="Component Helper Text"
|
|
242
|
+
id="helper-text"
|
|
243
|
+
labelText="On"
|
|
196
244
|
/>
|
|
197
245
|
</VStack>
|
|
198
246
|
</SimpleGrid>
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
import { render, screen } from "@testing-library/react";
|
|
3
2
|
import userEvent from "@testing-library/user-event";
|
|
4
3
|
import { axe } from "jest-axe";
|
|
4
|
+
import * as React from "react";
|
|
5
5
|
import renderer from "react-test-renderer";
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
import Toggle from "./Toggle";
|
|
8
|
+
import { ToggleSizes } from "./ToggleTypes";
|
|
8
9
|
|
|
9
10
|
describe("Toggle Accessibility", () => {
|
|
10
11
|
it("Passes axe accessibility test", async () => {
|
|
@@ -17,7 +18,6 @@ describe("Toggle Accessibility", () => {
|
|
|
17
18
|
|
|
18
19
|
describe("Toggle", () => {
|
|
19
20
|
let changeHandler;
|
|
20
|
-
let generateUUIDSpy;
|
|
21
21
|
|
|
22
22
|
beforeEach(() => {
|
|
23
23
|
changeHandler = jest.fn();
|
|
@@ -63,13 +63,6 @@ describe("Toggle", () => {
|
|
|
63
63
|
expect(screen.getByRole("checkbox")).toHaveAttribute("id", "inputID");
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
it("Calls the UUID generation function if no id prop value is passed", () => {
|
|
67
|
-
generateUUIDSpy = jest.spyOn(generateUUID, "default");
|
|
68
|
-
expect(generateUUIDSpy).toHaveBeenCalledTimes(0);
|
|
69
|
-
render(<Toggle labelText="Test Label" />);
|
|
70
|
-
expect(generateUUIDSpy).toHaveBeenCalledTimes(1);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
66
|
it("Sets the 'checked' attribute", () => {
|
|
74
67
|
render(<Toggle id="inputID" labelText="Test Label" isChecked />);
|
|
75
68
|
expect(screen.getByRole("checkbox")).toHaveAttribute("checked");
|
|
@@ -118,6 +111,18 @@ describe("Toggle", () => {
|
|
|
118
111
|
expect(changeHandler).toHaveBeenCalledTimes(1);
|
|
119
112
|
});
|
|
120
113
|
|
|
114
|
+
it("Logs a warning when there is no `id` passed", () => {
|
|
115
|
+
const warn = jest.spyOn(console, "warn");
|
|
116
|
+
render(
|
|
117
|
+
// @ts-ignore: Typescript complains when a required prop is not passed, but
|
|
118
|
+
// here we don't want to pass the required prop to make sure the warning appears.
|
|
119
|
+
<Toggle labelText="test" />
|
|
120
|
+
);
|
|
121
|
+
expect(warn).toHaveBeenCalledWith(
|
|
122
|
+
"NYPL Reservoir Toggle: This component's required `id` prop was not passed."
|
|
123
|
+
);
|
|
124
|
+
});
|
|
125
|
+
|
|
121
126
|
it("Renders the UI snapshot correctly", () => {
|
|
122
127
|
const primary = renderer
|
|
123
128
|
.create(<Toggle id="inputID" labelText="Test Label" />)
|
|
@@ -131,10 +136,36 @@ describe("Toggle", () => {
|
|
|
131
136
|
const isDisabled = renderer
|
|
132
137
|
.create(<Toggle id="Toggle-disabled" labelText="Test Label" isDisabled />)
|
|
133
138
|
.toJSON();
|
|
139
|
+
const small = renderer
|
|
140
|
+
.create(
|
|
141
|
+
<Toggle
|
|
142
|
+
id="Toggle-disabled"
|
|
143
|
+
labelText="Test Label"
|
|
144
|
+
isDisabled
|
|
145
|
+
size={ToggleSizes.Small}
|
|
146
|
+
/>
|
|
147
|
+
)
|
|
148
|
+
.toJSON();
|
|
149
|
+
const withChakraProps = renderer
|
|
150
|
+
.create(
|
|
151
|
+
<Toggle
|
|
152
|
+
id="chakra"
|
|
153
|
+
labelText="Test Label"
|
|
154
|
+
p="20px"
|
|
155
|
+
color="ui.error.primray"
|
|
156
|
+
/>
|
|
157
|
+
)
|
|
158
|
+
.toJSON();
|
|
159
|
+
const withOtherProps = renderer
|
|
160
|
+
.create(<Toggle id="props" labelText="Test Label" data-testid="props" />)
|
|
161
|
+
.toJSON();
|
|
134
162
|
|
|
135
163
|
expect(primary).toMatchSnapshot();
|
|
136
164
|
expect(isChecked).toMatchSnapshot();
|
|
137
165
|
expect(isInvalid).toMatchSnapshot();
|
|
138
166
|
expect(isDisabled).toMatchSnapshot();
|
|
167
|
+
expect(small).toMatchSnapshot();
|
|
168
|
+
expect(withChakraProps).toMatchSnapshot();
|
|
169
|
+
expect(withOtherProps).toMatchSnapshot();
|
|
139
170
|
});
|
|
140
171
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Box,
|
|
3
|
+
chakra,
|
|
3
4
|
Switch,
|
|
4
5
|
useMultiStyleConfig,
|
|
5
6
|
useStyleConfig,
|
|
@@ -9,9 +10,7 @@ import * as React from "react";
|
|
|
9
10
|
import HelperErrorText, {
|
|
10
11
|
HelperErrorTextType,
|
|
11
12
|
} from "../HelperErrorText/HelperErrorText";
|
|
12
|
-
import { ToggleSizes } from "./
|
|
13
|
-
import generateUUID from "../../helpers/generateUUID";
|
|
14
|
-
|
|
13
|
+
import { ToggleSizes } from "./ToggleTypes";
|
|
15
14
|
export interface ToggleProps {
|
|
16
15
|
/** Optionally pass in additional Chakra-based styles. */
|
|
17
16
|
additionalStyles?: { [key: string]: any };
|
|
@@ -21,7 +20,7 @@ export interface ToggleProps {
|
|
|
21
20
|
/** Optional string to populate the HelperErrorText for standard state */
|
|
22
21
|
helperText?: HelperErrorTextType;
|
|
23
22
|
/** ID that other components can cross reference for accessibility purposes */
|
|
24
|
-
id
|
|
23
|
+
id: string;
|
|
25
24
|
/** Optional string to populate the HelperErrorText for the error state
|
|
26
25
|
* when `isInvalid` is true. */
|
|
27
26
|
invalidText?: HelperErrorTextType;
|
|
@@ -33,20 +32,18 @@ export interface ToggleProps {
|
|
|
33
32
|
/** Adds the 'disabled' and `aria-disabled` attributes to the input when true.
|
|
34
33
|
* This also makes the text italic and color scheme gray. */
|
|
35
34
|
isDisabled?: boolean;
|
|
36
|
-
/** Adds the 'aria-invalid' attribute to the input when true.
|
|
37
|
-
* the color theme "NYPL error" red for the button and text. */
|
|
35
|
+
/** Adds the 'aria-invalid' attribute to the input when true. */
|
|
38
36
|
isInvalid?: boolean;
|
|
39
37
|
/** Adds the 'required' attribute to the input when true. */
|
|
40
38
|
isRequired?: boolean;
|
|
41
|
-
/** The
|
|
42
|
-
* element if `showlabel` is true, or an "aria-label" if `showLabel` is false. */
|
|
39
|
+
/** The toggle's label. This will serve as the text content for the `<label>` element */
|
|
43
40
|
labelText: string;
|
|
44
|
-
/** The name prop indicates
|
|
45
|
-
*
|
|
41
|
+
/** The name prop indicates the `Toggle`'s form element name. If none is
|
|
42
|
+
* specified, 'default' will be used. */
|
|
46
43
|
name?: string;
|
|
47
44
|
/** The action to perform on the `<input>`'s onChange function */
|
|
48
45
|
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
49
|
-
/**
|
|
46
|
+
/** The size of the Toggle. Defaults to "large". */
|
|
50
47
|
size?: ToggleSizes;
|
|
51
48
|
}
|
|
52
49
|
|
|
@@ -57,13 +54,13 @@ export const onChangeDefault = () => {
|
|
|
57
54
|
/**
|
|
58
55
|
* Component that renders Chakra's `Switch` component along with NYPL defaults.
|
|
59
56
|
*/
|
|
60
|
-
const Toggle =
|
|
61
|
-
(props, ref?) => {
|
|
57
|
+
export const Toggle = chakra(
|
|
58
|
+
React.forwardRef<HTMLInputElement, ToggleProps>((props, ref?) => {
|
|
62
59
|
const {
|
|
63
60
|
additionalStyles = {},
|
|
64
61
|
defaultChecked = false,
|
|
65
62
|
helperText,
|
|
66
|
-
id
|
|
63
|
+
id,
|
|
67
64
|
invalidText,
|
|
68
65
|
isChecked,
|
|
69
66
|
isDisabled = false,
|
|
@@ -72,18 +69,25 @@ const Toggle = React.forwardRef<HTMLInputElement, ToggleProps>(
|
|
|
72
69
|
labelText,
|
|
73
70
|
name,
|
|
74
71
|
onChange = onChangeDefault,
|
|
75
|
-
size = ToggleSizes.
|
|
72
|
+
size = ToggleSizes.Default,
|
|
73
|
+
...rest
|
|
76
74
|
} = props;
|
|
77
75
|
const footnote: HelperErrorTextType = isInvalid ? invalidText : helperText;
|
|
78
76
|
const ariaAttributes = {};
|
|
79
|
-
const styles = useMultiStyleConfig("Toggle", {});
|
|
77
|
+
const styles = useMultiStyleConfig("Toggle", { isDisabled, size });
|
|
80
78
|
const switchStyles = useStyleConfig("Switch", { size });
|
|
81
79
|
ariaAttributes["aria-label"] =
|
|
82
80
|
labelText && footnote ? `${labelText} - ${footnote}` : labelText;
|
|
83
81
|
|
|
82
|
+
if (!id) {
|
|
83
|
+
console.warn(
|
|
84
|
+
"NYPL Reservoir Toggle: This component's required `id` prop was not passed."
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
84
88
|
return (
|
|
85
89
|
<>
|
|
86
|
-
<Box __css={{ ...styles, ...additionalStyles }}>
|
|
90
|
+
<Box __css={{ ...styles, ...additionalStyles }} {...rest}>
|
|
87
91
|
<Switch
|
|
88
92
|
id={id}
|
|
89
93
|
name={name || "default"}
|
|
@@ -91,7 +95,7 @@ const Toggle = React.forwardRef<HTMLInputElement, ToggleProps>(
|
|
|
91
95
|
isInvalid={isInvalid}
|
|
92
96
|
isRequired={isRequired}
|
|
93
97
|
ref={ref}
|
|
94
|
-
size={size === ToggleSizes.
|
|
98
|
+
size={size === ToggleSizes.Default ? "lg" : "sm"}
|
|
95
99
|
lineHeight="1.5"
|
|
96
100
|
{...(isChecked !== undefined
|
|
97
101
|
? {
|
|
@@ -108,17 +112,16 @@ const Toggle = React.forwardRef<HTMLInputElement, ToggleProps>(
|
|
|
108
112
|
</Switch>
|
|
109
113
|
</Box>
|
|
110
114
|
{footnote && (
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
</Box>
|
|
115
|
+
<HelperErrorText
|
|
116
|
+
additionalStyles={styles.helperErrorText}
|
|
117
|
+
id={`${id}-helperText`}
|
|
118
|
+
isInvalid={isInvalid}
|
|
119
|
+
text={footnote}
|
|
120
|
+
/>
|
|
118
121
|
)}
|
|
119
122
|
</>
|
|
120
123
|
);
|
|
121
|
-
}
|
|
124
|
+
})
|
|
122
125
|
);
|
|
123
126
|
|
|
124
127
|
export default Toggle;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Toggle Renders the UI snapshot correctly 1`] = `
|
|
4
4
|
<div
|
|
5
|
-
className="css-
|
|
5
|
+
className="css-1xdhyk6"
|
|
6
6
|
>
|
|
7
7
|
<label
|
|
8
8
|
className="chakra-switch css-18x0has"
|
|
@@ -63,7 +63,7 @@ exports[`Toggle Renders the UI snapshot correctly 1`] = `
|
|
|
63
63
|
|
|
64
64
|
exports[`Toggle Renders the UI snapshot correctly 2`] = `
|
|
65
65
|
<div
|
|
66
|
-
className="css-
|
|
66
|
+
className="css-1xdhyk6"
|
|
67
67
|
>
|
|
68
68
|
<label
|
|
69
69
|
className="chakra-switch css-18x0has"
|
|
@@ -128,7 +128,7 @@ exports[`Toggle Renders the UI snapshot correctly 2`] = `
|
|
|
128
128
|
|
|
129
129
|
exports[`Toggle Renders the UI snapshot correctly 3`] = `
|
|
130
130
|
<div
|
|
131
|
-
className="css-
|
|
131
|
+
className="css-1xdhyk6"
|
|
132
132
|
>
|
|
133
133
|
<label
|
|
134
134
|
className="chakra-switch css-18x0has"
|
|
@@ -192,7 +192,7 @@ exports[`Toggle Renders the UI snapshot correctly 3`] = `
|
|
|
192
192
|
|
|
193
193
|
exports[`Toggle Renders the UI snapshot correctly 4`] = `
|
|
194
194
|
<div
|
|
195
|
-
className="css-
|
|
195
|
+
className="css-1xdhyk6"
|
|
196
196
|
>
|
|
197
197
|
<label
|
|
198
198
|
className="chakra-switch css-18x0has"
|
|
@@ -253,3 +253,190 @@ exports[`Toggle Renders the UI snapshot correctly 4`] = `
|
|
|
253
253
|
</label>
|
|
254
254
|
</div>
|
|
255
255
|
`;
|
|
256
|
+
|
|
257
|
+
exports[`Toggle Renders the UI snapshot correctly 5`] = `
|
|
258
|
+
<div
|
|
259
|
+
className="css-1xdhyk6"
|
|
260
|
+
>
|
|
261
|
+
<label
|
|
262
|
+
className="chakra-switch css-18x0has"
|
|
263
|
+
data-disabled=""
|
|
264
|
+
onClick={[Function]}
|
|
265
|
+
>
|
|
266
|
+
<input
|
|
267
|
+
aria-disabled={true}
|
|
268
|
+
aria-invalid={false}
|
|
269
|
+
aria-label="Test Label"
|
|
270
|
+
checked={false}
|
|
271
|
+
className="chakra-switch__input"
|
|
272
|
+
disabled={true}
|
|
273
|
+
id="Toggle-disabled"
|
|
274
|
+
name="default"
|
|
275
|
+
onBlur={[Function]}
|
|
276
|
+
onChange={[Function]}
|
|
277
|
+
onFocus={[Function]}
|
|
278
|
+
onKeyDown={[Function]}
|
|
279
|
+
onKeyUp={[Function]}
|
|
280
|
+
required={false}
|
|
281
|
+
style={
|
|
282
|
+
Object {
|
|
283
|
+
"border": "0px",
|
|
284
|
+
"clip": "rect(0px, 0px, 0px, 0px)",
|
|
285
|
+
"height": "1px",
|
|
286
|
+
"margin": "-1px",
|
|
287
|
+
"overflow": "hidden",
|
|
288
|
+
"padding": "0px",
|
|
289
|
+
"position": "absolute",
|
|
290
|
+
"whiteSpace": "nowrap",
|
|
291
|
+
"width": "1px",
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
type="checkbox"
|
|
295
|
+
/>
|
|
296
|
+
<span
|
|
297
|
+
aria-hidden={true}
|
|
298
|
+
className="chakra-switch__track css-14qxnv8"
|
|
299
|
+
data-disabled=""
|
|
300
|
+
onMouseDown={[Function]}
|
|
301
|
+
onMouseEnter={[Function]}
|
|
302
|
+
onMouseLeave={[Function]}
|
|
303
|
+
onMouseUp={[Function]}
|
|
304
|
+
>
|
|
305
|
+
<span
|
|
306
|
+
className="chakra-switch__thumb css-0"
|
|
307
|
+
/>
|
|
308
|
+
</span>
|
|
309
|
+
<span
|
|
310
|
+
className="chakra-switch__label css-1y8kf23"
|
|
311
|
+
data-disabled=""
|
|
312
|
+
onMouseDown={[Function]}
|
|
313
|
+
onTouchStart={[Function]}
|
|
314
|
+
>
|
|
315
|
+
Test Label
|
|
316
|
+
</span>
|
|
317
|
+
</label>
|
|
318
|
+
</div>
|
|
319
|
+
`;
|
|
320
|
+
|
|
321
|
+
exports[`Toggle Renders the UI snapshot correctly 6`] = `
|
|
322
|
+
<div
|
|
323
|
+
className="css-13xjm0o"
|
|
324
|
+
>
|
|
325
|
+
<label
|
|
326
|
+
className="chakra-switch css-18x0has"
|
|
327
|
+
onClick={[Function]}
|
|
328
|
+
>
|
|
329
|
+
<input
|
|
330
|
+
aria-disabled={false}
|
|
331
|
+
aria-invalid={false}
|
|
332
|
+
aria-label="Test Label"
|
|
333
|
+
checked={false}
|
|
334
|
+
className="chakra-switch__input"
|
|
335
|
+
disabled={false}
|
|
336
|
+
id="chakra"
|
|
337
|
+
name="default"
|
|
338
|
+
onBlur={[Function]}
|
|
339
|
+
onChange={[Function]}
|
|
340
|
+
onFocus={[Function]}
|
|
341
|
+
onKeyDown={[Function]}
|
|
342
|
+
onKeyUp={[Function]}
|
|
343
|
+
required={false}
|
|
344
|
+
style={
|
|
345
|
+
Object {
|
|
346
|
+
"border": "0px",
|
|
347
|
+
"clip": "rect(0px, 0px, 0px, 0px)",
|
|
348
|
+
"height": "1px",
|
|
349
|
+
"margin": "-1px",
|
|
350
|
+
"overflow": "hidden",
|
|
351
|
+
"padding": "0px",
|
|
352
|
+
"position": "absolute",
|
|
353
|
+
"whiteSpace": "nowrap",
|
|
354
|
+
"width": "1px",
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
type="checkbox"
|
|
358
|
+
/>
|
|
359
|
+
<span
|
|
360
|
+
aria-hidden={true}
|
|
361
|
+
className="chakra-switch__track css-14qxnv8"
|
|
362
|
+
onMouseDown={[Function]}
|
|
363
|
+
onMouseEnter={[Function]}
|
|
364
|
+
onMouseLeave={[Function]}
|
|
365
|
+
onMouseUp={[Function]}
|
|
366
|
+
>
|
|
367
|
+
<span
|
|
368
|
+
className="chakra-switch__thumb css-0"
|
|
369
|
+
/>
|
|
370
|
+
</span>
|
|
371
|
+
<span
|
|
372
|
+
className="chakra-switch__label css-1y8kf23"
|
|
373
|
+
onMouseDown={[Function]}
|
|
374
|
+
onTouchStart={[Function]}
|
|
375
|
+
>
|
|
376
|
+
Test Label
|
|
377
|
+
</span>
|
|
378
|
+
</label>
|
|
379
|
+
</div>
|
|
380
|
+
`;
|
|
381
|
+
|
|
382
|
+
exports[`Toggle Renders the UI snapshot correctly 7`] = `
|
|
383
|
+
<div
|
|
384
|
+
className="css-1xdhyk6"
|
|
385
|
+
data-testid="props"
|
|
386
|
+
>
|
|
387
|
+
<label
|
|
388
|
+
className="chakra-switch css-18x0has"
|
|
389
|
+
onClick={[Function]}
|
|
390
|
+
>
|
|
391
|
+
<input
|
|
392
|
+
aria-disabled={false}
|
|
393
|
+
aria-invalid={false}
|
|
394
|
+
aria-label="Test Label"
|
|
395
|
+
checked={false}
|
|
396
|
+
className="chakra-switch__input"
|
|
397
|
+
disabled={false}
|
|
398
|
+
id="props"
|
|
399
|
+
name="default"
|
|
400
|
+
onBlur={[Function]}
|
|
401
|
+
onChange={[Function]}
|
|
402
|
+
onFocus={[Function]}
|
|
403
|
+
onKeyDown={[Function]}
|
|
404
|
+
onKeyUp={[Function]}
|
|
405
|
+
required={false}
|
|
406
|
+
style={
|
|
407
|
+
Object {
|
|
408
|
+
"border": "0px",
|
|
409
|
+
"clip": "rect(0px, 0px, 0px, 0px)",
|
|
410
|
+
"height": "1px",
|
|
411
|
+
"margin": "-1px",
|
|
412
|
+
"overflow": "hidden",
|
|
413
|
+
"padding": "0px",
|
|
414
|
+
"position": "absolute",
|
|
415
|
+
"whiteSpace": "nowrap",
|
|
416
|
+
"width": "1px",
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
type="checkbox"
|
|
420
|
+
/>
|
|
421
|
+
<span
|
|
422
|
+
aria-hidden={true}
|
|
423
|
+
className="chakra-switch__track css-14qxnv8"
|
|
424
|
+
onMouseDown={[Function]}
|
|
425
|
+
onMouseEnter={[Function]}
|
|
426
|
+
onMouseLeave={[Function]}
|
|
427
|
+
onMouseUp={[Function]}
|
|
428
|
+
>
|
|
429
|
+
<span
|
|
430
|
+
className="chakra-switch__thumb css-0"
|
|
431
|
+
/>
|
|
432
|
+
</span>
|
|
433
|
+
<span
|
|
434
|
+
className="chakra-switch__label css-1y8kf23"
|
|
435
|
+
onMouseDown={[Function]}
|
|
436
|
+
onTouchStart={[Function]}
|
|
437
|
+
>
|
|
438
|
+
Test Label
|
|
439
|
+
</span>
|
|
440
|
+
</label>
|
|
441
|
+
</div>
|
|
442
|
+
`;
|