@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
@@ -1,3 +1,4 @@
1
+ import { Flex, Spacer } from "@chakra-ui/react";
1
2
  import { action } from "@storybook/addon-actions";
2
3
  import {
3
4
  ArgsTable,
@@ -172,14 +173,51 @@ need to render multiple input components in a horizontal row.
172
173
  <FormRow>
173
174
  <FormField>
174
175
  <CheckboxGroup
176
+ isFullWidth
175
177
  labelText="Checkbox Group"
176
- name="cbg1"
178
+ name="checkbox-example"
177
179
  optReqFlag={false}
178
180
  >
179
- <Checkbox labelText="Checkbox 1" showLabel />
180
- <Checkbox labelText="Checkbox 2" showLabel />
181
- <Checkbox labelText="Checkbox 3" showLabel />
182
- <Checkbox labelText="Checkbox 4" showLabel />
181
+ <Checkbox
182
+ labelText={
183
+ <Flex>
184
+ <span>Arts</span>
185
+ <Spacer />
186
+ <span>4</span>
187
+ </Flex>
188
+ }
189
+ value="arts"
190
+ />
191
+ <Checkbox
192
+ labelText={
193
+ <Flex>
194
+ <span>English</span>
195
+ <Spacer />
196
+ <span>23</span>
197
+ </Flex>
198
+ }
199
+ value="English"
200
+ />
201
+ <Checkbox
202
+ labelText={
203
+ <Flex>
204
+ <span>Science</span>
205
+ <Spacer />
206
+ <span>10</span>
207
+ </Flex>
208
+ }
209
+ value="Science"
210
+ />
211
+ <Checkbox
212
+ labelText={
213
+ <Flex>
214
+ <span>Math</span>
215
+ <Spacer />
216
+ <span>3</span>
217
+ </Flex>
218
+ }
219
+ value="Math"
220
+ />
183
221
  </CheckboxGroup>
184
222
  </FormField>
185
223
  <FormField>
@@ -192,9 +230,9 @@ need to render multiple input components in a horizontal row.
192
230
  </FormField>
193
231
  <FormField>
194
232
  <Select
233
+ helperText="The select field helper text."
195
234
  labelText="Select Field"
196
235
  showLabel={true}
197
- helperText="The select field helper text."
198
236
  >
199
237
  <option>Option 1</option>
200
238
  <option>Option 2</option>
@@ -225,9 +263,9 @@ export const formRow = (nameString, size) => {
225
263
  <FormRow>
226
264
  <FormField>
227
265
  <Select
266
+ helperText="The select field helper text."
228
267
  labelText="Select Field"
229
268
  showLabel={true}
230
- helperText="The select field helper text."
231
269
  >
232
270
  <option>Option 1</option>
233
271
  <option>Option 2</option>
@@ -237,9 +275,9 @@ export const formRow = (nameString, size) => {
237
275
  </FormField>
238
276
  <FormField>
239
277
  <Select
278
+ helperText="The select field helper text."
240
279
  labelText="Select Field"
241
280
  showLabel={true}
242
- helperText="The select field helper text."
243
281
  >
244
282
  <option>Option 1</option>
245
283
  <option>Option 2</option>
@@ -249,9 +287,9 @@ export const formRow = (nameString, size) => {
249
287
  </FormField>
250
288
  <FormField>
251
289
  <Select
290
+ helperText="The select field helper text."
252
291
  labelText="Select Field"
253
292
  showLabel={true}
254
- helperText="The select field helper text."
255
293
  >
256
294
  <option>Option 1</option>
257
295
  <option>Option 2</option>
@@ -169,7 +169,7 @@ describe("Form", () => {
169
169
  </Form>
170
170
  );
171
171
  expect(warn).toHaveBeenCalledWith(
172
- "FormRow children must be `FormField` components."
172
+ "NYPL Reservoir FormRow: Children must be `FormField` components."
173
173
  );
174
174
  });
175
175
 
@@ -37,7 +37,9 @@ export function FormRow(props: React.PropsWithChildren<FormChildProps>) {
37
37
  if (child.type === FormField || child.props.mdxType === "FormField") {
38
38
  return React.cloneElement(child, { id: `${id}-grandchild${i}` });
39
39
  }
40
- console.warn("FormRow children must be `FormField` components.");
40
+ console.warn(
41
+ "NYPL Reservoir FormRow: Children must be `FormField` components."
42
+ );
41
43
  return null;
42
44
  }
43
45
  );
@@ -10,8 +10,7 @@ import { withDesign } from "storybook-addon-designs";
10
10
  import SimpleGrid from "./SimpleGrid";
11
11
  import { GridGaps } from "./GridTypes";
12
12
  import Card, { CardHeading, CardContent, CardActions } from "../Card/Card";
13
- import { CardLayouts } from "../Card/CardTypes";
14
- import { HeadingDisplaySizes, HeadingLevels } from "../Heading/HeadingTypes";
13
+ import { HeadingSizes, HeadingLevels } from "../Heading/HeadingTypes";
15
14
  import Icon from "../Icons/Icon";
16
15
  import {
17
16
  IconNames,
@@ -21,6 +20,7 @@ import {
21
20
  } from "../Icons/IconTypes";
22
21
  import Image from "../Image/Image";
23
22
  import { ImageRatios } from "../Image/ImageTypes";
23
+ import { LayoutTypes } from "../../helpers/enums";
24
24
  import { getCategory } from "../../utils/componentCategories";
25
25
  import DSProvider from "../../theme/provider";
26
26
  import { getStorybookEnumValues } from "../../utils/utils";
@@ -78,9 +78,11 @@ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for t
78
78
  {(args) => (
79
79
  <SimpleGrid {...args} gap={enumValues.getValue(args.gap)}>
80
80
  <Card
81
- imageSrc="https://placeimg.com/400/220/animals"
82
- imageAlt="Alt text"
83
- imageAspectRatio={ImageRatios.TwoByOne}
81
+ imageProps={{
82
+ alt: "Alt text",
83
+ aspectRatio: ImageRatios.TwoByOne,
84
+ src: "https://placeimg.com/400/220/animals",
85
+ }}
84
86
  >
85
87
  <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
86
88
  <CardContent>
@@ -89,9 +91,11 @@ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for t
89
91
  </CardContent>
90
92
  </Card>
91
93
  <Card
92
- imageSrc="https://placeimg.com/400/220/animals"
93
- imageAlt="Alt text"
94
- imageAspectRatio={ImageRatios.TwoByOne}
94
+ imageProps={{
95
+ alt: "Alt text",
96
+ aspectRatio: ImageRatios.TwoByOne,
97
+ src: "https://placeimg.com/400/220/animals",
98
+ }}
95
99
  >
96
100
  <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
97
101
  <CardContent>
@@ -100,9 +104,11 @@ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for t
100
104
  </CardContent>
101
105
  </Card>
102
106
  <Card
103
- imageSrc="https://placeimg.com/400/240/animals"
104
- imageAlt="Alt text"
105
- imageAspectRatio={ImageRatios.TwoByOne}
107
+ imageProps={{
108
+ alt: "Alt text",
109
+ aspectRatio: ImageRatios.TwoByOne,
110
+ src: "https://placeimg.com/400/240/animals",
111
+ }}
106
112
  >
107
113
  <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
108
114
  <CardContent>
@@ -111,9 +117,11 @@ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for t
111
117
  </CardContent>
112
118
  </Card>
113
119
  <Card
114
- imageSrc="https://placeimg.com/400/260/animals"
115
- imageAlt="Alt text"
116
- imageAspectRatio={ImageRatios.TwoByOne}
120
+ imageProps={{
121
+ alt: "Alt text",
122
+ aspectRatio: ImageRatios.TwoByOne,
123
+ src: "https://placeimg.com/400/260/animals",
124
+ }}
117
125
  >
118
126
  <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
119
127
  <CardContent>
@@ -122,9 +130,11 @@ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for t
122
130
  </CardContent>
123
131
  </Card>
124
132
  <Card
125
- imageSrc="https://placeimg.com/400/320/animals"
126
- imageAlt="Alt text"
127
- imageAspectRatio={ImageRatios.TwoByOne}
133
+ imageProps={{
134
+ alt: "Alt text",
135
+ aspectRatio: ImageRatios.TwoByOne,
136
+ src: "https://placeimg.com/400/320/animals",
137
+ }}
128
138
  >
129
139
  <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
130
140
  <CardContent>
@@ -133,9 +143,11 @@ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for t
133
143
  </CardContent>
134
144
  </Card>
135
145
  <Card
136
- imageSrc="https://placeimg.com/400/300/animals"
137
- imageAlt="Alt text"
138
- imageAspectRatio={ImageRatios.TwoByOne}
146
+ imageProps={{
147
+ alt: "Alt text",
148
+ aspectRatio: ImageRatios.TwoByOne,
149
+ src: "https://placeimg.com/400/300/animals",
150
+ }}
139
151
  >
140
152
  <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
141
153
  <CardContent>
@@ -213,12 +225,14 @@ This example is rendering horizontal `Card` components with the `columns` prop s
213
225
  <DSProvider>
214
226
  <SimpleGrid columns={1}>
215
227
  <Card
216
- layout={CardLayouts.Row}
217
228
  border
218
- center
219
- imageSrc="https://placeimg.com/400/200/animals"
220
- imageAlt="Alt text"
221
- imageAspectRatio={ImageRatios.FourByThree}
229
+ imageProps={{
230
+ alt: "Alt text",
231
+ aspectRatio: ImageRatios.FourByThree,
232
+ src: "https://placeimg.com/400/200/animals",
233
+ }}
234
+ isCentered
235
+ layout={LayoutTypes.Row}
222
236
  >
223
237
  <CardHeading level={HeadingLevels.Four} id="heading1">
224
238
  Card Heading
@@ -230,12 +244,14 @@ This example is rendering horizontal `Card` components with the `columns` prop s
230
244
  </CardContent>
231
245
  </Card>
232
246
  <Card
233
- layout={CardLayouts.Row}
234
247
  border
235
- center
236
- imageSrc="https://placeimg.com/410/210/animals"
237
- imageAlt="Alt text"
238
- imageAspectRatio={ImageRatios.FourByThree}
248
+ imageProps={{
249
+ alt: "Alt text",
250
+ aspectRatio: ImageRatios.FourByThree,
251
+ src: "https://placeimg.com/410/210/animals",
252
+ }}
253
+ isCentered
254
+ layout={LayoutTypes.Row}
239
255
  >
240
256
  <CardHeading level={HeadingLevels.Four} id="heading2">
241
257
  Card Heading
@@ -247,12 +263,14 @@ This example is rendering horizontal `Card` components with the `columns` prop s
247
263
  </CardContent>
248
264
  </Card>
249
265
  <Card
250
- layout={CardLayouts.Row}
251
266
  border
252
- center
253
- imageSrc="https://placeimg.com/320/320/animals"
254
- imageAlt="Alt text"
255
- imageAspectRatio={ImageRatios.FourByThree}
267
+ imageProps={{
268
+ alt: "Alt text",
269
+ aspectRatio: ImageRatios.FourByThree,
270
+ src: "https://placeimg.com/320/320/animals",
271
+ }}
272
+ isCentered
273
+ layout={LayoutTypes.Row}
256
274
  >
257
275
  <CardHeading level={HeadingLevels.Four} id="heading3">
258
276
  Card Heading
@@ -13,9 +13,11 @@ describe("Grid Accessibility", () => {
13
13
  const { container } = render(
14
14
  <SimpleGrid>
15
15
  <Card
16
- imageSrc="https://placeimg.com/500/200/animals"
17
- imageAlt="Alt text"
18
- imageAspectRatio={ImageRatios.TwoByOne}
16
+ imageProps={{
17
+ alt: "Alt text",
18
+ aspectRatio: ImageRatios.TwoByOne,
19
+ src: "https://placeimg.com/500/200/animals",
20
+ }}
19
21
  >
20
22
  <CardHeading level={HeadingLevels.Two}>Card Heading</CardHeading>
21
23
  <CardContent>
@@ -24,9 +26,11 @@ describe("Grid Accessibility", () => {
24
26
  </CardContent>
25
27
  </Card>
26
28
  <Card
27
- imageSrc="https://placeimg.com/400/220/animals"
28
- imageAlt="Alt text"
29
- imageAspectRatio={ImageRatios.TwoByOne}
29
+ imageProps={{
30
+ alt: "Alt text",
31
+ aspectRatio: ImageRatios.TwoByOne,
32
+ src: "https://placeimg.com/400/220/animals",
33
+ }}
30
34
  >
31
35
  <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
32
36
  <CardContent>
@@ -35,9 +39,11 @@ describe("Grid Accessibility", () => {
35
39
  </CardContent>
36
40
  </Card>
37
41
  <Card
38
- imageSrc="https://placeimg.com/400/240/animals"
39
- imageAlt="Alt text"
40
- imageAspectRatio={ImageRatios.TwoByOne}
42
+ imageProps={{
43
+ alt: "Alt text",
44
+ aspectRatio: ImageRatios.TwoByOne,
45
+ src: "https://placeimg.com/400/240/animals",
46
+ }}
41
47
  >
42
48
  <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
43
49
  <CardContent>
@@ -8,13 +8,13 @@ import {
8
8
  import { withDesign } from "storybook-addon-designs";
9
9
 
10
10
  import Heading from "./Heading";
11
- import { HeadingDisplaySizes, HeadingLevels } from "./HeadingTypes";
11
+ import { HeadingSizes, HeadingLevels } from "./HeadingTypes";
12
12
  import { getCategory } from "../../utils/componentCategories";
13
13
  import { getStorybookEnumValues } from "../../utils/utils";
14
14
 
15
15
  export const sizesEnumValues = getStorybookEnumValues(
16
- HeadingDisplaySizes,
17
- "HeadingDisplaySizes"
16
+ HeadingSizes,
17
+ "HeadingSizes"
18
18
  );
19
19
  export const levelsEnumValues = getStorybookEnumValues(
20
20
  HeadingLevels,
@@ -35,16 +35,16 @@ export const levelsEnumValues = getStorybookEnumValues(
35
35
  argTypes={{
36
36
  additionalStyles: { control: false },
37
37
  className: { control: false },
38
- displaySize: {
39
- control: { type: "select" },
40
- options: sizesEnumValues.options,
41
- },
42
38
  id: { control: false },
43
39
  level: {
44
40
  control: { type: "select" },
45
41
  options: levelsEnumValues.options,
46
42
  table: { defaultValue: { summary: "HeadingLevels.Two" } },
47
43
  },
44
+ size: {
45
+ control: { type: "select" },
46
+ options: sizesEnumValues.options,
47
+ },
48
48
  }}
49
49
  />
50
50
 
@@ -53,13 +53,13 @@ export const levelsEnumValues = getStorybookEnumValues(
53
53
  | Component Version | DS Version |
54
54
  | ----------------- | ---------- |
55
55
  | Added | `0.0.4` |
56
- | Latest | `0.25.9` |
56
+ | Latest | `0.25.13` |
57
57
 
58
58
  <Description of={Heading} />
59
59
 
60
60
  A `Heading` component will render a standard HTML `<h>` tag (1-6). The heading's
61
61
  text can be passed in through a `text` prop or as a child. Default styles for
62
- semantic elements can be overwritten using the `displaySize` prop.
62
+ semantic elements can be overwritten using the `size` prop.
63
63
 
64
64
  <Canvas withToolbar>
65
65
  <Story
@@ -67,9 +67,9 @@ semantic elements can be overwritten using the `displaySize` prop.
67
67
  args={{
68
68
  additionalStyles: undefined,
69
69
  className: undefined,
70
- displaySize: undefined,
71
70
  id: "heading-id",
72
71
  level: "HeadingLevels.Two",
72
+ size: undefined,
73
73
  text: "Default Heading",
74
74
  url: undefined,
75
75
  urlClass: undefined,
@@ -78,10 +78,8 @@ semantic elements can be overwritten using the `displaySize` prop.
78
78
  {(args) => (
79
79
  <Heading
80
80
  {...args}
81
- displaySize={
82
- args.displaySize && sizesEnumValues.getValue(args.displaySize)
83
- }
84
81
  level={levelsEnumValues.getValue(args.level)}
82
+ size={args.size && sizesEnumValues.getValue(args.size)}
85
83
  />
86
84
  )}
87
85
  </Story>
@@ -128,37 +126,37 @@ semantic elements can be overwritten using the `displaySize` prop.
128
126
  </Story>
129
127
  </Canvas>
130
128
 
131
- ## DisplaySize Styles
129
+ ## Size Styles
132
130
 
133
131
  Note: The `level` prop for the `Heading`s in the next example are all set to
134
132
  `level={HeadingLevels.One}`.
135
133
 
136
134
  <Canvas>
137
- <Story name="DisplaySize Styles">
135
+ <Story name="Size Styles">
138
136
  <div>
139
137
  <Heading
140
138
  id="heading-primary"
141
139
  level={HeadingLevels.One}
142
- displaySize={HeadingDisplaySizes.Primary}
143
- text="<h1> HeadingDisplaySizes.Primary"
140
+ size={HeadingSizes.Primary}
141
+ text="<h1> HeadingSizes.Primary"
144
142
  />
145
143
  <Heading
146
144
  id="heading-secondary"
147
145
  level={HeadingLevels.One}
148
- displaySize={HeadingDisplaySizes.Secondary}
149
- text="<h1> HeadingDisplaySizes.Secondary"
146
+ size={HeadingSizes.Secondary}
147
+ text="<h1> HeadingSizes.Secondary"
150
148
  />
151
149
  <Heading
152
150
  id="heading-tertiary"
153
151
  level={HeadingLevels.One}
154
- displaySize={HeadingDisplaySizes.Tertiary}
155
- text="<h1> HeadingDisplaySizes.Tertiary"
152
+ size={HeadingSizes.Tertiary}
153
+ text="<h1> HeadingSizes.Tertiary"
156
154
  />
157
155
  <Heading
158
156
  id="heading-callout"
159
157
  level={HeadingLevels.One}
160
- displaySize={HeadingDisplaySizes.Callout}
161
- text="<h1> HeadingDisplaySizes.Callout"
158
+ size={HeadingSizes.Callout}
159
+ text="<h1> HeadingSizes.Callout"
162
160
  />
163
161
  </div>
164
162
  </Story>
@@ -4,7 +4,7 @@ import { axe } from "jest-axe";
4
4
  import renderer from "react-test-renderer";
5
5
 
6
6
  import Heading from "./Heading";
7
- import { HeadingDisplaySizes, HeadingLevels } from "./HeadingTypes";
7
+ import { HeadingSizes, HeadingLevels } from "./HeadingTypes";
8
8
 
9
9
  describe("Heading Accessibility", () => {
10
10
  it("passes axe accessibility test", async () => {
@@ -93,7 +93,7 @@ describe("Heading", () => {
93
93
 
94
94
  it("throws error when neither child nor text is passed", () => {
95
95
  expect(() => render(<Heading id="h1" level={HeadingLevels.One} />)).toThrow(
96
- "Heading has no children, please pass prop: text"
96
+ "NYPL Reservoir Heading: No children or value was passed to the `text` prop."
97
97
  );
98
98
  });
99
99
 
@@ -105,7 +105,7 @@ describe("Heading", () => {
105
105
  <span>many</span>
106
106
  </Heading>
107
107
  )
108
- ).toThrow("Please only pass one child into Heading, got span, span");
108
+ ).toThrow("NYPL Reservoir Heading: Only pass one child into Heading.");
109
109
  });
110
110
 
111
111
  it("uses custom display size", () => {
@@ -113,8 +113,8 @@ describe("Heading", () => {
113
113
  <Heading
114
114
  id="h1"
115
115
  level={HeadingLevels.One}
116
- text="Heading with Secondary displaySize"
117
- displaySize={HeadingDisplaySizes.Secondary}
116
+ size={HeadingSizes.Secondary}
117
+ text="Heading with Secondary size"
118
118
  />
119
119
  );
120
120
  expect(screen.getByRole("heading", { level: 1 })).toHaveStyle({
@@ -140,8 +140,8 @@ describe("Heading", () => {
140
140
  <Heading
141
141
  id="customDisplaySize"
142
142
  level={HeadingLevels.One}
143
- text="Heading with Secondary displaySize"
144
- displaySize={HeadingDisplaySizes.Secondary}
143
+ size={HeadingSizes.Secondary}
144
+ text="Heading with Secondary size"
145
145
  />
146
146
  )
147
147
  .toJSON();
@@ -1,7 +1,7 @@
1
1
  import { Heading as ChakraHeading, useStyleConfig } from "@chakra-ui/react";
2
2
  import * as React from "react";
3
3
 
4
- import { HeadingDisplaySizes, HeadingLevels } from "./HeadingTypes";
4
+ import { HeadingSizes, HeadingLevels } from "./HeadingTypes";
5
5
  import Link from "../Link/Link";
6
6
  import { getVariant } from "../../utils/utils";
7
7
  import generateUUID from "../../helpers/generateUUID";
@@ -11,14 +11,14 @@ export interface HeadingProps {
11
11
  additionalStyles?: { [key: string]: any };
12
12
  /** Optional className that appears in addition to `heading` */
13
13
  className?: string;
14
- /** Optional size used to override the default styles of the semantic HTM
15
- * `<h>` elements */
16
- displaySize?: HeadingDisplaySizes;
17
14
  /** Optional ID that other components can cross reference for accessibility purposes */
18
15
  id?: string;
19
16
  /** Optional number 1-6 used to create the `<h*>` tag; if prop is not passed,
20
17
  * `Heading` will default to `<h2>` */
21
18
  level?: HeadingLevels;
19
+ /** Optional size used to override the default styles of the semantic HTM
20
+ * `<h>` elements */
21
+ size?: HeadingSizes;
22
22
  /** Inner text of the `<h*>` element */
23
23
  text?: string;
24
24
  /** Optional URL that header points to; when `url` prop is passed to
@@ -46,17 +46,15 @@ function Heading(props: React.PropsWithChildren<HeadingProps>) {
46
46
  const {
47
47
  additionalStyles = {},
48
48
  className,
49
- displaySize,
50
49
  id = generateUUID(),
51
50
  level = HeadingLevels.Two,
51
+ size,
52
52
  text,
53
53
  url,
54
54
  urlClass,
55
55
  } = props;
56
56
  const finalLevel = getMappedLevel(level);
57
- const variant = displaySize
58
- ? getVariant(displaySize, HeadingDisplaySizes)
59
- : `h${finalLevel}`;
57
+ const variant = size ? getVariant(size, HeadingSizes) : `h${finalLevel}`;
60
58
  const styles = useStyleConfig("Heading", { variant });
61
59
  // Combine native base styles with any additional styles.
62
60
  // This is used in the `Hero` and `Notification` components.
@@ -64,17 +62,15 @@ function Heading(props: React.PropsWithChildren<HeadingProps>) {
64
62
  const asHeading: any = `h${finalLevel}`;
65
63
 
66
64
  if (!props.children && !text) {
67
- throw new Error("Heading has no children, please pass prop: text");
65
+ throw new Error(
66
+ "NYPL Reservoir Heading: No children or value was passed to the `text` prop."
67
+ );
68
68
  }
69
69
 
70
70
  if (React.Children.count(props.children) > 1) {
71
- const children = React.Children.map(
72
- props.children,
73
- (child) => (child as JSX.Element).type
74
- );
75
71
  // Catching the error because React's error isn't as helpful.
76
72
  throw new Error(
77
- `Please only pass one child into Heading, got ${children.join(", ")}`
73
+ "NYPL Reservoir Heading: Only pass one child into Heading."
78
74
  );
79
75
  }
80
76
 
@@ -1,4 +1,4 @@
1
- export enum HeadingDisplaySizes {
1
+ export enum HeadingSizes {
2
2
  Primary = "primary",
3
3
  Secondary = "secondary",
4
4
  Tertiary = "tertiary",
@@ -23,7 +23,7 @@ exports[`Heading renders the UI snapshot correctly 3`] = `
23
23
  className="chakra-heading css-0"
24
24
  id="customDisplaySize"
25
25
  >
26
- Heading with Secondary displaySize
26
+ Heading with Secondary size
27
27
  </h1>
28
28
  `;
29
29