@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
|
@@ -5,10 +5,8 @@ import {
|
|
|
5
5
|
useMultiStyleConfig,
|
|
6
6
|
} from "@chakra-ui/react";
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
SkeletonLoaderLayouts,
|
|
11
|
-
} from "./SkeletonLoaderTypes";
|
|
8
|
+
import { SkeletonLoaderImageRatios } from "./SkeletonLoaderTypes";
|
|
9
|
+
import { LayoutTypes } from "../../helpers/enums";
|
|
12
10
|
|
|
13
11
|
export interface SkeletonLoaderProps {
|
|
14
12
|
/** Optional boolean value to control visibility of border around skeleton loader. */
|
|
@@ -25,8 +23,8 @@ export interface SkeletonLoaderProps {
|
|
|
25
23
|
* default value is `SkeletonLoaderImageRatios.Square`. */
|
|
26
24
|
imageAspectRatio?: SkeletonLoaderImageRatios;
|
|
27
25
|
/** Optional value to control the position of the image placeholder;
|
|
28
|
-
* default value is `
|
|
29
|
-
layout?:
|
|
26
|
+
* default value is `LayoutTypes.Column`. */
|
|
27
|
+
layout?: LayoutTypes;
|
|
30
28
|
/** Optional boolean value to control visibility of button placeholder. */
|
|
31
29
|
showButton?: boolean;
|
|
32
30
|
/** Optional boolean value to control visibility of content placeholder. */
|
|
@@ -54,7 +52,7 @@ export default function SkeletonLoader(
|
|
|
54
52
|
contentSize = 3,
|
|
55
53
|
headingSize = 1,
|
|
56
54
|
imageAspectRatio = SkeletonLoaderImageRatios.Square,
|
|
57
|
-
layout =
|
|
55
|
+
layout = LayoutTypes.Column,
|
|
58
56
|
showButton = false,
|
|
59
57
|
showContent = true,
|
|
60
58
|
showHeading = true,
|
|
@@ -76,13 +76,26 @@ import DSProvider from "../../theme/provider";
|
|
|
76
76
|
| Component Version | DS Version |
|
|
77
77
|
| ----------------- | ---------- |
|
|
78
78
|
| Added | `0.25.4` |
|
|
79
|
-
| Latest | `0.25.
|
|
79
|
+
| Latest | `0.25.13` |
|
|
80
|
+
|
|
81
|
+
## Table of Contents
|
|
82
|
+
|
|
83
|
+
- [Overview](#overview)
|
|
84
|
+
- [Component Props](#component-props)
|
|
85
|
+
- [Accessibility](#accessibility)
|
|
86
|
+
- [RangeSlider](#rangeslider)
|
|
87
|
+
- [Examples](#examples)
|
|
88
|
+
- [Get Input Values](#get-input-values)
|
|
89
|
+
|
|
90
|
+
## Overview
|
|
80
91
|
|
|
81
92
|
<Description of={Slider} />
|
|
82
93
|
|
|
83
94
|
The text input component doubles as a display for the slider's current value.
|
|
84
95
|
For this type of component, the `value` prop must be a single number.
|
|
85
96
|
|
|
97
|
+
## Component Props
|
|
98
|
+
|
|
86
99
|
<Canvas withToolbar>
|
|
87
100
|
<Story
|
|
88
101
|
name="Slider with Controls"
|
|
@@ -123,7 +136,25 @@ For this type of component, the `value` prop must be a single number.
|
|
|
123
136
|
|
|
124
137
|
<ArgsTable story="Slider with Controls" />
|
|
125
138
|
|
|
126
|
-
|
|
139
|
+
## Accessibility
|
|
140
|
+
|
|
141
|
+
- UI component should be accessible via keyboard. In addition to the text fields,
|
|
142
|
+
a keyboard user should be able to tab to the blue circle and then with left and
|
|
143
|
+
right arrows increase or decrease the value.
|
|
144
|
+
- The color contrast between foreground color and background color should be
|
|
145
|
+
4.5:1 contrast ratio.
|
|
146
|
+
- If text size is 200%, the button should scale with text so there is no overlap.
|
|
147
|
+
- A `Slider` is an input component, so it should have a label. A `Slider` without a
|
|
148
|
+
label is ambiguous and not accessible.
|
|
149
|
+
|
|
150
|
+
Resources:
|
|
151
|
+
|
|
152
|
+
- [W3C WAI-Aria Practices - Slider](https://www.w3.org/TR/wai-aria-practices-1.1/#slider)
|
|
153
|
+
- [W3C WAI-Aria Practices - Slider (Multi-Thumb)](https://www.w3.org/TR/wai-aria-practices-1.1/#slidertwothumb)
|
|
154
|
+
- [Chakra Slider](https://chakra-ui.com/docs/components/form/slider)
|
|
155
|
+
- [Chakra RangeSlider](https://chakra-ui.com/docs/components/form/range-slider)
|
|
156
|
+
|
|
157
|
+
### Slider Accessibility Implementation
|
|
127
158
|
|
|
128
159
|
Chakra's `Slider` component is accessible and, as recommended, we pass in an
|
|
129
160
|
`aria-label` to their `Slider` component. On top of that, the DS `Slider`
|
|
@@ -134,7 +165,7 @@ is hidden, the `for` attribute in the `label` element is removed.
|
|
|
134
165
|
Note that Chakra handles its single slider thumb aria attributes: `aria-valuemin`,
|
|
135
166
|
`aria-valuemax`, `aria-valuenow`, and `aria-orientation`.
|
|
136
167
|
|
|
137
|
-
##
|
|
168
|
+
## RangeSlider
|
|
138
169
|
|
|
139
170
|
Set `isRangeSlider` to `true` to create a range slider. The text input
|
|
140
171
|
components double as displays for the slider's current minimum and maximum
|
|
@@ -143,7 +174,7 @@ numbers. This signifies the starting and ending values of the range slider.
|
|
|
143
174
|
|
|
144
175
|
<Canvas withToolbar>
|
|
145
176
|
<Story
|
|
146
|
-
name="
|
|
177
|
+
name="RangeSlider with Controls"
|
|
147
178
|
args={{
|
|
148
179
|
className: undefined,
|
|
149
180
|
defaultValue: [25, 75],
|
|
@@ -179,7 +210,7 @@ numbers. This signifies the starting and ending values of the range slider.
|
|
|
179
210
|
</Story>
|
|
180
211
|
</Canvas>
|
|
181
212
|
|
|
182
|
-
### Accessibility
|
|
213
|
+
### RangeSlider Accessibility Implementation
|
|
183
214
|
|
|
184
215
|
Chakra's `RangeSlider` component is accessible and, as recommended, we pass in
|
|
185
216
|
two `aria-label`s to their `RangeSlider` component. The syntax is different than
|
|
@@ -192,6 +223,8 @@ When the input boxes are hidden, the `for` attribute in the `label` element is r
|
|
|
192
223
|
Note that Chakra handles its two slider thumbs aria attributes: `aria-valuemin`,
|
|
193
224
|
`aria-valuemax`, `aria-valuenow`, and `aria-orientation`.
|
|
194
225
|
|
|
226
|
+
## Examples
|
|
227
|
+
|
|
195
228
|
### Single Slider States
|
|
196
229
|
|
|
197
230
|
Note: In the following examples, the "Required"/"Optional" text in the label is
|
|
@@ -483,7 +516,7 @@ In the following examples, all the labels are hidden.
|
|
|
483
516
|
</DSProvider>
|
|
484
517
|
</Canvas>
|
|
485
518
|
|
|
486
|
-
|
|
519
|
+
## Get Input Values
|
|
487
520
|
|
|
488
521
|
Pass a callback function to the `onChange` prop to get the current number value
|
|
489
522
|
of the `Slider` component or an array of two numbers when it is a range slider.
|
|
@@ -492,7 +525,7 @@ value or values. Once the value(s) is updated, the `onChange` callback will be
|
|
|
492
525
|
called and the values will be passed. If no `onChange` callback is provided,
|
|
493
526
|
you won't be able to get the updated value(s) of the `Slider` component.
|
|
494
527
|
|
|
495
|
-
|
|
528
|
+
### Single Slider Value
|
|
496
529
|
|
|
497
530
|
Open up the browser's developer console to see the value of the `Slider`
|
|
498
531
|
after updating it.
|
|
@@ -532,7 +565,7 @@ export function SliderExample() {
|
|
|
532
565
|
</DSProvider>
|
|
533
566
|
</Canvas>
|
|
534
567
|
|
|
535
|
-
|
|
568
|
+
### Range Slider Values
|
|
536
569
|
|
|
537
570
|
Open up the browser's developer console to see the values of the `Slider`
|
|
538
571
|
after updating it in the `isRangeSlider` state.
|
|
@@ -133,10 +133,10 @@ export default function Slider(props: React.PropsWithChildren<SliderProps>) {
|
|
|
133
133
|
max,
|
|
134
134
|
min,
|
|
135
135
|
name,
|
|
136
|
-
onChange: (val) =>
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
onChange: (val) => {
|
|
137
|
+
setCurrentValue(val);
|
|
138
|
+
onChange && onChange(val);
|
|
139
|
+
},
|
|
140
140
|
step,
|
|
141
141
|
// Additional margins so slider thumbs don't overflow past the
|
|
142
142
|
// edge when the value boxes or min/max values are hidden.
|
|
@@ -24,7 +24,9 @@ describe("StatusBadge", () => {
|
|
|
24
24
|
it("throws a warning when no children are passed", () => {
|
|
25
25
|
const warn = jest.spyOn(console, "warn");
|
|
26
26
|
render(<StatusBadge></StatusBadge>);
|
|
27
|
-
expect(warn).toHaveBeenCalledWith(
|
|
27
|
+
expect(warn).toHaveBeenCalledWith(
|
|
28
|
+
"NYPL Reservoir StatusBadge: No children were passed."
|
|
29
|
+
);
|
|
28
30
|
});
|
|
29
31
|
|
|
30
32
|
it("renders the UI snapshot correctly", () => {
|
|
@@ -24,7 +24,7 @@ function StatusBadge(props: React.PropsWithChildren<StatusBadgeProps>) {
|
|
|
24
24
|
const styles = useStyleConfig("StatusBadge", { variant: level });
|
|
25
25
|
|
|
26
26
|
if (!children) {
|
|
27
|
-
console.warn("
|
|
27
|
+
console.warn("NYPL Reservoir StatusBadge: No children were passed.");
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
return (
|
|
@@ -41,25 +41,34 @@ export const imageSizeEnumValues = getStorybookEnumValues(
|
|
|
41
41
|
argTypes={{
|
|
42
42
|
className: { control: false },
|
|
43
43
|
id: { control: false },
|
|
44
|
-
|
|
44
|
+
"imageProps.aspectRatio": {
|
|
45
|
+
control: {
|
|
46
|
+
type: "select",
|
|
47
|
+
},
|
|
45
48
|
table: {
|
|
46
49
|
defaultValue: { summary: "ImageRatios.Square" },
|
|
47
50
|
},
|
|
48
51
|
options: imageAspectRatioEnumValues.options,
|
|
49
52
|
},
|
|
50
|
-
|
|
53
|
+
"imageProps.component": { control: false },
|
|
54
|
+
"imageProps.position": {
|
|
55
|
+
control: {
|
|
56
|
+
type: "select",
|
|
57
|
+
},
|
|
51
58
|
table: {
|
|
52
59
|
defaultValue: { summary: "StructuredContentImagePosition.Left" },
|
|
53
60
|
},
|
|
54
61
|
options: imagePositionEnumValues.options,
|
|
55
62
|
},
|
|
56
|
-
|
|
63
|
+
"imageProps.size": {
|
|
64
|
+
control: {
|
|
65
|
+
type: "select",
|
|
66
|
+
},
|
|
57
67
|
table: {
|
|
58
68
|
defaultValue: { summary: "ImageSizes.Medium" },
|
|
59
69
|
},
|
|
60
70
|
options: imageSizeEnumValues.options,
|
|
61
71
|
},
|
|
62
|
-
imageComponent: { control: false },
|
|
63
72
|
}}
|
|
64
73
|
/>
|
|
65
74
|
|
|
@@ -68,25 +77,27 @@ export const imageSizeEnumValues = getStorybookEnumValues(
|
|
|
68
77
|
| Component Version | DS Version |
|
|
69
78
|
| ----------------- | ---------- |
|
|
70
79
|
| Added | `0.25.9` |
|
|
71
|
-
| Latest | `0.25.
|
|
80
|
+
| Latest | `0.25.13` |
|
|
81
|
+
|
|
82
|
+
## Table of Contents
|
|
83
|
+
|
|
84
|
+
- [Overview](#overview)
|
|
85
|
+
- [Component Props](#component-props)
|
|
86
|
+
- [Accessibility](#accessibility)
|
|
87
|
+
- [With HTML String Text Content](#with-html-string-text-content)
|
|
88
|
+
- [With HTML Element Text Content](#with-html-element-text-content)
|
|
89
|
+
- [Examples](#examples)
|
|
90
|
+
|
|
91
|
+
## Overview
|
|
72
92
|
|
|
73
93
|
<Description of={StructuredContent} />
|
|
74
94
|
|
|
95
|
+
## Component Props
|
|
96
|
+
|
|
75
97
|
<Canvas withToolbar>
|
|
76
98
|
<Story
|
|
77
99
|
name="StructuredContent with Controls"
|
|
78
100
|
args={{
|
|
79
|
-
calloutText: "This is the callout text",
|
|
80
|
-
className: undefined,
|
|
81
|
-
headingText: "Heading text",
|
|
82
|
-
id: "structured-content",
|
|
83
|
-
imageAlt: "Image alt text",
|
|
84
|
-
imageAspectRatio: "ImageRatios.Square",
|
|
85
|
-
imageCaption: "Image caption",
|
|
86
|
-
imageCredit: "Image credit",
|
|
87
|
-
imagePosition: "StructuredContentImagePosition.Left",
|
|
88
|
-
imageSize: "ImageSizes.Medium",
|
|
89
|
-
imageSrc: "https://placeimg.com/400/300/animals",
|
|
90
101
|
bodyContent:
|
|
91
102
|
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod" +
|
|
92
103
|
" tempor incididunt ut labore et dolore magna aliqua. Pellentesque massa" +
|
|
@@ -111,16 +122,36 @@ export const imageSizeEnumValues = getStorybookEnumValues(
|
|
|
111
122
|
"Nullam non nisi est sit. Turpis egestas integer eget aliquet nibh " +
|
|
112
123
|
"praesent. Tortor at risus viverra adipiscing at. Eu augue ut lectus " +
|
|
113
124
|
"arcu bibendum at varius vel pharetra.",
|
|
125
|
+
calloutText: "This is the callout text",
|
|
126
|
+
className: undefined,
|
|
127
|
+
headingText: "Heading text",
|
|
128
|
+
id: "structured-content",
|
|
129
|
+
"imageProps.alt": "Image alt text",
|
|
130
|
+
"imageProps.aspectRatio": "ImageRatios.Square",
|
|
131
|
+
"imageProps.caption": "Image caption",
|
|
132
|
+
"imageProps.component": undefined,
|
|
133
|
+
"imageProps.credit": "Image credit",
|
|
134
|
+
"imageProps.position": "StructuredContentImagePosition.Left",
|
|
135
|
+
"imageProps.size": "ImageSizes.Medium",
|
|
136
|
+
"imageProps.src": "https://placeimg.com/400/300/animals",
|
|
114
137
|
}}
|
|
115
138
|
>
|
|
116
139
|
{(args) => (
|
|
117
140
|
<StructuredContent
|
|
118
141
|
{...args}
|
|
119
|
-
|
|
120
|
-
args.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
142
|
+
imageProps={{
|
|
143
|
+
alt: args["imageProps.alt"],
|
|
144
|
+
aspectRatio: imageAspectRatioEnumValues.getValue(
|
|
145
|
+
args["imageProps.aspectRatio"]
|
|
146
|
+
),
|
|
147
|
+
caption: args["imageProps.caption"],
|
|
148
|
+
credit: args["imageProps.credit"],
|
|
149
|
+
position: imagePositionEnumValues.getValue(
|
|
150
|
+
args["imageProps.position"]
|
|
151
|
+
),
|
|
152
|
+
size: imageSizeEnumValues.getValue(args["imageProps.size"]),
|
|
153
|
+
src: args["imageProps.src"],
|
|
154
|
+
}}
|
|
124
155
|
/>
|
|
125
156
|
)}
|
|
126
157
|
</Story>
|
|
@@ -128,6 +159,14 @@ export const imageSizeEnumValues = getStorybookEnumValues(
|
|
|
128
159
|
|
|
129
160
|
<ArgsTable story="StructuredContent with Controls" />
|
|
130
161
|
|
|
162
|
+
## Accessibility
|
|
163
|
+
|
|
164
|
+
- Containers should allow font-size to be scaled to 200% without content overlapping.
|
|
165
|
+
- Images should have descriptive (but not too lengthy) alt text.
|
|
166
|
+
- Headings levels should not be skipped. Meaning, a `<h2>` should not be followed
|
|
167
|
+
by a `<h4>`.
|
|
168
|
+
- Any links or text with colors should have a 4.5:1 contrast ratio.
|
|
169
|
+
|
|
131
170
|
## With HTML String Text Content
|
|
132
171
|
|
|
133
172
|
The following body content is passed as a string to the `bodyContent` prop. It
|
|
@@ -138,13 +177,15 @@ includes HTML tags in the string.
|
|
|
138
177
|
<StructuredContent
|
|
139
178
|
calloutText="This is the callout text"
|
|
140
179
|
headingText="Heading text"
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
180
|
+
imageProps={{
|
|
181
|
+
alt: "Image alt text",
|
|
182
|
+
aspectRatio: ImageRatios.Original,
|
|
183
|
+
caption: "Image caption",
|
|
184
|
+
credit: "Image credit",
|
|
185
|
+
position: StructuredContentImagePosition.Left,
|
|
186
|
+
size: ImageSizes.Medium,
|
|
187
|
+
src: "https://placeimg.com/400/300/animals",
|
|
188
|
+
}}
|
|
148
189
|
bodyContent={
|
|
149
190
|
"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do " +
|
|
150
191
|
"eiusmod tempor incididunt ut labore et dolore magna aliqua. " +
|
|
@@ -185,13 +226,15 @@ The following content is passed as HTML DOM elements to the `bodyContent` prop.
|
|
|
185
226
|
<StructuredContent
|
|
186
227
|
calloutText="This is the callout text"
|
|
187
228
|
headingText="Heading text"
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
229
|
+
imageProps={{
|
|
230
|
+
alt: "Image alt text",
|
|
231
|
+
aspectRatio: ImageRatios.Original,
|
|
232
|
+
caption: "Image caption",
|
|
233
|
+
credit: "Image credit",
|
|
234
|
+
position: StructuredContentImagePosition.Left,
|
|
235
|
+
size: ImageSizes.Medium,
|
|
236
|
+
src: "https://placeimg.com/400/300/animals",
|
|
237
|
+
}}
|
|
195
238
|
bodyContent={
|
|
196
239
|
<>
|
|
197
240
|
<p>
|
|
@@ -255,13 +298,15 @@ but no callout content. The second component does not have an image.
|
|
|
255
298
|
<DSProvider>
|
|
256
299
|
<StructuredContent
|
|
257
300
|
headingText="Heading text"
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
301
|
+
imageProps={{
|
|
302
|
+
alt: "Image alt text",
|
|
303
|
+
aspectRatio: ImageRatios.Original,
|
|
304
|
+
caption: "Image caption",
|
|
305
|
+
credit: "Image credit",
|
|
306
|
+
position: StructuredContentImagePosition.Left,
|
|
307
|
+
size: ImageSizes.Medium,
|
|
308
|
+
src: "https://placeimg.com/400/300/animals",
|
|
309
|
+
}}
|
|
265
310
|
bodyContent={
|
|
266
311
|
"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do " +
|
|
267
312
|
"eiusmod tempor incididunt ut labore et dolore magna aliqua. " +
|
|
@@ -319,13 +364,15 @@ The third one does not contain an image.
|
|
|
319
364
|
/>
|
|
320
365
|
<StructuredContent
|
|
321
366
|
headingText="Heading text"
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
367
|
+
imageProps={{
|
|
368
|
+
alt: "Image alt text",
|
|
369
|
+
aspectRatio: ImageRatios.Original,
|
|
370
|
+
caption: "Image caption",
|
|
371
|
+
credit: "Image credit",
|
|
372
|
+
position: StructuredContentImagePosition.Left,
|
|
373
|
+
size: ImageSizes.Medium,
|
|
374
|
+
src: "https://placeimg.com/400/300/animals",
|
|
375
|
+
}}
|
|
329
376
|
bodyContent={
|
|
330
377
|
"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do " +
|
|
331
378
|
"eiusmod tempor incididunt ut labore et dolore magna aliqua. " +
|
|
@@ -390,11 +437,13 @@ text content. The second one has a callout content and image spanning full width
|
|
|
390
437
|
<StructuredContent
|
|
391
438
|
calloutText="This is the callout text"
|
|
392
439
|
headingText="Heading text"
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
440
|
+
imageProps={{
|
|
441
|
+
alt: "Image alt text",
|
|
442
|
+
aspectRatio: ImageRatios.Original,
|
|
443
|
+
position: StructuredContentImagePosition.Center,
|
|
444
|
+
size: ImageSizes.Medium,
|
|
445
|
+
src: "https://placeimg.com/400/300/animals",
|
|
446
|
+
}}
|
|
398
447
|
bodyContent={
|
|
399
448
|
"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do " +
|
|
400
449
|
"eiusmod tempor incididunt ut labore et dolore magna aliqua." +
|