@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.
Files changed (194) hide show
  1. package/CHANGELOG.md +63 -1
  2. package/dist/components/Accordion/Accordion.d.ts +5 -3
  3. package/dist/components/Accordion/AccordionTypes.d.ts +5 -0
  4. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +3 -3
  5. package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +1 -1
  6. package/dist/components/Card/Card.d.ts +11 -20
  7. package/dist/components/Checkbox/Checkbox.d.ts +1 -1
  8. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +4 -2
  9. package/dist/components/Heading/Heading.d.ts +4 -4
  10. package/dist/components/Heading/HeadingTypes.d.ts +1 -1
  11. package/dist/components/Hero/Hero.d.ts +7 -4
  12. package/dist/components/Icons/IconTypes.d.ts +1 -0
  13. package/dist/components/Image/Image.d.ts +25 -7
  14. package/dist/components/Image/ImageTypes.d.ts +4 -4
  15. package/dist/components/Logo/LogoTypes.d.ts +2 -2
  16. package/dist/components/Notification/Notification.d.ts +4 -4
  17. package/dist/components/Radio/Radio.d.ts +1 -1
  18. package/dist/components/RadioGroup/RadioGroup.d.ts +4 -2
  19. package/dist/components/Select/Select.d.ts +2 -2
  20. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -3
  21. package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +0 -4
  22. package/dist/components/StructuredContent/StructuredContent.d.ts +9 -22
  23. package/dist/components/Tabs/Tabs.d.ts +3 -3
  24. package/dist/components/Template/Template.d.ts +13 -5
  25. package/dist/components/Text/Text.d.ts +3 -3
  26. package/dist/components/Text/TextTypes.d.ts +1 -1
  27. package/dist/components/TextInput/TextInput.d.ts +2 -2
  28. package/dist/components/Toggle/Toggle.d.ts +6 -7
  29. package/dist/components/Toggle/{ToggleSizes.d.ts → ToggleTypes.d.ts} +1 -1
  30. package/dist/design-system-react-components.cjs.development.js +505 -422
  31. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  32. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  33. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  34. package/dist/design-system-react-components.esm.js +514 -435
  35. package/dist/design-system-react-components.esm.js.map +1 -1
  36. package/dist/helpers/enums.d.ts +4 -0
  37. package/dist/index.d.ts +7 -8
  38. package/dist/theme/components/accordion.d.ts +7 -12
  39. package/dist/theme/components/breadcrumb.d.ts +3 -0
  40. package/dist/theme/components/card.d.ts +4 -4
  41. package/dist/theme/components/checkbox.d.ts +1 -0
  42. package/dist/theme/components/checkboxGroup.d.ts +3 -1
  43. package/dist/theme/components/global.d.ts +2 -1
  44. package/dist/theme/components/hero.d.ts +1 -1
  45. package/dist/theme/components/image.d.ts +1 -1
  46. package/dist/theme/components/notification.d.ts +4 -4
  47. package/dist/theme/components/pagination.d.ts +2 -5
  48. package/dist/theme/components/radio.d.ts +1 -0
  49. package/dist/theme/components/radioGroup.d.ts +3 -1
  50. package/dist/theme/components/select.d.ts +3 -0
  51. package/dist/theme/components/toggle.d.ts +13 -1
  52. package/package.json +1 -1
  53. package/src/components/AccessibilityGuide/SkipNavigation.stories.mdx +34 -0
  54. package/src/components/Accordion/Accordion.stories.mdx +150 -66
  55. package/src/components/Accordion/Accordion.test.tsx +44 -17
  56. package/src/components/Accordion/Accordion.tsx +50 -20
  57. package/src/components/Accordion/AccordionTypes.tsx +5 -0
  58. package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +244 -2
  59. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +17 -15
  60. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +6 -6
  61. package/src/components/Breadcrumbs/Breadcrumbs.tsx +6 -6
  62. package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +1 -1
  63. package/src/components/Card/Card.stories.mdx +236 -165
  64. package/src/components/Card/Card.test.tsx +36 -18
  65. package/src/components/Card/Card.tsx +84 -59
  66. package/src/components/Card/__snapshots__/Card.test.tsx.snap +25 -65
  67. package/src/components/Chakra/Center.stories.mdx +2 -2
  68. package/src/components/Checkbox/Checkbox.stories.mdx +13 -1
  69. package/src/components/Checkbox/Checkbox.test.tsx +58 -2
  70. package/src/components/Checkbox/Checkbox.tsx +6 -1
  71. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +76 -0
  72. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +73 -9
  73. package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +79 -9
  74. package/src/components/CheckboxGroup/CheckboxGroup.tsx +10 -7
  75. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +169 -0
  76. package/src/components/ComponentWrapper/ComponentWrapper.tsx +1 -1
  77. package/src/components/DatePicker/DatePicker.test.tsx +5 -2
  78. package/src/components/DatePicker/DatePicker.tsx +5 -2
  79. package/src/components/Form/Form.stories.mdx +47 -9
  80. package/src/components/Form/Form.test.tsx +1 -1
  81. package/src/components/Form/Form.tsx +3 -1
  82. package/src/components/Grid/SimpleGrid.stories.mdx +53 -35
  83. package/src/components/Grid/SimpleGrid.test.tsx +15 -9
  84. package/src/components/Heading/Heading.stories.mdx +21 -23
  85. package/src/components/Heading/Heading.test.tsx +7 -7
  86. package/src/components/Heading/Heading.tsx +10 -14
  87. package/src/components/Heading/HeadingTypes.tsx +1 -1
  88. package/src/components/Heading/__snapshots__/Heading.test.tsx.snap +1 -1
  89. package/src/components/Hero/Hero.stories.mdx +27 -27
  90. package/src/components/Hero/Hero.test.tsx +113 -58
  91. package/src/components/Hero/Hero.tsx +43 -20
  92. package/src/components/HorizontalRule/HorizontalRule.test.tsx +6 -4
  93. package/src/components/HorizontalRule/HorizontalRule.tsx +3 -2
  94. package/src/components/Icons/Icon.stories.mdx +50 -18
  95. package/src/components/Icons/Icon.test.tsx +13 -2
  96. package/src/components/Icons/Icon.tsx +11 -6
  97. package/src/components/Icons/IconTypes.tsx +1 -0
  98. package/src/components/Image/Image.stories.mdx +133 -68
  99. package/src/components/Image/Image.test.tsx +32 -48
  100. package/src/components/Image/Image.tsx +46 -26
  101. package/src/components/Image/ImageTypes.ts +4 -4
  102. package/src/components/Image/__snapshots__/Image.test.tsx.snap +60 -13
  103. package/src/components/Link/Link.tsx +8 -1
  104. package/src/components/List/List.stories.mdx +1 -1
  105. package/src/components/List/List.test.tsx +7 -4
  106. package/src/components/List/List.tsx +7 -4
  107. package/src/components/Logo/Logo.stories.mdx +13 -13
  108. package/src/components/Logo/Logo.test.tsx +12 -2
  109. package/src/components/Logo/Logo.tsx +10 -5
  110. package/src/components/Logo/LogoTypes.tsx +1 -1
  111. package/src/components/Notification/Notification.stories.mdx +5 -5
  112. package/src/components/Notification/Notification.tsx +10 -10
  113. package/src/components/Pagination/Pagination.stories.mdx +4 -3
  114. package/src/components/Pagination/Pagination.test.tsx +30 -2
  115. package/src/components/Pagination/Pagination.tsx +6 -3
  116. package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +1 -1
  117. package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +6 -2
  118. package/src/components/ProgressIndicator/ProgressIndicator.tsx +3 -1
  119. package/src/components/Radio/Radio.stories.mdx +13 -1
  120. package/src/components/Radio/Radio.test.tsx +56 -2
  121. package/src/components/Radio/Radio.tsx +6 -1
  122. package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +61 -0
  123. package/src/components/RadioGroup/RadioGroup.stories.mdx +73 -9
  124. package/src/components/RadioGroup/RadioGroup.test.tsx +72 -7
  125. package/src/components/RadioGroup/RadioGroup.tsx +10 -7
  126. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +140 -0
  127. package/src/components/SearchBar/SearchBar.stories.mdx +1 -1
  128. package/src/components/SearchBar/SearchBar.tsx +3 -3
  129. package/src/components/Select/Select.stories.mdx +26 -16
  130. package/src/components/Select/Select.test.tsx +1 -36
  131. package/src/components/Select/Select.tsx +4 -16
  132. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +12 -14
  133. package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +6 -8
  134. package/src/components/SkeletonLoader/SkeletonLoader.tsx +5 -7
  135. package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +0 -5
  136. package/src/components/Slider/Slider.stories.mdx +41 -8
  137. package/src/components/Slider/Slider.tsx +4 -4
  138. package/src/components/StatusBadge/StatusBadge.test.tsx +3 -1
  139. package/src/components/StatusBadge/StatusBadge.tsx +1 -1
  140. package/src/components/StructuredContent/StructuredContent.stories.mdx +103 -54
  141. package/src/components/StructuredContent/StructuredContent.test.tsx +129 -102
  142. package/src/components/StructuredContent/StructuredContent.tsx +43 -53
  143. package/src/components/StyleGuide/ColorCard.tsx +3 -3
  144. package/src/components/StyleGuide/Typography.stories.mdx +17 -12
  145. package/src/components/Table/Table.test.tsx +1 -1
  146. package/src/components/Table/Table.tsx +3 -1
  147. package/src/components/Tabs/Tabs.stories.mdx +8 -8
  148. package/src/components/Tabs/Tabs.test.tsx +13 -11
  149. package/src/components/Tabs/Tabs.tsx +18 -15
  150. package/src/components/Template/Template.stories.mdx +62 -25
  151. package/src/components/Template/Template.test.tsx +35 -5
  152. package/src/components/Template/Template.tsx +26 -13
  153. package/src/components/Template/__snapshots__/Template.test.tsx.snap +4 -2
  154. package/src/components/Text/Text.stories.mdx +13 -15
  155. package/src/components/Text/Text.test.tsx +6 -15
  156. package/src/components/Text/Text.tsx +7 -12
  157. package/src/components/Text/TextTypes.tsx +1 -1
  158. package/src/components/TextInput/TextInput.stories.mdx +9 -9
  159. package/src/components/TextInput/TextInput.test.tsx +28 -27
  160. package/src/components/TextInput/TextInput.tsx +4 -4
  161. package/src/components/Toggle/Toggle.stories.mdx +12 -22
  162. package/src/components/Toggle/Toggle.test.tsx +15 -2
  163. package/src/components/Toggle/Toggle.tsx +8 -9
  164. package/src/components/Toggle/{ToggleSizes.tsx → ToggleTypes.tsx} +1 -1
  165. package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +64 -0
  166. package/src/components/VideoPlayer/VideoPlayer.test.tsx +18 -6
  167. package/src/components/VideoPlayer/VideoPlayer.tsx +14 -7
  168. package/src/docs/{Intro.stories.mdx → Welcome.stories.mdx} +5 -9
  169. package/src/{components/Card/CardTypes.tsx → helpers/enums.ts} +2 -2
  170. package/src/hooks/tests/useNYPLTheme.test.tsx +1 -1
  171. package/src/hooks/useCarouselStyles.stories.mdx +10 -0
  172. package/src/hooks/useNYPLTheme.ts +1 -1
  173. package/src/index.ts +7 -14
  174. package/src/theme/components/accordion.ts +7 -12
  175. package/src/theme/components/breadcrumb.ts +3 -0
  176. package/src/theme/components/card.ts +29 -20
  177. package/src/theme/components/checkboxGroup.ts +3 -1
  178. package/src/theme/components/global.ts +4 -3
  179. package/src/theme/components/hero.ts +1 -1
  180. package/src/theme/components/icon.ts +5 -2
  181. package/src/theme/components/image.ts +1 -1
  182. package/src/theme/components/list.ts +1 -1
  183. package/src/theme/components/notification.ts +5 -5
  184. package/src/theme/components/pagination.ts +2 -5
  185. package/src/theme/components/progressIndicator.ts +3 -3
  186. package/src/theme/components/radioGroup.ts +3 -1
  187. package/src/theme/components/select.ts +6 -0
  188. package/src/theme/components/toggle.ts +26 -3
  189. package/src/utils/componentCategories.ts +27 -19
  190. package/dist/components/Card/CardTypes.d.ts +0 -4
  191. package/dist/components/CheckboxGroup/CheckboxGroupLayoutTypes.d.ts +0 -4
  192. package/dist/components/RadioGroup/RadioGroupLayoutTypes.d.ts +0 -4
  193. package/src/components/CheckboxGroup/CheckboxGroupLayoutTypes.tsx +0 -4
  194. 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
