@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
@@ -83,16 +83,18 @@ describe("StructuredContent Accessibility", () => {
83
83
  it("passes axe accessibility for HTML string text content", async () => {
84
84
  const { container } = render(
85
85
  <StructuredContent
86
+ bodyContent={htmlStringBodyContent}
86
87
  calloutText="This is the callout text"
87
88
  headingText="Heading text"
88
- imageAlt="Image alt text"
89
- imageAspectRatio={ImageRatios.Original}
90
- imageCaption="Image caption"
91
- imageCredit="Image credit"
92
- imagePosition={StructuredContentImagePosition.Left}
93
- imageSize={ImageSizes.Medium}
94
- imageSrc="https://placeimg.com/400/300/animals"
95
- bodyContent={htmlStringBodyContent}
89
+ imageProps={{
90
+ alt: "Image alt text",
91
+ aspectRatio: ImageRatios.Original,
92
+ caption: "Image caption",
93
+ credit: "Image credit",
94
+ position: StructuredContentImagePosition.Left,
95
+ size: ImageSizes.Medium,
96
+ src: "https://placeimg.com/400/300/animals",
97
+ }}
96
98
  />
97
99
  );
98
100
  expect(await axe(container)).toHaveNoViolations();
@@ -101,16 +103,18 @@ describe("StructuredContent Accessibility", () => {
101
103
  it("passes axe accessibility for HTML DOM text content", async () => {
102
104
  const { container } = render(
103
105
  <StructuredContent
106
+ bodyContent={htmlDOMBodyContent}
104
107
  calloutText="This is the callout text"
105
108
  headingText="Heading text"
106
- imageAlt="Image alt text"
107
- imageAspectRatio={ImageRatios.Original}
108
- imageCaption="Image caption"
109
- imageCredit="Image credit"
110
- imagePosition={StructuredContentImagePosition.Left}
111
- imageSize={ImageSizes.Medium}
112
- imageSrc="https://placeimg.com/400/300/animals"
113
- bodyContent={htmlDOMBodyContent}
109
+ imageProps={{
110
+ alt: "Image alt text",
111
+ aspectRatio: ImageRatios.Original,
112
+ caption: "Image caption",
113
+ credit: "Image credit",
114
+ position: StructuredContentImagePosition.Left,
115
+ size: ImageSizes.Medium,
116
+ src: "https://placeimg.com/400/300/animals",
117
+ }}
114
118
  />
115
119
  );
116
120
  expect(await axe(container)).toHaveNoViolations();
@@ -119,9 +123,9 @@ describe("StructuredContent Accessibility", () => {
119
123
  it("passes axe accessibility without an image", async () => {
120
124
  const { container } = render(
121
125
  <StructuredContent
126
+ bodyContent={htmlStringBodyContent}
122
127
  calloutText="This is the callout text"
123
128
  headingText="Heading text"
124
- bodyContent={htmlStringBodyContent}
125
129
  />
126
130
  );
127
131
  expect(await axe(container)).toHaveNoViolations();
@@ -132,16 +136,18 @@ describe("StructuredContent", () => {
132
136
  it("renders two headings, an image, and body text", () => {
133
137
  render(
134
138
  <StructuredContent
139
+ bodyContent={htmlStringBodyContent}
135
140
  calloutText="This is the callout text"
136
141
  headingText="Heading text"
137
- imageAlt="Image alt text"
138
- imageAspectRatio={ImageRatios.Original}
139
- imageCaption="Image caption"
140
- imageCredit="Image credit"
141
- imagePosition={StructuredContentImagePosition.Left}
142
- imageSize={ImageSizes.Medium}
143
- imageSrc="https://placeimg.com/400/300/animals"
144
- bodyContent={htmlStringBodyContent}
142
+ imageProps={{
143
+ alt: "Image alt text",
144
+ aspectRatio: ImageRatios.Original,
145
+ caption: "Image caption",
146
+ credit: "Image credit",
147
+ position: StructuredContentImagePosition.Left,
148
+ size: ImageSizes.Medium,
149
+ src: "https://placeimg.com/400/300/animals",
150
+ }}
145
151
  />
146
152
  );
147
153
  const mainHeading = screen.getByRole("heading", { level: 2 });
@@ -156,14 +162,16 @@ describe("StructuredContent", () => {
156
162
  it("optionally renders without the headings", () => {
157
163
  render(
158
164
  <StructuredContent
159
- imageAlt="Image alt text"
160
- imageAspectRatio={ImageRatios.Original}
161
- imageCaption="Image caption"
162
- imageCredit="Image credit"
163
- imagePosition={StructuredContentImagePosition.Left}
164
- imageSize={ImageSizes.Medium}
165
- imageSrc="https://placeimg.com/400/300/animals"
166
165
  bodyContent={htmlStringBodyContent}
166
+ imageProps={{
167
+ alt: "Image alt text",
168
+ aspectRatio: ImageRatios.Original,
169
+ caption: "Image caption",
170
+ credit: "Image credit",
171
+ position: StructuredContentImagePosition.Left,
172
+ size: ImageSizes.Medium,
173
+ src: "https://placeimg.com/400/300/animals",
174
+ }}
167
175
  />
168
176
  );
169
177
  const mainHeading = screen.queryByRole("heading", { level: 2 });
@@ -178,9 +186,9 @@ describe("StructuredContent", () => {
178
186
  it("optionally renders without the image", () => {
179
187
  render(
180
188
  <StructuredContent
189
+ bodyContent={htmlStringBodyContent}
181
190
  calloutText="This is the callout text"
182
191
  headingText="Heading text"
183
- bodyContent={htmlStringBodyContent}
184
192
  />
185
193
  );
186
194
  const mainHeading = screen.getByRole("heading", { level: 2 });
@@ -192,24 +200,27 @@ describe("StructuredContent", () => {
192
200
  expect(screen.getByText(/Lorem ipsum dolor sit amet/i)).toBeInTheDocument();
193
201
  });
194
202
 
195
- it("logs a warning when an image is used but no alt text is passed to `imageAlt`", () => {
203
+ it("logs a warning when an image is used but no alt text is passed to `imageProps.alt`", () => {
196
204
  const warn = jest.spyOn(console, "warn");
197
205
  render(
198
206
  <StructuredContent
207
+ bodyContent={htmlStringBodyContent}
199
208
  calloutText="This is the callout text"
200
209
  headingText="Heading text"
201
- imageAspectRatio={ImageRatios.Original}
202
- imageCaption="Image caption"
203
- imageCredit="Image credit"
204
- imagePosition={StructuredContentImagePosition.Left}
205
- imageSize={ImageSizes.Medium}
206
- imageSrc="https://placeimg.com/400/300/animals"
207
- bodyContent={htmlStringBodyContent}
210
+ imageProps={{
211
+ aspectRatio: ImageRatios.Original,
212
+ caption: "Image caption",
213
+ credit: "Image credit",
214
+ position: StructuredContentImagePosition.Left,
215
+ size: ImageSizes.Medium,
216
+ src: "https://placeimg.com/400/300/animals",
217
+ }}
208
218
  />
209
219
  );
210
220
 
211
221
  expect(warn).toHaveBeenCalledWith(
212
- "StructuredContent: `imageAlt` prop is required when using an image."
222
+ "NYPL Reservoir StructuredContent: The `imageProps.alt` prop is required " +
223
+ "when using an image."
213
224
  );
214
225
  expect(screen.getByRole("img")).toBeInTheDocument();
215
226
  });
@@ -217,16 +228,18 @@ describe("StructuredContent", () => {
217
228
  it("renders an image wrapped in figure when provided an image caption or credit", () => {
218
229
  const { rerender } = render(
219
230
  <StructuredContent
231
+ bodyContent={htmlStringBodyContent}
220
232
  calloutText="This is the callout text"
221
233
  headingText="Heading text"
222
- imageAlt="Image alt text"
223
- imageAspectRatio={ImageRatios.Original}
224
- imageCaption="Image caption"
225
- imageCredit="Image credit"
226
- imagePosition={StructuredContentImagePosition.Left}
227
- imageSize={ImageSizes.Medium}
228
- imageSrc="https://placeimg.com/400/300/animals"
229
- bodyContent={htmlStringBodyContent}
234
+ imageProps={{
235
+ alt: "Image alt text",
236
+ aspectRatio: ImageRatios.Original,
237
+ caption: "Image caption",
238
+ credit: "Image credit",
239
+ position: StructuredContentImagePosition.Left,
240
+ size: ImageSizes.Medium,
241
+ src: "https://placeimg.com/400/300/animals",
242
+ }}
230
243
  />
231
244
  );
232
245
  expect(screen.getByRole("img")).toBeInTheDocument();
@@ -237,15 +250,17 @@ describe("StructuredContent", () => {
237
250
  // Not passing in the image's caption
238
251
  rerender(
239
252
  <StructuredContent
253
+ bodyContent={htmlStringBodyContent}
240
254
  calloutText="This is the callout text"
241
255
  headingText="Heading text"
242
- imageAlt="Image alt text"
243
- imageAspectRatio={ImageRatios.Original}
244
- imageCredit="Image credit"
245
- imagePosition={StructuredContentImagePosition.Left}
246
- imageSize={ImageSizes.Medium}
247
- imageSrc="https://placeimg.com/400/300/animals"
248
- bodyContent={htmlStringBodyContent}
256
+ imageProps={{
257
+ alt: "Image alt text",
258
+ aspectRatio: ImageRatios.Original,
259
+ credit: "Image credit",
260
+ position: StructuredContentImagePosition.Left,
261
+ size: ImageSizes.Medium,
262
+ src: "https://placeimg.com/400/300/animals",
263
+ }}
249
264
  />
250
265
  );
251
266
  expect(screen.getByRole("img")).toBeInTheDocument();
@@ -257,14 +272,16 @@ describe("StructuredContent", () => {
257
272
  it("renders a simple image element when no image caption or credit are provided", () => {
258
273
  render(
259
274
  <StructuredContent
275
+ bodyContent={htmlStringBodyContent}
260
276
  calloutText="This is the callout text"
261
277
  headingText="Heading text"
262
- imageAlt="Image alt text"
263
- imageAspectRatio={ImageRatios.Original}
264
- imagePosition={StructuredContentImagePosition.Left}
265
- imageSize={ImageSizes.Medium}
266
- imageSrc="https://placeimg.com/400/300/animals"
267
- bodyContent={htmlStringBodyContent}
278
+ imageProps={{
279
+ alt: "Image alt text",
280
+ aspectRatio: ImageRatios.Original,
281
+ position: StructuredContentImagePosition.Left,
282
+ size: ImageSizes.Medium,
283
+ src: "https://placeimg.com/400/300/animals",
284
+ }}
268
285
  />
269
286
  );
270
287
  expect(screen.getByRole("img")).toBeInTheDocument();
@@ -277,91 +294,101 @@ describe("StructuredContent", () => {
277
294
  const withHTMLStringContent = renderer
278
295
  .create(
279
296
  <StructuredContent
297
+ bodyContent={htmlStringBodyContent}
280
298
  calloutText="This is the callout text"
281
299
  headingText="Heading text"
282
300
  id="withHTMLStringContent"
283
- imageAlt="Image alt text"
284
- imageAspectRatio={ImageRatios.Original}
285
- imageCaption="Image caption"
286
- imageCredit="Image credit"
287
- imagePosition={StructuredContentImagePosition.Left}
288
- imageSize={ImageSizes.Medium}
289
- imageSrc="https://placeimg.com/400/300/animals"
290
- bodyContent={htmlStringBodyContent}
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
+ }}
291
310
  />
292
311
  )
293
312
  .toJSON();
294
313
  const withHTMLDOMContent = renderer
295
314
  .create(
296
315
  <StructuredContent
316
+ bodyContent={htmlDOMBodyContent}
297
317
  calloutText="This is the callout text"
298
318
  headingText="Heading text"
299
319
  id="withHTMLDOMContent"
300
- imageAlt="Image alt text"
301
- imageAspectRatio={ImageRatios.Original}
302
- imageCaption="Image caption"
303
- imageCredit="Image credit"
304
- imagePosition={StructuredContentImagePosition.Left}
305
- imageSize={ImageSizes.Medium}
306
- imageSrc="https://placeimg.com/400/300/animals"
307
- bodyContent={htmlDOMBodyContent}
320
+ imageProps={{
321
+ alt: "Image alt text",
322
+ aspectRatio: ImageRatios.Original,
323
+ caption: "Image caption",
324
+ credit: "Image credit",
325
+ position: StructuredContentImagePosition.Left,
326
+ size: ImageSizes.Medium,
327
+ src: "https://placeimg.com/400/300/animals",
328
+ }}
308
329
  />
309
330
  )
310
331
  .toJSON();
311
332
  const withoutAnImage = renderer
312
333
  .create(
313
334
  <StructuredContent
335
+ bodyContent={htmlStringBodyContent}
314
336
  calloutText="This is the callout text"
315
337
  headingText="Heading text"
316
338
  id="withoutAnImage"
317
- bodyContent={htmlStringBodyContent}
318
339
  />
319
340
  )
320
341
  .toJSON();
321
342
  const withImageWithoutCaptionOrCredit = renderer
322
343
  .create(
323
344
  <StructuredContent
345
+ bodyContent={htmlStringBodyContent}
324
346
  calloutText="This is the callout text"
325
347
  headingText="Heading text"
326
348
  id="withImageWithoutCaptionOrCredit"
327
- imageAlt="Image alt text"
328
- imageAspectRatio={ImageRatios.Original}
329
- imagePosition={StructuredContentImagePosition.Left}
330
- imageSize={ImageSizes.Medium}
331
- imageSrc="https://placeimg.com/400/300/animals"
332
- bodyContent={htmlStringBodyContent}
349
+ imageProps={{
350
+ alt: "Image alt text",
351
+ aspectRatio: ImageRatios.Original,
352
+ position: StructuredContentImagePosition.Left,
353
+ size: ImageSizes.Medium,
354
+ src: "https://placeimg.com/400/300/animals",
355
+ }}
333
356
  />
334
357
  )
335
358
  .toJSON();
336
359
  const withoutHeading = renderer
337
360
  .create(
338
361
  <StructuredContent
362
+ bodyContent={htmlStringBodyContent}
339
363
  calloutText="This is the callout text"
340
364
  id="withoutHeading"
341
- imageAlt="Image alt text"
342
- imageAspectRatio={ImageRatios.Original}
343
- imageCaption="Image caption"
344
- imageCredit="Image credit"
345
- imagePosition={StructuredContentImagePosition.Left}
346
- imageSize={ImageSizes.Medium}
347
- imageSrc="https://placeimg.com/400/300/animals"
348
- bodyContent={htmlStringBodyContent}
365
+ imageProps={{
366
+ alt: "Image alt text",
367
+ aspectRatio: ImageRatios.Original,
368
+ caption: "Image caption",
369
+ credit: "Image credit",
370
+ position: StructuredContentImagePosition.Left,
371
+ size: ImageSizes.Medium,
372
+ src: "https://placeimg.com/400/300/animals",
373
+ }}
349
374
  />
350
375
  )
351
376
  .toJSON();
352
377
  const withoutCalloutText = renderer
353
378
  .create(
354
379
  <StructuredContent
380
+ bodyContent={htmlStringBodyContent}
355
381
  headingText="Heading text"
356
382
  id="withoutCalloutText"
357
- imageAlt="Image alt text"
358
- imageAspectRatio={ImageRatios.Original}
359
- imageCaption="Image caption"
360
- imageCredit="Image credit"
361
- imagePosition={StructuredContentImagePosition.Left}
362
- imageSize={ImageSizes.Medium}
363
- imageSrc="https://placeimg.com/400/300/animals"
364
- bodyContent={htmlStringBodyContent}
383
+ imageProps={{
384
+ alt: "Image alt text",
385
+ aspectRatio: ImageRatios.Original,
386
+ caption: "Image caption",
387
+ credit: "Image credit",
388
+ position: StructuredContentImagePosition.Left,
389
+ size: ImageSizes.Medium,
390
+ src: "https://placeimg.com/400/300/animals",
391
+ }}
365
392
  />
366
393
  )
367
394
  .toJSON();
@@ -2,12 +2,18 @@ import * as React from "react";
2
2
  import { Box, useMultiStyleConfig } from "@chakra-ui/react";
3
3
 
4
4
  import Heading from "../Heading/Heading";
5
- import { HeadingDisplaySizes, HeadingLevels } from "../Heading/HeadingTypes";
6
- import Image, { ImageProps } from "../Image/Image";
5
+ import { HeadingSizes, HeadingLevels } from "../Heading/HeadingTypes";
6
+ import Image, { ComponentImageProps, ImageProps } from "../Image/Image";
7
7
  import { ImageRatios, ImageSizes } from "../Image/ImageTypes";
8
8
  import { StructuredContentImagePosition } from "./StructuredContentTypes";
9
9
  import generateUUID from "../../helpers/generateUUID";
10
10
 
11
+ interface StructuredContentImageProps extends ComponentImageProps {
12
+ /** Optional value to control the positioning of the internal `Image` component.
13
+ * Defaults to `StructuredContentImagePosition.Left`. */
14
+ position?: StructuredContentImagePosition;
15
+ }
16
+
11
17
  export interface StructuredContentProps {
12
18
  /** Optional value to set the text for the callout heading text. */
13
19
  calloutText?: string;
@@ -17,27 +23,8 @@ export interface StructuredContentProps {
17
23
  headingText?: string;
18
24
  /** ID that other components can cross reference for accessibility purposes. */
19
25
  id?: string;
20
- /** String value used to populate the `alt` attribute of the internal `Image`
21
- * component's `img` element. @NOTE if an image is used, this value must be passed. */
22
- imageAlt?: string;
23
- /** Optional value to control the aspect ratio of the internal `Image` component.
24
- * Defaults to `ImageRatios.Square`. */
25
- imageAspectRatio?: ImageRatios;
26
- /** Optional value to render as a caption for the internal `Image` component. */
27
- imageCaption?: string;
28
- /** Optional DOM element to use instead of the DS `Image` component. */
29
- imageComponent?: JSX.Element;
30
- /** Optional value to render as a credit for the internal `Image` component. */
31
- imageCredit?: string;
32
- /** Optional value to control the positioning of the internal `Image` component.
33
- * Defaults to `StructuredContentImagePosition.Left`. */
34
- imagePosition?: StructuredContentImagePosition;
35
- /** Optional value to control the size of the internal `Image` component.
36
- * Defaults to `ImageSizes.Medium`. */
37
- imageSize?: ImageSizes;
38
- /** Optional value that contains the path to an image. If omitted, the internal
39
- * DS `Image` component will not render. */
40
- imageSrc?: string;
26
+ /** Object used to create and render the `Image` component. */
27
+ imageProps?: StructuredContentImageProps;
41
28
  /** Required value to set the text for the body content. */
42
29
  bodyContent: string | JSX.Element;
43
30
  }
@@ -52,11 +39,11 @@ function StructuredContentImage(props: ImageProps) {
52
39
  additionalImageStyles,
53
40
  additionalWrapperStyles,
54
41
  alt,
42
+ aspectRatio,
43
+ caption,
55
44
  component,
56
- imageAspectRatio,
57
- imageCaption,
58
- imageCredit,
59
- imageSize,
45
+ credit,
46
+ size,
60
47
  src,
61
48
  } = props;
62
49
  return (
@@ -66,10 +53,10 @@ function StructuredContentImage(props: ImageProps) {
66
53
  additionalWrapperStyles={additionalWrapperStyles}
67
54
  alt={alt}
68
55
  component={component}
69
- imageAspectRatio={imageAspectRatio}
70
- imageSize={imageSize}
71
- imageCaption={imageCaption}
72
- imageCredit={imageCredit}
56
+ aspectRatio={aspectRatio}
57
+ size={size}
58
+ caption={caption}
59
+ credit={credit}
73
60
  src={src}
74
61
  />
75
62
  );
@@ -87,22 +74,24 @@ export default function StructuredContent(
87
74
  className,
88
75
  headingText,
89
76
  id = generateUUID(),
90
- imageAlt = "",
91
- imageAspectRatio = ImageRatios.Square,
92
- imageCaption,
93
- imageComponent,
94
- imageCredit,
95
- imagePosition = StructuredContentImagePosition.Left,
96
- imageSize = ImageSizes.Medium,
97
- imageSrc,
77
+ imageProps = {
78
+ alt: "",
79
+ aspectRatio: ImageRatios.Square,
80
+ caption: undefined,
81
+ component: undefined,
82
+ credit: undefined,
83
+ position: StructuredContentImagePosition.Left,
84
+ size: ImageSizes.Medium,
85
+ src: "",
86
+ },
98
87
  bodyContent,
99
88
  } = props;
100
- const hasImage = imageSrc || imageComponent;
101
- const hasFigureImage = imageCaption || imageCredit;
89
+ const hasImage = imageProps.src || imageProps.component;
90
+ const hasFigureImage = imageProps.caption || imageProps.credit;
102
91
  const styles = useMultiStyleConfig("StructuredContent", {
103
92
  hasFigureImage,
104
- imageAspectRatio,
105
- imagePosition,
93
+ imageAspectRatio: imageProps.aspectRatio,
94
+ imagePosition: imageProps.position,
106
95
  });
107
96
  const finalBodyContent =
108
97
  typeof bodyContent === "string" ? (
@@ -111,9 +100,10 @@ export default function StructuredContent(
111
100
  <Box>{bodyContent}</Box>
112
101
  );
113
102
 
114
- if (hasImage && !imageAlt) {
103
+ if (hasImage && !imageProps.alt) {
115
104
  console.warn(
116
- "StructuredContent: `imageAlt` prop is required when using an image."
105
+ "NYPL Reservoir StructuredContent: The `imageProps.alt` prop is required " +
106
+ "when using an image."
117
107
  );
118
108
  }
119
109
 
@@ -126,9 +116,9 @@ export default function StructuredContent(
126
116
  )}
127
117
  {calloutText && (
128
118
  <Heading
129
- displaySize={HeadingDisplaySizes.Callout}
130
119
  id={`${id}-callout`}
131
120
  level={HeadingLevels.Three}
121
+ size={HeadingSizes.Callout}
132
122
  >
133
123
  {calloutText}
134
124
  </Heading>
@@ -138,13 +128,13 @@ export default function StructuredContent(
138
128
  additionalFigureStyles={styles.imageFigure}
139
129
  additionalImageStyles={styles.image}
140
130
  additionalWrapperStyles={styles.imageWrapper}
141
- alt={imageAlt}
142
- component={imageComponent}
143
- imageAspectRatio={imageAspectRatio}
144
- imageCaption={imageCaption}
145
- imageCredit={imageCredit}
146
- imageSize={imageSize}
147
- src={imageSrc ? imageSrc : null}
131
+ alt={imageProps.alt}
132
+ component={imageProps.component}
133
+ aspectRatio={imageProps.aspectRatio}
134
+ caption={imageProps.caption}
135
+ credit={imageProps.credit}
136
+ size={imageProps.size}
137
+ src={imageProps.src ? imageProps.src : null}
148
138
  />
149
139
  )}
150
140
  {finalBodyContent}
@@ -1,9 +1,9 @@
1
1
  import * as React from "react";
2
2
 
3
3
  import Card from "../Card/Card";
4
- import { CardLayouts } from "../Card/CardTypes";
5
4
  import Heading from "../Heading/Heading";
6
5
  import { HeadingLevels } from "../Heading/HeadingTypes";
6
+ import { LayoutTypes } from "../../helpers/enums";
7
7
 
8
8
  export interface ColorCardProps {
9
9
  /** backgroundColor of the color card */
@@ -25,9 +25,9 @@ export default function ColorCard(
25
25
  <div style={{ display: "flex", alignItems: "center" }}>
26
26
  <Card
27
27
  backgroundColor={backgroundColor}
28
- center
29
- layout={CardLayouts.Column}
30
28
  border
29
+ isCentered
30
+ layout={LayoutTypes.Column}
31
31
  />
32
32
  <div style={{ marginLeft: "1rem" }}>
33
33
  <Heading level={HeadingLevels.Four}>{colorName}</Heading>
@@ -2,11 +2,11 @@ import { Canvas, Meta } from "@storybook/addon-docs";
2
2
  import { withDesign } from "storybook-addon-designs";
3
3
 
4
4
  import Heading from "../Heading/Heading";
5
- import { HeadingDisplaySizes, HeadingLevels } from "../Heading/HeadingTypes";
5
+ import { HeadingSizes, HeadingLevels } from "../Heading/HeadingTypes";
6
6
  import List from "../List/List";
7
7
  import { ListTypes } from "../List/ListTypes";
8
8
  import Text from "../Text/Text";
9
- import { TextDisplaySizes } from "../Text/TextTypes";
9
+ import { TextSizes } from "../Text/TextTypes";
10
10
  import { getCategory } from "../../utils/componentCategories";
11
11
  import DSProvider from "../../theme/provider";
12
12
 
@@ -59,9 +59,14 @@ Use the NYPL Design System [Heading](/docs/components-typography-styles-heading-
59
59
 
60
60
  <DSProvider>
61
61
 
62
- Each heading level has a default style and size, but those styles can be overridden using the `displaySize` prop. The display sizes are separate from semantic elements and may be used to override the default size and styling of the semantic HTML heading elements. For example, the `h1` element has the `Primary` style applied by default, but a new style can be applied through the `displaySize` prop. Any `displaySize` style can be applied to any `Heading` element.
62
+ Each heading level has a default style and size, but those styles can be overridden
63
+ using the `size` prop. The display sizes are separate from semantic elements and
64
+ may be used to override the default size and styling of the semantic HTML heading
65
+ elements. For example, the `h1` element has the `Primary` style applied by default,
66
+ but a new style can be applied through the `size` prop. Any `size` style can be
67
+ applied to any `Heading` element.
63
68
 
64
- <Heading level={HeadingLevels.One} displaySize={HeadingDisplaySizes.Primary}>
69
+ <Heading level={HeadingLevels.One} size={HeadingSizes.Primary}>
65
70
  Primary Heading
66
71
  </Heading>
67
72
 
@@ -71,7 +76,7 @@ Each heading level has a default style and size, but those styles can be overrid
71
76
  | **Font Weight** | `300` | `fontWeight: "heading.primary"` | `font-weight: var(--nypl-fontWeights-heading-primary)` |
72
77
  | **Line Height** | `1.1` | n/a | n/a |
73
78
 
74
- <Heading level={HeadingLevels.One} displaySize={HeadingDisplaySizes.Secondary}>
79
+ <Heading level={HeadingLevels.One} size={HeadingSizes.Secondary}>
75
80
  Secondary Heading
76
81
  </Heading>
77
82
 
@@ -81,7 +86,7 @@ Each heading level has a default style and size, but those styles can be overrid
81
86
  | **Font Weight** | `500` | `fontWeight: "heading.secondary"` | `font-weight: var(--nypl-fontWeights-heading-secondary)` |
82
87
  | **Line Height** | `1.25` | n/a | n/a |
83
88
 
84
- <Heading level={HeadingLevels.One} displaySize={HeadingDisplaySizes.Tertiary}>
89
+ <Heading level={HeadingLevels.One} size={HeadingSizes.Tertiary}>
85
90
  Tertiary Heading
86
91
  </Heading>
87
92
 
@@ -91,7 +96,7 @@ Each heading level has a default style and size, but those styles can be overrid
91
96
  | **Font Weight** | `500` | `fontWeight: "heading.tertiary"` | `font-weight: var(--nypl-fontWeights-heading-tertiary)` |
92
97
  | **Line Height** | `1.25` | n/a | n/a |
93
98
 
94
- <Heading level={HeadingLevels.One} displaySize={HeadingDisplaySizes.Callout}>
99
+ <Heading level={HeadingLevels.One} size={HeadingSizes.Callout}>
95
100
  Callout Heading
96
101
  </Heading>
97
102
 
@@ -122,12 +127,12 @@ Use the NYPL Design System [Text](/docs/components-typography-styles-text--text)
122
127
 
123
128
  <DSProvider>
124
129
 
125
- The `displaySize` prop can be used to render a specific style from the DS default text styles.
130
+ The `size` prop can be used to render a specific style from the DS default text styles.
126
131
 
127
132
  - [Typography: Body Styles](https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Main?node-id=10975%3A52)
128
133
  - [Typography: Other Styles](https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Main?node-id=10975%3A100)
129
134
 
130
- <Text displaySize={TextDisplaySizes.Default}>Default</Text>
135
+ <Text size={TextSizes.Default}>Default</Text>
131
136
 
132
137
  | | Value | JS Theme Object | CSS Variable |
133
138
  | --------------- | ------ | ---------------------------- | --------------------------------------------------- |
@@ -135,7 +140,7 @@ The `displaySize` prop can be used to render a specific style from the DS defaul
135
140
  | **Font Weight** | `300` | `fontWeight: "text.default"` | `font-weight: var(--nypl-fontWeights-text-default)` |
136
141
  | **Line Height** | `1.5` | `fontWeight: 1.5` | `font-weight: 1.5` |
137
142
 
138
- <Text displaySize={TextDisplaySizes.Caption}>Caption</Text>
143
+ <Text size={TextSizes.Caption}>Caption</Text>
139
144
 
140
145
  | | Value | JS Theme Object | CSS Variable |
141
146
  | --------------- | ---------- | ---------------------------- | --------------------------------------------------- |
@@ -143,7 +148,7 @@ The `displaySize` prop can be used to render a specific style from the DS defaul
143
148
  | **Font Weight** | `300` | `fontWeight: "text.caption"` | `font-weight: var(--nypl-fontWeights-text-caption)` |
144
149
  | **Line Height** | `1.25` | `fontWeight: 1.25` | `font-weight: 1.25` |
145
150
 
146
- <Text displaySize={TextDisplaySizes.Tag}>Tag</Text>
151
+ <Text size={TextSizes.Tag}>Tag</Text>
147
152
 
148
153
  | | Value | JS Theme Object | CSS Variable |
149
154
  | --------------- | --------- | ------------------------ | ----------------------------------------------- |
@@ -151,7 +156,7 @@ The `displaySize` prop can be used to render a specific style from the DS defaul
151
156
  | **Font Weight** | `400` | `fontWeight: "text.tag"` | `font-weight: var(--nypl-fontWeights-text-tag)` |
152
157
  | **Line Height** | `1.5` | `fontWeight: 1.5` | `font-weight: 1.5` |
153
158
 
154
- <Text displaySize={TextDisplaySizes.Mini}>Mini</Text>
159
+ <Text size={TextSizes.Mini}>Mini</Text>
155
160
 
156
161
  | | Value | JS Theme Object | CSS Variable |
157
162
  | --------------- | ---------- | ------------------------- | ------------------------------------------------ |