@nypl/design-system-react-components 0.25.12 → 0.25.13
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 +63 -1
- package/dist/components/Accordion/Accordion.d.ts +5 -3
- package/dist/components/Accordion/AccordionTypes.d.ts +5 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +3 -3
- package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +1 -1
- package/dist/components/Card/Card.d.ts +11 -20
- package/dist/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +4 -2
- package/dist/components/Heading/Heading.d.ts +4 -4
- package/dist/components/Heading/HeadingTypes.d.ts +1 -1
- package/dist/components/Hero/Hero.d.ts +7 -4
- package/dist/components/Icons/IconTypes.d.ts +1 -0
- package/dist/components/Image/Image.d.ts +25 -7
- package/dist/components/Image/ImageTypes.d.ts +4 -4
- package/dist/components/Logo/LogoTypes.d.ts +2 -2
- package/dist/components/Notification/Notification.d.ts +4 -4
- package/dist/components/Radio/Radio.d.ts +1 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +4 -2
- package/dist/components/Select/Select.d.ts +2 -2
- package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -3
- package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +0 -4
- package/dist/components/StructuredContent/StructuredContent.d.ts +9 -22
- package/dist/components/Tabs/Tabs.d.ts +3 -3
- package/dist/components/Template/Template.d.ts +13 -5
- package/dist/components/Text/Text.d.ts +3 -3
- package/dist/components/Text/TextTypes.d.ts +1 -1
- package/dist/components/TextInput/TextInput.d.ts +2 -2
- package/dist/components/Toggle/Toggle.d.ts +6 -7
- package/dist/components/Toggle/{ToggleSizes.d.ts → ToggleTypes.d.ts} +1 -1
- package/dist/design-system-react-components.cjs.development.js +505 -422
- 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 +514 -435
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/helpers/enums.d.ts +4 -0
- package/dist/index.d.ts +7 -8
- package/dist/theme/components/accordion.d.ts +7 -12
- package/dist/theme/components/breadcrumb.d.ts +3 -0
- package/dist/theme/components/card.d.ts +4 -4
- package/dist/theme/components/checkbox.d.ts +1 -0
- package/dist/theme/components/checkboxGroup.d.ts +3 -1
- package/dist/theme/components/global.d.ts +2 -1
- package/dist/theme/components/hero.d.ts +1 -1
- package/dist/theme/components/image.d.ts +1 -1
- package/dist/theme/components/notification.d.ts +4 -4
- package/dist/theme/components/pagination.d.ts +2 -5
- package/dist/theme/components/radio.d.ts +1 -0
- package/dist/theme/components/radioGroup.d.ts +3 -1
- package/dist/theme/components/select.d.ts +3 -0
- package/dist/theme/components/toggle.d.ts +13 -1
- package/package.json +1 -1
- package/src/components/AccessibilityGuide/SkipNavigation.stories.mdx +34 -0
- package/src/components/Accordion/Accordion.stories.mdx +150 -66
- package/src/components/Accordion/Accordion.test.tsx +44 -17
- package/src/components/Accordion/Accordion.tsx +50 -20
- package/src/components/Accordion/AccordionTypes.tsx +5 -0
- package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +244 -2
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +17 -15
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +6 -6
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +6 -6
- package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +1 -1
- package/src/components/Card/Card.stories.mdx +236 -165
- package/src/components/Card/Card.test.tsx +36 -18
- package/src/components/Card/Card.tsx +84 -59
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +25 -65
- package/src/components/Chakra/Center.stories.mdx +2 -2
- package/src/components/Checkbox/Checkbox.stories.mdx +13 -1
- package/src/components/Checkbox/Checkbox.test.tsx +58 -2
- package/src/components/Checkbox/Checkbox.tsx +6 -1
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +76 -0
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +73 -9
- package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +79 -9
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +10 -7
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +169 -0
- package/src/components/ComponentWrapper/ComponentWrapper.tsx +1 -1
- package/src/components/DatePicker/DatePicker.test.tsx +5 -2
- package/src/components/DatePicker/DatePicker.tsx +5 -2
- package/src/components/Form/Form.stories.mdx +47 -9
- package/src/components/Form/Form.test.tsx +1 -1
- package/src/components/Form/Form.tsx +3 -1
- package/src/components/Grid/SimpleGrid.stories.mdx +53 -35
- package/src/components/Grid/SimpleGrid.test.tsx +15 -9
- package/src/components/Heading/Heading.stories.mdx +21 -23
- package/src/components/Heading/Heading.test.tsx +7 -7
- package/src/components/Heading/Heading.tsx +10 -14
- package/src/components/Heading/HeadingTypes.tsx +1 -1
- package/src/components/Heading/__snapshots__/Heading.test.tsx.snap +1 -1
- package/src/components/Hero/Hero.stories.mdx +27 -27
- package/src/components/Hero/Hero.test.tsx +113 -58
- package/src/components/Hero/Hero.tsx +43 -20
- package/src/components/HorizontalRule/HorizontalRule.test.tsx +6 -4
- package/src/components/HorizontalRule/HorizontalRule.tsx +3 -2
- package/src/components/Icons/Icon.stories.mdx +50 -18
- package/src/components/Icons/Icon.test.tsx +13 -2
- package/src/components/Icons/Icon.tsx +11 -6
- package/src/components/Icons/IconTypes.tsx +1 -0
- package/src/components/Image/Image.stories.mdx +133 -68
- package/src/components/Image/Image.test.tsx +32 -48
- package/src/components/Image/Image.tsx +46 -26
- package/src/components/Image/ImageTypes.ts +4 -4
- package/src/components/Image/__snapshots__/Image.test.tsx.snap +60 -13
- package/src/components/Link/Link.tsx +8 -1
- package/src/components/List/List.stories.mdx +1 -1
- package/src/components/List/List.test.tsx +7 -4
- package/src/components/List/List.tsx +7 -4
- package/src/components/Logo/Logo.stories.mdx +13 -13
- package/src/components/Logo/Logo.test.tsx +12 -2
- package/src/components/Logo/Logo.tsx +10 -5
- package/src/components/Logo/LogoTypes.tsx +1 -1
- package/src/components/Notification/Notification.stories.mdx +5 -5
- package/src/components/Notification/Notification.tsx +10 -10
- package/src/components/Pagination/Pagination.stories.mdx +4 -3
- package/src/components/Pagination/Pagination.test.tsx +30 -2
- package/src/components/Pagination/Pagination.tsx +6 -3
- package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +1 -1
- package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +6 -2
- package/src/components/ProgressIndicator/ProgressIndicator.tsx +3 -1
- package/src/components/Radio/Radio.stories.mdx +13 -1
- package/src/components/Radio/Radio.test.tsx +56 -2
- package/src/components/Radio/Radio.tsx +6 -1
- package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +61 -0
- package/src/components/RadioGroup/RadioGroup.stories.mdx +73 -9
- package/src/components/RadioGroup/RadioGroup.test.tsx +72 -7
- package/src/components/RadioGroup/RadioGroup.tsx +10 -7
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +140 -0
- package/src/components/SearchBar/SearchBar.stories.mdx +1 -1
- package/src/components/SearchBar/SearchBar.tsx +3 -3
- package/src/components/Select/Select.stories.mdx +26 -16
- package/src/components/Select/Select.test.tsx +1 -36
- package/src/components/Select/Select.tsx +4 -16
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +12 -14
- package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +6 -8
- package/src/components/SkeletonLoader/SkeletonLoader.tsx +5 -7
- package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +0 -5
- package/src/components/Slider/Slider.stories.mdx +41 -8
- package/src/components/Slider/Slider.tsx +4 -4
- package/src/components/StatusBadge/StatusBadge.test.tsx +3 -1
- package/src/components/StatusBadge/StatusBadge.tsx +1 -1
- package/src/components/StructuredContent/StructuredContent.stories.mdx +103 -54
- package/src/components/StructuredContent/StructuredContent.test.tsx +129 -102
- package/src/components/StructuredContent/StructuredContent.tsx +43 -53
- package/src/components/StyleGuide/ColorCard.tsx +3 -3
- package/src/components/StyleGuide/Typography.stories.mdx +17 -12
- package/src/components/Table/Table.test.tsx +1 -1
- package/src/components/Table/Table.tsx +3 -1
- package/src/components/Tabs/Tabs.stories.mdx +8 -8
- package/src/components/Tabs/Tabs.test.tsx +13 -11
- package/src/components/Tabs/Tabs.tsx +18 -15
- package/src/components/Template/Template.stories.mdx +62 -25
- package/src/components/Template/Template.test.tsx +35 -5
- package/src/components/Template/Template.tsx +26 -13
- package/src/components/Template/__snapshots__/Template.test.tsx.snap +4 -2
- package/src/components/Text/Text.stories.mdx +13 -15
- package/src/components/Text/Text.test.tsx +6 -15
- package/src/components/Text/Text.tsx +7 -12
- package/src/components/Text/TextTypes.tsx +1 -1
- package/src/components/TextInput/TextInput.stories.mdx +9 -9
- package/src/components/TextInput/TextInput.test.tsx +28 -27
- package/src/components/TextInput/TextInput.tsx +4 -4
- package/src/components/Toggle/Toggle.stories.mdx +12 -22
- package/src/components/Toggle/Toggle.test.tsx +15 -2
- package/src/components/Toggle/Toggle.tsx +8 -9
- package/src/components/Toggle/{ToggleSizes.tsx → ToggleTypes.tsx} +1 -1
- package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +64 -0
- package/src/components/VideoPlayer/VideoPlayer.test.tsx +18 -6
- package/src/components/VideoPlayer/VideoPlayer.tsx +14 -7
- package/src/docs/{Intro.stories.mdx → Welcome.stories.mdx} +5 -9
- package/src/{components/Card/CardTypes.tsx → helpers/enums.ts} +2 -2
- package/src/hooks/tests/useNYPLTheme.test.tsx +1 -1
- package/src/hooks/useCarouselStyles.stories.mdx +10 -0
- package/src/hooks/useNYPLTheme.ts +1 -1
- package/src/index.ts +7 -14
- package/src/theme/components/accordion.ts +7 -12
- package/src/theme/components/breadcrumb.ts +3 -0
- package/src/theme/components/card.ts +29 -20
- package/src/theme/components/checkboxGroup.ts +3 -1
- package/src/theme/components/global.ts +4 -3
- package/src/theme/components/hero.ts +1 -1
- package/src/theme/components/icon.ts +5 -2
- package/src/theme/components/image.ts +1 -1
- package/src/theme/components/list.ts +1 -1
- package/src/theme/components/notification.ts +5 -5
- package/src/theme/components/pagination.ts +2 -5
- package/src/theme/components/progressIndicator.ts +3 -3
- package/src/theme/components/radioGroup.ts +3 -1
- package/src/theme/components/select.ts +6 -0
- package/src/theme/components/toggle.ts +26 -3
- package/src/utils/componentCategories.ts +27 -19
- package/dist/components/Card/CardTypes.d.ts +0 -4
- package/dist/components/CheckboxGroup/CheckboxGroupLayoutTypes.d.ts +0 -4
- package/dist/components/RadioGroup/RadioGroupLayoutTypes.d.ts +0 -4
- package/src/components/CheckboxGroup/CheckboxGroupLayoutTypes.tsx +0 -4
- package/src/components/RadioGroup/RadioGroupLayoutTypes.tsx +0 -4
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import { withDesign } from "storybook-addon-designs";
|
|
10
10
|
|
|
11
11
|
import Heading from "../Heading/Heading";
|
|
12
|
+
import { HeadingLevels } from "../Heading/HeadingTypes";
|
|
12
13
|
import Image from "./Image";
|
|
13
14
|
import { ImageRatios, ImageSizes, ImageTypes } from "./ImageTypes";
|
|
14
15
|
import SimpleGrid from "../Grid/SimpleGrid";
|
|
@@ -49,26 +50,26 @@ export const imageBlockStyles = {
|
|
|
49
50
|
description:
|
|
50
51
|
"Alternate text description of the image. Needed for accessibility purposes.",
|
|
51
52
|
},
|
|
53
|
+
aspectRatio: {
|
|
54
|
+
control: { type: "select" },
|
|
55
|
+
table: { defaultValue: { summary: "ImageRatios.Original" } },
|
|
56
|
+
options: ratiosEnumValues.options,
|
|
57
|
+
},
|
|
52
58
|
className: {
|
|
53
59
|
control: false,
|
|
54
60
|
description: "Additional class name for the component to use.",
|
|
55
61
|
},
|
|
56
62
|
component: { control: false },
|
|
57
|
-
|
|
63
|
+
imageType: {
|
|
58
64
|
control: { type: "select" },
|
|
59
|
-
table: { defaultValue: { summary: "
|
|
60
|
-
options:
|
|
65
|
+
table: { defaultValue: { summary: "ImageTypes.Default" } },
|
|
66
|
+
options: typesEnumValues.options,
|
|
61
67
|
},
|
|
62
|
-
|
|
68
|
+
size: {
|
|
63
69
|
control: { type: "select" },
|
|
64
70
|
table: { defaultValue: { summary: "ImageSizes.Default" } },
|
|
65
71
|
options: sizesEnumValues.options,
|
|
66
72
|
},
|
|
67
|
-
imageType: {
|
|
68
|
-
control: { type: "select" },
|
|
69
|
-
table: { defaultValue: { summary: "ImageTypes.Default" } },
|
|
70
|
-
options: typesEnumValues.options,
|
|
71
|
-
},
|
|
72
73
|
src: {
|
|
73
74
|
description:
|
|
74
75
|
"The src attribute is required, and contains the path to the image you want to embed.",
|
|
@@ -81,13 +82,13 @@ export const imageBlockStyles = {
|
|
|
81
82
|
| Component Version | DS Version |
|
|
82
83
|
| ----------------- | ---------- |
|
|
83
84
|
| Added | `0.0.6` |
|
|
84
|
-
| Latest | `0.25.
|
|
85
|
+
| Latest | `0.25.13` |
|
|
85
86
|
|
|
86
87
|
<Description of={Image} />
|
|
87
88
|
|
|
88
89
|
<p>
|
|
89
90
|
If you want a simple HTML `img` element then don't pass in values for the
|
|
90
|
-
`
|
|
91
|
+
`aspectRatio` or `size` props.
|
|
91
92
|
</p>
|
|
92
93
|
|
|
93
94
|
<Canvas>
|
|
@@ -98,22 +99,22 @@ export const imageBlockStyles = {
|
|
|
98
99
|
additionalImageStyles: undefined,
|
|
99
100
|
additionalWrapperStyles: undefined,
|
|
100
101
|
alt: "Alt text",
|
|
102
|
+
aspectRatio: "ImageRatios.TwoByOne",
|
|
103
|
+
caption: "Image caption",
|
|
101
104
|
className: undefined,
|
|
102
105
|
component: undefined,
|
|
103
|
-
|
|
104
|
-
imageCaption: "Image caption",
|
|
105
|
-
imageCredit: "Image credit",
|
|
106
|
-
imageSize: "ImageSizes.Medium",
|
|
106
|
+
credit: "Image credit",
|
|
107
107
|
imageType: "ImageTypes.Default",
|
|
108
|
+
size: "ImageSizes.Medium",
|
|
108
109
|
src: "https://placeimg.com/400/300/animals",
|
|
109
110
|
}}
|
|
110
111
|
>
|
|
111
112
|
{(args) => (
|
|
112
113
|
<Image
|
|
113
114
|
{...args}
|
|
114
|
-
|
|
115
|
-
imageSize={sizesEnumValues.getValue(args.imageSize)}
|
|
115
|
+
aspectRatio={ratiosEnumValues.getValue(args.aspectRatio)}
|
|
116
116
|
imageType={typesEnumValues.getValue(args.imageType)}
|
|
117
|
+
size={sizesEnumValues.getValue(args.size)}
|
|
117
118
|
/>
|
|
118
119
|
)}
|
|
119
120
|
</Story>
|
|
@@ -123,9 +124,9 @@ export const imageBlockStyles = {
|
|
|
123
124
|
|
|
124
125
|
## Image Figure
|
|
125
126
|
|
|
126
|
-
By passing in `
|
|
127
|
+
By passing in `credit` or `caption`, the `Image` component will
|
|
127
128
|
render an HTML `figure` element and render an `img` element inside with the
|
|
128
|
-
proper props. If no `
|
|
129
|
+
proper props. If no `credit` or `caption` prop values are passed,
|
|
129
130
|
then an `img` element will be rendered with or without wrapper style divs.
|
|
130
131
|
|
|
131
132
|
<Canvas>
|
|
@@ -133,19 +134,19 @@ then an `img` element will be rendered with or without wrapper style divs.
|
|
|
133
134
|
name="Figure and figcaption"
|
|
134
135
|
args={{
|
|
135
136
|
alt: "Alt text",
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
imageSize: ImageSizes.Medium,
|
|
137
|
+
aspectRatio: ImageRatios.ThreeByTwo,
|
|
138
|
+
caption: "Image caption",
|
|
139
|
+
credit: "Image credit",
|
|
140
140
|
imageType: ImageTypes.Default,
|
|
141
|
+
size: ImageSizes.Medium,
|
|
141
142
|
src: "https://placeimg.com/400/300/animals",
|
|
142
143
|
}}
|
|
143
144
|
argTypes={{
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
imageSize: { table: { disable: true } },
|
|
145
|
+
aspectRatio: { table: { disable: true } },
|
|
146
|
+
caption: { table: { disable: true } },
|
|
147
|
+
credit: { table: { disable: true } },
|
|
148
148
|
imageType: { table: { disable: true } },
|
|
149
|
+
size: { table: { disable: true } },
|
|
149
150
|
src: { table: { disable: true } },
|
|
150
151
|
}}
|
|
151
152
|
>
|
|
@@ -155,61 +156,85 @@ then an `img` element will be rendered with or without wrapper style divs.
|
|
|
155
156
|
|
|
156
157
|
## Image Sizes
|
|
157
158
|
|
|
158
|
-
Use the `
|
|
159
|
+
Use the `size` prop to set the desired size with the `ImageSizes` enum.
|
|
159
160
|
|
|
160
161
|
<Canvas>
|
|
161
162
|
<Story name="Image Sizes">
|
|
162
163
|
<SimpleGrid columns={1}>
|
|
163
164
|
<div style={{ textAlign: "center" }}>
|
|
164
|
-
<Heading
|
|
165
|
+
<Heading
|
|
166
|
+
id="ExtraExtraSmall"
|
|
167
|
+
level={HeadingLevels.Four}
|
|
168
|
+
text="ImageSizes.ExtraExtraSmall"
|
|
169
|
+
/>
|
|
165
170
|
<Image
|
|
166
171
|
alt="Alt text"
|
|
167
|
-
|
|
168
|
-
|
|
172
|
+
caption="64px"
|
|
173
|
+
size={ImageSizes.ExtraExtraSmall}
|
|
169
174
|
src="https://placeimg.com/400/300/animals"
|
|
170
175
|
/>
|
|
171
176
|
</div>
|
|
172
177
|
<div style={{ textAlign: "center" }}>
|
|
173
|
-
<Heading
|
|
178
|
+
<Heading
|
|
179
|
+
id="ExtraSmall"
|
|
180
|
+
level={HeadingLevels.Four}
|
|
181
|
+
text="ImageSizes.ExtraSmall"
|
|
182
|
+
/>
|
|
174
183
|
<Image
|
|
175
184
|
alt="Alt text"
|
|
176
|
-
|
|
177
|
-
|
|
185
|
+
caption="96px"
|
|
186
|
+
size={ImageSizes.ExtraSmall}
|
|
178
187
|
src="https://placeimg.com/400/300/animals"
|
|
179
188
|
/>
|
|
180
189
|
</div>
|
|
181
190
|
<div style={{ textAlign: "center" }}>
|
|
182
|
-
<Heading
|
|
191
|
+
<Heading
|
|
192
|
+
id="Small"
|
|
193
|
+
level={HeadingLevels.Four}
|
|
194
|
+
text="ImageSizes.Small"
|
|
195
|
+
/>
|
|
183
196
|
<Image
|
|
184
197
|
alt="Alt text"
|
|
185
|
-
|
|
186
|
-
|
|
198
|
+
caption="165px"
|
|
199
|
+
size={ImageSizes.Small}
|
|
187
200
|
src="https://placeimg.com/400/300/animals"
|
|
188
201
|
/>
|
|
189
202
|
</div>
|
|
190
203
|
<div style={{ textAlign: "center" }}>
|
|
191
|
-
<Heading
|
|
204
|
+
<Heading
|
|
205
|
+
id="Medium"
|
|
206
|
+
level={HeadingLevels.Four}
|
|
207
|
+
text="ImageSizes.Medium"
|
|
208
|
+
/>
|
|
192
209
|
<Image
|
|
193
210
|
alt="Alt text"
|
|
194
|
-
|
|
195
|
-
|
|
211
|
+
caption="225px"
|
|
212
|
+
size={ImageSizes.Medium}
|
|
196
213
|
src="https://placeimg.com/400/300/animals"
|
|
197
214
|
/>
|
|
198
215
|
</div>
|
|
199
216
|
<div style={{ textAlign: "center" }}>
|
|
200
|
-
<Heading
|
|
217
|
+
<Heading
|
|
218
|
+
id="Large"
|
|
219
|
+
level={HeadingLevels.Four}
|
|
220
|
+
text="ImageSizes.Large"
|
|
221
|
+
/>
|
|
201
222
|
<Image
|
|
202
223
|
alt="Alt text"
|
|
203
|
-
|
|
204
|
-
|
|
224
|
+
caption="360px"
|
|
225
|
+
size={ImageSizes.Large}
|
|
205
226
|
src="https://placeimg.com/400/300/animals"
|
|
206
227
|
/>
|
|
207
228
|
</div>
|
|
208
229
|
<div style={{ textAlign: "center" }}>
|
|
209
|
-
<Heading
|
|
230
|
+
<Heading
|
|
231
|
+
id="Default"
|
|
232
|
+
level={HeadingLevels.Four}
|
|
233
|
+
text="ImageSizes.Default"
|
|
234
|
+
/>
|
|
210
235
|
<Image
|
|
211
236
|
alt="Alt text"
|
|
212
|
-
|
|
237
|
+
caption="100%"
|
|
213
238
|
src="https://placeimg.com/400/300/animals"
|
|
214
239
|
/>
|
|
215
240
|
</div>
|
|
@@ -219,8 +244,8 @@ Use the `ImageSizes` prop to set the desired size.
|
|
|
219
244
|
|
|
220
245
|
## Image Aspect Ratios
|
|
221
246
|
|
|
222
|
-
Use the `
|
|
223
|
-
following example has `
|
|
247
|
+
Use the `aspectRatio` prop to set the desired aspect ratio. Note: the
|
|
248
|
+
following example has `size` set to `ImageSizes.Small`.
|
|
224
249
|
|
|
225
250
|
For a better viewing experience, the `Image` components below have been wrapped
|
|
226
251
|
in an element with a fixed width value.
|
|
@@ -229,66 +254,98 @@ in an element with a fixed width value.
|
|
|
229
254
|
<Story name="Image Aspect Ratios">
|
|
230
255
|
<SimpleGrid columns={1}>
|
|
231
256
|
<div style={imageBlockStyles}>
|
|
232
|
-
<Heading
|
|
257
|
+
<Heading
|
|
258
|
+
id="fourbythree"
|
|
259
|
+
level={HeadingLevels.Four}
|
|
260
|
+
text="ImageRatios.FourByThree"
|
|
261
|
+
/>
|
|
233
262
|
<Image
|
|
234
263
|
alt="Alt text"
|
|
235
|
-
|
|
264
|
+
aspectRatio={ImageRatios.FourByThree}
|
|
236
265
|
src="https://placeimg.com/400/300/animals"
|
|
237
266
|
/>
|
|
238
267
|
</div>
|
|
239
268
|
<div style={imageBlockStyles}>
|
|
240
|
-
<Heading
|
|
269
|
+
<Heading
|
|
270
|
+
id="onebytwo"
|
|
271
|
+
level={HeadingLevels.Four}
|
|
272
|
+
text="ImageRatios.OneByTwo"
|
|
273
|
+
/>
|
|
241
274
|
<Image
|
|
242
275
|
alt="Alt text"
|
|
243
|
-
|
|
276
|
+
aspectRatio={ImageRatios.OneByTwo}
|
|
244
277
|
src="https://placeimg.com/400/300/animals"
|
|
245
278
|
/>
|
|
246
279
|
</div>
|
|
247
280
|
<div style={imageBlockStyles}>
|
|
248
|
-
<Heading
|
|
281
|
+
<Heading
|
|
282
|
+
id="original"
|
|
283
|
+
level={HeadingLevels.Four}
|
|
284
|
+
text="ImageRatios.Original"
|
|
285
|
+
/>
|
|
249
286
|
<Image
|
|
250
287
|
alt="Alt text"
|
|
251
|
-
|
|
288
|
+
aspectRatio={ImageRatios.Original}
|
|
252
289
|
src="https://placeimg.com/400/300/animals"
|
|
253
290
|
/>
|
|
254
291
|
</div>
|
|
255
292
|
<div style={imageBlockStyles}>
|
|
256
|
-
<Heading
|
|
293
|
+
<Heading
|
|
294
|
+
id="sixteenbynine"
|
|
295
|
+
level={HeadingLevels.Four}
|
|
296
|
+
text="ImageRatios.SixteenByNine"
|
|
297
|
+
/>
|
|
257
298
|
<Image
|
|
258
299
|
alt="Alt text"
|
|
259
|
-
|
|
300
|
+
aspectRatio={ImageRatios.SixteenByNine}
|
|
260
301
|
src="https://placeimg.com/400/300/animals"
|
|
261
302
|
/>
|
|
262
303
|
</div>
|
|
263
304
|
<div style={imageBlockStyles}>
|
|
264
|
-
<Heading
|
|
305
|
+
<Heading
|
|
306
|
+
id="square"
|
|
307
|
+
level={HeadingLevels.Four}
|
|
308
|
+
text="ImageRatios.Square"
|
|
309
|
+
/>
|
|
265
310
|
<Image
|
|
266
311
|
alt="Alt text"
|
|
267
|
-
|
|
312
|
+
aspectRatio={ImageRatios.Square}
|
|
268
313
|
src="https://placeimg.com/400/300/animals"
|
|
269
314
|
/>
|
|
270
315
|
</div>
|
|
271
316
|
<div style={imageBlockStyles}>
|
|
272
|
-
<Heading
|
|
317
|
+
<Heading
|
|
318
|
+
id="threebyfour"
|
|
319
|
+
level={HeadingLevels.Four}
|
|
320
|
+
text="ImageRatios.ThreeByFour"
|
|
321
|
+
/>
|
|
273
322
|
<Image
|
|
274
323
|
alt="Alt text"
|
|
275
|
-
|
|
324
|
+
aspectRatio={ImageRatios.ThreeByFour}
|
|
276
325
|
src="https://placeimg.com/400/300/animals"
|
|
277
326
|
/>
|
|
278
327
|
</div>
|
|
279
328
|
<div style={imageBlockStyles}>
|
|
280
|
-
<Heading
|
|
329
|
+
<Heading
|
|
330
|
+
id="threebytwo"
|
|
331
|
+
level={HeadingLevels.Four}
|
|
332
|
+
text="ImageRatios.ThreeByTwo"
|
|
333
|
+
/>
|
|
281
334
|
<Image
|
|
282
335
|
alt="Alt text"
|
|
283
|
-
|
|
336
|
+
aspectRatio={ImageRatios.ThreeByTwo}
|
|
284
337
|
src="https://placeimg.com/400/300/animals"
|
|
285
338
|
/>
|
|
286
339
|
</div>
|
|
287
340
|
<div style={imageBlockStyles}>
|
|
288
|
-
<Heading
|
|
341
|
+
<Heading
|
|
342
|
+
id="twobyone"
|
|
343
|
+
level={HeadingLevels.Four}
|
|
344
|
+
text="ImageRatios.TwoByOne"
|
|
345
|
+
/>
|
|
289
346
|
<Image
|
|
290
347
|
alt="Alt text"
|
|
291
|
-
|
|
348
|
+
aspectRatio={ImageRatios.TwoByOne}
|
|
292
349
|
src="https://placeimg.com/400/300/animals"
|
|
293
350
|
/>
|
|
294
351
|
</div>
|
|
@@ -299,7 +356,7 @@ in an element with a fixed width value.
|
|
|
299
356
|
## Image Types
|
|
300
357
|
|
|
301
358
|
Use the `imageType` prop to get an image variant. Note that to get a perfect
|
|
302
|
-
circle, the `
|
|
359
|
+
circle, the `aspectRatio` prop _must_ be set to `ImageRatios.Square`.
|
|
303
360
|
|
|
304
361
|
For a better viewing experience, the `Image` components below have been wrapped
|
|
305
362
|
in an element with a fixed width value.
|
|
@@ -308,19 +365,27 @@ in an element with a fixed width value.
|
|
|
308
365
|
<Story name="Image Types">
|
|
309
366
|
<SimpleGrid columns={1}>
|
|
310
367
|
<div style={imageBlockStyles}>
|
|
311
|
-
<Heading
|
|
368
|
+
<Heading
|
|
369
|
+
id="default"
|
|
370
|
+
level={HeadingLevels.Four}
|
|
371
|
+
text="ImageTypes.Default"
|
|
372
|
+
/>
|
|
312
373
|
<Image
|
|
313
374
|
alt="Alt text"
|
|
314
|
-
|
|
375
|
+
aspectRatio={ImageRatios.Square}
|
|
315
376
|
imageType={ImageTypes.Default}
|
|
316
377
|
src="https://placeimg.com/400/400/animals"
|
|
317
378
|
/>
|
|
318
379
|
</div>
|
|
319
380
|
<div style={imageBlockStyles}>
|
|
320
|
-
<Heading
|
|
381
|
+
<Heading
|
|
382
|
+
id="circle"
|
|
383
|
+
level={HeadingLevels.Four}
|
|
384
|
+
text="ImageTypes.Circle"
|
|
385
|
+
/>
|
|
321
386
|
<Image
|
|
322
387
|
alt="Alt text"
|
|
323
|
-
|
|
388
|
+
aspectRatio={ImageRatios.Square}
|
|
324
389
|
imageType={ImageTypes.Circle}
|
|
325
390
|
src="https://placeimg.com/400/400/animals"
|
|
326
391
|
/>
|
|
@@ -14,7 +14,7 @@ describe("Image Accessibility", () => {
|
|
|
14
14
|
|
|
15
15
|
it("passes axe accessibility for figure element wrapper", async () => {
|
|
16
16
|
const { container } = render(
|
|
17
|
-
<Image src="test.png" alt=""
|
|
17
|
+
<Image src="test.png" alt="" caption="This is a caption" />
|
|
18
18
|
);
|
|
19
19
|
expect(await axe(container)).toHaveNoViolations();
|
|
20
20
|
});
|
|
@@ -35,28 +35,21 @@ describe("Image", () => {
|
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
it("renders an image wrapped in figure when provided a caption", () => {
|
|
38
|
-
render(<Image src="test.png"
|
|
38
|
+
render(<Image src="test.png" caption="caption" alt="" />);
|
|
39
39
|
expect(screen.getByRole("img")).toBeInTheDocument();
|
|
40
40
|
expect(screen.getByRole("figure")).toBeInTheDocument();
|
|
41
41
|
expect(screen.getByText("caption")).toBeInTheDocument();
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
it("renders an image wrapped in figure when provided an image credit", () => {
|
|
45
|
-
render(<Image src="test.png"
|
|
45
|
+
render(<Image src="test.png" credit="credit" alt="" />);
|
|
46
46
|
expect(screen.getByRole("img")).toBeInTheDocument();
|
|
47
47
|
expect(screen.getByRole("figure")).toBeInTheDocument();
|
|
48
48
|
expect(screen.getByText("credit")).toBeInTheDocument();
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
it("renders an image wrapped in figure with credit and caption", () => {
|
|
52
|
-
render(
|
|
53
|
-
<Image
|
|
54
|
-
src="test.png"
|
|
55
|
-
imageCaption="caption"
|
|
56
|
-
imageCredit="credit"
|
|
57
|
-
alt=""
|
|
58
|
-
/>
|
|
59
|
-
);
|
|
52
|
+
render(<Image src="test.png" caption="caption" credit="credit" alt="" />);
|
|
60
53
|
expect(screen.getByRole("img")).toBeInTheDocument();
|
|
61
54
|
expect(screen.getByRole("figure")).toBeInTheDocument();
|
|
62
55
|
expect(screen.getByText("caption")).toBeInTheDocument();
|
|
@@ -66,85 +59,73 @@ describe("Image", () => {
|
|
|
66
59
|
it("throws error when alt text is too long", () => {
|
|
67
60
|
expect(() =>
|
|
68
61
|
render(<Image src="test.png" alt={tooManyChars} />)
|
|
69
|
-
).toThrowError(
|
|
62
|
+
).toThrowError(
|
|
63
|
+
"NYPL Reservoir Image: Alt text must be less than 300 characters."
|
|
64
|
+
);
|
|
70
65
|
});
|
|
71
66
|
|
|
72
67
|
it("Renders the UI snapshot correctly", () => {
|
|
73
68
|
const basic = renderer.create(<Image src="test.png" alt="" />).toJSON();
|
|
74
69
|
const figCaption = renderer
|
|
75
|
-
.create(<Image src="test.png" alt=""
|
|
70
|
+
.create(<Image src="test.png" alt="" caption="Caption" />)
|
|
71
|
+
.toJSON();
|
|
72
|
+
const figCredit = renderer
|
|
73
|
+
.create(<Image src="test.png" alt="" credit="Credit" />)
|
|
74
|
+
.toJSON();
|
|
75
|
+
const figCaptionCredit = renderer
|
|
76
|
+
.create(<Image src="test.png" alt="" caption="Caption" credit="Credit" />)
|
|
76
77
|
.toJSON();
|
|
77
78
|
const sizeExtraExtraSmall = renderer
|
|
78
|
-
.create(
|
|
79
|
-
<Image src="test.png" alt="" imageSize={ImageSizes.ExtraExtraSmall} />
|
|
80
|
-
)
|
|
79
|
+
.create(<Image src="test.png" alt="" size={ImageSizes.ExtraExtraSmall} />)
|
|
81
80
|
.toJSON();
|
|
82
81
|
const sizeExtraSmall = renderer
|
|
83
|
-
.create(<Image src="test.png" alt=""
|
|
82
|
+
.create(<Image src="test.png" alt="" size={ImageSizes.ExtraSmall} />)
|
|
84
83
|
.toJSON();
|
|
85
84
|
const sizeSmall = renderer
|
|
86
|
-
.create(<Image src="test.png" alt=""
|
|
85
|
+
.create(<Image src="test.png" alt="" size={ImageSizes.Small} />)
|
|
87
86
|
.toJSON();
|
|
88
87
|
const sizeMedium = renderer
|
|
89
|
-
.create(<Image src="test.png" alt=""
|
|
88
|
+
.create(<Image src="test.png" alt="" size={ImageSizes.Medium} />)
|
|
90
89
|
.toJSON();
|
|
91
90
|
const sizeLarge = renderer
|
|
92
|
-
.create(<Image src="test.png" alt=""
|
|
91
|
+
.create(<Image src="test.png" alt="" size={ImageSizes.Large} />)
|
|
93
92
|
.toJSON();
|
|
94
93
|
const ratioFourByThree = renderer
|
|
95
94
|
.create(
|
|
96
|
-
<Image
|
|
97
|
-
src="test.png"
|
|
98
|
-
alt=""
|
|
99
|
-
imageAspectRatio={ImageRatios.FourByThree}
|
|
100
|
-
/>
|
|
95
|
+
<Image src="test.png" alt="" aspectRatio={ImageRatios.FourByThree} />
|
|
101
96
|
)
|
|
102
97
|
.toJSON();
|
|
103
98
|
const ratioOneByTwo = renderer
|
|
104
99
|
.create(
|
|
105
|
-
<Image src="test.png" alt=""
|
|
100
|
+
<Image src="test.png" alt="" aspectRatio={ImageRatios.OneByTwo} />
|
|
106
101
|
)
|
|
107
102
|
.toJSON();
|
|
108
103
|
const ratioOriginal = renderer
|
|
109
104
|
.create(
|
|
110
|
-
<Image src="test.png" alt=""
|
|
105
|
+
<Image src="test.png" alt="" aspectRatio={ImageRatios.Original} />
|
|
111
106
|
)
|
|
112
107
|
.toJSON();
|
|
113
108
|
const ratioSixteenByNine = renderer
|
|
114
109
|
.create(
|
|
115
|
-
<Image
|
|
116
|
-
src="test.png"
|
|
117
|
-
alt=""
|
|
118
|
-
imageAspectRatio={ImageRatios.SixteenByNine}
|
|
119
|
-
/>
|
|
110
|
+
<Image src="test.png" alt="" aspectRatio={ImageRatios.SixteenByNine} />
|
|
120
111
|
)
|
|
121
112
|
.toJSON();
|
|
122
113
|
const ratioSquare = renderer
|
|
123
|
-
.create(
|
|
124
|
-
<Image src="test.png" alt="" imageAspectRatio={ImageRatios.Square} />
|
|
125
|
-
)
|
|
114
|
+
.create(<Image src="test.png" alt="" aspectRatio={ImageRatios.Square} />)
|
|
126
115
|
.toJSON();
|
|
127
116
|
const ratioThreeByFour = renderer
|
|
128
117
|
.create(
|
|
129
|
-
<Image
|
|
130
|
-
src="test.png"
|
|
131
|
-
alt=""
|
|
132
|
-
imageAspectRatio={ImageRatios.ThreeByFour}
|
|
133
|
-
/>
|
|
118
|
+
<Image src="test.png" alt="" aspectRatio={ImageRatios.ThreeByFour} />
|
|
134
119
|
)
|
|
135
120
|
.toJSON();
|
|
136
121
|
const ratioThreeByTwo = renderer
|
|
137
122
|
.create(
|
|
138
|
-
<Image
|
|
139
|
-
src="test.png"
|
|
140
|
-
alt=""
|
|
141
|
-
imageAspectRatio={ImageRatios.ThreeByTwo}
|
|
142
|
-
/>
|
|
123
|
+
<Image src="test.png" alt="" aspectRatio={ImageRatios.ThreeByTwo} />
|
|
143
124
|
)
|
|
144
125
|
.toJSON();
|
|
145
126
|
const ratioTwoByOne = renderer
|
|
146
127
|
.create(
|
|
147
|
-
<Image src="test.png" alt=""
|
|
128
|
+
<Image src="test.png" alt="" aspectRatio={ImageRatios.TwoByOne} />
|
|
148
129
|
)
|
|
149
130
|
.toJSON();
|
|
150
131
|
const typeCircle = renderer
|
|
@@ -152,14 +133,17 @@ describe("Image", () => {
|
|
|
152
133
|
<Image
|
|
153
134
|
src="test.png"
|
|
154
135
|
alt=""
|
|
155
|
-
|
|
156
|
-
|
|
136
|
+
aspectRatio={ImageRatios.Square}
|
|
137
|
+
size={ImageSizes.Small}
|
|
157
138
|
imageType={ImageTypes.Circle}
|
|
158
139
|
/>
|
|
159
140
|
)
|
|
160
141
|
.toJSON();
|
|
142
|
+
|
|
161
143
|
expect(basic).toMatchSnapshot();
|
|
162
144
|
expect(figCaption).toMatchSnapshot();
|
|
145
|
+
expect(figCredit).toMatchSnapshot();
|
|
146
|
+
expect(figCaptionCredit).toMatchSnapshot();
|
|
163
147
|
expect(sizeExtraExtraSmall).toMatchSnapshot();
|
|
164
148
|
expect(sizeExtraSmall).toMatchSnapshot();
|
|
165
149
|
expect(sizeSmall).toMatchSnapshot();
|