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