@nypl/design-system-react-components 0.25.8 → 0.25.11
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 +110 -1
- package/README.md +1 -1
- package/dist/components/Button/Button.d.ts +6 -6
- package/dist/components/Button/ButtonTypes.d.ts +0 -1
- package/dist/components/Card/Card.d.ts +6 -4
- package/dist/components/Checkbox/Checkbox.d.ts +3 -2
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +3 -2
- package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +8 -2
- package/dist/components/DatePicker/DatePicker.d.ts +4 -3
- package/dist/components/Fieldset/Fieldset.d.ts +1 -3
- package/dist/components/Form/Form.d.ts +15 -14
- package/dist/components/Form/FormTypes.d.ts +2 -2
- package/dist/components/Heading/Heading.d.ts +7 -3
- package/dist/components/Heading/HeadingTypes.d.ts +6 -6
- package/dist/components/HelperErrorText/HelperErrorText.d.ts +5 -2
- package/dist/components/HorizontalRule/HorizontalRule.d.ts +3 -3
- package/dist/components/Icons/Icon.d.ts +4 -4
- package/dist/components/Icons/IconSvgs.d.ts +0 -21
- package/dist/components/Icons/IconTypes.d.ts +0 -23
- package/dist/components/Image/Image.d.ts +11 -3
- package/dist/components/List/List.d.ts +1 -1
- package/dist/components/Logo/Logo.d.ts +28 -0
- package/dist/components/Logo/LogoSvgs.d.ts +34 -0
- package/dist/components/Logo/LogoTypes.d.ts +46 -0
- package/dist/components/Modal/Modal.d.ts +0 -4
- package/dist/components/Notification/Notification.d.ts +4 -2
- package/dist/components/Placeholder/Placeholder.d.ts +3 -5
- package/dist/components/Radio/Radio.d.ts +6 -5
- package/dist/components/RadioGroup/RadioGroup.d.ts +6 -5
- package/dist/components/SearchBar/SearchBar.d.ts +15 -7
- package/dist/components/Select/Select.d.ts +7 -2
- package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +8 -4
- package/dist/components/Slider/Slider.d.ts +3 -2
- package/dist/components/StatusBadge/StatusBadge.d.ts +2 -1
- package/dist/components/StructuredContent/StructuredContent.d.ts +41 -0
- package/dist/components/StructuredContent/StructuredContentTypes.d.ts +5 -0
- package/dist/components/Table/Table.d.ts +29 -0
- package/dist/components/Template/Template.d.ts +30 -6
- package/dist/components/Text/Text.d.ts +2 -2
- package/dist/components/TextInput/TextInput.d.ts +4 -3
- package/dist/components/Toggle/Toggle.d.ts +3 -2
- package/dist/components/VideoPlayer/VideoPlayer.d.ts +14 -5
- package/dist/design-system-react-components.cjs.development.js +6721 -5777
- 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 +6774 -5839
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/index.d.ts +10 -8
- package/dist/resources.scss +0 -2
- package/dist/styles.css +2 -2
- package/dist/theme/components/breadcrumb.d.ts +1 -1
- package/dist/theme/components/button.d.ts +0 -12
- package/dist/theme/components/card.d.ts +14 -2
- package/dist/theme/components/customTable.d.ts +56 -0
- package/dist/theme/components/fieldset.d.ts +2 -2
- package/dist/theme/components/global.d.ts +1 -1
- package/dist/theme/components/heading.d.ts +4 -0
- package/dist/theme/components/label.d.ts +1 -1
- package/dist/theme/components/link.d.ts +14 -1
- package/dist/theme/components/list.d.ts +0 -2
- package/dist/theme/components/logo.d.ts +4 -0
- package/dist/theme/components/notification.d.ts +13 -4
- package/dist/theme/components/searchBar.d.ts +9 -11
- package/dist/theme/components/select.d.ts +1 -0
- package/dist/theme/components/structuredContent.d.ts +33 -0
- package/dist/theme/components/template.d.ts +10 -10
- package/dist/theme/components/textInput.d.ts +4 -0
- package/dist/theme/components/toggle.d.ts +8 -5
- package/dist/utils/utils.d.ts +10 -0
- package/package.json +40 -37
- package/src/__tests__/utils/utils.test.ts +23 -1
- package/src/components/Accordion/Accordion.stories.mdx +15 -13
- package/src/components/Accordion/Accordion.test.tsx +45 -1
- package/src/components/Accordion/Accordion.tsx +20 -8
- package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +243 -0
- package/src/components/Autosuggest/Autosuggest.stories.mdx +2 -1
- package/src/components/Autosuggest/Autosuggest.stories.tsx +24 -48
- package/src/components/Autosuggest/_Autosuggest.scss +2 -6
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +43 -13
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +15 -0
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +9 -3
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +5 -5
- package/src/components/Button/Button.stories.mdx +93 -48
- package/src/components/Button/Button.test.tsx +0 -12
- package/src/components/Button/Button.tsx +7 -7
- package/src/components/Button/ButtonTypes.tsx +0 -1
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +0 -12
- package/src/components/Card/Card.stories.mdx +186 -71
- package/src/components/Card/Card.test.tsx +45 -22
- package/src/components/Card/Card.tsx +21 -6
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +9 -3
- package/src/components/Chakra/Box.stories.mdx +3 -3
- package/src/components/Chakra/Center.stories.mdx +5 -5
- package/src/components/Chakra/Flex.stories.mdx +113 -0
- package/src/components/Chakra/Grid.stories.mdx +3 -3
- package/src/components/Chakra/Stack.stories.mdx +2 -2
- package/src/components/Checkbox/Checkbox.stories.mdx +37 -15
- package/src/components/Checkbox/Checkbox.tsx +13 -8
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +48 -16
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +14 -10
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +6 -3
- package/src/components/ComponentWrapper/ComponentWrapper.test.tsx +151 -0
- package/src/components/ComponentWrapper/ComponentWrapper.tsx +36 -23
- package/src/components/ComponentWrapper/__snapshots__/ComponentWrapper.test.tsx.snap +85 -0
- package/src/components/DatePicker/DatePicker.stories.mdx +63 -18
- package/src/components/DatePicker/DatePicker.test.tsx +6 -6
- package/src/components/DatePicker/DatePicker.tsx +17 -11
- package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +50 -24
- package/src/components/Fieldset/Fieldset.stories.mdx +20 -9
- package/src/components/Fieldset/Fieldset.tsx +2 -4
- package/src/components/Form/Form.stories.mdx +75 -49
- package/src/components/Form/Form.test.tsx +92 -3
- package/src/components/Form/Form.tsx +28 -23
- package/src/components/Form/FormTypes.tsx +2 -2
- package/src/components/Form/__snapshots__/Form.test.tsx.snap +0 -1
- package/src/components/Grid/SimpleGrid.stories.mdx +26 -26
- package/src/components/Heading/Heading.stories.mdx +59 -23
- package/src/components/Heading/Heading.test.tsx +82 -18
- package/src/components/Heading/Heading.tsx +31 -31
- package/src/components/Heading/HeadingTypes.tsx +6 -6
- package/src/components/Heading/__snapshots__/Heading.test.tsx.snap +71 -0
- package/src/components/HelperErrorText/HelperErrorText.stories.mdx +55 -27
- package/src/components/HelperErrorText/HelperErrorText.test.tsx +42 -15
- package/src/components/HelperErrorText/HelperErrorText.tsx +24 -24
- package/src/components/HelperErrorText/__snapshots__/HelperErrorText.test.tsx.snap +41 -4
- package/src/components/Hero/Hero.stories.mdx +72 -53
- package/src/components/HorizontalRule/HorizontalRule.stories.mdx +11 -9
- package/src/components/HorizontalRule/HorizontalRule.tsx +4 -6
- package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +4 -4
- package/src/components/Icons/Icon.stories.mdx +78 -77
- package/src/components/Icons/Icon.test.tsx +1 -1
- package/src/components/Icons/Icon.tsx +5 -6
- package/src/components/Icons/IconSvgs.tsx +0 -42
- package/src/components/Icons/IconTypes.tsx +0 -24
- package/src/components/Image/Image.stories.mdx +66 -18
- package/src/components/Image/Image.tsx +21 -10
- package/src/components/Label/Label.stories.mdx +20 -19
- package/src/components/Link/Link.stories.mdx +102 -51
- package/src/components/Link/Link.test.tsx +38 -8
- package/src/components/Link/Link.tsx +19 -12
- package/src/components/Link/__snapshots__/Link.test.tsx.snap +60 -0
- package/src/components/List/List.stories.mdx +60 -29
- package/src/components/List/List.test.tsx +1 -1
- package/src/components/List/List.tsx +2 -2
- package/src/components/List/__snapshots__/List.test.tsx.snap +3 -1
- package/src/components/Logo/Logo.stories.mdx +222 -0
- package/src/components/Logo/Logo.test.tsx +98 -0
- package/src/components/Logo/Logo.tsx +97 -0
- package/src/components/Logo/LogoSvgs.tsx +66 -0
- package/src/components/Logo/LogoTypes.tsx +48 -0
- package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +71 -0
- package/src/components/Modal/Modal.stories.mdx +20 -5
- package/src/components/Modal/Modal.tsx +2 -8
- package/src/components/Notification/Notification.stories.mdx +128 -38
- package/src/components/Notification/Notification.test.tsx +49 -1
- package/src/components/Notification/Notification.tsx +25 -12
- package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +4 -0
- package/src/components/Pagination/Pagination.stories.mdx +18 -7
- package/src/components/Pagination/Pagination.tsx +3 -3
- package/src/components/Placeholder/Placeholder.tsx +7 -14
- package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +72 -43
- package/src/components/Radio/Radio.stories.mdx +39 -19
- package/src/components/Radio/Radio.tsx +13 -9
- package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +5 -5
- package/src/components/RadioGroup/RadioGroup.stories.mdx +50 -16
- package/src/components/RadioGroup/RadioGroup.test.tsx +13 -11
- package/src/components/RadioGroup/RadioGroup.tsx +97 -94
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +24 -21
- package/src/components/SearchBar/SearchBar.Test.tsx +160 -34
- package/src/components/SearchBar/SearchBar.stories.mdx +115 -33
- package/src/components/SearchBar/SearchBar.tsx +72 -51
- package/src/components/Select/Select.stories.mdx +48 -14
- package/src/components/Select/Select.test.tsx +89 -0
- package/src/components/Select/Select.tsx +27 -12
- package/src/components/Select/__snapshots__/Select.test.tsx.snap +545 -0
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +50 -16
- package/src/components/SkeletonLoader/SkeletonLoader.tsx +8 -4
- package/src/components/Slider/Slider.stories.mdx +72 -22
- package/src/components/Slider/Slider.tsx +15 -10
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +67 -30
- package/src/components/StatusBadge/StatusBadge.stories.mdx +33 -18
- package/src/components/StatusBadge/StatusBadge.tsx +2 -1
- package/src/components/StructuredContent/StructuredContent.stories.mdx +427 -0
- package/src/components/StructuredContent/StructuredContent.test.tsx +376 -0
- package/src/components/StructuredContent/StructuredContent.tsx +153 -0
- package/src/components/StructuredContent/StructuredContentTypes.tsx +5 -0
- package/src/components/StructuredContent/__snapshots__/StructuredContent.test.tsx.snap +283 -0
- package/src/components/StyleGuide/Bidirectionality.stories.mdx +32 -83
- package/src/components/StyleGuide/Breakpoints.stories.mdx +1 -11
- package/src/components/StyleGuide/Buttons.stories.mdx +3 -18
- package/src/components/StyleGuide/ColorCard.tsx +1 -2
- package/src/components/StyleGuide/Colors.stories.mdx +3 -11
- package/src/components/StyleGuide/DesignTokens.stories.mdx +3 -8
- package/src/components/StyleGuide/Forms.stories.mdx +2 -10
- package/src/components/StyleGuide/Iconography.stories.mdx +8 -34
- package/src/components/StyleGuide/Spacing.stories.mdx +3 -14
- package/src/components/StyleGuide/Typography.stories.mdx +64 -76
- package/src/components/Table/Table.stories.mdx +165 -0
- package/src/components/Table/Table.test.tsx +137 -0
- package/src/components/Table/Table.tsx +126 -0
- package/src/components/Table/__snapshots__/Table.test.tsx.snap +1179 -0
- package/src/components/Tabs/Tabs.stories.mdx +20 -14
- package/src/components/Tabs/Tabs.test.tsx +21 -5
- package/src/components/Tabs/Tabs.tsx +35 -20
- package/src/components/Tabs/__snapshots__/Tabs.test.tsx.snap +195 -0
- package/src/components/Template/Template.stories.mdx +132 -48
- package/src/components/Template/Template.test.tsx +128 -6
- package/src/components/Template/Template.tsx +93 -13
- package/src/components/Template/__snapshots__/Template.test.tsx.snap +169 -0
- package/src/components/Text/Text.stories.mdx +33 -11
- package/src/components/Text/Text.tsx +2 -2
- package/src/components/TextInput/TextInput.stories.mdx +84 -17
- package/src/components/TextInput/TextInput.test.tsx +96 -0
- package/src/components/TextInput/TextInput.tsx +12 -8
- package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +240 -0
- package/src/components/Toggle/Toggle.stories.mdx +33 -9
- package/src/components/Toggle/Toggle.tsx +14 -9
- package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +4 -4
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +64 -14
- package/src/components/VideoPlayer/VideoPlayer.tsx +17 -7
- package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +12 -6
- package/src/docs/Chakra.stories.mdx +5 -8
- package/src/docs/Intro.stories.mdx +2 -2
- package/src/index.ts +13 -6
- package/src/styles/base/_03-base.scss +1 -1
- package/src/styles/base/_place-holder.scss +7 -7
- package/src/styles.scss +1 -5
- package/src/theme/components/breadcrumb.ts +4 -4
- package/src/theme/components/button.ts +5 -12
- package/src/theme/components/card.ts +5 -2
- package/src/theme/components/checkbox.ts +1 -1
- package/src/theme/components/customTable.ts +63 -0
- package/src/theme/components/datePicker.ts +1 -1
- package/src/theme/components/global.ts +7 -7
- package/src/theme/components/heading.ts +13 -11
- package/src/theme/components/helperErrorText.ts +1 -1
- package/src/theme/components/image.ts +1 -1
- package/src/theme/components/link.ts +17 -5
- package/src/theme/components/list.ts +3 -5
- package/src/theme/components/logo.ts +54 -0
- package/src/theme/components/notification.ts +19 -9
- package/src/theme/components/searchBar.ts +11 -13
- package/src/theme/components/select.ts +1 -0
- package/src/theme/components/statusBadge.ts +1 -1
- package/src/theme/components/structuredContent.ts +74 -0
- package/src/theme/components/template.ts +10 -10
- package/src/theme/components/text.ts +6 -6
- package/src/theme/components/textInput.ts +2 -0
- package/src/theme/components/toggle.ts +10 -6
- package/src/theme/components/videoPlayer.ts +0 -2
- package/src/theme/foundations/global.ts +2 -2
- package/src/theme/foundations/typography.ts +84 -12
- package/src/theme/index.ts +6 -0
- package/src/utils/componentCategories.ts +2 -1
- package/src/utils/utils.ts +17 -0
- package/dist/__tests__/utils/bem.test.d.ts +0 -1
- package/dist/components/CardEdition/CardEdition.d.ts +0 -21
- package/dist/components/CardEdition/CardEdition.stories.d.ts +0 -27
- package/dist/components/Input/Input.d.ts +0 -36
- package/dist/components/Input/Input.stories.d.ts +0 -29
- package/dist/components/Input/InputTypes.d.ts +0 -6
- package/dist/components/StyleGuide/UIDocCard.d.ts +0 -11
- package/dist/helpers/CSSVariablesHelper.d.ts +0 -3
- package/dist/helpers/getCSSVariable.d.ts +0 -1
- package/dist/interfaces.d.ts +0 -3
- package/dist/utils/bem.d.ts +0 -1
- package/src/__tests__/utils/bem.test.ts +0 -37
- package/src/components/CardEdition/CardEdition.stories.tsx +0 -122
- package/src/components/CardEdition/CardEdition.test.tsx +0 -395
- package/src/components/CardEdition/CardEdition.tsx +0 -60
- package/src/components/CardEdition/_CardEdition.scss +0 -137
- package/src/components/Input/Input.stories.tsx +0 -133
- package/src/components/Input/Input.test.tsx +0 -266
- package/src/components/Input/Input.tsx +0 -81
- package/src/components/Input/InputTypes.tsx +0 -8
- package/src/components/Input/_Input.scss +0 -78
- package/src/components/StyleGuide/UIDocCard.tsx +0 -36
- package/src/helpers/CSSVariablesHelper.tsx +0 -34
- package/src/helpers/getCSSVariable.tsx +0 -5
- package/src/interfaces.ts +0 -3
- package/src/utils/bem.ts +0 -44
|
@@ -1,25 +1,38 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Meta,
|
|
3
|
-
Story,
|
|
4
|
-
Canvas,
|
|
5
2
|
ArgsTable,
|
|
3
|
+
Canvas,
|
|
6
4
|
Description,
|
|
7
|
-
|
|
5
|
+
Meta,
|
|
6
|
+
Story,
|
|
7
|
+
} from "@storybook/addon-docs";
|
|
8
8
|
import { withDesign } from "storybook-addon-designs";
|
|
9
9
|
|
|
10
10
|
import Icon from "./Icon";
|
|
11
11
|
import {
|
|
12
12
|
IconAlign,
|
|
13
|
-
IconNames,
|
|
14
|
-
LogoNames,
|
|
15
13
|
IconColors,
|
|
16
|
-
|
|
14
|
+
IconNames,
|
|
17
15
|
IconRotationTypes,
|
|
16
|
+
IconSizes,
|
|
17
|
+
IconTypes,
|
|
18
18
|
} from "./IconTypes";
|
|
19
19
|
import iconSvgs from "./IconSvgs";
|
|
20
20
|
import List from "../List/List";
|
|
21
21
|
import { ListTypes } from "../List/ListTypes";
|
|
22
22
|
import { getCategory } from "../../utils/componentCategories";
|
|
23
|
+
import { getStorybookEnumValues } from "../../utils/utils";
|
|
24
|
+
|
|
25
|
+
export const alignEnumValues = getStorybookEnumValues(IconAlign, "IconAlign");
|
|
26
|
+
export const namesEnumValues = getStorybookEnumValues(IconNames, "IconNames");
|
|
27
|
+
export const colorsEnumValues = getStorybookEnumValues(
|
|
28
|
+
IconColors,
|
|
29
|
+
"IconColors"
|
|
30
|
+
);
|
|
31
|
+
export const sizesEnumValues = getStorybookEnumValues(IconSizes, "IconSizes");
|
|
32
|
+
export const rotationEnumValues = getStorybookEnumValues(
|
|
33
|
+
IconRotationTypes,
|
|
34
|
+
"IconRotationTypes"
|
|
35
|
+
);
|
|
23
36
|
|
|
24
37
|
<Meta
|
|
25
38
|
title={getCategory("Icon")}
|
|
@@ -28,15 +41,46 @@ import { getCategory } from "../../utils/componentCategories";
|
|
|
28
41
|
parameters={{
|
|
29
42
|
design: {
|
|
30
43
|
type: "figma",
|
|
31
|
-
url:
|
|
32
|
-
"https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Main?node-id=10734%3A3945",
|
|
44
|
+
url: "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Main?node-id=10734%3A3945",
|
|
33
45
|
},
|
|
34
46
|
jest: ["Icon.test.tsx"],
|
|
35
47
|
}}
|
|
36
48
|
argTypes={{
|
|
49
|
+
align: {
|
|
50
|
+
control: { type: "select" },
|
|
51
|
+
table: { defaultValue: { summary: "IconAlign.None" } },
|
|
52
|
+
options: alignEnumValues.options,
|
|
53
|
+
},
|
|
37
54
|
children: { table: { disable: true } },
|
|
38
|
-
className: {
|
|
39
|
-
|
|
55
|
+
className: { control: false },
|
|
56
|
+
color: {
|
|
57
|
+
control: { type: "select" },
|
|
58
|
+
table: { defaultValue: { summary: "IconColors.UiBlack" } },
|
|
59
|
+
options: colorsEnumValues.options,
|
|
60
|
+
},
|
|
61
|
+
iconRotation: {
|
|
62
|
+
control: { type: "select" },
|
|
63
|
+
table: { defaultValue: { summary: "IconRotationTypes.Rotate0" } },
|
|
64
|
+
options: rotationEnumValues.options,
|
|
65
|
+
},
|
|
66
|
+
id: { control: false },
|
|
67
|
+
name: {
|
|
68
|
+
control: { type: "select" },
|
|
69
|
+
options: namesEnumValues.options,
|
|
70
|
+
},
|
|
71
|
+
size: {
|
|
72
|
+
control: { type: "select" },
|
|
73
|
+
table: { defaultValue: { summary: "IconSizes.Medium" } },
|
|
74
|
+
options: sizesEnumValues.options,
|
|
75
|
+
},
|
|
76
|
+
title: {
|
|
77
|
+
control: false,
|
|
78
|
+
table: { defaultValue: { summary: "`${name} icon`" } },
|
|
79
|
+
},
|
|
80
|
+
type: {
|
|
81
|
+
control: false,
|
|
82
|
+
table: { defaultValue: { summary: "IconTypes.Default" } },
|
|
83
|
+
},
|
|
40
84
|
}}
|
|
41
85
|
/>
|
|
42
86
|
|
|
@@ -45,68 +89,41 @@ import { getCategory } from "../../utils/componentCategories";
|
|
|
45
89
|
| Component Version | DS Version |
|
|
46
90
|
| ----------------- | ---------- |
|
|
47
91
|
| Added | `0.0.4` |
|
|
48
|
-
| Latest | `0.25.
|
|
92
|
+
| Latest | `0.25.11` |
|
|
49
93
|
|
|
50
94
|
<Description of={Icon} />
|
|
51
95
|
|
|
52
96
|
<Canvas withToolbar>
|
|
53
97
|
<Story
|
|
54
|
-
name="Icon
|
|
98
|
+
name="Icon with Controls"
|
|
55
99
|
args={{
|
|
56
|
-
|
|
57
|
-
|
|
100
|
+
additionalStyles: undefined,
|
|
101
|
+
align: "IconAlign.None",
|
|
102
|
+
className: undefined,
|
|
103
|
+
color: "IconColors.UiBlack",
|
|
58
104
|
decorative: true,
|
|
59
|
-
iconRotation: "Rotate0",
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
control: {
|
|
66
|
-
type: "select",
|
|
67
|
-
},
|
|
68
|
-
options: Object.keys(IconAlign),
|
|
69
|
-
},
|
|
70
|
-
color: {
|
|
71
|
-
control: {
|
|
72
|
-
type: "select",
|
|
73
|
-
},
|
|
74
|
-
options: Object.keys(IconColors),
|
|
75
|
-
},
|
|
76
|
-
iconRotation: {
|
|
77
|
-
control: {
|
|
78
|
-
type: "select",
|
|
79
|
-
},
|
|
80
|
-
options: Object.keys(IconRotationTypes),
|
|
81
|
-
},
|
|
82
|
-
name: {
|
|
83
|
-
control: {
|
|
84
|
-
type: "select",
|
|
85
|
-
},
|
|
86
|
-
options: Object.keys(IconNames),
|
|
87
|
-
},
|
|
88
|
-
size: {
|
|
89
|
-
control: {
|
|
90
|
-
type: "select",
|
|
91
|
-
},
|
|
92
|
-
options: Object.keys(IconSizes),
|
|
93
|
-
},
|
|
105
|
+
iconRotation: "IconRotationTypes.Rotate0",
|
|
106
|
+
id: "icon-id",
|
|
107
|
+
name: "IconNames.Check",
|
|
108
|
+
size: "IconSizes.ExtraLarge",
|
|
109
|
+
title: undefined,
|
|
110
|
+
type: IconTypes.Default,
|
|
94
111
|
}}
|
|
95
112
|
>
|
|
96
113
|
{(args) => (
|
|
97
114
|
<Icon
|
|
98
|
-
align={
|
|
99
|
-
color={
|
|
100
|
-
iconRotation={
|
|
101
|
-
name={
|
|
102
|
-
size={
|
|
115
|
+
align={alignEnumValues.getValue(args.align)}
|
|
116
|
+
color={colorsEnumValues.getValue(args.color)}
|
|
117
|
+
iconRotation={rotationEnumValues.getValue(args.iconRotation)}
|
|
118
|
+
name={namesEnumValues.getValue(args.name)}
|
|
119
|
+
size={sizesEnumValues.getValue(args.size)}
|
|
103
120
|
title={args.title}
|
|
104
121
|
/>
|
|
105
122
|
)}
|
|
106
123
|
</Story>
|
|
107
124
|
</Canvas>
|
|
108
125
|
|
|
109
|
-
<ArgsTable story="Icon
|
|
126
|
+
<ArgsTable story="Icon with Controls" />
|
|
110
127
|
|
|
111
128
|
export const iconRow = (icon, iconType = IconNames, opts = {}) => {
|
|
112
129
|
// We'll use this setup function to render all the icons in a list item.
|
|
@@ -147,22 +164,18 @@ export const iconRow = (icon, iconType = IconNames, opts = {}) => {
|
|
|
147
164
|
);
|
|
148
165
|
};
|
|
149
166
|
export const icons = [];
|
|
150
|
-
export const logos = [];
|
|
151
167
|
export const rotations = [];
|
|
152
168
|
export const colors = [];
|
|
153
169
|
export const sizes = [];
|
|
154
170
|
for (const icon in IconNames) {
|
|
155
|
-
icons.push(iconRow(icon, IconNames));
|
|
156
|
-
}
|
|
157
|
-
for (const logo in LogoNames) {
|
|
158
|
-
logos.push(iconRow(logo, LogoNames, { iconSize: IconSizes.ExtraLarge }));
|
|
171
|
+
icons.push(iconRow(icon, IconNames, { displayValue: `IconNames.${icon}` }));
|
|
159
172
|
}
|
|
160
173
|
for (const iconRotation in IconRotationTypes) {
|
|
161
174
|
rotations.push(
|
|
162
175
|
iconRow("Arrow", IconNames, {
|
|
163
176
|
size: IconSizes.Large,
|
|
164
177
|
iconRotation: IconRotationTypes[iconRotation],
|
|
165
|
-
displayValue: iconRotation
|
|
178
|
+
displayValue: `IconRotationTypes.${iconRotation}`,
|
|
166
179
|
})
|
|
167
180
|
);
|
|
168
181
|
}
|
|
@@ -170,7 +183,7 @@ for (const iconColor in IconColors) {
|
|
|
170
183
|
colors.push(
|
|
171
184
|
iconRow("Download", IconNames, {
|
|
172
185
|
color: IconColors[iconColor],
|
|
173
|
-
displayValue: iconColor
|
|
186
|
+
displayValue: `IconColors.${iconColor}`,
|
|
174
187
|
})
|
|
175
188
|
);
|
|
176
189
|
}
|
|
@@ -178,7 +191,7 @@ for (const iconSize in IconSizes) {
|
|
|
178
191
|
sizes.push(
|
|
179
192
|
iconRow("Arrow", IconNames, {
|
|
180
193
|
size: IconSizes[iconSize],
|
|
181
|
-
displayValue: iconSize
|
|
194
|
+
displayValue: `IconSizes.${iconSize}`,
|
|
182
195
|
})
|
|
183
196
|
);
|
|
184
197
|
}
|
|
@@ -240,25 +253,13 @@ The `IconSizes` enum can be found in`src/components/Icons/IconTypes.tsx`.
|
|
|
240
253
|
|
|
241
254
|
## All Display Icons
|
|
242
255
|
|
|
243
|
-
The following icons are for generic purposes. All the available
|
|
256
|
+
The following icons are for generic purposes. All the available icon names can
|
|
244
257
|
be found in the `IconNames` enum in `src/components/Icons/IconTypes.tsx`.
|
|
245
258
|
|
|
246
259
|
<Canvas withToolbar>
|
|
247
260
|
<Story name="All Display Icons">{allIconsType(icons)}</Story>
|
|
248
261
|
</Canvas>
|
|
249
262
|
|
|
250
|
-
## All Logo Icons
|
|
251
|
-
|
|
252
|
-
_Note: this is a work in progress_
|
|
253
|
-
|
|
254
|
-
The following icons are meant to be used for logos for different libraries
|
|
255
|
-
and products. All the available logo names can
|
|
256
|
-
be found in the `LogoNames` enum in `src/components/Icons/IconTypes.tsx`.
|
|
257
|
-
|
|
258
|
-
<Canvas withToolbar>
|
|
259
|
-
<Story name="All Logo Icons">{allIconsType(logos)}</Story>
|
|
260
|
-
</Canvas>
|
|
261
|
-
|
|
262
263
|
## Custom Icons
|
|
263
264
|
|
|
264
265
|
If you'd like to pass a custom svg to your application, you can pass it a
|
|
@@ -35,7 +35,7 @@ describe("Icon", () => {
|
|
|
35
35
|
const warn = jest.spyOn(console, "warn");
|
|
36
36
|
render(<Icon />);
|
|
37
37
|
expect(warn).toHaveBeenCalledWith(
|
|
38
|
-
"Pass an icon `name` prop or an SVG child to
|
|
38
|
+
"Icon: Pass an icon `name` prop or an SVG child to ensure an icon appears."
|
|
39
39
|
);
|
|
40
40
|
});
|
|
41
41
|
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
IconRotationTypes,
|
|
10
10
|
IconSizes,
|
|
11
11
|
IconTypes,
|
|
12
|
-
LogoNames,
|
|
13
12
|
} from "./IconTypes";
|
|
14
13
|
import iconSvgs from "./IconSvgs";
|
|
15
14
|
|
|
@@ -18,7 +17,7 @@ export interface IconProps {
|
|
|
18
17
|
additionalStyles?: { [key: string]: any };
|
|
19
18
|
/** Aligns the icon. */
|
|
20
19
|
align?: IconAlign;
|
|
21
|
-
/** className that
|
|
20
|
+
/** Optional className that will be added to the parent element */
|
|
22
21
|
className?: string;
|
|
23
22
|
/** Overrides default icon color (black). */
|
|
24
23
|
color?: IconColors;
|
|
@@ -30,14 +29,14 @@ export interface IconProps {
|
|
|
30
29
|
/** ID that other components can cross reference for accessibility purposes */
|
|
31
30
|
id?: string;
|
|
32
31
|
/** The name of the icon you want to use. */
|
|
33
|
-
name?: IconNames
|
|
32
|
+
name?: IconNames;
|
|
34
33
|
/** Sets the icon size. */
|
|
35
34
|
size?: IconSizes;
|
|
36
35
|
/** For accessibility purposes, the text passed in the `title` prop gets
|
|
37
36
|
* rendered in a `title` element in the SVG. This descriptive text is not
|
|
38
37
|
* visible but is needed for screenreaders to describe the graphic. */
|
|
39
38
|
title?: string;
|
|
40
|
-
/**
|
|
39
|
+
/** FOR INTERNAL DS USE ONLY: the icon variant to display. */
|
|
41
40
|
type?: IconTypes;
|
|
42
41
|
}
|
|
43
42
|
|
|
@@ -47,7 +46,7 @@ export interface IconProps {
|
|
|
47
46
|
export default function Icon(props: React.PropsWithChildren<IconProps>) {
|
|
48
47
|
const {
|
|
49
48
|
additionalStyles = {},
|
|
50
|
-
align =
|
|
49
|
+
align = IconAlign.None,
|
|
51
50
|
children,
|
|
52
51
|
className,
|
|
53
52
|
color = IconColors.UiBlack,
|
|
@@ -83,7 +82,7 @@ export default function Icon(props: React.PropsWithChildren<IconProps>) {
|
|
|
83
82
|
return null;
|
|
84
83
|
} else if (!name && !children) {
|
|
85
84
|
console.warn(
|
|
86
|
-
"Pass an icon `name` prop or an SVG child to
|
|
85
|
+
"Icon: Pass an icon `name` prop or an SVG child to ensure an icon appears."
|
|
87
86
|
);
|
|
88
87
|
return null;
|
|
89
88
|
}
|
|
@@ -7,7 +7,6 @@ import action_help_outline from "../../../icons/svg/action_help_outline.svg";
|
|
|
7
7
|
import action_launch from "../../../icons/svg/action_launch.svg";
|
|
8
8
|
import alert_notification_important from "../../../icons/svg/alert_notification_important.svg";
|
|
9
9
|
import arrow from "../../../icons/svg/arrow.svg";
|
|
10
|
-
import brooklyn from "../../../icons/svg/brooklyn.svg";
|
|
11
10
|
import check from "../../../icons/svg/check.svg";
|
|
12
11
|
import clock from "../../../icons/svg/clock.svg";
|
|
13
12
|
import close from "../../../icons/svg/close.svg";
|
|
@@ -22,29 +21,9 @@ import download from "../../../icons/svg/download.svg";
|
|
|
22
21
|
import error_filled from "../../../icons/svg/error_filled.svg";
|
|
23
22
|
import error_outline from "../../../icons/svg/error_outline.svg";
|
|
24
23
|
import headset from "../../../icons/svg/headset.svg";
|
|
25
|
-
import logo_brooklyn from "../../../icons/svg/logo_brooklynpl.svg";
|
|
26
|
-
import logo_nypl from "../../../icons/svg/logo_nypl.svg";
|
|
27
|
-
import logo_nypl_negative from "../../../icons/svg/logo_nypl_negative.svg";
|
|
28
|
-
import logo_queens from "../../../icons/svg/logo_queenspl.svg";
|
|
29
|
-
import lpa_negative from "../../../icons/svg/lpa_negative.svg";
|
|
30
|
-
import lpa_positive from "../../../icons/svg/lpa_positive.svg";
|
|
31
24
|
import minus from "../../../icons/svg/minus.svg";
|
|
32
|
-
import nypl_circle_negative from "../../../icons/svg/nypl_circle_negative.svg";
|
|
33
|
-
import nypl_circle_positive from "../../../icons/svg/nypl_circle_positive.svg";
|
|
34
|
-
import nypl_full_lock_up_negative from "../../../icons/svg/nypl_full_lock_up_negative.svg";
|
|
35
|
-
import nypl_full_lock_up from "../../../icons/svg/nypl_full_lock_up.svg";
|
|
36
|
-
import nypl_no_lion_negative from "../../../icons/svg/nypl_no_lion_negative.svg";
|
|
37
|
-
import nypl_no_lion_positive from "../../../icons/svg/nypl_no_lion_positive.svg";
|
|
38
25
|
import plus from "../../../icons/svg/plus.svg";
|
|
39
|
-
import queens_long from "../../../icons/svg/queens_long.svg";
|
|
40
|
-
import queens_stacked from "../../../icons/svg/queens_stacked.svg";
|
|
41
|
-
import schomburg_circle from "../../../icons/svg/schomburg_circle.svg";
|
|
42
|
-
import schomburg_positive from "../../../icons/svg/schomburg_positive.svg";
|
|
43
26
|
import search from "../../../icons/svg/search.svg";
|
|
44
|
-
import simplye_black from "../../../icons/svg/simplye_black.svg";
|
|
45
|
-
import simplye_color from "../../../icons/svg/simplye_color.svg";
|
|
46
|
-
import snfl_negative from "../../../icons/svg/snfl_negative.svg";
|
|
47
|
-
import snfl_positive from "../../../icons/svg/snfl_positive.svg";
|
|
48
27
|
import speaker_notes from "../../../icons/svg/speaker_notes.svg";
|
|
49
28
|
import utility_account_filled from "../../../icons/svg/utility_account_filled.svg";
|
|
50
29
|
import utility_account_unfilled from "../../../icons/svg/utility_account_unfilled.svg";
|
|
@@ -60,7 +39,6 @@ export default {
|
|
|
60
39
|
action_launch,
|
|
61
40
|
alert_notification_important,
|
|
62
41
|
arrow,
|
|
63
|
-
brooklyn,
|
|
64
42
|
check,
|
|
65
43
|
clock,
|
|
66
44
|
close,
|
|
@@ -75,29 +53,9 @@ export default {
|
|
|
75
53
|
file_type_spreadsheet,
|
|
76
54
|
file_type_video,
|
|
77
55
|
headset,
|
|
78
|
-
logo_brooklyn,
|
|
79
|
-
logo_nypl,
|
|
80
|
-
logo_nypl_negative,
|
|
81
|
-
logo_queens,
|
|
82
|
-
lpa_negative,
|
|
83
|
-
lpa_positive,
|
|
84
56
|
minus,
|
|
85
|
-
nypl_circle_negative,
|
|
86
|
-
nypl_circle_positive,
|
|
87
|
-
nypl_full_lock_up_negative,
|
|
88
|
-
nypl_full_lock_up,
|
|
89
|
-
nypl_no_lion_negative,
|
|
90
|
-
nypl_no_lion_positive,
|
|
91
57
|
plus,
|
|
92
|
-
queens_long,
|
|
93
|
-
queens_stacked,
|
|
94
|
-
schomburg_circle,
|
|
95
|
-
schomburg_positive,
|
|
96
58
|
search,
|
|
97
|
-
simplye_black,
|
|
98
|
-
simplye_color,
|
|
99
|
-
snfl_negative,
|
|
100
|
-
snfl_positive,
|
|
101
59
|
speaker_notes,
|
|
102
60
|
utility_account_filled,
|
|
103
61
|
utility_account_unfilled,
|
|
@@ -78,27 +78,3 @@ export enum IconNames {
|
|
|
78
78
|
UtilityHamburger = "utility_hamburger",
|
|
79
79
|
UtilitySearch = "utility_search",
|
|
80
80
|
}
|
|
81
|
-
|
|
82
|
-
export enum LogoNames {
|
|
83
|
-
Brooklyn = "brooklyn",
|
|
84
|
-
LogoBrooklyn = "logo_brooklyn",
|
|
85
|
-
LogoNypl = "logo_nypl",
|
|
86
|
-
LogoNyplNegative = "logo_nypl_negative",
|
|
87
|
-
LogoQueens = "logo_queens",
|
|
88
|
-
LpaNegative = "lpa_negative",
|
|
89
|
-
LpaPositive = "lpa_positive",
|
|
90
|
-
NyplCircleNegative = "nypl_circle_negative",
|
|
91
|
-
NyplCirclePositive = "nypl_circle_positive",
|
|
92
|
-
NyplFullLockUpNegative = "nypl_full_lock_up_negative",
|
|
93
|
-
NyplFullLockUp = "nypl_full_lock_up",
|
|
94
|
-
NyplNoLionNegative = "nypl_no_lion_negative",
|
|
95
|
-
NyplNoLionPositive = "nypl_no_lion_positive",
|
|
96
|
-
QueensLong = "queens_long",
|
|
97
|
-
QueensStacked = "queens_stacked",
|
|
98
|
-
SchomburgCircle = "schomburg_circle",
|
|
99
|
-
SchomburgPositive = "schomburg_positive",
|
|
100
|
-
SimplyeBlack = "simplye_black",
|
|
101
|
-
SimplyeColor = "simplye_color",
|
|
102
|
-
SnflNegative = "snfl_negative",
|
|
103
|
-
SnflPositive = "snfl_positive",
|
|
104
|
-
}
|
|
@@ -1,18 +1,26 @@
|
|
|
1
|
+
import { VStack } from "@chakra-ui/react";
|
|
1
2
|
import {
|
|
2
|
-
Meta,
|
|
3
|
-
Story,
|
|
4
|
-
Canvas,
|
|
5
3
|
ArgsTable,
|
|
4
|
+
Canvas,
|
|
6
5
|
Description,
|
|
7
|
-
|
|
6
|
+
Meta,
|
|
7
|
+
Story,
|
|
8
|
+
} from "@storybook/addon-docs";
|
|
8
9
|
import { withDesign } from "storybook-addon-designs";
|
|
9
|
-
import { VStack } from "@chakra-ui/react";
|
|
10
10
|
|
|
11
|
+
import Heading from "../Heading/Heading";
|
|
11
12
|
import Image from "./Image";
|
|
12
13
|
import { ImageRatios, ImageSizes, ImageTypes } from "./ImageTypes";
|
|
13
|
-
import Heading from "../Heading/Heading";
|
|
14
14
|
import SimpleGrid from "../Grid/SimpleGrid";
|
|
15
15
|
import { getCategory } from "../../utils/componentCategories";
|
|
16
|
+
import { getStorybookEnumValues } from "../../utils/utils";
|
|
17
|
+
|
|
18
|
+
export const ratiosEnumValues = getStorybookEnumValues(
|
|
19
|
+
ImageRatios,
|
|
20
|
+
"ImageRatios"
|
|
21
|
+
);
|
|
22
|
+
export const sizesEnumValues = getStorybookEnumValues(ImageSizes, "ImageSizes");
|
|
23
|
+
export const typesEnumValues = getStorybookEnumValues(ImageTypes, "ImageTypes");
|
|
16
24
|
|
|
17
25
|
export const imageBlockStyles = {
|
|
18
26
|
margin: "auto",
|
|
@@ -28,15 +36,43 @@ export const imageBlockStyles = {
|
|
|
28
36
|
parameters={{
|
|
29
37
|
design: {
|
|
30
38
|
type: "figma",
|
|
31
|
-
url:
|
|
32
|
-
"https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Master?node-id=11896%3A45379",
|
|
39
|
+
url: "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Master?node-id=11896%3A45379",
|
|
33
40
|
},
|
|
34
41
|
jest: ["Image.test.tsx"],
|
|
35
42
|
}}
|
|
36
43
|
argTypes={{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
additionalFigureStyles: { control: false },
|
|
45
|
+
additionalImageStyles: { control: false },
|
|
46
|
+
additionalWrapperStyles: { control: false },
|
|
47
|
+
alt: {
|
|
48
|
+
control: false,
|
|
49
|
+
description:
|
|
50
|
+
"Alternate text description of the image. Needed for accessibility purposes.",
|
|
51
|
+
},
|
|
52
|
+
className: {
|
|
53
|
+
control: false,
|
|
54
|
+
description: "Additional class name for the component to use.",
|
|
55
|
+
},
|
|
56
|
+
component: { control: false },
|
|
57
|
+
imageAspectRatio: {
|
|
58
|
+
control: { type: "select" },
|
|
59
|
+
table: { defaultValue: { summary: "ImageRatios.Original" } },
|
|
60
|
+
options: ratiosEnumValues.options,
|
|
61
|
+
},
|
|
62
|
+
imageSize: {
|
|
63
|
+
control: { type: "select" },
|
|
64
|
+
table: { defaultValue: { summary: "ImageSizes.Default" } },
|
|
65
|
+
options: sizesEnumValues.options,
|
|
66
|
+
},
|
|
67
|
+
imageType: {
|
|
68
|
+
control: { type: "select" },
|
|
69
|
+
table: { defaultValue: { summary: "ImageTypes.Default" } },
|
|
70
|
+
options: typesEnumValues.options,
|
|
71
|
+
},
|
|
72
|
+
src: {
|
|
73
|
+
description:
|
|
74
|
+
"The src attribute is required, and contains the path to the image you want to embed.",
|
|
75
|
+
},
|
|
40
76
|
}}
|
|
41
77
|
/>
|
|
42
78
|
|
|
@@ -45,7 +81,7 @@ export const imageBlockStyles = {
|
|
|
45
81
|
| Component Version | DS Version |
|
|
46
82
|
| ----------------- | ---------- |
|
|
47
83
|
| Added | `0.0.6` |
|
|
48
|
-
| Latest | `0.25.
|
|
84
|
+
| Latest | `0.25.9` |
|
|
49
85
|
|
|
50
86
|
<Description of={Image} />
|
|
51
87
|
|
|
@@ -56,22 +92,34 @@ export const imageBlockStyles = {
|
|
|
56
92
|
|
|
57
93
|
<Canvas>
|
|
58
94
|
<Story
|
|
59
|
-
name="Image
|
|
95
|
+
name="Image with Controls"
|
|
60
96
|
args={{
|
|
97
|
+
additionalFigureStyles: undefined,
|
|
98
|
+
additionalImageStyles: undefined,
|
|
99
|
+
additionalWrapperStyles: undefined,
|
|
61
100
|
alt: "Alt text",
|
|
62
|
-
|
|
101
|
+
className: undefined,
|
|
102
|
+
component: undefined,
|
|
103
|
+
imageAspectRatio: "ImageRatios.TwoByOne",
|
|
63
104
|
imageCaption: "Image caption",
|
|
64
105
|
imageCredit: "Image credit",
|
|
65
|
-
imageSize: ImageSizes.Medium,
|
|
66
|
-
imageType: ImageTypes.Default,
|
|
106
|
+
imageSize: "ImageSizes.Medium",
|
|
107
|
+
imageType: "ImageTypes.Default",
|
|
67
108
|
src: "https://placeimg.com/400/300/animals",
|
|
68
109
|
}}
|
|
69
110
|
>
|
|
70
|
-
{(args) =>
|
|
111
|
+
{(args) => (
|
|
112
|
+
<Image
|
|
113
|
+
{...args}
|
|
114
|
+
imageAspectRatio={ratiosEnumValues.getValue(args.imageAspectRatio)}
|
|
115
|
+
imageSize={sizesEnumValues.getValue(args.imageSize)}
|
|
116
|
+
imageType={typesEnumValues.getValue(args.imageType)}
|
|
117
|
+
/>
|
|
118
|
+
)}
|
|
71
119
|
</Story>
|
|
72
120
|
</Canvas>
|
|
73
121
|
|
|
74
|
-
<ArgsTable story="Image
|
|
122
|
+
<ArgsTable story="Image with Controls" />
|
|
75
123
|
|
|
76
124
|
## Image Figure
|
|
77
125
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
import { Box, useMultiStyleConfig } from "@chakra-ui/react";
|
|
2
|
+
import * as React from "react";
|
|
3
3
|
|
|
4
4
|
import { ImageRatios, ImageSizes, ImageTypes } from "./ImageTypes";
|
|
5
5
|
|
|
6
6
|
interface ImageWrapperProps {
|
|
7
7
|
/** Optionally pass in additional Chakra-based styles. */
|
|
8
|
-
|
|
8
|
+
additionalWrapperStyles?: { [key: string]: any };
|
|
9
9
|
/** ClassName you can add in addition to 'image' */
|
|
10
10
|
className?: string;
|
|
11
11
|
/** Optional value to control the aspect ratio of the cartd image; default value is `square` */
|
|
@@ -15,6 +15,10 @@ interface ImageWrapperProps {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export interface ImageProps extends ImageWrapperProps {
|
|
18
|
+
/** Optionally pass in additional Chakra-based styles only for the figure. */
|
|
19
|
+
additionalFigureStyles?: { [key: string]: any };
|
|
20
|
+
/** Optionally pass in additional Chakra-based styles only for the image. */
|
|
21
|
+
additionalImageStyles?: { [key: string]: any };
|
|
18
22
|
/** Alternate text description of the image */
|
|
19
23
|
alt: string;
|
|
20
24
|
/** Custom image component */
|
|
@@ -33,7 +37,7 @@ export interface ImageProps extends ImageWrapperProps {
|
|
|
33
37
|
|
|
34
38
|
function ImageWrapper(props: React.PropsWithChildren<ImageWrapperProps>) {
|
|
35
39
|
const {
|
|
36
|
-
|
|
40
|
+
additionalWrapperStyles = {},
|
|
37
41
|
className = "",
|
|
38
42
|
children,
|
|
39
43
|
imageAspectRatio = ImageRatios.Original,
|
|
@@ -45,19 +49,21 @@ function ImageWrapper(props: React.PropsWithChildren<ImageWrapperProps>) {
|
|
|
45
49
|
});
|
|
46
50
|
return (
|
|
47
51
|
<Box
|
|
48
|
-
__css={{ ...styles, ...additionalStyles }}
|
|
49
52
|
className={`the-wrap ${className}`}
|
|
53
|
+
__css={{ ...styles, ...additionalWrapperStyles }}
|
|
50
54
|
>
|
|
51
|
-
<Box __css={styles.crop}
|
|
55
|
+
<Box className="the-crop" __css={styles.crop}>
|
|
52
56
|
{children}
|
|
53
57
|
</Box>
|
|
54
58
|
</Box>
|
|
55
59
|
);
|
|
56
60
|
}
|
|
57
61
|
|
|
58
|
-
export default function Image(props:
|
|
62
|
+
export default function Image(props: ImageProps) {
|
|
59
63
|
const {
|
|
60
|
-
|
|
64
|
+
additionalFigureStyles = {},
|
|
65
|
+
additionalImageStyles = {},
|
|
66
|
+
additionalWrapperStyles = {},
|
|
61
67
|
alt,
|
|
62
68
|
className = "",
|
|
63
69
|
component,
|
|
@@ -81,14 +87,19 @@ export default function Image(props: React.ComponentProps<"img"> & ImageProps) {
|
|
|
81
87
|
const imageComponent: JSX.Element = component ? (
|
|
82
88
|
component
|
|
83
89
|
) : (
|
|
84
|
-
<Box
|
|
90
|
+
<Box
|
|
91
|
+
as="img"
|
|
92
|
+
src={src}
|
|
93
|
+
alt={alt}
|
|
94
|
+
__css={{ ...styles.img, ...additionalImageStyles }}
|
|
95
|
+
/>
|
|
85
96
|
);
|
|
86
97
|
const finalImage = useImageWrapper ? (
|
|
87
98
|
<ImageWrapper
|
|
88
99
|
className={className}
|
|
89
100
|
imageAspectRatio={imageAspectRatio}
|
|
90
101
|
imageSize={imageSize}
|
|
91
|
-
|
|
102
|
+
additionalWrapperStyles={additionalWrapperStyles}
|
|
92
103
|
>
|
|
93
104
|
{imageComponent}
|
|
94
105
|
</ImageWrapper>
|
|
@@ -97,7 +108,7 @@ export default function Image(props: React.ComponentProps<"img"> & ImageProps) {
|
|
|
97
108
|
);
|
|
98
109
|
|
|
99
110
|
return imageCaption || imageCredit ? (
|
|
100
|
-
<Box as="figure" __css={styles.figure}>
|
|
111
|
+
<Box as="figure" __css={{ ...styles.figure, ...additionalFigureStyles }}>
|
|
101
112
|
{finalImage}
|
|
102
113
|
<Box as="figcaption" __css={styles.figcaption}>
|
|
103
114
|
{imageCaption && (
|