- SkeletonLoaderImageRatios,
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 `SkeletonLoaderLayouts.Column`. */
29
- layout?: SkeletonLoaderLayouts;
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 = SkeletonLoaderLayouts.Column,
55
+ layout = LayoutTypes.Column,
58
56
  showButton = false,
59
57
  showContent = true,
60
58
  showHeading = true,
@@ -1,8 +1,3 @@
1
- export enum SkeletonLoaderLayouts {
2
- Row = "row",
3
- Column = "column",
4
- }
5
-
6
1
  export enum SkeletonLoaderImageRatios {
7
2
  Landscape = "landscape",
8
3
  Portrait = "portrait",
@@ -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.12` |
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
- ### Accessibility
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
- ## Range Slider
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="Range Slider with Props"
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
- ### Get Data Values
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
- #### Single Slider Value
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
- #### Range Slider Values
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) => setCurrentValue(val),
137
- // Call the passed in `onChange` function prop to get the
138
- // *final* value once a user stops dragging the slider.
139
- onChangeEnd: (val) => onChange && onChange(val),
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("Status Badge has no children.");
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("Status Badge has no children.");
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
- imageAspectRatio: {
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
- imagePosition: {
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
- imageSize: {
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.11` |
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
- imageAspectRatio={imageAspectRatioEnumValues.getValue(
120
- args.imageAspectRatio
121
- )}
122
- imagePosition={imagePositionEnumValues.getValue(args.imagePosition)}
123
- imageSize={imageSizeEnumValues.getValue(args.imageSize)}
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
- imageAlt="Image alt text"
142
- imageAspectRatio={ImageRatios.Original}
143
- imageCaption="Image caption"
144
- imageCredit="Image credit"
145
- imagePosition={StructuredContentImagePosition.Left}
146
- imageSize={ImageSizes.Medium}
147
- imageSrc="https://placeimg.com/400/300/animals"
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
- imageAlt="Image alt text"
189
- imageAspectRatio={ImageRatios.Original}
190
- imageCaption="Image caption"
191
- imageCredit="Image credit"
192
- imagePosition={StructuredContentImagePosition.Left}
193
- imageSize={ImageSizes.Medium}
194
- imageSrc="https://placeimg.com/400/300/animals"
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
- imageAlt="Image alt text"
259
- imageAspectRatio={ImageRatios.Original}
260
- imageCaption="Image caption"
261
- imageCredit="Image credit"
262
- imagePosition={StructuredContentImagePosition.Left}
263
- imageSize={ImageSizes.Medium}
264
- imageSrc="https://placeimg.com/400/300/animals"
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
- imageAlt="Image alt text"
323
- imageAspectRatio={ImageRatios.Original}
324
- imageCaption="Image caption"
325
- imageCredit="Image credit"
326
- imagePosition={StructuredContentImagePosition.Left}
327
- imageSize={ImageSizes.Medium}
328
- imageSrc="https://placeimg.com/400/300/animals"
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
- imageAlt="Image alt text"
394
- imageAspectRatio={ImageRatios.Original}
395
- imagePosition={StructuredContentImagePosition.Center}
396
- imageSize={ImageSizes.Medium}
397
- imageSrc="https://placeimg.com/400/300/animals"
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." +