@nypl/design-system-react-components 0.23.4 → 0.25.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 +98 -1
- package/README.md +46 -11
- package/dist/components/Accordion/Accordion.d.ts +14 -14
- package/dist/components/Autosuggest/Autosuggest.stories.d.ts +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +11 -14
- package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +6 -0
- package/dist/components/Button/Button.d.ts +6 -13
- package/dist/components/Button/ButtonTypes.d.ts +5 -3
- package/dist/components/Card/Card.d.ts +59 -10
- package/dist/components/Card/CardTypes.d.ts +19 -0
- package/dist/components/CardEdition/CardEdition.d.ts +21 -0
- package/dist/components/{StyleGuide/Colors.stories.d.ts → CardEdition/CardEdition.stories.d.ts} +5 -2
- package/dist/components/Checkbox/Checkbox.d.ts +21 -16
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +43 -0
- package/dist/components/CheckboxGroup/CheckboxGroupLayoutTypes.d.ts +4 -0
- package/dist/components/DatePicker/DatePicker.d.ts +79 -0
- package/dist/components/DatePicker/DatePickerTypes.d.ts +5 -0
- package/dist/components/Form/Form.d.ts +16 -8
- package/dist/components/Form/FormTypes.d.ts +2 -0
- 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 +9 -11
- package/dist/components/Heading/{HeadingDisplaySizes.d.ts → HeadingTypes.d.ts} +8 -0
- package/dist/components/HelperErrorText/HelperErrorText.stories.d.ts +2 -1
- package/dist/components/Hero/Hero.d.ts +19 -14
- package/dist/components/Hero/HeroTypes.d.ts +10 -5
- package/dist/components/Icons/Icon.d.ts +13 -16
- package/dist/components/Icons/IconSvgs.d.ts +4 -0
- package/dist/components/Icons/IconTypes.d.ts +78 -60
- package/dist/components/Image/Image.stories.d.ts +2 -1
- package/dist/components/Label/Label.d.ts +10 -26
- package/dist/components/Link/Link.d.ts +8 -12
- package/dist/components/List/List.stories.d.ts +1 -0
- package/dist/components/Radio/Radio.d.ts +30 -24
- package/dist/components/RadioGroup/RadioGroup.d.ts +40 -0
- package/dist/components/RadioGroup/RadioGroupLayoutTypes.d.ts +4 -0
- 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 +1 -1
- package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +2 -2
- package/dist/components/StatusBadge/StatusBadge.d.ts +8 -6
- package/dist/components/StatusBadge/StatusBadgeTypes.d.ts +5 -0
- package/dist/components/Tabs/Tabs.d.ts +25 -0
- 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 +37 -30
- package/dist/components/TextInput/TextInputTypes.d.ts +5 -0
- package/dist/design-system-react-components.cjs.development.js +4102 -917
- 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 +4023 -920
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/index.d.ts +23 -5
- package/dist/resources.scss +133 -24
- 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 +109 -0
- package/dist/theme/components/checkbox.d.ts +91 -0
- package/dist/theme/components/customCheckboxGroup.d.ts +18 -0
- package/dist/theme/components/customRadioGroup.d.ts +18 -0
- package/dist/theme/components/global.d.ts +55 -0
- package/dist/theme/components/globalMixins.d.ts +15 -0
- package/dist/theme/components/heading.d.ts +110 -0
- package/dist/theme/components/hero.d.ts +492 -0
- package/dist/theme/components/icon.d.ts +13 -0
- package/dist/theme/components/label.d.ts +16 -0
- package/dist/theme/components/link.d.ts +45 -0
- package/dist/theme/components/radio.d.ts +95 -0
- package/dist/theme/components/searchBar.d.ts +20 -0
- package/dist/theme/components/select.d.ts +58 -0
- package/dist/theme/components/statusBadge.d.ts +25 -0
- package/dist/theme/components/tabs.d.ts +85 -0
- 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 +105 -0
- package/dist/theme/foundations/breakpoints.d.ts +23 -0
- package/dist/theme/foundations/colors.d.ts +3 -0
- package/dist/theme/foundations/global.d.ts +23 -0
- package/dist/theme/foundations/shadows.d.ts +4 -0
- package/dist/theme/foundations/spacing.d.ts +77 -0
- package/dist/theme/foundations/typography.d.ts +8 -0
- package/dist/theme/index.d.ts +20 -0
- package/dist/theme/provider.d.ts +5 -0
- package/dist/theme/types.d.ts +1 -0
- package/dist/utils/utils.d.ts +6 -0
- package/package.json +9 -2
- package/src/components/Accordion/Accordion.stories.mdx +233 -33
- 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 -3
- package/src/components/Autosuggest/Autosuggest.stories.tsx +1 -1
- package/src/components/Autosuggest/_Autosuggest.scss +2 -2
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +57 -56
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +31 -25
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +71 -73
- package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +6 -0
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +100 -0
- package/src/components/Button/Button.stories.mdx +125 -138
- package/src/components/Button/Button.test.tsx +65 -11
- package/src/components/Button/Button.tsx +72 -68
- package/src/components/Button/ButtonTypes.tsx +4 -2
- package/src/components/Button/_Button.scss +7 -92
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +58 -3
- package/src/components/Card/Card.stories.mdx +694 -0
- package/src/components/Card/Card.test.tsx +97 -102
- package/src/components/Card/Card.tsx +182 -31
- package/src/components/Card/CardTypes.tsx +21 -0
- package/src/components/Card/_Card.scss +234 -49
- package/src/components/{Card/Card.stories.tsx → CardEdition/CardEdition.stories.tsx} +32 -22
- package/src/components/CardEdition/CardEdition.test.tsx +395 -0
- package/src/components/CardEdition/CardEdition.tsx +60 -0
- package/src/components/CardEdition/_CardEdition.scss +138 -0
- package/src/components/Chakra/Box.stories.mdx +57 -0
- package/src/components/Chakra/Center.stories.mdx +99 -0
- package/src/components/Chakra/Grid.stories.mdx +79 -0
- package/src/components/Chakra/Stack.stories.mdx +93 -0
- package/src/components/Checkbox/Checkbox.stories.mdx +57 -35
- package/src/components/Checkbox/Checkbox.test.tsx +117 -147
- package/src/components/Checkbox/Checkbox.tsx +76 -50
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +325 -0
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +249 -0
- package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +345 -0
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +148 -0
- package/src/components/CheckboxGroup/CheckboxGroupLayoutTypes.tsx +4 -0
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +1360 -0
- package/src/components/DatePicker/DatePicker.stories.mdx +284 -0
- package/src/components/DatePicker/DatePicker.test.tsx +657 -0
- package/src/components/DatePicker/DatePicker.tsx +396 -0
- package/src/components/DatePicker/DatePickerTypes.tsx +5 -0
- package/src/components/DatePicker/_DatePicker.scss +76 -0
- package/src/components/Form/Form.stories.mdx +130 -27
- package/src/components/Form/Form.test.tsx +78 -36
- package/src/components/Form/Form.tsx +53 -19
- package/src/components/Form/FormTypes.tsx +3 -0
- package/src/components/Form/__snapshots__/Form.test.tsx.snap +38 -0
- package/src/components/Grid/GridTypes.tsx +9 -0
- package/src/components/Grid/SimpleGrid.stories.mdx +275 -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 +63 -33
- package/src/components/Heading/Heading.test.tsx +24 -16
- package/src/components/Heading/Heading.tsx +54 -38
- package/src/components/Heading/{HeadingDisplaySizes.tsx → HeadingTypes.tsx} +9 -0
- package/src/components/HelperErrorText/HelperErrorText.stories.tsx +2 -1
- package/src/components/HelperErrorText/_HelperErrorText.scss +1 -1
- package/src/components/Hero/Hero.stories.mdx +195 -85
- package/src/components/Hero/Hero.test.tsx +544 -113
- package/src/components/Hero/Hero.tsx +80 -93
- package/src/components/Hero/HeroTypes.tsx +17 -5
- package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +307 -0
- package/src/components/HorizontalRule/HorizontalRule.stories.mdx +6 -1
- package/src/components/HorizontalRule/_HorizontalRule.scss +1 -1
- package/src/components/Icons/Icon.stories.mdx +89 -74
- package/src/components/Icons/Icon.test.tsx +30 -22
- package/src/components/Icons/Icon.tsx +63 -61
- package/src/components/Icons/IconSvgs.tsx +8 -0
- package/src/components/Icons/IconTypes.tsx +80 -60
- package/src/components/Image/Image.stories.tsx +2 -1
- package/src/components/Input/_Input.scss +2 -2
- package/src/components/Label/Label.stories.mdx +77 -0
- package/src/components/Label/Label.test.tsx +43 -12
- package/src/components/Label/Label.tsx +28 -45
- package/src/components/Label/__snapshots__/Label.test.tsx.snap +41 -0
- package/src/components/Link/Link.stories.mdx +47 -41
- package/src/components/Link/Link.test.tsx +33 -44
- package/src/components/Link/Link.tsx +114 -100
- package/src/components/List/List.stories.mdx +7 -3
- package/src/components/List/List.stories.tsx +14 -9
- package/src/components/List/List.test.tsx +12 -8
- package/src/components/List/List.tsx +9 -7
- package/src/components/List/_List.scss +3 -3
- package/src/components/Modal/Modal.stories.mdx +7 -3
- package/src/components/Modal/_Modal.scss +1 -1
- package/src/components/Notification/Notification.stories.mdx +99 -65
- package/src/components/Notification/Notification.test.tsx +3 -16
- package/src/components/Notification/Notification.tsx +12 -12
- package/src/components/Notification/_Notification.scss +5 -4
- package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +1 -1
- package/src/components/Pagination/Pagination.stories.mdx +7 -1
- package/src/components/Pagination/Pagination.test.tsx +16 -10
- package/src/components/Radio/Radio.stories.mdx +57 -46
- package/src/components/Radio/Radio.test.tsx +92 -138
- package/src/components/Radio/Radio.tsx +70 -69
- package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +250 -0
- package/src/components/RadioGroup/RadioGroup.stories.mdx +247 -0
- package/src/components/RadioGroup/RadioGroup.test.tsx +327 -0
- package/src/components/RadioGroup/RadioGroup.tsx +154 -0
- package/src/components/RadioGroup/RadioGroupLayoutTypes.tsx +4 -0
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +1101 -0
- package/src/components/SearchBar/SearchBar.Test.tsx +151 -16
- package/src/components/SearchBar/SearchBar.stories.mdx +196 -224
- package/src/components/SearchBar/SearchBar.tsx +151 -46
- package/src/components/Select/Select.stories.mdx +193 -168
- package/src/components/Select/Select.test.tsx +129 -324
- package/src/components/Select/Select.tsx +120 -160
- package/src/components/Select/SelectTypes.tsx +4 -0
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +18 -29
- package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +7 -7
- package/src/components/SkeletonLoader/SkeletonLoader.tsx +4 -2
- package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +2 -2
- package/src/components/SkeletonLoader/_SkeletonLoader.scss +3 -3
- 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 +112 -90
- package/src/components/StyleGuide/Buttons.stories.mdx +98 -100
- package/src/components/StyleGuide/Colors.stories.mdx +336 -0
- package/src/components/StyleGuide/Forms.stories.mdx +85 -0
- package/src/components/StyleGuide/Iconography.stories.mdx +86 -93
- package/src/components/StyleGuide/Spacing.stories.mdx +0 -1
- package/src/components/StyleGuide/Typography.stories.mdx +164 -166
- package/src/components/StyleGuide/UIDocCard.tsx +4 -4
- package/src/components/Tabs/Tabs.stories.mdx +221 -0
- package/src/components/Tabs/Tabs.test.tsx +264 -0
- package/src/components/Tabs/Tabs.tsx +220 -0
- package/src/components/Template/Template.stories.mdx +574 -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 +90 -90
- package/src/components/TextInput/TextInput.test.tsx +103 -83
- package/src/components/TextInput/TextInput.tsx +108 -91
- package/src/components/TextInput/TextInputTypes.tsx +6 -0
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +2 -1
- package/src/components/VideoPlayer/VideoPlayer.tsx +4 -2
- package/src/components/VideoPlayer/_VideoPlayer.scss +1 -1
- package/src/docs/Chakra.stories.mdx +341 -0
- package/src/docs/Intro.stories.mdx +31 -24
- package/src/index.ts +70 -5
- package/src/styles/01-colors/_colors-brand.scss +6 -4
- package/src/styles/01-colors/_colors-utility.scss +14 -15
- package/src/styles/03-space/_space-inline.scss +47 -7
- package/src/styles/03-space/_space-inset.scss +33 -5
- package/src/styles/03-space/_space-stack.scss +48 -8
- package/src/styles/base/_02-breakpoints.scss +5 -4
- package/src/styles/base/_04-base.scss +2 -1
- package/src/styles/base/_place-holder.scss +1 -1
- package/src/styles/base/_typography.scss +1 -29
- package/src/styles.scss +22 -25
- package/src/theme/components/accordion.ts +30 -0
- package/src/theme/components/breadcrumb.ts +77 -0
- package/src/theme/components/button.ts +125 -0
- package/src/theme/components/checkbox.ts +107 -0
- package/src/theme/components/customCheckboxGroup.ts +12 -0
- package/src/theme/components/customRadioGroup.ts +12 -0
- package/src/theme/components/global.ts +71 -0
- package/src/theme/components/globalMixins.ts +16 -0
- package/src/theme/components/heading.ts +72 -0
- package/src/theme/components/hero.ts +239 -0
- package/src/theme/components/icon.ts +79 -0
- package/src/theme/components/label.ts +17 -0
- package/src/theme/components/link.ts +47 -0
- package/src/theme/components/radio.ts +106 -0
- package/src/theme/components/searchBar.ts +21 -0
- package/src/theme/components/select.ts +50 -0
- package/src/theme/components/statusBadge.ts +27 -0
- package/src/theme/components/tabs.ts +79 -0
- package/src/theme/components/template.ts +114 -0
- package/src/theme/components/text.ts +31 -0
- package/src/theme/components/textInput.ts +61 -0
- package/src/theme/foundations/breakpoints.ts +24 -0
- package/src/theme/foundations/colors.ts +208 -0
- package/src/theme/foundations/global.ts +26 -0
- package/src/theme/foundations/shadows.ts +5 -0
- package/src/theme/foundations/spacing.ts +85 -0
- package/src/theme/foundations/typography.ts +35 -0
- package/src/theme/index.ts +88 -0
- package/src/theme/provider.tsx +9 -0
- package/src/theme/types.ts +1 -0
- package/src/utils/componentCategories.ts +56 -21
- package/src/utils/utils.ts +13 -0
- package/dist/components/Accordion/Accordion.stories.d.ts +0 -5
- package/dist/components/Card/Card.stories.d.ts +0 -27
- package/dist/components/Label/Label.stories.d.ts +0 -12
- package/dist/components/StatusBadge/StatusBadge.stories.d.ts +0 -8
- package/dist/components/Template/Template.stories.d.ts +0 -29
- package/src/components/Accordion/Accordion.stories.tsx +0 -65
- package/src/components/Accordion/_Accordion.scss +0 -81
- package/src/components/Breadcrumbs/_Breadcrumbs.scss +0 -97
- package/src/components/Checkbox/_Checkbox.scss +0 -97
- package/src/components/Form/_Form.scss +0 -28
- package/src/components/Heading/_Heading.scss +0 -163
- package/src/components/Hero/_Hero.scss +0 -256
- package/src/components/Icons/_Icons.scss +0 -116
- package/src/components/Label/Label.stories.tsx +0 -30
- package/src/components/Label/_Label.scss +0 -22
- package/src/components/Link/_Link.scss +0 -73
- package/src/components/Radio/_Radio.scss +0 -84
- package/src/components/SearchBar/_SearchBar.scss +0 -16
- package/src/components/Select/_Select.scss +0 -82
- package/src/components/StatusBadge/StatusBadge.stories.tsx +0 -33
- package/src/components/StatusBadge/_StatusBadge.scss +0 -23
- package/src/components/StyleGuide/Colors.stories.tsx +0 -288
- package/src/components/Template/Template.stories.tsx +0 -85
- package/src/components/Template/_Template.scss +0 -63
- package/src/components/TextInput/_TextInput.scss +0 -59
|
@@ -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,
|
|
@@ -19,9 +19,10 @@ import {
|
|
|
19
19
|
import iconSvgs from "./IconSvgs";
|
|
20
20
|
import List from "../List/List";
|
|
21
21
|
import { ListTypes } from "../List/ListTypes";
|
|
22
|
+
import { getCategory } from "../../utils/componentCategories";
|
|
22
23
|
|
|
23
24
|
<Meta
|
|
24
|
-
title="Icon"
|
|
25
|
+
title={getCategory("Icon")}
|
|
25
26
|
component={Icon}
|
|
26
27
|
decorators={[withDesign]}
|
|
27
28
|
parameters={{
|
|
@@ -32,91 +33,109 @@ import { ListTypes } from "../List/ListTypes";
|
|
|
32
33
|
},
|
|
33
34
|
jest: ["Icon.test.tsx"],
|
|
34
35
|
}}
|
|
36
|
+
argTypes={{
|
|
37
|
+
children: { table: { disable: true } },
|
|
38
|
+
className: { table: { disable: true } },
|
|
39
|
+
id: { table: { disable: true } },
|
|
40
|
+
}}
|
|
35
41
|
/>
|
|
36
42
|
|
|
37
43
|
# Icon
|
|
38
44
|
|
|
45
|
+
| Component Version | DS Version |
|
|
46
|
+
| ----------------- | ---------- |
|
|
47
|
+
| Added | `0.0.4` |
|
|
48
|
+
| Latest | `0.25.1` |
|
|
49
|
+
|
|
39
50
|
<Description of={Icon} />
|
|
40
51
|
|
|
41
|
-
<
|
|
52
|
+
<Canvas withToolbar>
|
|
42
53
|
<Story
|
|
43
54
|
name="Icon Props Control"
|
|
44
55
|
args={{
|
|
45
|
-
|
|
46
|
-
color:
|
|
47
|
-
size: IconSizes.xlarge,
|
|
48
|
-
iconRotation: IconRotationTypes.rotate0,
|
|
56
|
+
align: "None",
|
|
57
|
+
color: "UiBlack",
|
|
49
58
|
decorative: true,
|
|
50
|
-
|
|
59
|
+
iconRotation: "Rotate0",
|
|
60
|
+
name: "Check",
|
|
61
|
+
size: "ExtraLarge",
|
|
51
62
|
}}
|
|
52
63
|
argTypes={{
|
|
53
|
-
|
|
64
|
+
align: {
|
|
54
65
|
control: {
|
|
55
66
|
type: "select",
|
|
56
|
-
options: IconColors,
|
|
57
67
|
},
|
|
68
|
+
options: Object.keys(IconAlign),
|
|
58
69
|
},
|
|
59
|
-
|
|
70
|
+
color: {
|
|
60
71
|
control: {
|
|
61
72
|
type: "select",
|
|
62
|
-
options: IconSizes,
|
|
63
73
|
},
|
|
74
|
+
options: Object.keys(IconColors),
|
|
64
75
|
},
|
|
65
76
|
iconRotation: {
|
|
66
77
|
control: {
|
|
67
78
|
type: "select",
|
|
68
|
-
options: IconRotationTypes,
|
|
69
79
|
},
|
|
80
|
+
options: Object.keys(IconRotationTypes),
|
|
70
81
|
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
82
|
+
name: {
|
|
83
|
+
control: {
|
|
84
|
+
type: "select",
|
|
74
85
|
},
|
|
86
|
+
options: Object.keys(IconNames),
|
|
75
87
|
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
88
|
+
size: {
|
|
89
|
+
control: {
|
|
90
|
+
type: "select",
|
|
79
91
|
},
|
|
92
|
+
options: Object.keys(IconSizes),
|
|
80
93
|
},
|
|
81
94
|
}}
|
|
82
95
|
>
|
|
83
|
-
{(args) =>
|
|
96
|
+
{(args) => (
|
|
97
|
+
<Icon
|
|
98
|
+
align={IconAlign[args.align]}
|
|
99
|
+
color={IconColors[args.color]}
|
|
100
|
+
iconRotation={IconRotationTypes[args.iconRotation]}
|
|
101
|
+
name={IconNames[args.name]}
|
|
102
|
+
size={IconSizes[args.size]}
|
|
103
|
+
/>
|
|
104
|
+
)}
|
|
84
105
|
</Story>
|
|
85
|
-
</
|
|
106
|
+
</Canvas>
|
|
86
107
|
|
|
87
108
|
<ArgsTable story="Icon Props Control" />
|
|
88
109
|
|
|
89
|
-
export const iconRow = (icon, opts = {}) => {
|
|
110
|
+
export const iconRow = (icon, iconType = IconNames, opts = {}) => {
|
|
90
111
|
// We'll use this setup function to render all the icons in a list item.
|
|
91
112
|
// Some icons display better with a dark background.
|
|
92
113
|
const styles = { padding: "1rem" };
|
|
93
114
|
const {
|
|
94
|
-
size = IconSizes.
|
|
95
|
-
iconRotation = IconRotationTypes.
|
|
96
|
-
color = IconColors.
|
|
115
|
+
size = IconSizes.Large,
|
|
116
|
+
iconRotation = IconRotationTypes.Rotate0,
|
|
117
|
+
color = IconColors.UiBlack,
|
|
97
118
|
displayValue = icon,
|
|
98
119
|
} = opts;
|
|
99
120
|
let key = icon;
|
|
100
|
-
if (icon.indexOf("
|
|
121
|
+
if (icon.indexOf("Negative") !== -1 || color.indexOf("white") !== -1) {
|
|
101
122
|
styles.backgroundColor = "#000";
|
|
102
|
-
styles.display = "inline-block";
|
|
103
123
|
}
|
|
104
124
|
// The following is just to fix duplicate React key issues.
|
|
105
|
-
if (iconRotation !== IconRotationTypes.
|
|
125
|
+
if (iconRotation !== IconRotationTypes.Rotate0) {
|
|
106
126
|
key += `-${iconRotation}`;
|
|
107
127
|
}
|
|
108
|
-
if (color !== IconColors.
|
|
128
|
+
if (color !== IconColors.UiBlack) {
|
|
109
129
|
key += `-${color}`;
|
|
110
130
|
}
|
|
111
|
-
if (size !== IconSizes.
|
|
131
|
+
if (size !== IconSizes.Large) {
|
|
112
132
|
key += `-${size}`;
|
|
113
133
|
}
|
|
114
134
|
return (
|
|
115
135
|
<li key={key} style={{ marginBottom: "var(--space-s)" }}>
|
|
116
136
|
<span style={styles}>
|
|
117
137
|
<Icon
|
|
118
|
-
name={icon}
|
|
119
|
-
decorative={true}
|
|
138
|
+
name={iconType[icon]}
|
|
120
139
|
size={size}
|
|
121
140
|
iconRotation={iconRotation}
|
|
122
141
|
color={color}
|
|
@@ -132,33 +151,33 @@ export const rotations = [];
|
|
|
132
151
|
export const colors = [];
|
|
133
152
|
export const sizes = [];
|
|
134
153
|
for (const icon in IconNames) {
|
|
135
|
-
icons.push(iconRow(icon));
|
|
154
|
+
icons.push(iconRow(icon, IconNames));
|
|
136
155
|
}
|
|
137
156
|
for (const logo in LogoNames) {
|
|
138
|
-
logos.push(iconRow(logo, { iconSize: IconSizes.
|
|
157
|
+
logos.push(iconRow(logo, LogoNames, { iconSize: IconSizes.ExtraLarge }));
|
|
139
158
|
}
|
|
140
159
|
for (const iconRotation in IconRotationTypes) {
|
|
141
160
|
rotations.push(
|
|
142
|
-
iconRow(IconNames
|
|
143
|
-
size: IconSizes.
|
|
161
|
+
iconRow("Arrow", IconNames, {
|
|
162
|
+
size: IconSizes.Large,
|
|
144
163
|
iconRotation: IconRotationTypes[iconRotation],
|
|
145
|
-
displayValue:
|
|
164
|
+
displayValue: iconRotation,
|
|
146
165
|
})
|
|
147
166
|
);
|
|
148
167
|
}
|
|
149
168
|
for (const iconColor in IconColors) {
|
|
150
169
|
colors.push(
|
|
151
|
-
iconRow(IconNames
|
|
170
|
+
iconRow("Download", IconNames, {
|
|
152
171
|
color: IconColors[iconColor],
|
|
153
|
-
displayValue:
|
|
172
|
+
displayValue: iconColor,
|
|
154
173
|
})
|
|
155
174
|
);
|
|
156
175
|
}
|
|
157
176
|
for (const iconSize in IconSizes) {
|
|
158
177
|
sizes.push(
|
|
159
|
-
iconRow(IconNames
|
|
178
|
+
iconRow("Arrow", IconNames, {
|
|
160
179
|
size: IconSizes[iconSize],
|
|
161
|
-
displayValue:
|
|
180
|
+
displayValue: iconSize,
|
|
162
181
|
})
|
|
163
182
|
);
|
|
164
183
|
}
|
|
@@ -173,59 +192,51 @@ Passing an `iconRotation` prop with a value from `IconRotationTypes` allows
|
|
|
173
192
|
the icon to be rotated when it is rendered. The `IconRotationTypes` enum
|
|
174
193
|
can be found in `src/components/Icons/IconTypes.tsx`.
|
|
175
194
|
|
|
176
|
-
```
|
|
195
|
+
```jsx
|
|
177
196
|
// Example
|
|
178
|
-
<Icon
|
|
179
|
-
name={IconNames.arrow}
|
|
180
|
-
decorative={true}
|
|
181
|
-
iconRotation={IconRotationTypes.rotate180}
|
|
182
|
-
/>
|
|
197
|
+
<Icon name={IconNames.Arrow} iconRotation={IconRotationTypes.Rotate180} />
|
|
183
198
|
```
|
|
184
199
|
|
|
185
|
-
<
|
|
200
|
+
<Canvas>
|
|
186
201
|
<Story name="Rotation Types">{allIconsType(rotations)}</Story>
|
|
187
|
-
</
|
|
202
|
+
</Canvas>
|
|
188
203
|
|
|
189
204
|
## IconColors Types
|
|
190
205
|
|
|
191
206
|
Update an SVG icon by passing a `color` prop with a value from `IconColors`.
|
|
192
|
-
The `IconColors` enum can be found in`src/components/Icons/IconTypes.tsx`.
|
|
207
|
+
The `IconColors` enum can be found in `src/components/Icons/IconTypes.tsx`.
|
|
193
208
|
|
|
194
|
-
```
|
|
209
|
+
```jsx
|
|
195
210
|
// Example
|
|
196
|
-
<Icon
|
|
197
|
-
name={IconNames.speaker_notes}
|
|
198
|
-
decorative={true}
|
|
199
|
-
color={IconColors.brand_primary}
|
|
200
|
-
/>
|
|
211
|
+
<Icon name={IconNames.Speaker_notes} color={IconColors.BrandPrimary} />
|
|
201
212
|
```
|
|
202
213
|
|
|
203
|
-
<
|
|
214
|
+
<Canvas>
|
|
204
215
|
<Story name="Color Types">{allIconsType(colors)}</Story>
|
|
205
|
-
</
|
|
216
|
+
</Canvas>
|
|
206
217
|
|
|
207
218
|
## IconSizes Types
|
|
208
219
|
|
|
209
220
|
Update an SVG icon by passing a `size` prop with a value from `IconSizes`.
|
|
210
221
|
The `IconSizes` enum can be found in`src/components/Icons/IconTypes.tsx`.
|
|
211
222
|
|
|
212
|
-
```
|
|
223
|
+
```jsx
|
|
213
224
|
// Example
|
|
214
|
-
<Icon name={IconNames.
|
|
225
|
+
<Icon name={IconNames.Clock} size={IconSizes.ExtraExtraLarge} />
|
|
215
226
|
```
|
|
216
227
|
|
|
217
|
-
<
|
|
228
|
+
<Canvas>
|
|
218
229
|
<Story name="Sizes Types">{allIconsType(sizes)}</Story>
|
|
219
|
-
</
|
|
230
|
+
</Canvas>
|
|
220
231
|
|
|
221
232
|
## All Display Icons
|
|
222
233
|
|
|
223
234
|
The following icons are for generic purposes. All the available logo names can
|
|
224
235
|
be found in the `IconNames` enum in `src/components/Icons/IconTypes.tsx`.
|
|
225
236
|
|
|
226
|
-
<
|
|
237
|
+
<Canvas withToolbar>
|
|
227
238
|
<Story name="All Display Icons">{allIconsType(icons)}</Story>
|
|
228
|
-
</
|
|
239
|
+
</Canvas>
|
|
229
240
|
|
|
230
241
|
## All Logo Icons
|
|
231
242
|
|
|
@@ -235,28 +246,32 @@ The following icons are meant to be used for logos for different libraries
|
|
|
235
246
|
and products. All the available logo names can
|
|
236
247
|
be found in the `LogoNames` enum in `src/components/Icons/IconTypes.tsx`.
|
|
237
248
|
|
|
238
|
-
<
|
|
249
|
+
<Canvas withToolbar>
|
|
239
250
|
<Story name="All Logo Icons">{allIconsType(logos)}</Story>
|
|
240
|
-
</
|
|
251
|
+
</Canvas>
|
|
241
252
|
|
|
242
253
|
## Custom Icons
|
|
243
254
|
|
|
244
255
|
If you'd like to pass a custom svg to your application, you can pass it a
|
|
245
256
|
child to the `Icon` component.
|
|
246
257
|
|
|
247
|
-
```
|
|
248
|
-
<Icon {...
|
|
249
|
-
<svg
|
|
258
|
+
```jsx
|
|
259
|
+
<Icon {...props}>
|
|
260
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 750 750" fill="#6BE9D8">
|
|
261
|
+
<g>
|
|
262
|
+
<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" />
|
|
263
|
+
</g>
|
|
264
|
+
</svg>
|
|
250
265
|
</Icon>
|
|
251
266
|
```
|
|
252
267
|
|
|
253
|
-
<
|
|
268
|
+
<Canvas>
|
|
254
269
|
<Story
|
|
255
270
|
name="Custom Icons"
|
|
256
271
|
args={{
|
|
257
|
-
color: IconColors.
|
|
258
|
-
size: IconSizes.
|
|
259
|
-
iconRotation: IconRotationTypes.
|
|
272
|
+
color: IconColors.UiBlack,
|
|
273
|
+
size: IconSizes.ExtraExtraExtraLarge,
|
|
274
|
+
iconRotation: IconRotationTypes.Rotate0,
|
|
260
275
|
decorative: true,
|
|
261
276
|
}}
|
|
262
277
|
>
|
|
@@ -274,4 +289,4 @@ child to the `Icon` component.
|
|
|
274
289
|
</Icon>
|
|
275
290
|
)}
|
|
276
291
|
</Story>
|
|
277
|
-
</
|
|
292
|
+
</Canvas>
|
|
@@ -7,38 +7,46 @@ 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();
|
|
37
45
|
});
|
|
38
46
|
|
|
39
47
|
it("renders an icon based on the child", () => {
|
|
40
|
-
const
|
|
41
|
-
<Icon
|
|
48
|
+
const { container } = render(
|
|
49
|
+
<Icon>
|
|
42
50
|
<svg viewBox="0 0 24 14" xmlns="http://www.w3.org/2000/svg">
|
|
43
51
|
<path
|
|
44
52
|
fillRule="evenodd"
|
|
@@ -48,6 +56,6 @@ describe("Icon", () => {
|
|
|
48
56
|
</svg>
|
|
49
57
|
</Icon>
|
|
50
58
|
);
|
|
51
|
-
expect(
|
|
59
|
+
expect(container.querySelector("svg")).toBeInTheDocument();
|
|
52
60
|
});
|
|
53
61
|
});
|
|
@@ -1,39 +1,38 @@
|
|
|
1
|
-
/* eslint-disable camelcase */
|
|
2
1
|
import * as React from "react";
|
|
3
|
-
import
|
|
4
|
-
import generateUUID from "../../helpers/generateUUID";
|
|
2
|
+
import { Icon as ChakraIcon, Box, useStyleConfig } from "@chakra-ui/react";
|
|
5
3
|
|
|
4
|
+
import generateUUID from "../../helpers/generateUUID";
|
|
6
5
|
import {
|
|
7
|
-
|
|
8
|
-
IconNames,
|
|
9
|
-
LogoNames,
|
|
6
|
+
IconAlign,
|
|
10
7
|
IconColors,
|
|
8
|
+
IconNames,
|
|
9
|
+
IconRotationTypes,
|
|
11
10
|
IconSizes,
|
|
11
|
+
IconTypes,
|
|
12
|
+
LogoNames,
|
|
12
13
|
} from "./IconTypes";
|
|
13
|
-
|
|
14
14
|
import iconSvgs from "./IconSvgs";
|
|
15
15
|
|
|
16
16
|
export interface IconProps {
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
/** BlockName for use with BEM. See how to work with blockNames and BEM here: http://getbem.com/introduction/ */
|
|
20
|
-
blockName?: string;
|
|
21
|
-
/** Modifiers array for use with BEM. See how to work with modifiers and BEM here: http://getbem.com/introduction/ */
|
|
22
|
-
modifiers?: string[];
|
|
17
|
+
/** Aligns the icon. */
|
|
18
|
+
align?: IconAlign;
|
|
23
19
|
/** className that appears in addition to "icon" */
|
|
24
20
|
className?: string;
|
|
25
|
-
/**
|
|
21
|
+
/** Overrides default icon color (black). */
|
|
22
|
+
color?: IconColors;
|
|
23
|
+
/** Icons designated as decorative will be ignored by screenreaders. True
|
|
24
|
+
* by default. */
|
|
26
25
|
decorative?: boolean;
|
|
27
|
-
/** This text will be added as a child `<title>` element inside the `<svg>` tag. It is recommended to do this for increased accessibility. */
|
|
28
|
-
titleText?: string;
|
|
29
26
|
/** Rotates the icon clockwise in increments of 90deg */
|
|
30
27
|
iconRotation?: IconRotationTypes;
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
/** Sets the icon size. */
|
|
34
|
-
size?: IconSizes;
|
|
28
|
+
/** ID that other components can cross reference for accessibility purposes */
|
|
29
|
+
id?: string;
|
|
35
30
|
/** The name of the icon you want to use. */
|
|
36
31
|
name?: IconNames | LogoNames;
|
|
32
|
+
/** Sets the icon size. */
|
|
33
|
+
size?: IconSizes;
|
|
34
|
+
/** Sets the icon variant type. */
|
|
35
|
+
type?: IconTypes;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
/**
|
|
@@ -41,63 +40,66 @@ export interface IconProps {
|
|
|
41
40
|
*/
|
|
42
41
|
export default function Icon(props: React.PropsWithChildren<IconProps>) {
|
|
43
42
|
const {
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
align = "none",
|
|
44
|
+
children,
|
|
46
45
|
className,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
modifiers = [],
|
|
46
|
+
color = IconColors.UiBlack,
|
|
47
|
+
decorative = true,
|
|
48
|
+
iconRotation = IconRotationTypes.Rotate0,
|
|
49
|
+
id = generateUUID(),
|
|
52
50
|
name,
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
size = IconSizes.Medium,
|
|
52
|
+
type = IconTypes.Default,
|
|
55
53
|
} = props;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (size) {
|
|
66
|
-
modifiers.push(size);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const iconID = generateUUID();
|
|
54
|
+
const styles = useStyleConfig("Icon", {
|
|
55
|
+
align,
|
|
56
|
+
color,
|
|
57
|
+
iconRotation,
|
|
58
|
+
size,
|
|
59
|
+
variant: type,
|
|
60
|
+
});
|
|
70
61
|
const iconProps = {
|
|
71
|
-
className: bem("icon", modifiers, blockName, [className]),
|
|
72
|
-
id: iconID,
|
|
73
|
-
role: "img",
|
|
74
|
-
title: titleText || null,
|
|
75
62
|
"aria-hidden": decorative,
|
|
76
|
-
|
|
63
|
+
className,
|
|
64
|
+
id,
|
|
65
|
+
role: "img",
|
|
77
66
|
};
|
|
78
|
-
|
|
79
|
-
// Apply icon props to SVG that was passed as a child.
|
|
80
|
-
const renderChildren = () =>
|
|
81
|
-
React.Children.map(children, (child) =>
|
|
82
|
-
React.cloneElement(child as JSX.Element, { ...iconProps })
|
|
83
|
-
);
|
|
67
|
+
let childSVG = null;
|
|
84
68
|
|
|
85
69
|
// Component prop validation
|
|
86
70
|
if (name && children) {
|
|
87
|
-
|
|
71
|
+
console.warn(
|
|
72
|
+
"Icon accepts either a `name` prop or an `svg` element child, not both."
|
|
73
|
+
);
|
|
74
|
+
return null;
|
|
88
75
|
} else if (!name && !children) {
|
|
89
76
|
console.warn(
|
|
90
|
-
"Pass
|
|
77
|
+
"Pass an icon `name` prop or an SVG child to `Icon` to ensure an icon appears."
|
|
91
78
|
);
|
|
79
|
+
return null;
|
|
92
80
|
}
|
|
93
81
|
|
|
94
82
|
// The user wants to render an existing icon. Load the icon and render it
|
|
95
|
-
// as a component. Otherwise, we're
|
|
96
|
-
//
|
|
83
|
+
// as a component through Chakra's Icon component. Otherwise, we're going to
|
|
84
|
+
// render the SVG child with NYPL-theme styling.
|
|
97
85
|
if (name) {
|
|
98
|
-
const SvgComponent = iconSvgs[name];
|
|
99
|
-
return <SvgComponent {...iconProps} />;
|
|
86
|
+
const SvgComponent: any = iconSvgs[name];
|
|
87
|
+
return <ChakraIcon as={SvgComponent} {...iconProps} __css={styles} />;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// If no `name` prop was passed, we expect a child SVG element to be passed.
|
|
91
|
+
// Apply icon props to the SVG child.
|
|
92
|
+
if (
|
|
93
|
+
(children as JSX.Element).type === "svg" ||
|
|
94
|
+
(children as JSX.Element).props.type === "svg" ||
|
|
95
|
+
(children as JSX.Element).props.mdxType === "svg"
|
|
96
|
+
) {
|
|
97
|
+
childSVG = React.cloneElement(children as JSX.Element, {
|
|
98
|
+
...iconProps,
|
|
99
|
+
});
|
|
100
|
+
} else {
|
|
101
|
+
console.warn("You must pass an `svg` element to the `Icon` component.");
|
|
100
102
|
}
|
|
101
103
|
|
|
102
|
-
return
|
|
104
|
+
return <Box __css={styles}>{childSVG}</Box>;
|
|
103
105
|
}
|
|
@@ -34,6 +34,10 @@ import simplye_color from "../../../icons/svg/simplye_color.svg";
|
|
|
34
34
|
import snfl_negative from "../../../icons/svg/snfl_negative.svg";
|
|
35
35
|
import snfl_positive from "../../../icons/svg/snfl_positive.svg";
|
|
36
36
|
import speaker_notes from "../../../icons/svg/speaker_notes.svg";
|
|
37
|
+
import utility_account_filled from "../../../icons/svg/utility_account_filled.svg";
|
|
38
|
+
import utility_account_unfilled from "../../../icons/svg/utility_account_unfilled.svg";
|
|
39
|
+
import utility_hamburger from "../../../icons/svg/utility_hamburger.svg";
|
|
40
|
+
import utility_search from "../../../icons/svg/search.svg";
|
|
37
41
|
|
|
38
42
|
export default {
|
|
39
43
|
accessibility_full,
|
|
@@ -71,4 +75,8 @@ export default {
|
|
|
71
75
|
snfl_negative,
|
|
72
76
|
snfl_positive,
|
|
73
77
|
speaker_notes,
|
|
78
|
+
utility_account_filled,
|
|
79
|
+
utility_account_unfilled,
|
|
80
|
+
utility_hamburger,
|
|
81
|
+
utility_search,
|
|
74
82
|
};
|