@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
|
@@ -9,10 +9,15 @@ import { ProgressIndicatorTypes } from "./ProgressIndicatorTypes";
|
|
|
9
9
|
describe("ProgressIndicator Accessibility", () => {
|
|
10
10
|
it("passes axe accessibility for linear and circular types", async () => {
|
|
11
11
|
const linearUtils = render(
|
|
12
|
-
<ProgressIndicator
|
|
12
|
+
<ProgressIndicator
|
|
13
|
+
id="progressIndicatorLinear"
|
|
14
|
+
labelText="Linear"
|
|
15
|
+
value={50}
|
|
16
|
+
/>
|
|
13
17
|
);
|
|
14
18
|
const circularUtils = render(
|
|
15
19
|
<ProgressIndicator
|
|
20
|
+
id="progressIndicatorCircular"
|
|
16
21
|
labelText="Circular"
|
|
17
22
|
value={50}
|
|
18
23
|
indicatorType={ProgressIndicatorTypes.Circular}
|
|
@@ -24,10 +29,16 @@ describe("ProgressIndicator Accessibility", () => {
|
|
|
24
29
|
|
|
25
30
|
it("passes axe accessibility for linear and circular types without labels", async () => {
|
|
26
31
|
const linearUtils = render(
|
|
27
|
-
<ProgressIndicator
|
|
32
|
+
<ProgressIndicator
|
|
33
|
+
id="progressIndicatorLinear"
|
|
34
|
+
labelText="Linear"
|
|
35
|
+
value={50}
|
|
36
|
+
showLabel={false}
|
|
37
|
+
/>
|
|
28
38
|
);
|
|
29
39
|
const circularUtils = render(
|
|
30
40
|
<ProgressIndicator
|
|
41
|
+
id="progressIndicatorCircular"
|
|
31
42
|
labelText="Circular"
|
|
32
43
|
value={50}
|
|
33
44
|
indicatorType={ProgressIndicatorTypes.Circular}
|
|
@@ -40,10 +51,16 @@ describe("ProgressIndicator Accessibility", () => {
|
|
|
40
51
|
|
|
41
52
|
it("passes axe accessibility for linear and circular types for indeterminate state", async () => {
|
|
42
53
|
const linearUtils = render(
|
|
43
|
-
<ProgressIndicator
|
|
54
|
+
<ProgressIndicator
|
|
55
|
+
id="progressIndicatorLinear"
|
|
56
|
+
labelText="Linear"
|
|
57
|
+
value={50}
|
|
58
|
+
isIndeterminate
|
|
59
|
+
/>
|
|
44
60
|
);
|
|
45
61
|
const circularUtils = render(
|
|
46
62
|
<ProgressIndicator
|
|
63
|
+
id="progressIndicatorCircular"
|
|
47
64
|
labelText="Circular"
|
|
48
65
|
value={50}
|
|
49
66
|
indicatorType={ProgressIndicatorTypes.Circular}
|
|
@@ -56,10 +73,16 @@ describe("ProgressIndicator Accessibility", () => {
|
|
|
56
73
|
|
|
57
74
|
it("passes axe accessibility for linear and circular types for dark mode", async () => {
|
|
58
75
|
const linearUtils = render(
|
|
59
|
-
<ProgressIndicator
|
|
76
|
+
<ProgressIndicator
|
|
77
|
+
id="progressIndicatorLinear"
|
|
78
|
+
labelText="Linear"
|
|
79
|
+
value={50}
|
|
80
|
+
darkMode
|
|
81
|
+
/>
|
|
60
82
|
);
|
|
61
83
|
const circularUtils = render(
|
|
62
84
|
<ProgressIndicator
|
|
85
|
+
id="progressIndicatorCircular"
|
|
63
86
|
labelText="Circular"
|
|
64
87
|
value={50}
|
|
65
88
|
indicatorType={ProgressIndicatorTypes.Circular}
|
|
@@ -73,7 +96,9 @@ describe("ProgressIndicator Accessibility", () => {
|
|
|
73
96
|
|
|
74
97
|
describe("ProgressIndicator", () => {
|
|
75
98
|
it("renders a label and a progressbar for the linear type", () => {
|
|
76
|
-
render(
|
|
99
|
+
render(
|
|
100
|
+
<ProgressIndicator id="progressIndicator" labelText="Linear" value={50} />
|
|
101
|
+
);
|
|
77
102
|
expect(screen.getByLabelText("Linear")).toBeInTheDocument();
|
|
78
103
|
expect(screen.getByRole("progressbar")).toBeInTheDocument();
|
|
79
104
|
});
|
|
@@ -81,6 +106,7 @@ describe("ProgressIndicator", () => {
|
|
|
81
106
|
it("renders a label, a progressbar, and an svg for the circular type", () => {
|
|
82
107
|
const { container } = render(
|
|
83
108
|
<ProgressIndicator
|
|
109
|
+
id="progressIndicator"
|
|
84
110
|
labelText="Circular"
|
|
85
111
|
indicatorType={ProgressIndicatorTypes.Circular}
|
|
86
112
|
value={50}
|
|
@@ -93,7 +119,12 @@ describe("ProgressIndicator", () => {
|
|
|
93
119
|
|
|
94
120
|
it("renders the appropriate aria atttribute when the label is hidden", () => {
|
|
95
121
|
render(
|
|
96
|
-
<ProgressIndicator
|
|
122
|
+
<ProgressIndicator
|
|
123
|
+
id="progressIndicator"
|
|
124
|
+
labelText="Linear"
|
|
125
|
+
value={50}
|
|
126
|
+
showLabel={false}
|
|
127
|
+
/>
|
|
97
128
|
);
|
|
98
129
|
expect(screen.getByLabelText("Linear")).toBeInTheDocument();
|
|
99
130
|
expect(screen.getByRole("progressbar")).toHaveAttribute(
|
|
@@ -104,32 +135,52 @@ describe("ProgressIndicator", () => {
|
|
|
104
135
|
|
|
105
136
|
it("renders the value passed", () => {
|
|
106
137
|
const { rerender } = render(
|
|
107
|
-
<ProgressIndicator labelText="Linear" value={50} />
|
|
138
|
+
<ProgressIndicator id="progressIndicator" labelText="Linear" value={50} />
|
|
108
139
|
);
|
|
109
140
|
expect(screen.getByText("50%")).toBeInTheDocument();
|
|
110
141
|
|
|
111
|
-
rerender(
|
|
142
|
+
rerender(
|
|
143
|
+
<ProgressIndicator id="progressIndicator" labelText="Linear" value={89} />
|
|
144
|
+
);
|
|
112
145
|
expect(screen.getByText("89%")).toBeInTheDocument();
|
|
113
146
|
|
|
114
|
-
rerender(
|
|
147
|
+
rerender(
|
|
148
|
+
<ProgressIndicator id="progressIndicator" labelText="Linear" value={4} />
|
|
149
|
+
);
|
|
115
150
|
expect(screen.getByText("4%")).toBeInTheDocument();
|
|
116
151
|
});
|
|
117
152
|
|
|
118
153
|
it("logs a warning if a value less than 0 is passed", () => {
|
|
119
154
|
const warn = jest.spyOn(console, "warn");
|
|
120
|
-
render(
|
|
155
|
+
render(
|
|
156
|
+
<ProgressIndicator
|
|
157
|
+
id="progressIndicator"
|
|
158
|
+
labelText="Linear"
|
|
159
|
+
value={-20}
|
|
160
|
+
/>
|
|
161
|
+
);
|
|
121
162
|
|
|
122
163
|
expect(warn).toHaveBeenCalledWith(
|
|
123
|
-
"ProgressIndicator:
|
|
164
|
+
"NYPL Reservoir ProgressIndicator: An invalid value was passed for the" +
|
|
165
|
+
" `value` prop, so 0 will be used. A valid value should be a number" +
|
|
166
|
+
" between 0 and 100."
|
|
124
167
|
);
|
|
125
168
|
});
|
|
126
169
|
|
|
127
170
|
it("logs a warning if a value more than 100 is passed", () => {
|
|
128
171
|
const warn = jest.spyOn(console, "warn");
|
|
129
|
-
render(
|
|
172
|
+
render(
|
|
173
|
+
<ProgressIndicator
|
|
174
|
+
id="progressIndicator"
|
|
175
|
+
labelText="Linear"
|
|
176
|
+
value={150}
|
|
177
|
+
/>
|
|
178
|
+
);
|
|
130
179
|
|
|
131
180
|
expect(warn).toHaveBeenCalledWith(
|
|
132
|
-
"ProgressIndicator:
|
|
181
|
+
"NYPL Reservoir ProgressIndicator: An invalid value was passed for the" +
|
|
182
|
+
" `value` prop, so 0 will be used. A valid value should be a number" +
|
|
183
|
+
" between 0 and 100."
|
|
133
184
|
);
|
|
134
185
|
});
|
|
135
186
|
|
|
@@ -212,6 +263,27 @@ describe("ProgressIndicator", () => {
|
|
|
212
263
|
/>
|
|
213
264
|
)
|
|
214
265
|
.toJSON();
|
|
266
|
+
const withChakraProps = renderer
|
|
267
|
+
.create(
|
|
268
|
+
<ProgressIndicator
|
|
269
|
+
id="chakra"
|
|
270
|
+
labelText="Linear"
|
|
271
|
+
value={50}
|
|
272
|
+
p="20px"
|
|
273
|
+
color="ui.red.primary"
|
|
274
|
+
/>
|
|
275
|
+
)
|
|
276
|
+
.toJSON();
|
|
277
|
+
const withOtherProps = renderer
|
|
278
|
+
.create(
|
|
279
|
+
<ProgressIndicator
|
|
280
|
+
id="props"
|
|
281
|
+
labelText="Linear"
|
|
282
|
+
value={50}
|
|
283
|
+
data-testid="props"
|
|
284
|
+
/>
|
|
285
|
+
)
|
|
286
|
+
.toJSON();
|
|
215
287
|
|
|
216
288
|
expect(linearBasic).toMatchSnapshot();
|
|
217
289
|
expect(circularBasic).toMatchSnapshot();
|
|
@@ -221,5 +293,7 @@ describe("ProgressIndicator", () => {
|
|
|
221
293
|
expect(circularIndeterminate).toMatchSnapshot();
|
|
222
294
|
expect(linearDarkMode).toMatchSnapshot();
|
|
223
295
|
expect(circularDarkMode).toMatchSnapshot();
|
|
296
|
+
expect(withChakraProps).toMatchSnapshot();
|
|
297
|
+
expect(withOtherProps).toMatchSnapshot();
|
|
224
298
|
});
|
|
225
299
|
});
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import {
|
|
3
2
|
Box,
|
|
3
|
+
chakra,
|
|
4
4
|
CircularProgress as ChakraCircularProgress,
|
|
5
5
|
CircularProgressLabel as ChakraCircularProgressLabel,
|
|
6
6
|
Progress as ChakraProgress,
|
|
7
7
|
useMultiStyleConfig,
|
|
8
8
|
} from "@chakra-ui/react";
|
|
9
|
+
import React from "react";
|
|
9
10
|
|
|
10
11
|
import {
|
|
11
12
|
ProgressIndicatorSizes,
|
|
12
13
|
ProgressIndicatorTypes,
|
|
13
14
|
} from "./ProgressIndicatorTypes";
|
|
14
|
-
import generateUUID from "../../helpers/generateUUID";
|
|
15
15
|
import Label from "../Label/Label";
|
|
16
16
|
|
|
17
17
|
export interface ProgressIndicatorProps {
|
|
18
18
|
/** Flag to render the component in a dark background. */
|
|
19
19
|
darkMode?: boolean;
|
|
20
20
|
/** ID that other components can cross reference for accessibility purposes. */
|
|
21
|
-
id
|
|
21
|
+
id: string;
|
|
22
22
|
/** Whether the `ProgressIndicator` should be linear or circular. */
|
|
23
23
|
indicatorType?: ProgressIndicatorTypes;
|
|
24
24
|
/** Whether the progress animation should display because the `value` prop is
|
|
@@ -40,27 +40,33 @@ export interface ProgressIndicatorProps {
|
|
|
40
40
|
* time to complete or consists of multiple steps. Examples include downloading,
|
|
41
41
|
* uploading, or processing.
|
|
42
42
|
*/
|
|
43
|
-
const ProgressIndicator:
|
|
44
|
-
props: ProgressIndicatorProps
|
|
45
|
-
) => {
|
|
43
|
+
export const ProgressIndicator = chakra((props: ProgressIndicatorProps) => {
|
|
46
44
|
const {
|
|
47
45
|
darkMode = false,
|
|
48
|
-
id
|
|
46
|
+
id,
|
|
49
47
|
indicatorType = ProgressIndicatorTypes.Linear,
|
|
50
48
|
isIndeterminate = false,
|
|
51
49
|
labelText,
|
|
52
50
|
showLabel = true,
|
|
53
51
|
size = ProgressIndicatorSizes.Default,
|
|
54
52
|
value = 0,
|
|
53
|
+
...rest
|
|
55
54
|
} = props;
|
|
56
55
|
const styles = useMultiStyleConfig("ProgressIndicator", {
|
|
57
56
|
darkMode,
|
|
58
57
|
size,
|
|
59
58
|
});
|
|
60
59
|
let finalValue = value;
|
|
60
|
+
if (!id) {
|
|
61
|
+
console.warn(
|
|
62
|
+
"NYPL Reservoir Progress Indicator: This component's required `id` prop was not passed."
|
|
63
|
+
);
|
|
64
|
+
}
|
|
61
65
|
if (finalValue < 0 || finalValue > 100) {
|
|
62
66
|
console.warn(
|
|
63
|
-
"ProgressIndicator:
|
|
67
|
+
"NYPL Reservoir ProgressIndicator: An invalid value was passed for the" +
|
|
68
|
+
" `value` prop, so 0 will be used. A valid value should be a number" +
|
|
69
|
+
" between 0 and 100."
|
|
64
70
|
);
|
|
65
71
|
finalValue = 0;
|
|
66
72
|
}
|
|
@@ -120,7 +126,11 @@ const ProgressIndicator: React.FC<ProgressIndicatorProps> = (
|
|
|
120
126
|
);
|
|
121
127
|
};
|
|
122
128
|
|
|
123
|
-
return
|
|
124
|
-
}
|
|
129
|
+
return (
|
|
130
|
+
<Box __css={styles} {...rest}>
|
|
131
|
+
{progressComponent(indicatorType)}
|
|
132
|
+
</Box>
|
|
133
|
+
);
|
|
134
|
+
});
|
|
125
135
|
|
|
126
136
|
export default ProgressIndicator;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`ProgressIndicator Renders the UI snapshot correctly 1`] = `
|
|
4
4
|
<div
|
|
5
|
-
className="css-
|
|
5
|
+
className="css-1xdhyk6"
|
|
6
6
|
>
|
|
7
7
|
<label
|
|
8
|
-
className="css-
|
|
8
|
+
className="css-1xdhyk6"
|
|
9
9
|
htmlFor="linearBasic"
|
|
10
10
|
id="linearBasic-label"
|
|
11
11
|
>
|
|
@@ -45,7 +45,7 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 1`] = `
|
|
|
45
45
|
|
|
46
46
|
exports[`ProgressIndicator Renders the UI snapshot correctly 2`] = `
|
|
47
47
|
<div
|
|
48
|
-
className="css-
|
|
48
|
+
className="css-1xdhyk6"
|
|
49
49
|
>
|
|
50
50
|
<div
|
|
51
51
|
className="css-0"
|
|
@@ -89,7 +89,7 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 2`] = `
|
|
|
89
89
|
</div>
|
|
90
90
|
</div>
|
|
91
91
|
<label
|
|
92
|
-
className="css-
|
|
92
|
+
className="css-1xdhyk6"
|
|
93
93
|
htmlFor="circularBasic"
|
|
94
94
|
id="circularBasic-label"
|
|
95
95
|
>
|
|
@@ -101,7 +101,7 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 2`] = `
|
|
|
101
101
|
|
|
102
102
|
exports[`ProgressIndicator Renders the UI snapshot correctly 3`] = `
|
|
103
103
|
<div
|
|
104
|
-
className="css-
|
|
104
|
+
className="css-1xdhyk6"
|
|
105
105
|
>
|
|
106
106
|
<div
|
|
107
107
|
className="css-0"
|
|
@@ -131,7 +131,7 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 3`] = `
|
|
|
131
131
|
|
|
132
132
|
exports[`ProgressIndicator Renders the UI snapshot correctly 4`] = `
|
|
133
133
|
<div
|
|
134
|
-
className="css-
|
|
134
|
+
className="css-1xdhyk6"
|
|
135
135
|
>
|
|
136
136
|
<div
|
|
137
137
|
className="css-0"
|
|
@@ -174,10 +174,10 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 4`] = `
|
|
|
174
174
|
|
|
175
175
|
exports[`ProgressIndicator Renders the UI snapshot correctly 5`] = `
|
|
176
176
|
<div
|
|
177
|
-
className="css-
|
|
177
|
+
className="css-1xdhyk6"
|
|
178
178
|
>
|
|
179
179
|
<label
|
|
180
|
-
className="css-
|
|
180
|
+
className="css-1xdhyk6"
|
|
181
181
|
htmlFor="linearIndeterminate"
|
|
182
182
|
id="linearIndeterminate-label"
|
|
183
183
|
>
|
|
@@ -211,7 +211,7 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 5`] = `
|
|
|
211
211
|
|
|
212
212
|
exports[`ProgressIndicator Renders the UI snapshot correctly 6`] = `
|
|
213
213
|
<div
|
|
214
|
-
className="css-
|
|
214
|
+
className="css-1xdhyk6"
|
|
215
215
|
>
|
|
216
216
|
<div
|
|
217
217
|
className="css-0"
|
|
@@ -247,7 +247,7 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 6`] = `
|
|
|
247
247
|
</svg>
|
|
248
248
|
</div>
|
|
249
249
|
<label
|
|
250
|
-
className="css-
|
|
250
|
+
className="css-1xdhyk6"
|
|
251
251
|
htmlFor="circularIndeterminate"
|
|
252
252
|
id="circularIndeterminate-label"
|
|
253
253
|
>
|
|
@@ -259,10 +259,10 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 6`] = `
|
|
|
259
259
|
|
|
260
260
|
exports[`ProgressIndicator Renders the UI snapshot correctly 7`] = `
|
|
261
261
|
<div
|
|
262
|
-
className="css-
|
|
262
|
+
className="css-1xdhyk6"
|
|
263
263
|
>
|
|
264
264
|
<label
|
|
265
|
-
className="css-
|
|
265
|
+
className="css-1xdhyk6"
|
|
266
266
|
htmlFor="linearDarkMode"
|
|
267
267
|
id="linearDarkMode-label"
|
|
268
268
|
>
|
|
@@ -302,7 +302,7 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 7`] = `
|
|
|
302
302
|
|
|
303
303
|
exports[`ProgressIndicator Renders the UI snapshot correctly 8`] = `
|
|
304
304
|
<div
|
|
305
|
-
className="css-
|
|
305
|
+
className="css-1xdhyk6"
|
|
306
306
|
>
|
|
307
307
|
<div
|
|
308
308
|
className="css-0"
|
|
@@ -346,7 +346,7 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 8`] = `
|
|
|
346
346
|
</div>
|
|
347
347
|
</div>
|
|
348
348
|
<label
|
|
349
|
-
className="css-
|
|
349
|
+
className="css-1xdhyk6"
|
|
350
350
|
htmlFor="circularDarkMode"
|
|
351
351
|
id="circularDarkMode-label"
|
|
352
352
|
>
|
|
@@ -355,3 +355,90 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 8`] = `
|
|
|
355
355
|
</div>
|
|
356
356
|
</div>
|
|
357
357
|
`;
|
|
358
|
+
|
|
359
|
+
exports[`ProgressIndicator Renders the UI snapshot correctly 9`] = `
|
|
360
|
+
<div
|
|
361
|
+
className="css-10g9ftz"
|
|
362
|
+
>
|
|
363
|
+
<label
|
|
364
|
+
className="css-1xdhyk6"
|
|
365
|
+
htmlFor="chakra"
|
|
366
|
+
id="chakra-label"
|
|
367
|
+
>
|
|
368
|
+
Linear
|
|
369
|
+
</label>
|
|
370
|
+
<div
|
|
371
|
+
className="css-0"
|
|
372
|
+
>
|
|
373
|
+
<div
|
|
374
|
+
className="css-kdwx3d"
|
|
375
|
+
id="chakra"
|
|
376
|
+
>
|
|
377
|
+
<div
|
|
378
|
+
aria-label={null}
|
|
379
|
+
aria-labelledby="chakra-label"
|
|
380
|
+
aria-valuemax={100}
|
|
381
|
+
aria-valuemin={0}
|
|
382
|
+
aria-valuenow={50}
|
|
383
|
+
className="css-1jy0d03"
|
|
384
|
+
role="progressbar"
|
|
385
|
+
style={
|
|
386
|
+
Object {
|
|
387
|
+
"width": "50%",
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
/>
|
|
391
|
+
</div>
|
|
392
|
+
<div
|
|
393
|
+
className="css-0"
|
|
394
|
+
>
|
|
395
|
+
50
|
|
396
|
+
%
|
|
397
|
+
</div>
|
|
398
|
+
</div>
|
|
399
|
+
</div>
|
|
400
|
+
`;
|
|
401
|
+
|
|
402
|
+
exports[`ProgressIndicator Renders the UI snapshot correctly 10`] = `
|
|
403
|
+
<div
|
|
404
|
+
className="css-1xdhyk6"
|
|
405
|
+
data-testid="props"
|
|
406
|
+
>
|
|
407
|
+
<label
|
|
408
|
+
className="css-1xdhyk6"
|
|
409
|
+
htmlFor="props"
|
|
410
|
+
id="props-label"
|
|
411
|
+
>
|
|
412
|
+
Linear
|
|
413
|
+
</label>
|
|
414
|
+
<div
|
|
415
|
+
className="css-0"
|
|
416
|
+
>
|
|
417
|
+
<div
|
|
418
|
+
className="css-kdwx3d"
|
|
419
|
+
id="props"
|
|
420
|
+
>
|
|
421
|
+
<div
|
|
422
|
+
aria-label={null}
|
|
423
|
+
aria-labelledby="props-label"
|
|
424
|
+
aria-valuemax={100}
|
|
425
|
+
aria-valuemin={0}
|
|
426
|
+
aria-valuenow={50}
|
|
427
|
+
className="css-1jy0d03"
|
|
428
|
+
role="progressbar"
|
|
429
|
+
style={
|
|
430
|
+
Object {
|
|
431
|
+
"width": "50%",
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
/>
|
|
435
|
+
</div>
|
|
436
|
+
<div
|
|
437
|
+
className="css-0"
|
|
438
|
+
>
|
|
439
|
+
50
|
|
440
|
+
%
|
|
441
|
+
</div>
|
|
442
|
+
</div>
|
|
443
|
+
</div>
|
|
444
|
+
`;
|
|
@@ -53,7 +53,22 @@ import DSProvider from "../../theme/provider";
|
|
|
53
53
|
| Component Version | DS Version |
|
|
54
54
|
| ----------------- | ---------- |
|
|
55
55
|
| Added | `0.22.0` |
|
|
56
|
-
| Latest | `0.
|
|
56
|
+
| Latest | `0.26.0` |
|
|
57
|
+
|
|
58
|
+
## Table of Contents
|
|
59
|
+
|
|
60
|
+
- [Overview](#overview)
|
|
61
|
+
- [Component Props](#component-props)
|
|
62
|
+
- [Accessibility](#accessibility)
|
|
63
|
+
- [Checked](#checked)
|
|
64
|
+
- [Focused](#focused)
|
|
65
|
+
- [Errored](#errored)
|
|
66
|
+
- [Disabled](#disabled)
|
|
67
|
+
- [Helper Text](#helper-text)
|
|
68
|
+
- [Error Text](#error-text)
|
|
69
|
+
- [With JSX Element Label](#with-jsx-element-label)
|
|
70
|
+
|
|
71
|
+
## Overview
|
|
57
72
|
|
|
58
73
|
<Description of={Radio} />
|
|
59
74
|
|
|
@@ -62,6 +77,8 @@ show the `Radio` button in isolation. We recommend to always use the `Radio`
|
|
|
62
77
|
component inside the Design System `RadioGroup` component. The `RadioGroup`
|
|
63
78
|
component will handle all the states and data management.
|
|
64
79
|
|
|
80
|
+
## Component Props
|
|
81
|
+
|
|
65
82
|
<Canvas withToolbar>
|
|
66
83
|
<Story
|
|
67
84
|
name="Radio"
|
|
@@ -88,11 +105,27 @@ component will handle all the states and data management.
|
|
|
88
105
|
|
|
89
106
|
<ArgsTable story="Radio" />
|
|
90
107
|
|
|
108
|
+
## Accessibility
|
|
109
|
+
|
|
110
|
+
The `Radio` component renders an `input` element with the `type="radio"` attribute.
|
|
111
|
+
This HTML element is accessible by default.
|
|
112
|
+
|
|
113
|
+
When `showLabel` is set to false, the `labelText` value will be set to the
|
|
114
|
+
`<input>`'s `aria-label` attribute.
|
|
115
|
+
|
|
116
|
+
Resources:
|
|
117
|
+
|
|
118
|
+
- [W3C ARIA radiogroup and radio example](https://www.w3.org/TR/2016/WD-wai-aria-practices-1.1-20160317/examples/radio/radio.html)
|
|
119
|
+
- [W3C Radio Button Example](https://www.w3.org/TR/2017/WD-wai-aria-practices-1.1-20170628/examples/radio/radio-1/radio-1.html)
|
|
120
|
+
- [MDN input type="radio"](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio)
|
|
121
|
+
- [Deque University Radio and Radio Group](https://dequeuniversity.com/library/aria/radio-and-radio-group)
|
|
122
|
+
- [Chakra UI Radio](https://chakra-ui.com/docs/components/form/radio)
|
|
123
|
+
|
|
91
124
|
## Checked
|
|
92
125
|
|
|
93
126
|
<Canvas>
|
|
94
127
|
<DSProvider>
|
|
95
|
-
<Radio labelText="I am checked" isChecked value="1" />
|
|
128
|
+
<Radio labelText="I am checked" id="checked" isChecked value="1" />
|
|
96
129
|
</DSProvider>
|
|
97
130
|
</Canvas>
|
|
98
131
|
|
|
@@ -100,7 +133,10 @@ component will handle all the states and data management.
|
|
|
100
133
|
|
|
101
134
|
<Canvas>
|
|
102
135
|
<DSProvider>
|
|
103
|
-
<Radio
|
|
136
|
+
<Radio
|
|
137
|
+
id="focused"
|
|
138
|
+
labelText="Click or tab to the Radio to see its focus state"
|
|
139
|
+
/>
|
|
104
140
|
</DSProvider>
|
|
105
141
|
</Canvas>
|
|
106
142
|
|
|
@@ -109,8 +145,13 @@ component will handle all the states and data management.
|
|
|
109
145
|
<Canvas>
|
|
110
146
|
<DSProvider>
|
|
111
147
|
<HStack>
|
|
112
|
-
<Radio isInvalid labelText="I am in an error state" />
|
|
113
|
-
<Radio
|
|
148
|
+
<Radio id="invalid" isInvalid labelText="I am in an error state" />
|
|
149
|
+
<Radio
|
|
150
|
+
id="invalid-checked"
|
|
151
|
+
isInvalid
|
|
152
|
+
isChecked
|
|
153
|
+
labelText="I am checked in an error state"
|
|
154
|
+
/>
|
|
114
155
|
</HStack>
|
|
115
156
|
</DSProvider>
|
|
116
157
|
</Canvas>
|
|
@@ -120,8 +161,13 @@ component will handle all the states and data management.
|
|
|
120
161
|
<Canvas>
|
|
121
162
|
<DSProvider>
|
|
122
163
|
<HStack>
|
|
123
|
-
<Radio isDisabled labelText="I am disabled" />
|
|
124
|
-
<Radio
|
|
164
|
+
<Radio id="disabled" isDisabled labelText="I am disabled" />
|
|
165
|
+
<Radio
|
|
166
|
+
id="disabled-checked"
|
|
167
|
+
isDisabled
|
|
168
|
+
isChecked
|
|
169
|
+
labelText="I am checked and disabled"
|
|
170
|
+
/>
|
|
125
171
|
</HStack>
|
|
126
172
|
</DSProvider>
|
|
127
173
|
</Canvas>
|
|
@@ -131,9 +177,10 @@ component will handle all the states and data management.
|
|
|
131
177
|
<Canvas>
|
|
132
178
|
<DSProvider>
|
|
133
179
|
<Radio
|
|
134
|
-
name="testHelperText"
|
|
135
|
-
labelText="I have helper text"
|
|
136
180
|
helperText="I am the helper text for this Radio"
|
|
181
|
+
id="help-text"
|
|
182
|
+
labelText="I have helper text"
|
|
183
|
+
name="testHelperText"
|
|
137
184
|
/>
|
|
138
185
|
</DSProvider>
|
|
139
186
|
</Canvas>
|
|
@@ -143,10 +190,27 @@ component will handle all the states and data management.
|
|
|
143
190
|
<Canvas>
|
|
144
191
|
<DSProvider>
|
|
145
192
|
<Radio
|
|
146
|
-
|
|
147
|
-
labelText="I have error text"
|
|
193
|
+
id="invalid-text"
|
|
148
194
|
invalidText="I am the error text for this Radio"
|
|
149
195
|
isInvalid
|
|
196
|
+
labelText="I have error text"
|
|
197
|
+
name="testErrorText"
|
|
198
|
+
/>
|
|
199
|
+
</DSProvider>
|
|
200
|
+
</Canvas>
|
|
201
|
+
|
|
202
|
+
## With JSX Element Label
|
|
203
|
+
|
|
204
|
+
This is useful when you want to add dynamic content to the label or add
|
|
205
|
+
a layout to the label. View the `RadioGroup` documentation for this
|
|
206
|
+
usage.
|
|
207
|
+
|
|
208
|
+
<Canvas>
|
|
209
|
+
<DSProvider>
|
|
210
|
+
<Radio
|
|
211
|
+
id="jsx-label"
|
|
212
|
+
labelText={<span>Arts</span>}
|
|
213
|
+
name="jsxElementLabel"
|
|
150
214
|
/>
|
|
151
215
|
</DSProvider>
|
|
152
216
|
</Canvas>
|