@nypl/design-system-react-components 0.25.0 → 0.25.4
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 +142 -1
- package/README.md +98 -50
- package/dist/components/Accordion/Accordion.d.ts +14 -14
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +15 -14
- package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +6 -0
- package/dist/components/Button/Button.d.ts +13 -8
- package/dist/components/Button/ButtonTypes.d.ts +3 -1
- package/dist/components/Card/Card.d.ts +36 -52
- package/dist/components/Card/CardTypes.d.ts +2 -17
- package/dist/components/Checkbox/Checkbox.d.ts +17 -13
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +45 -0
- package/dist/components/CheckboxGroup/CheckboxGroupLayoutTypes.d.ts +4 -0
- package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +15 -0
- package/dist/components/DatePicker/DatePicker.d.ts +37 -35
- package/dist/components/Fieldset/Fieldset.d.ts +25 -0
- package/dist/components/Form/Form.d.ts +13 -8
- package/dist/components/Form/FormTypes.d.ts +2 -8
- package/dist/components/Grid/GridTypes.d.ts +9 -0
- package/dist/components/Grid/SimpleGrid.d.ts +14 -0
- package/dist/components/Heading/Heading.d.ts +4 -4
- package/dist/components/HelperErrorText/HelperErrorText.d.ts +17 -14
- package/dist/components/Hero/Hero.d.ts +19 -14
- package/dist/components/Hero/HeroTypes.d.ts +10 -5
- package/dist/components/HorizontalRule/HorizontalRule.d.ts +10 -9
- package/dist/components/Icons/Icon.d.ts +19 -14
- package/dist/components/Icons/IconSvgs.d.ts +11 -0
- package/dist/components/Icons/IconTypes.d.ts +89 -64
- package/dist/components/Image/Image.d.ts +19 -9
- package/dist/components/Image/ImageTypes.d.ts +20 -0
- package/dist/components/Label/Label.d.ts +5 -17
- package/dist/components/Link/Link.d.ts +12 -12
- package/dist/components/List/List.d.ts +19 -14
- package/dist/components/Notification/Notification.d.ts +37 -16
- package/dist/components/Pagination/Pagination.d.ts +16 -13
- package/dist/components/Pagination/Pagination.stories.d.ts +2 -0
- package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +29 -0
- package/dist/components/ProgressIndicator/ProgressIndicatorTypes.d.ts +8 -0
- package/dist/components/Radio/Radio.d.ts +2 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +4 -2
- package/dist/components/SearchBar/SearchBar.d.ts +45 -27
- package/dist/components/Select/Select.d.ts +34 -35
- package/dist/components/Select/SelectTypes.d.ts +4 -0
- package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +18 -14
- package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +2 -2
- package/dist/components/Slider/Slider.d.ts +57 -0
- package/dist/components/StatusBadge/StatusBadge.d.ts +8 -6
- package/dist/components/StatusBadge/StatusBadgeTypes.d.ts +5 -0
- package/dist/components/StyleGuide/ColorCard.d.ts +12 -0
- package/dist/components/Tabs/Tabs.d.ts +1 -1
- package/dist/components/Template/Template.d.ts +91 -0
- package/dist/components/Text/Text.d.ts +16 -0
- package/dist/components/Text/TextTypes.d.ts +6 -0
- package/dist/components/TextInput/TextInput.d.ts +44 -31
- package/dist/components/TextInput/TextInputTypes.d.ts +5 -0
- package/dist/components/VideoPlayer/VideoPlayer.d.ts +6 -8
- package/dist/components/VideoPlayer/VideoPlayerTypes.d.ts +2 -2
- package/dist/design-system-react-components.cjs.development.js +6473 -2630
- 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 +6463 -2631
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/hooks/tests/useCarouselStyles.test.d.ts +1 -0
- package/dist/hooks/useCarouselStyles.d.ts +16 -0
- package/dist/hooks/useNYPLTheme.d.ts +54 -0
- package/dist/hooks/useWindowSize.d.ts +10 -0
- package/dist/index.d.ts +19 -7
- package/dist/resources.scss +180 -170
- package/dist/styles.css +1 -1
- package/dist/theme/components/accordion.d.ts +25 -0
- package/dist/theme/components/breadcrumb.d.ts +90 -0
- package/dist/theme/components/button.d.ts +39 -15
- package/dist/theme/components/card.d.ts +168 -0
- package/dist/theme/components/checkbox.d.ts +12 -8
- package/dist/theme/components/checkboxGroup.d.ts +12 -0
- package/dist/theme/components/componentWrapper.d.ts +11 -0
- package/dist/theme/components/datePicker.d.ts +16 -0
- package/dist/theme/components/fieldset.d.ts +27 -0
- package/dist/theme/components/global.d.ts +65 -0
- package/dist/theme/components/globalMixins.d.ts +23 -0
- package/dist/theme/components/heading.d.ts +55 -20
- package/dist/theme/components/helperErrorText.d.ts +10 -0
- package/dist/theme/components/hero.d.ts +493 -0
- package/dist/theme/components/horizontalRule.d.ts +14 -0
- package/dist/theme/components/icon.d.ts +13 -0
- package/dist/theme/components/image.d.ts +31 -0
- package/dist/theme/components/label.d.ts +18 -0
- package/dist/theme/components/link.d.ts +49 -0
- package/dist/theme/components/list.d.ts +89 -0
- package/dist/theme/components/notification.d.ts +75 -0
- package/dist/theme/components/pagination.d.ts +19 -0
- package/dist/theme/components/progressIndicator.d.ts +50 -0
- package/dist/theme/components/radio.d.ts +8 -7
- package/dist/theme/components/radioGroup.d.ts +12 -0
- package/dist/theme/components/searchBar.d.ts +20 -0
- package/dist/theme/components/select.d.ts +67 -0
- package/dist/theme/components/skeletonLoader.d.ts +98 -0
- package/dist/theme/components/slider.d.ts +51 -0
- package/dist/theme/components/statusBadge.d.ts +25 -0
- package/dist/theme/components/tabs.d.ts +63 -12
- package/dist/theme/components/template.d.ts +105 -0
- package/dist/theme/components/text.d.ts +20 -0
- package/dist/theme/components/textInput.d.ts +112 -0
- package/dist/theme/components/videoPlayer.d.ts +40 -0
- package/dist/theme/foundations/breakpoints.d.ts +8 -8
- package/dist/theme/foundations/global.d.ts +8 -0
- package/dist/theme/foundations/radii.d.ts +5 -0
- package/dist/theme/foundations/shadows.d.ts +4 -0
- package/dist/theme/foundations/spacing.d.ts +16 -16
- package/dist/utils/utils.d.ts +6 -0
- package/package.json +72 -82
- package/src/__tests__/setup.ts +2 -2
- package/src/components/Accordion/Accordion.stories.mdx +223 -34
- package/src/components/Accordion/Accordion.test.tsx +135 -19
- package/src/components/Accordion/Accordion.tsx +81 -56
- package/src/components/Autosuggest/Autosuggest.stories.mdx +4 -4
- package/src/components/Autosuggest/Autosuggest.stories.tsx +3 -2
- package/src/components/Autosuggest/_Autosuggest.scss +5 -5
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +48 -50
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +54 -25
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +75 -73
- package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +6 -0
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +298 -0
- package/src/components/Button/Button.stories.mdx +45 -36
- package/src/components/Button/Button.test.tsx +37 -11
- package/src/components/Button/Button.tsx +22 -34
- package/src/components/Button/ButtonTypes.tsx +2 -0
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +50 -8
- package/src/components/Card/Card.stories.mdx +314 -273
- package/src/components/Card/Card.test.tsx +157 -91
- package/src/components/Card/Card.tsx +195 -145
- package/src/components/Card/CardTypes.tsx +2 -19
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +410 -0
- package/src/components/CardEdition/CardEdition.stories.tsx +26 -53
- package/src/components/CardEdition/CardEdition.test.tsx +23 -31
- package/src/components/CardEdition/_CardEdition.scss +22 -23
- package/src/components/Chakra/Box.stories.mdx +15 -16
- package/src/components/Chakra/Center.stories.mdx +56 -24
- package/src/components/Chakra/Grid.stories.mdx +92 -0
- package/src/components/Chakra/Stack.stories.mdx +38 -21
- package/src/components/Checkbox/Checkbox.stories.mdx +33 -11
- package/src/components/Checkbox/Checkbox.test.tsx +47 -2
- package/src/components/Checkbox/Checkbox.tsx +44 -41
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +92 -7
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +329 -0
- package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +372 -0
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +152 -0
- package/src/components/CheckboxGroup/CheckboxGroupLayoutTypes.tsx +4 -0
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +1326 -0
- package/src/components/ComponentWrapper/ComponentWrapper.tsx +63 -0
- package/src/components/DatePicker/DatePicker.stories.mdx +163 -62
- package/src/components/DatePicker/DatePicker.test.tsx +264 -64
- package/src/components/DatePicker/DatePicker.tsx +165 -134
- package/src/components/DatePicker/_DatePicker.scss +33 -66
- package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +818 -0
- package/src/components/Fieldset/Fieldset.stories.mdx +55 -0
- package/src/components/Fieldset/Fieldset.test.tsx +125 -0
- package/src/components/Fieldset/Fieldset.tsx +52 -0
- package/src/components/Fieldset/__snapshots__/Fieldset.test.tsx.snap +68 -0
- package/src/components/Form/Form.stories.mdx +70 -27
- package/src/components/Form/Form.test.tsx +58 -45
- package/src/components/Form/Form.tsx +50 -21
- package/src/components/Form/FormTypes.tsx +3 -8
- package/src/components/Form/__snapshots__/Form.test.tsx.snap +24 -14
- package/src/components/Grid/GridTypes.tsx +9 -0
- package/src/components/Grid/SimpleGrid.stories.mdx +268 -0
- package/src/components/Grid/SimpleGrid.test.tsx +66 -0
- package/src/components/Grid/SimpleGrid.tsx +37 -0
- package/src/components/Grid/__snapshots__/SimpleGrid.test.tsx.snap +8 -0
- package/src/components/Heading/Heading.stories.mdx +3 -3
- package/src/components/Heading/Heading.tsx +12 -6
- package/src/components/HelperErrorText/HelperErrorText.stories.mdx +124 -0
- package/src/components/HelperErrorText/HelperErrorText.test.tsx +39 -44
- package/src/components/HelperErrorText/HelperErrorText.tsx +37 -39
- package/src/components/HelperErrorText/__snapshots__/HelperErrorText.test.tsx.snap +25 -0
- package/src/components/Hero/Hero.stories.mdx +198 -121
- package/src/components/Hero/Hero.test.tsx +537 -107
- package/src/components/Hero/Hero.tsx +79 -92
- package/src/components/Hero/HeroTypes.tsx +18 -5
- package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +307 -0
- package/src/components/HorizontalRule/HorizontalRule.stories.mdx +8 -6
- package/src/components/HorizontalRule/HorizontalRule.test.tsx +33 -28
- package/src/components/HorizontalRule/HorizontalRule.tsx +27 -29
- package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +27 -9
- package/src/components/Icons/Icon.stories.mdx +94 -77
- package/src/components/Icons/Icon.test.tsx +48 -22
- package/src/components/Icons/Icon.tsx +78 -61
- package/src/components/Icons/IconSvgs.tsx +22 -0
- package/src/components/Icons/IconTypes.tsx +91 -64
- package/src/components/Image/Image.stories.mdx +220 -0
- package/src/components/Image/Image.test.tsx +131 -29
- package/src/components/Image/Image.tsx +84 -56
- package/src/components/Image/ImageTypes.ts +22 -0
- package/src/components/Image/__snapshots__/Image.test.tsx.snap +190 -0
- package/src/components/Input/Input.stories.tsx +23 -67
- package/src/components/Input/Input.test.tsx +4 -4
- package/src/components/Input/_Input.scss +23 -14
- package/src/components/Label/Label.stories.mdx +28 -7
- package/src/components/Label/Label.test.tsx +43 -12
- package/src/components/Label/Label.tsx +21 -34
- package/src/components/Label/__snapshots__/Label.test.tsx.snap +41 -0
- package/src/components/Link/Link.stories.mdx +41 -41
- package/src/components/Link/Link.test.tsx +33 -44
- package/src/components/Link/Link.tsx +117 -100
- package/src/components/List/List.stories.mdx +124 -51
- package/src/components/List/List.test.tsx +142 -63
- package/src/components/List/List.tsx +89 -93
- package/src/components/List/__snapshots__/List.test.tsx.snap +109 -0
- package/src/components/Modal/Modal.stories.mdx +3 -3
- package/src/components/Modal/_Modal.scss +2 -2
- package/src/components/Notification/Notification.stories.mdx +119 -111
- package/src/components/Notification/Notification.test.tsx +102 -126
- package/src/components/Notification/Notification.tsx +157 -161
- package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +159 -8
- package/src/components/Pagination/Pagination.stories.mdx +26 -27
- package/src/components/Pagination/Pagination.stories.tsx +11 -16
- package/src/components/Pagination/Pagination.test.tsx +276 -140
- package/src/components/Pagination/Pagination.tsx +174 -154
- package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +285 -0
- package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +292 -0
- package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +225 -0
- package/src/components/ProgressIndicator/ProgressIndicator.tsx +126 -0
- package/src/components/ProgressIndicator/ProgressIndicatorTypes.ts +8 -0
- package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +357 -0
- package/src/components/Radio/Radio.test.tsx +20 -4
- package/src/components/Radio/Radio.tsx +6 -3
- package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +3 -0
- package/src/components/RadioGroup/RadioGroup.stories.mdx +4 -5
- package/src/components/RadioGroup/RadioGroup.test.tsx +24 -1
- package/src/components/RadioGroup/RadioGroup.tsx +21 -29
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +42 -72
- package/src/components/SearchBar/SearchBar.Test.tsx +170 -16
- package/src/components/SearchBar/SearchBar.stories.mdx +294 -219
- package/src/components/SearchBar/SearchBar.tsx +161 -46
- package/src/components/Select/Select.stories.mdx +188 -170
- package/src/components/Select/Select.test.tsx +132 -375
- package/src/components/Select/Select.tsx +121 -165
- package/src/components/Select/SelectTypes.tsx +5 -0
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +33 -76
- package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +97 -177
- package/src/components/SkeletonLoader/SkeletonLoader.tsx +75 -70
- package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +2 -2
- package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +739 -0
- package/src/components/Slider/Slider.stories.mdx +529 -0
- package/src/components/Slider/Slider.test.tsx +653 -0
- package/src/components/Slider/Slider.tsx +303 -0
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +1946 -0
- package/src/components/StatusBadge/StatusBadge.stories.mdx +91 -0
- package/src/components/StatusBadge/StatusBadge.test.tsx +35 -7
- package/src/components/StatusBadge/StatusBadge.tsx +24 -25
- package/src/components/StatusBadge/StatusBadgeTypes.tsx +5 -0
- package/src/components/StatusBadge/__snapshots__/StatusBadge.test.tsx.snap +28 -0
- package/src/components/StyleGuide/Bidirectionality.stories.mdx +17 -17
- package/src/components/StyleGuide/Breakpoints.stories.mdx +34 -10
- package/src/components/StyleGuide/Buttons.stories.mdx +102 -86
- package/src/components/StyleGuide/ColorCard.tsx +46 -0
- package/src/components/StyleGuide/Colors.stories.mdx +196 -0
- package/src/components/StyleGuide/DesignTokens.stories.mdx +170 -0
- package/src/components/StyleGuide/Forms.stories.mdx +9 -7
- package/src/components/StyleGuide/Iconography.stories.mdx +119 -127
- package/src/components/StyleGuide/Spacing.stories.mdx +31 -23
- package/src/components/StyleGuide/Typography.stories.mdx +202 -189
- package/src/components/StyleGuide/UIDocCard.tsx +1 -1
- package/src/components/Tabs/Tabs.stories.mdx +73 -11
- package/src/components/Tabs/Tabs.tsx +88 -67
- package/src/components/Template/Template.stories.mdx +572 -0
- package/src/components/Template/Template.test.tsx +124 -0
- package/src/components/Template/Template.tsx +226 -0
- package/src/components/Text/Text.stories.mdx +70 -0
- package/src/components/Text/Text.test.tsx +63 -0
- package/src/components/Text/Text.tsx +55 -0
- package/src/components/Text/TextTypes.tsx +6 -0
- package/src/components/Text/__snapshots__/Text.test.tsx.snap +33 -0
- package/src/components/TextInput/TextInput.stories.mdx +89 -90
- package/src/components/TextInput/TextInput.test.tsx +84 -85
- package/src/components/TextInput/TextInput.tsx +121 -95
- package/src/components/TextInput/TextInputTypes.tsx +8 -0
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +17 -4
- package/src/components/VideoPlayer/VideoPlayer.test.tsx +54 -53
- package/src/components/VideoPlayer/VideoPlayer.tsx +50 -51
- package/src/components/VideoPlayer/VideoPlayerTypes.tsx +2 -2
- package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +91 -0
- package/src/docs/Chakra.stories.mdx +246 -65
- package/src/docs/Intro.stories.mdx +18 -13
- package/src/hooks/tests/useCarouselStyles.test.ts +140 -0
- package/src/hooks/tests/useNYPLTheme.test.tsx +36 -0
- package/src/hooks/useCarouselStyles.ts +34 -0
- package/src/hooks/useNYPLTheme.ts +67 -0
- package/src/hooks/useWindowSize.ts +40 -0
- package/src/index.ts +39 -16
- package/src/resources.scss +5 -5
- package/src/styles/base/{_02-breakpoints.scss → _01-breakpoints.scss} +9 -10
- package/src/styles/base/{_03-mixins.scss → _02-mixins.scss} +16 -5
- package/src/styles/base/_03-base.scss +25 -0
- package/src/styles/base/{_05-focus.scss → _04-focus.scss} +0 -15
- package/src/styles/base/_place-holder.scss +14 -3
- package/src/styles/{03-space → space}/_space-inline.scss +14 -14
- package/src/styles/{03-space → space}/_space-inset.scss +10 -10
- package/src/styles/space/_space-stack.scss +116 -0
- package/src/styles.scss +13 -62
- package/src/theme/components/accordion.ts +30 -0
- package/src/theme/components/breadcrumb.ts +77 -0
- package/src/theme/components/button.ts +91 -71
- package/src/theme/components/card.ts +174 -0
- package/src/theme/components/checkbox.ts +22 -29
- package/src/theme/components/checkboxGroup.ts +8 -0
- package/src/theme/components/componentWrapper.ts +10 -0
- package/src/theme/components/datePicker.ts +17 -0
- package/src/theme/components/fieldset.ts +18 -0
- package/src/theme/components/global.ts +82 -0
- package/src/theme/components/globalMixins.ts +24 -0
- package/src/theme/components/heading.ts +25 -13
- package/src/theme/components/helperErrorText.ts +9 -0
- package/src/theme/components/hero.ts +240 -0
- package/src/theme/components/horizontalRule.ts +13 -0
- package/src/theme/components/icon.ts +79 -0
- package/src/theme/components/image.ts +116 -0
- package/src/theme/components/label.ts +10 -0
- package/src/theme/components/link.ts +51 -0
- package/src/theme/components/list.ts +73 -0
- package/src/theme/components/notification.ts +93 -0
- package/src/theme/components/pagination.ts +20 -0
- package/src/theme/components/progressIndicator.ts +62 -0
- package/src/theme/components/radio.ts +22 -33
- package/src/theme/components/radioGroup.ts +8 -0
- package/src/theme/components/searchBar.ts +21 -0
- package/src/theme/components/select.ts +53 -0
- package/src/theme/components/skeletonLoader.ts +107 -0
- package/src/theme/components/slider.ts +79 -0
- package/src/theme/components/statusBadge.ts +26 -0
- package/src/theme/components/tabs.ts +102 -69
- package/src/theme/components/template.ts +114 -0
- package/src/theme/components/text.ts +31 -0
- package/src/theme/components/textInput.ts +62 -0
- package/src/theme/components/videoPlayer.ts +49 -0
- package/src/theme/foundations/breakpoints.ts +8 -8
- package/src/theme/foundations/colors.ts +29 -13
- package/src/theme/foundations/global.ts +8 -0
- package/src/theme/foundations/radii.ts +6 -0
- package/src/theme/foundations/shadows.ts +5 -0
- package/src/theme/foundations/spacing.ts +24 -24
- package/src/theme/index.ts +74 -13
- package/src/utils/componentCategories.ts +12 -5
- package/src/utils/utils.ts +13 -0
- package/dist/components/Accordion/Accordion.stories.d.ts +0 -6
- package/dist/components/HelperErrorText/HelperErrorText.stories.d.ts +0 -16
- package/dist/components/Image/Image.stories.d.ts +0 -18
- package/dist/components/List/List.stories.d.ts +0 -7
- package/dist/components/StatusBadge/StatusBadge.stories.d.ts +0 -8
- package/dist/components/StyleGuide/Colors.stories.d.ts +0 -25
- package/dist/components/Template/Template.stories.d.ts +0 -30
- package/dist/theme/components/customRadioGroup.d.ts +0 -17
- package/src/components/Accordion/Accordion.stories.tsx +0 -66
- package/src/components/Accordion/_Accordion.scss +0 -81
- package/src/components/Breadcrumbs/_Breadcrumbs.scss +0 -97
- package/src/components/Button/_Button.scss +0 -56
- package/src/components/Card/_Card.scss +0 -308
- package/src/components/Form/_Form.scss +0 -67
- package/src/components/HelperErrorText/HelperErrorText.stories.tsx +0 -48
- package/src/components/HelperErrorText/_HelperErrorText.scss +0 -9
- package/src/components/Hero/_Hero.scss +0 -256
- package/src/components/HorizontalRule/_HorizontalRule.scss +0 -15
- package/src/components/Icons/_Icons.scss +0 -116
- package/src/components/Image/Image.stories.tsx +0 -54
- package/src/components/Image/_Image.scss +0 -38
- package/src/components/Label/_Label.scss +0 -22
- package/src/components/Link/_Link.scss +0 -73
- package/src/components/List/List.stories.tsx +0 -139
- package/src/components/List/_List.scss +0 -76
- package/src/components/Notification/_Notification.scss +0 -110
- package/src/components/Pagination/_Pagination.scss +0 -40
- package/src/components/SearchBar/_SearchBar.scss +0 -16
- package/src/components/Select/_Select.scss +0 -82
- package/src/components/SkeletonLoader/_SkeletonLoader.scss +0 -142
- package/src/components/StatusBadge/StatusBadge.stories.tsx +0 -34
- package/src/components/StatusBadge/_StatusBadge.scss +0 -23
- package/src/components/StyleGuide/Colors.stories.tsx +0 -289
- package/src/components/Template/Template.stories.tsx +0 -86
- package/src/components/Template/_Template.scss +0 -63
- package/src/components/TextInput/_TextInput.scss +0 -59
- package/src/components/VideoPlayer/_VideoPlayer.scss +0 -38
- package/src/styles/01-colors/_colors-brand.scss +0 -56
- package/src/styles/01-colors/_colors-utility.scss +0 -65
- package/src/styles/02-typography/_type-scale.css +0 -11
- package/src/styles/02-typography/_type-weight.css +0 -7
- package/src/styles/02-typography/_typefaces.css +0 -4
- package/src/styles/03-space/_space-stack.scss +0 -116
- package/src/styles/03-space/_space.css +0 -30
- package/src/styles/base/_04-base.scss +0 -19
- package/src/styles/base/_card-grid.scss +0 -78
- package/src/styles/base/_typography.scss +0 -11
- package/src/theme/components/customRadioGroup.ts +0 -18
|
@@ -13,45 +13,50 @@ describe("HorizontalRule Accessibility", () => {
|
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
describe("HorizontalRule", () => {
|
|
16
|
-
it("
|
|
17
|
-
const tree = renderer.create(<HorizontalRule />).toJSON();
|
|
18
|
-
expect(tree).toMatchSnapshot();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("Renders HorizontalRule component", () => {
|
|
16
|
+
it("renders HorizontalRule component", () => {
|
|
22
17
|
render(<HorizontalRule />);
|
|
23
18
|
expect(screen.getByRole("separator")).toBeInTheDocument();
|
|
24
19
|
});
|
|
25
20
|
|
|
26
|
-
it("
|
|
21
|
+
it("renders with proper custom class", () => {
|
|
27
22
|
render(<HorizontalRule className="custom-hr" />);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"horizontal-rule custom-hr"
|
|
31
|
-
);
|
|
23
|
+
const hrClass = screen.getByRole("separator").getAttribute("class");
|
|
24
|
+
expect(hrClass).toContain("custom-hr");
|
|
32
25
|
});
|
|
33
26
|
|
|
34
|
-
it("
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
it("renders with proper custom class", () => {
|
|
28
|
+
const warn = jest.spyOn(console, "warn");
|
|
29
|
+
const { rerender } = render(
|
|
30
|
+
<HorizontalRule className="custom-hr" height="20px" />
|
|
31
|
+
);
|
|
32
|
+
expect(warn).not.toHaveBeenCalledWith(
|
|
33
|
+
"`HorizontalRule`: For the `height` prop, use a whole number, a `px` " +
|
|
34
|
+
"value, a `em` value, or a `rem` value. Using the default of 2px."
|
|
37
35
|
);
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
37
|
+
rerender(<HorizontalRule className="custom-hr" height="20%" />);
|
|
38
|
+
expect(warn).toHaveBeenCalledWith(
|
|
39
|
+
"`HorizontalRule`: For the `height` prop, use a whole number, a `px` " +
|
|
40
|
+
"value, a `em` value, or a `rem` value. Using the default of 2px."
|
|
42
41
|
);
|
|
43
42
|
});
|
|
44
43
|
|
|
45
|
-
it("
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
it("renders the UI snapshot correctly", () => {
|
|
45
|
+
const basic = renderer.create(<HorizontalRule />).toJSON();
|
|
46
|
+
const updatedHeight = renderer
|
|
47
|
+
.create(<HorizontalRule height="5rem" />)
|
|
48
|
+
.toJSON();
|
|
49
|
+
const updatedWidth = renderer
|
|
50
|
+
.create(<HorizontalRule width="720px" />)
|
|
51
|
+
.toJSON();
|
|
52
|
+
const alignLeft = renderer.create(<HorizontalRule align="left" />).toJSON();
|
|
53
|
+
const alignRight = renderer
|
|
54
|
+
.create(<HorizontalRule align="right" />)
|
|
55
|
+
.toJSON();
|
|
56
|
+
expect(basic).toMatchSnapshot();
|
|
57
|
+
expect(updatedHeight).toMatchSnapshot();
|
|
58
|
+
expect(updatedWidth).toMatchSnapshot();
|
|
59
|
+
expect(alignLeft).toMatchSnapshot();
|
|
60
|
+
expect(alignRight).toMatchSnapshot();
|
|
56
61
|
});
|
|
57
62
|
});
|
|
@@ -1,47 +1,45 @@
|
|
|
1
1
|
// HorizontalRule
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import
|
|
3
|
+
import { Box, useStyleConfig } from "@chakra-ui/react";
|
|
4
4
|
|
|
5
5
|
export interface HorizontalRuleProps {
|
|
6
|
-
/** Optional alignment value to align the horizontal rule to one side or the
|
|
6
|
+
/** Optional alignment value to align the horizontal rule to one side or the
|
|
7
|
+
* other when the width is less than 100%. If omitted, the horizontal rule
|
|
8
|
+
* will have a default center alignment. */
|
|
7
9
|
align?: "left" | "right";
|
|
8
|
-
/** Additional attributes passed to the horizontal rule */
|
|
9
|
-
attributes?: { [key: string]: any };
|
|
10
10
|
/** ClassName you can add in addition to `horizontal-rule` */
|
|
11
11
|
className?: string;
|
|
12
|
-
/** Optional height value.
|
|
12
|
+
/** Optional height value. This value should be entered with the same
|
|
13
|
+
* formatting as a CSS height attribute except for percent values (ex. `2`,
|
|
14
|
+
* `5px`, `1.5rem`). If this prop is omitted or a percent value is used, the
|
|
15
|
+
* horizontal rule will have a default height of 2px. */
|
|
13
16
|
height?: string;
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
/** Optional width value. This value should be entered with the same
|
|
18
|
+
* formatting as a CSS width attribute (ex. `50%`, `640px`, `20rem`). If
|
|
19
|
+
* omitted, the horizontal rule will have a default width of "auto". */
|
|
17
20
|
width?: string;
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
export default function HorizontalRule(
|
|
21
24
|
props: React.ComponentProps<"hr"> & HorizontalRuleProps
|
|
22
25
|
) {
|
|
23
|
-
const {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
className,
|
|
27
|
-
width = "auto",
|
|
28
|
-
height = "2px",
|
|
29
|
-
modifiers = [],
|
|
30
|
-
} = props;
|
|
26
|
+
const { align, className, height = "2px", width = "auto" } = props;
|
|
27
|
+
const styles = useStyleConfig("HorizontalRule", { align });
|
|
28
|
+
let finalHeight = height;
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
modifiers.push(align);
|
|
30
|
+
if (height.endsWith("%")) {
|
|
31
|
+
console.warn(
|
|
32
|
+
"`HorizontalRule`: For the `height` prop, use a whole number, a `px`" +
|
|
33
|
+
" value, a `em` value, or a `rem` value. Using the default of 2px."
|
|
34
|
+
);
|
|
35
|
+
finalHeight = "2px";
|
|
39
36
|
}
|
|
40
37
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
const finalStyles = {
|
|
39
|
+
...styles,
|
|
40
|
+
height: finalHeight,
|
|
41
|
+
width,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return <Box as="hr" className={className} __css={finalStyles} />;
|
|
47
45
|
}
|
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`HorizontalRule
|
|
4
|
-
<hr
|
|
5
|
-
className="
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
exports[`HorizontalRule renders the UI snapshot correctly 1`] = `
|
|
4
|
+
<hr
|
|
5
|
+
className="css-ili6fu"
|
|
6
|
+
/>
|
|
7
|
+
`;
|
|
8
|
+
|
|
9
|
+
exports[`HorizontalRule renders the UI snapshot correctly 2`] = `
|
|
10
|
+
<hr
|
|
11
|
+
className="css-1pwp4fu"
|
|
12
|
+
/>
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
exports[`HorizontalRule renders the UI snapshot correctly 3`] = `
|
|
16
|
+
<hr
|
|
17
|
+
className="css-gj8znx"
|
|
18
|
+
/>
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
exports[`HorizontalRule renders the UI snapshot correctly 4`] = `
|
|
22
|
+
<hr
|
|
23
|
+
className="css-ili6fu"
|
|
24
|
+
/>
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
exports[`HorizontalRule renders the UI snapshot correctly 5`] = `
|
|
28
|
+
<hr
|
|
29
|
+
className="css-ili6fu"
|
|
12
30
|
/>
|
|
13
31
|
`;
|
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
Story,
|
|
4
4
|
Canvas,
|
|
5
5
|
ArgsTable,
|
|
6
|
-
Preview,
|
|
7
6
|
Description,
|
|
8
7
|
} from "@storybook/addon-docs/blocks";
|
|
9
8
|
import { withDesign } from "storybook-addon-designs";
|
|
10
9
|
|
|
11
10
|
import Icon from "./Icon";
|
|
12
11
|
import {
|
|
12
|
+
IconAlign,
|
|
13
13
|
IconNames,
|
|
14
14
|
LogoNames,
|
|
15
15
|
IconColors,
|
|
@@ -28,11 +28,15 @@ import { getCategory } from "../../utils/componentCategories";
|
|
|
28
28
|
parameters={{
|
|
29
29
|
design: {
|
|
30
30
|
type: "figma",
|
|
31
|
-
url:
|
|
32
|
-
"https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Main?node-id=10734%3A3945",
|
|
31
|
+
url: "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Main?node-id=10734%3A3945",
|
|
33
32
|
},
|
|
34
33
|
jest: ["Icon.test.tsx"],
|
|
35
34
|
}}
|
|
35
|
+
argTypes={{
|
|
36
|
+
children: { table: { disable: true } },
|
|
37
|
+
className: { table: { disable: true } },
|
|
38
|
+
id: { table: { disable: true } },
|
|
39
|
+
}}
|
|
36
40
|
/>
|
|
37
41
|
|
|
38
42
|
# Icon
|
|
@@ -40,89 +44,98 @@ import { getCategory } from "../../utils/componentCategories";
|
|
|
40
44
|
| Component Version | DS Version |
|
|
41
45
|
| ----------------- | ---------- |
|
|
42
46
|
| Added | `0.0.4` |
|
|
43
|
-
| Latest | `0.
|
|
47
|
+
| Latest | `0.25.4` |
|
|
44
48
|
|
|
45
49
|
<Description of={Icon} />
|
|
46
50
|
|
|
47
|
-
<
|
|
51
|
+
<Canvas withToolbar>
|
|
48
52
|
<Story
|
|
49
53
|
name="Icon Props Control"
|
|
50
54
|
args={{
|
|
51
|
-
|
|
52
|
-
color:
|
|
53
|
-
size: IconSizes.xlarge,
|
|
54
|
-
iconRotation: IconRotationTypes.rotate0,
|
|
55
|
+
align: "None",
|
|
56
|
+
color: "UiBlack",
|
|
55
57
|
decorative: true,
|
|
56
|
-
|
|
58
|
+
iconRotation: "Rotate0",
|
|
59
|
+
name: "Check",
|
|
60
|
+
size: "ExtraLarge",
|
|
57
61
|
}}
|
|
58
62
|
argTypes={{
|
|
59
|
-
|
|
63
|
+
align: {
|
|
60
64
|
control: {
|
|
61
65
|
type: "select",
|
|
62
|
-
options: IconColors,
|
|
63
66
|
},
|
|
67
|
+
options: Object.keys(IconAlign),
|
|
64
68
|
},
|
|
65
|
-
|
|
69
|
+
color: {
|
|
66
70
|
control: {
|
|
67
71
|
type: "select",
|
|
68
|
-
options: IconSizes,
|
|
69
72
|
},
|
|
73
|
+
options: Object.keys(IconColors),
|
|
70
74
|
},
|
|
71
75
|
iconRotation: {
|
|
72
76
|
control: {
|
|
73
77
|
type: "select",
|
|
74
|
-
options: IconRotationTypes,
|
|
75
78
|
},
|
|
79
|
+
options: Object.keys(IconRotationTypes),
|
|
76
80
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
name: {
|
|
82
|
+
control: {
|
|
83
|
+
type: "select",
|
|
80
84
|
},
|
|
85
|
+
options: Object.keys(IconNames),
|
|
81
86
|
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
size: {
|
|
88
|
+
control: {
|
|
89
|
+
type: "select",
|
|
85
90
|
},
|
|
91
|
+
options: Object.keys(IconSizes),
|
|
86
92
|
},
|
|
87
93
|
}}
|
|
88
94
|
>
|
|
89
|
-
{(args) =>
|
|
95
|
+
{(args) => (
|
|
96
|
+
<Icon
|
|
97
|
+
align={IconAlign[args.align]}
|
|
98
|
+
color={IconColors[args.color]}
|
|
99
|
+
iconRotation={IconRotationTypes[args.iconRotation]}
|
|
100
|
+
name={IconNames[args.name]}
|
|
101
|
+
size={IconSizes[args.size]}
|
|
102
|
+
title={args.title}
|
|
103
|
+
/>
|
|
104
|
+
)}
|
|
90
105
|
</Story>
|
|
91
|
-
</
|
|
106
|
+
</Canvas>
|
|
92
107
|
|
|
93
108
|
<ArgsTable story="Icon Props Control" />
|
|
94
109
|
|
|
95
|
-
export const iconRow = (icon, opts = {}) => {
|
|
110
|
+
export const iconRow = (icon, iconType = IconNames, opts = {}) => {
|
|
96
111
|
// We'll use this setup function to render all the icons in a list item.
|
|
97
112
|
// Some icons display better with a dark background.
|
|
98
113
|
const styles = { padding: "1rem" };
|
|
99
114
|
const {
|
|
100
|
-
size = IconSizes.
|
|
101
|
-
iconRotation = IconRotationTypes.
|
|
102
|
-
color = IconColors.
|
|
115
|
+
size = IconSizes.Large,
|
|
116
|
+
iconRotation = IconRotationTypes.Rotate0,
|
|
117
|
+
color = IconColors.UiBlack,
|
|
103
118
|
displayValue = icon,
|
|
104
119
|
} = opts;
|
|
105
120
|
let key = icon;
|
|
106
|
-
if (icon.indexOf("
|
|
121
|
+
if (icon.indexOf("Negative") !== -1 || color.indexOf("white") !== -1) {
|
|
107
122
|
styles.backgroundColor = "#000";
|
|
108
|
-
styles.display = "inline-block";
|
|
109
123
|
}
|
|
110
124
|
// The following is just to fix duplicate React key issues.
|
|
111
|
-
if (iconRotation !== IconRotationTypes.
|
|
125
|
+
if (iconRotation !== IconRotationTypes.Rotate0) {
|
|
112
126
|
key += `-${iconRotation}`;
|
|
113
127
|
}
|
|
114
|
-
if (color !== IconColors.
|
|
128
|
+
if (color !== IconColors.UiBlack) {
|
|
115
129
|
key += `-${color}`;
|
|
116
130
|
}
|
|
117
|
-
if (size !== IconSizes.
|
|
131
|
+
if (size !== IconSizes.Large) {
|
|
118
132
|
key += `-${size}`;
|
|
119
133
|
}
|
|
120
134
|
return (
|
|
121
|
-
<li key={key} style={{ marginBottom: "var(--space-s)" }}>
|
|
135
|
+
<li key={key} style={{ marginBottom: "var(--nypl-space-s)" }}>
|
|
122
136
|
<span style={styles}>
|
|
123
137
|
<Icon
|
|
124
|
-
name={icon}
|
|
125
|
-
decorative={true}
|
|
138
|
+
name={iconType[icon]}
|
|
126
139
|
size={size}
|
|
127
140
|
iconRotation={iconRotation}
|
|
128
141
|
color={color}
|
|
@@ -138,33 +151,33 @@ export const rotations = [];
|
|
|
138
151
|
export const colors = [];
|
|
139
152
|
export const sizes = [];
|
|
140
153
|
for (const icon in IconNames) {
|
|
141
|
-
icons.push(iconRow(icon));
|
|
154
|
+
icons.push(iconRow(icon, IconNames));
|
|
142
155
|
}
|
|
143
156
|
for (const logo in LogoNames) {
|
|
144
|
-
logos.push(iconRow(logo, { iconSize: IconSizes.
|
|
157
|
+
logos.push(iconRow(logo, LogoNames, { iconSize: IconSizes.ExtraLarge }));
|
|
145
158
|
}
|
|
146
159
|
for (const iconRotation in IconRotationTypes) {
|
|
147
160
|
rotations.push(
|
|
148
|
-
iconRow(IconNames
|
|
149
|
-
size: IconSizes.
|
|
161
|
+
iconRow("Arrow", IconNames, {
|
|
162
|
+
size: IconSizes.Large,
|
|
150
163
|
iconRotation: IconRotationTypes[iconRotation],
|
|
151
|
-
displayValue:
|
|
164
|
+
displayValue: iconRotation,
|
|
152
165
|
})
|
|
153
166
|
);
|
|
154
167
|
}
|
|
155
168
|
for (const iconColor in IconColors) {
|
|
156
169
|
colors.push(
|
|
157
|
-
iconRow(IconNames
|
|
170
|
+
iconRow("Download", IconNames, {
|
|
158
171
|
color: IconColors[iconColor],
|
|
159
|
-
displayValue:
|
|
172
|
+
displayValue: iconColor,
|
|
160
173
|
})
|
|
161
174
|
);
|
|
162
175
|
}
|
|
163
176
|
for (const iconSize in IconSizes) {
|
|
164
177
|
sizes.push(
|
|
165
|
-
iconRow(IconNames
|
|
178
|
+
iconRow("Arrow", IconNames, {
|
|
166
179
|
size: IconSizes[iconSize],
|
|
167
|
-
displayValue:
|
|
180
|
+
displayValue: iconSize,
|
|
168
181
|
})
|
|
169
182
|
);
|
|
170
183
|
}
|
|
@@ -173,65 +186,65 @@ export const allIconsType = (list) => (
|
|
|
173
186
|
<ul style={{ listStyle: "none" }}>{list}</ul>
|
|
174
187
|
);
|
|
175
188
|
|
|
189
|
+
## Accessibility
|
|
190
|
+
|
|
191
|
+
For accessibility purposes, every DS `Icon` will render the `svg` element with
|
|
192
|
+
its icon name in the `title` element. The default text in the `title` element
|
|
193
|
+
is the icon's code name. Pass in better descriptive text in the `title` prop
|
|
194
|
+
when using the `Icon` component in your application. This will give screenreaders
|
|
195
|
+
a better descriptive title for the `svg` graphic.
|
|
196
|
+
|
|
176
197
|
## Rotation Types
|
|
177
198
|
|
|
178
199
|
Passing an `iconRotation` prop with a value from `IconRotationTypes` allows
|
|
179
200
|
the icon to be rotated when it is rendered. The `IconRotationTypes` enum
|
|
180
201
|
can be found in `src/components/Icons/IconTypes.tsx`.
|
|
181
202
|
|
|
182
|
-
```
|
|
203
|
+
```jsx
|
|
183
204
|
// Example
|
|
184
|
-
<Icon
|
|
185
|
-
name={IconNames.arrow}
|
|
186
|
-
decorative={true}
|
|
187
|
-
iconRotation={IconRotationTypes.rotate180}
|
|
188
|
-
/>
|
|
205
|
+
<Icon name={IconNames.Arrow} iconRotation={IconRotationTypes.Rotate180} />
|
|
189
206
|
```
|
|
190
207
|
|
|
191
|
-
<
|
|
208
|
+
<Canvas>
|
|
192
209
|
<Story name="Rotation Types">{allIconsType(rotations)}</Story>
|
|
193
|
-
</
|
|
210
|
+
</Canvas>
|
|
194
211
|
|
|
195
212
|
## IconColors Types
|
|
196
213
|
|
|
197
214
|
Update an SVG icon by passing a `color` prop with a value from `IconColors`.
|
|
198
|
-
The `IconColors` enum can be found in`src/components/Icons/IconTypes.tsx`.
|
|
215
|
+
The `IconColors` enum can be found in `src/components/Icons/IconTypes.tsx`.
|
|
199
216
|
|
|
200
|
-
```
|
|
217
|
+
```jsx
|
|
201
218
|
// Example
|
|
202
|
-
<Icon
|
|
203
|
-
name={IconNames.speaker_notes}
|
|
204
|
-
decorative={true}
|
|
205
|
-
color={IconColors.brand_primary}
|
|
206
|
-
/>
|
|
219
|
+
<Icon name={IconNames.Speaker_notes} color={IconColors.BrandPrimary} />
|
|
207
220
|
```
|
|
208
221
|
|
|
209
|
-
<
|
|
222
|
+
<Canvas>
|
|
210
223
|
<Story name="Color Types">{allIconsType(colors)}</Story>
|
|
211
|
-
</
|
|
224
|
+
</Canvas>
|
|
212
225
|
|
|
213
226
|
## IconSizes Types
|
|
214
227
|
|
|
215
228
|
Update an SVG icon by passing a `size` prop with a value from `IconSizes`.
|
|
216
229
|
The `IconSizes` enum can be found in`src/components/Icons/IconTypes.tsx`.
|
|
217
230
|
|
|
218
|
-
```
|
|
231
|
+
```jsx
|
|
219
232
|
// Example
|
|
220
|
-
<Icon name={IconNames.
|
|
233
|
+
<Icon name={IconNames.Clock} size={IconSizes.ExtraExtraLarge} />
|
|
221
234
|
```
|
|
222
235
|
|
|
223
|
-
<
|
|
236
|
+
<Canvas>
|
|
224
237
|
<Story name="Sizes Types">{allIconsType(sizes)}</Story>
|
|
225
|
-
</
|
|
238
|
+
</Canvas>
|
|
226
239
|
|
|
227
240
|
## All Display Icons
|
|
228
241
|
|
|
229
242
|
The following icons are for generic purposes. All the available logo names can
|
|
230
243
|
be found in the `IconNames` enum in `src/components/Icons/IconTypes.tsx`.
|
|
231
244
|
|
|
232
|
-
<
|
|
245
|
+
<Canvas withToolbar>
|
|
233
246
|
<Story name="All Display Icons">{allIconsType(icons)}</Story>
|
|
234
|
-
</
|
|
247
|
+
</Canvas>
|
|
235
248
|
|
|
236
249
|
## All Logo Icons
|
|
237
250
|
|
|
@@ -241,28 +254,32 @@ The following icons are meant to be used for logos for different libraries
|
|
|
241
254
|
and products. All the available logo names can
|
|
242
255
|
be found in the `LogoNames` enum in `src/components/Icons/IconTypes.tsx`.
|
|
243
256
|
|
|
244
|
-
<
|
|
257
|
+
<Canvas withToolbar>
|
|
245
258
|
<Story name="All Logo Icons">{allIconsType(logos)}</Story>
|
|
246
|
-
</
|
|
259
|
+
</Canvas>
|
|
247
260
|
|
|
248
261
|
## Custom Icons
|
|
249
262
|
|
|
250
263
|
If you'd like to pass a custom svg to your application, you can pass it a
|
|
251
264
|
child to the `Icon` component.
|
|
252
265
|
|
|
253
|
-
```
|
|
254
|
-
<Icon {...
|
|
255
|
-
<svg
|
|
266
|
+
```jsx
|
|
267
|
+
<Icon {...props}>
|
|
268
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 750 750" fill="#6BE9D8">
|
|
269
|
+
<g>
|
|
270
|
+
<path d="M709.9 399.9c-4.5-145.7-115.8-169.6-151.1-170.3-4.2-.1-6.7-4.9-4.2-8.4L632 110.6c3.4-4.8 2.4-11.7-2.3-15.3-15.9-12-36.3-21.4-60.3-28.8-4.3-1.3-8.6 2-8.5 6.5 1.2 50.5-27.6 114.3-36.5 132.9-1 2-3.9 1.9-4.8-.1C485.1 124 397.7 95.1 327.9 104.4c-71.3 9.5-101.6 26.5-163.5 96.6-61.9 70.1-80.2 260.7-82.1 309.4C80.4 559 40 617.1 40 617.1c154 81.4 340.9 68.2 402.2 61.9 44.4-4.6 68.5-21.8 78.5-30.9 2.5-2.3 1.4-6.6-2-7.3-73.8-15.7-80.7-37.2-94.8-63.5-14.5-27.1 8.2-135.7 104.2-108.6 79.6 22.5 51.5 114.9 39.6 145.8-1.4 3.7 2.4 7.3 6 5.6 34-16.5 140.5-79.5 136.2-220.2zM234.7 181.3c17.7-17 69-56.7 167.1-38 99.8 18.9 98.5 109.5 80.4 141.7-2.3 4.1-7 4.5-8.8.1-11.1-27.7-45.5-97.4-112-108-61.8-9.8-105.6 1.7-124.2 8.3-2.5.8-4.4-2.3-2.5-4.1zm-60.2 72l16.9-27.4c5.1-8.3 13.2-14.3 22.6-16.6 16.3-4.1 33-6.9 49.5-8.9 40.3-4.8 79.4-2.1 116.7 15.1 17.4 8 33.6 18.2 46.1 32.9 11.4 13.4 19 29.6 23.7 46.5 1.8 6.3 3.2 12.8 4.3 19.3.6 3.2-.1 6.6-1.7 9.4l-15.8 27.1c-1.7 3-6.1 2.4-7.1-.9-6.7-22-17.9-43.9-32.8-61-12.6-14.4-29.1-23.5-46.1-31.6-12.2-5.8-24.9-10.5-38-13.6-35.3-8.4-71.9-4.4-106.3 5.9-9.2 2.8-18.3 5.9-27.2 9.5-2.3.9-4.9-.7-5.2-3.2-.2-1 0-1.8.4-2.5zm-21.9 64.2l11.7-40.8c1.2-4.3 5-7.5 9.5-7.9l5.2-.5s87.8-25.9 160.4 9.8c56.9 28 68.3 78.8 70.5 99.5.6 5.5-1.4 11-5.3 14.8L389 407.5c-3.8 3.7-10.2 2.2-12-2.8-6-17.2-13.8-34.1-23.5-49.3-5.8-9.1-12.7-18.3-21.6-24.6-16.2-11.5-36.5-19.2-55.7-23.9-14.4-3.6-29.3-4.8-44.1-3.8-12.9.8-25.6 3.2-38 6.7-7.2 2-14.3 4.4-21.3 7.1-3.8 1.5-7.6 3-11.3 4.7-.6.2-1.9.7-3.4 1.3-3.2 1.1-6.5-2-5.5-5.4zM410 465.8c4.4 2 5.8 7.5 3 11.4l-14.8 20.7c-3.5 4.9-9.9 6.6-15.4 4.3l-25.5-10.9c-4.5-1.9-5.5-7.8-1.9-11.1l17.3-15.7c5.8-5.7 14.6-9.1 22-5.8l15.3 7.1zm-270.3-96.3l4.5-23.6c1.2-6.5 5.7-11.9 11.8-14.3 15.7-6.2 50.5-14.3 109.2-.1 62.6 15.1 83.4 66.2 90 91.6 2.2 8.5-.7 17.5-7.5 23.1l-13.4 11.1c-4.2 3.4-10.5 1.5-12-3.7-5.3-18.5-21.2-54.5-66.1-73.7-45.5-19.5-88.3-9.3-107.8-2.6-4.8 1.5-9.7-2.8-8.7-7.8zm-4.4 29.7c.1-5.4 4.2-9.9 9.6-10.6 30.7-3.8 127.8-7.6 155.8 89.7 1.6 5.4-.5 11.3-5.2 14.4l-15.1 10.1c-5 3.4-11.9 1.2-14-4.5-9.5-26-40.2-85.6-119.7-68.3-6.2 1.3-12-3.4-11.9-9.7l.5-21.1zm-9.1 72.9l3.3-19.1c1.4-8.3 9-14.1 17.4-13.1 21.2 2.4 60.2 11.5 85.5 44.9 5.8 7.7 9.2 16.8 10 26.4l.3 3.4c.6 7.1-2.7 14-8.7 18l-12.1 8.2c-4.4 3-10.5 1.2-12.6-3.7l-8.2-24.4c-3.5-10.4-11-19.1-20.8-24.1l-11.1-5.6c-6.7-3.4-14.2-5-21.7-4.5l-14.8.9c-4 .2-7.1-3.4-6.5-7.3zm-15.5 55.7l9.4-30.7c1.8-5.9 8-9.2 13.9-7.4 18.3 5.6 53.5 21.9 54.3 65.2 0 2.7-1.3 5.1-3.6 6.4-8.5 4.9-26.8 12.9-27.8 12-1.2-1.1.8-42.6-39.7-37.7-1.2.1-2.5-.1-3.6-.7-2.5-1.3-3.8-4.3-2.9-7.1zm63.8 100.5c-1.1 6.4-7.4 10.5-13.7 8.9l-85.5-21.9c-3.9-1-5.7-5.5-3.6-8.9l31.4-51.7c1.8-3 5.5-4.5 8.9-3.4 8.3 2.6 22.4 9 24.4 23.2.6 4.3-.9 8.7-4 11.8-1.4 1.4-3 2.5-4.8 3.2l-26.8 10.4c-2.1.8-2.6 3.5-1 5 .6.5 1.3.8 2.1.8l19.5-.2c3.7 0 7.4-.4 11.1-1 12.8-2.1 47-5 42 23.8zm72.1 12.7c-2.3 2.8-5 5.9-8.8 6.3-1.5.2-2.9 0-4.4-.2-1.5-.2-2.9-.2-4.4-.3l-10.5-.9c-3.8-.3-7.5-.7-11.3-1.2-2.9-.3-5.8-.7-8.6-1.2-4-.7-6.6-4.7-5.4-8.6 2.5-8.6 4.2-23.7-8.4-37.6-2-2.2-1.4-5.8 1.2-7.3l24.8-14.1c3.6-2.1 8-2.1 11.6-.1 8.2 4.5 22.3 14.1 29 28.8 5.4 12.1 3.4 26.2-4.8 36.4zm67 3.1c-4.2 4.1-9.8 6.5-15.7 6.8l-24.2 1.1c-4.2.2-7.1-4.2-5.3-8 8.1-17 20.6-55.5-19.4-76.9-3-1.6-3.3-5.9-.4-7.8l15.3-10.2c4.7-3.2 10.8-3.5 15.8-.7 22.8 12.3 80.6 50.2 33.9 95.7zm118.2-5.2c3.5 2.7 1.6 8.2-2.8 8.3l-77.5.8c-4.8.1-8.1-5-6-9.3 30.8-64.1-17.7-97.3-37.5-107.6-3.5-1.8-4-6.7-.9-9.1l9.6-7.7c7.2-5.7 16.7-7.7 25.6-5.4 14.1 3.7 26.1 11.8 33.7 18 5.4 4.4 8.6 10.9 8.8 17.9.9 51.1 29.9 80.9 47 94.1zm76.6-205c-12.4 0-36.1 1.2-52.5 10.2-4.7 2.6-10.2 3.1-15.4 1.7l-26.8-7.4c-4-1.1-5.6-5.9-3-9.2l14.9-18.8c5.2-7.1 13-11.6 21.6-10.2 17.4 2.9 46.3 10.1 63.6 27.4 2.6 2.3 1 6.3-2.4 6.3zm115 112c-1.7 2.2-5 2.2-6.8 0l-.1-.1c-1.8-2.3-7.3-138.3-146.4-168.7-5.4-1.2-7.7-7.5-4.3-11.9l19.6-25.6c4.6-6 12.2-8.9 19.7-7.5 28.1 5.5 95.7 25.7 120.5 96.6 29.5 84.5 13.9 96.8-2.2 117.2zm46.4-88.4c-.8 4.1-6.6 4.2-7.5.1-9.8-43.6-44.3-150.3-147.6-150.8-4.4 0-7.2-4.8-5-8.6l17.6-31.4c4.4-7.9 19.3-9.1 28.1-7 41.1 9.9 143 47.6 114.4 197.7z" />
|
|
271
|
+
</g>
|
|
272
|
+
</svg>
|
|
256
273
|
</Icon>
|
|
257
274
|
```
|
|
258
275
|
|
|
259
|
-
<
|
|
276
|
+
<Canvas>
|
|
260
277
|
<Story
|
|
261
278
|
name="Custom Icons"
|
|
262
279
|
args={{
|
|
263
|
-
color: IconColors.
|
|
264
|
-
size: IconSizes.
|
|
265
|
-
iconRotation: IconRotationTypes.
|
|
280
|
+
color: IconColors.UiBlack,
|
|
281
|
+
size: IconSizes.ExtraExtraExtraLarge,
|
|
282
|
+
iconRotation: IconRotationTypes.Rotate0,
|
|
266
283
|
decorative: true,
|
|
267
284
|
}}
|
|
268
285
|
>
|
|
@@ -280,4 +297,4 @@ child to the `Icon` component.
|
|
|
280
297
|
</Icon>
|
|
281
298
|
)}
|
|
282
299
|
</Story>
|
|
283
|
-
</
|
|
300
|
+
</Canvas>
|
|
@@ -7,38 +7,64 @@ import { IconNames } from "./IconTypes";
|
|
|
7
7
|
|
|
8
8
|
describe("Icon Accessibility", () => {
|
|
9
9
|
it("passes axe accessibility test", async () => {
|
|
10
|
-
const { container } = render(
|
|
11
|
-
<Icon name={IconNames.download} decorative={true} />
|
|
12
|
-
);
|
|
10
|
+
const { container } = render(<Icon name={IconNames.Download} />);
|
|
13
11
|
expect(await axe(container)).toHaveNoViolations();
|
|
14
12
|
});
|
|
15
13
|
});
|
|
16
14
|
|
|
17
15
|
describe("Icon", () => {
|
|
18
|
-
it("
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
).
|
|
16
|
+
it("consoles a warning if both name and children are passed to Icon", () => {
|
|
17
|
+
const warn = jest.spyOn(console, "warn");
|
|
18
|
+
render(
|
|
19
|
+
<Icon name={IconNames.Download} decorative={true}>
|
|
20
|
+
<svg viewBox="0 0 24 14" xmlns="http://www.w3.org/2000/svg">
|
|
21
|
+
<path
|
|
22
|
+
fillRule="evenodd"
|
|
23
|
+
clipRule="evenodd"
|
|
24
|
+
d="M10.526 12.871L.263 1.676 1.737.324 12 11.52 22.263.324l1.474 1.352L13.474 12.87a2 2 0 01-2.948 0z"
|
|
25
|
+
/>
|
|
26
|
+
</svg>
|
|
27
|
+
</Icon>
|
|
28
|
+
);
|
|
29
|
+
expect(warn).toHaveBeenCalledWith(
|
|
30
|
+
"Icon accepts either a `name` prop or an `svg` element child, not both."
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("consoles a warning if both name and children are not passed", () => {
|
|
35
|
+
const warn = jest.spyOn(console, "warn");
|
|
36
|
+
render(<Icon />);
|
|
37
|
+
expect(warn).toHaveBeenCalledWith(
|
|
38
|
+
"Pass an icon `name` prop or an SVG child to `Icon` to ensure an icon appears."
|
|
39
|
+
);
|
|
32
40
|
});
|
|
33
41
|
|
|
34
42
|
it("renders an icon based on the icon `name` prop", () => {
|
|
35
|
-
const
|
|
36
|
-
expect(
|
|
43
|
+
const { container } = render(<Icon name={IconNames.Download} />);
|
|
44
|
+
expect(container.querySelector("svg")).toBeInTheDocument();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// NOTE: the svg icon is dynamically generated by the "svgr" package. At build
|
|
48
|
+
// time, it generate the `title` element but it doesn't generate it for tests.
|
|
49
|
+
// In order to test this, we can check the `title` attribute in the svg
|
|
50
|
+
// element itself. Inspect the `Icon` in Storybook to see the `title` element.
|
|
51
|
+
it("renders a title element", () => {
|
|
52
|
+
const { container, rerender } = render(<Icon name={IconNames.Download} />);
|
|
53
|
+
expect(container.querySelector("svg")).toHaveAttribute(
|
|
54
|
+
"title",
|
|
55
|
+
"download icon"
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
rerender(<Icon name={IconNames.Download} title="title content" />);
|
|
59
|
+
expect(container.querySelector("svg")).toHaveAttribute(
|
|
60
|
+
"title",
|
|
61
|
+
"title content"
|
|
62
|
+
);
|
|
37
63
|
});
|
|
38
64
|
|
|
39
65
|
it("renders an icon based on the child", () => {
|
|
40
|
-
const
|
|
41
|
-
<Icon
|
|
66
|
+
const { container } = render(
|
|
67
|
+
<Icon>
|
|
42
68
|
<svg viewBox="0 0 24 14" xmlns="http://www.w3.org/2000/svg">
|
|
43
69
|
<path
|
|
44
70
|
fillRule="evenodd"
|
|
@@ -48,6 +74,6 @@ describe("Icon", () => {
|
|
|
48
74
|
</svg>
|
|
49
75
|
</Icon>
|
|
50
76
|
);
|
|
51
|
-
expect(
|
|
77
|
+
expect(container.querySelector("svg")).toBeInTheDocument();
|
|
52
78
|
});
|
|
53
79
|
});
|