@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
@@ -2,6 +2,7 @@ import * as React from "react";
2
2
  import { Box, useMultiStyleConfig } from "@chakra-ui/react";
3
3
 
4
4
  import { HeroTypes, HeroSecondaryTypes } from "./HeroTypes";
5
+ import Image from "../Image/Image";
5
6
 
6
7
  export interface HeroProps {
7
8
  /** Optional hex color value used to override the default background
@@ -20,11 +21,14 @@ export interface HeroProps {
20
21
  heading?: JSX.Element;
21
22
  /** Used to control how the `Hero` component will be rendered. */
22
23
  heroType?: HeroTypes;
23
- /** Optional `Image` component used for SECONDARY, FIFTYFIFTY and CAMPAIGN
24
- * `Hero` types; Note: `image` can only be used in conjunction with
25
- * `backgroundImageSrc` for CAMPAIGN the `Hero` type.
24
+ /** Text description of the image; to follow best practices for accessibility,
25
+ * this prop should not be left blank if `imageSrc` is passed. */
26
+ imageAlt?: string;
27
+ /** Optional `imageSrc` used for SECONDARY, FIFTYFIFTY and CAMPAIGN
28
+ * `Hero` types; Note: `imageSrc` can only be used in conjunction with
29
+ * `backgroundImageSrc` for the CAMPAIGN `Hero` type.
26
30
  * Note: not all `Hero` variations utilize this prop. */
27
- image?: JSX.Element;
31
+ imageSrc?: string;
28
32
  /** Optional details area that contains location data.
29
33
  * Note: not all `Hero` variations utilize this prop. */
30
34
  locationDetails?: JSX.Element;
@@ -52,7 +56,8 @@ export default function Hero(props: React.PropsWithChildren<HeroProps>) {
52
56
  foregroundColor,
53
57
  heading,
54
58
  heroType,
55
- image,
59
+ imageAlt,
60
+ imageSrc,
56
61
  locationDetails,
57
62
  subHeaderText,
58
63
  } = props;
@@ -65,38 +70,54 @@ export default function Hero(props: React.PropsWithChildren<HeroProps>) {
65
70
  let backgroundImageStyle = {};
66
71
  let contentBoxStyling = {};
67
72
 
73
+ if (imageSrc && !imageAlt) {
74
+ console.warn(
75
+ `NYPL Reservoir: The "imageSrc" prop was passed but the "imageAlt" props was not. This will make the rendered image inaccessible.`
76
+ );
77
+ }
78
+
68
79
  if (heroType === HeroTypes.Primary) {
69
80
  if (!backgroundImageSrc) {
70
81
  console.warn(
71
- `Warning: it is recommended to use the "backgroundImageSrc" prop for PRIMARY hero.`
82
+ "NYPL Reservoir Hero: It is recommended to use the `backgroundImageSrc` " +
83
+ "prop for the `HeroTypes.Primary` `heroType` variant."
72
84
  );
73
85
  }
74
- if (image) {
86
+ if (imageAlt && imageSrc) {
75
87
  console.warn(
76
- `Warning: the "image" prop has been passed, but PRIMARY hero will not use it.`
88
+ "NYPL Reservoir Hero: The `imageSrc` and `imageAlt` props have been " +
89
+ "passed, but the `HeroTypes.Primary` `heroType` variant will not use it."
77
90
  );
78
91
  }
79
92
  } else if (locationDetails) {
80
93
  console.warn(
81
- `Warning: Please provide "locationDetails" only to PRIMARY hero.`
94
+ "NYPL Reservoir Hero: The `locationDetails` prop should only be used " +
95
+ "with the `HeroTypes.Primary` `heroType` variant."
82
96
  );
83
97
  }
84
98
  if (HeroSecondaryTypes.includes(heroType) && backgroundImageSrc) {
85
99
  console.warn(
86
- `Warning: the "backgroundImageSrc" prop has been passed, but SECONDARY hero will not use it.`
100
+ "NYPL Reservoir Hero: The `backgroundImageSrc` prop has been passed, " +
101
+ "but the `HeroTypes.Secondary` `heroType` variant will not use it."
87
102
  );
88
103
  }
89
- if (heroType === HeroTypes.Tertiary && (backgroundImageSrc || image)) {
90
- console.warn(`Warning: TERTIARY hero will not use any of the image props.`);
104
+ if (heroType === HeroTypes.Tertiary && (backgroundImageSrc || imageSrc)) {
105
+ console.warn(
106
+ "NYPL Reservoir Hero: The `HeroTypes.Tertiary` `heroType` variant hero " +
107
+ "will not use any of the image props."
108
+ );
91
109
  }
92
- if (heroType === HeroTypes.Campaign && (!backgroundImageSrc || !image)) {
110
+ if (heroType === HeroTypes.Campaign && (!backgroundImageSrc || !imageSrc)) {
93
111
  console.warn(
94
- `Warning: it is recommended to use both "backgroundImageSrc" and "image" props for CAMPAIGN hero.`
112
+ "NYPL Reservoir Hero: It is recommended to use both the " +
113
+ "`backgroundImageSrc` and `imageSrc` props for the " +
114
+ "`HeroTypes.Campaign` `heroType` variant."
95
115
  );
96
116
  }
97
117
  if (heroType === HeroTypes.FiftyFifty && backgroundImageSrc) {
98
118
  console.warn(
99
- `Warning: the "backgroundImageSrc" prop has been passed, but FIFTYFIFTY hero will not use it.`
119
+ "NYPL Reservoir Hero: The `backgroundImageSrc` prop has been passed, " +
120
+ "but the `HeroTypes.FiftyFifty` `heroType` variant hero will not use it."
100
121
  );
101
122
  }
102
123
 
@@ -122,14 +143,16 @@ export default function Hero(props: React.PropsWithChildren<HeroProps>) {
122
143
  };
123
144
  } else if (foregroundColor || backgroundColor) {
124
145
  console.warn(
125
- `Warning: the "foregroundColor" and/or "backgroundColor" props have been passed, but SECONDARY Hero will not use them.`
146
+ "NYPL Reservoir Hero: The `foregroundColor` and/or `backgroundColor` " +
147
+ "props have been passed, but the `HeroTypes.Secondary` `heroType` " +
148
+ "variant will not use them."
126
149
  );
127
150
  }
128
151
 
129
152
  const childrenToRender =
130
153
  heroType === HeroTypes.Campaign ? (
131
154
  <>
132
- {image}
155
+ <Image alt={imageAlt} src={imageSrc} />
133
156
  <Box __css={styles.interior}>
134
157
  {finalHeading}
135
158
  {subHeaderText}
@@ -137,9 +160,9 @@ export default function Hero(props: React.PropsWithChildren<HeroProps>) {
137
160
  </>
138
161
  ) : (
139
162
  <>
140
- {heroType !== HeroTypes.Primary &&
141
- heroType !== HeroTypes.Tertiary &&
142
- image}
163
+ {heroType !== HeroTypes.Primary && heroType !== HeroTypes.Tertiary && (
164
+ <Image alt={imageAlt} src={imageSrc} />
165
+ )}
143
166
  {finalHeading}
144
167
  {heroType === HeroTypes.Tertiary && subHeaderText ? (
145
168
  <p>{subHeaderText}</p>
@@ -30,14 +30,16 @@ describe("HorizontalRule", () => {
30
30
  <HorizontalRule className="custom-hr" height="20px" />
31
31
  );
32
32
  expect(warn).not.toHaveBeenCalledWith(
33
- "`HorizontalRule`: For the `height` prop, use a whole number, a `px` " +
34
- "value, a `em` value, or a `rem` value. Using the default of 2px."
33
+ "NYPL Reservoir HorizontalRule: An invalid value was passed for the " +
34
+ "`height` prop, so the default value of 2px will be used. A valid " +
35
+ "value should be a whole number, a `px` value, a `em` value, or a `rem` value."
35
36
  );
36
37
 
37
38
  rerender(<HorizontalRule className="custom-hr" height="20%" />);
38
39
  expect(warn).toHaveBeenCalledWith(
39
- "`HorizontalRule`: For the `height` prop, use a whole number, a `px` " +
40
- "value, a `em` value, or a `rem` value. Using the default of 2px."
40
+ "NYPL Reservoir HorizontalRule: An invalid value was passed for the " +
41
+ "`height` prop, so the default value of 2px will be used. A valid " +
42
+ "value should be a whole number, a `px` value, a `em` value, or a `rem` value."
41
43
  );
42
44
  });
43
45
 
@@ -27,8 +27,9 @@ export default function HorizontalRule(props: HorizontalRuleProps) {
27
27
 
28
28
  if (height.endsWith("%")) {
29
29
  console.warn(
30
- "`HorizontalRule`: For the `height` prop, use a whole number, a `px`" +
31
- " value, a `em` value, or a `rem` value. Using the default of 2px."
30
+ "NYPL Reservoir HorizontalRule: An invalid value was passed for the " +
31
+ "`height` prop, so the default value of 2px will be used. A valid " +
32
+ "value should be a whole number, a `px` value, a `em` value, or a `rem` value."
32
33
  );
33
34
  finalHeight = "2px";
34
35
  }
@@ -7,6 +7,8 @@ import {
7
7
  } from "@storybook/addon-docs";
8
8
  import { withDesign } from "storybook-addon-designs";
9
9
 
10
+ import Heading from "../Heading/Heading";
11
+ import { HeadingLevels } from "../Heading/HeadingTypes";
10
12
  import Icon from "./Icon";
11
13
  import {
12
14
  IconAlign,
@@ -89,7 +91,7 @@ export const rotationEnumValues = getStorybookEnumValues(
89
91
  | Component Version | DS Version |
90
92
  | ----------------- | ---------- |
91
93
  | Added | `0.0.4` |
92
- | Latest | `0.25.12` |
94
+ | Latest | `0.25.13` |
93
95
 
94
96
  <Description of={Icon} />
95
97
 
@@ -105,7 +107,7 @@ export const rotationEnumValues = getStorybookEnumValues(
105
107
  iconRotation: "IconRotationTypes.Rotate0",
106
108
  id: "icon-id",
107
109
  name: "IconNames.Check",
108
- size: "IconSizes.ExtraLarge",
110
+ size: "IconSizes.ExtraExtraLarge",
109
111
  title: undefined,
110
112
  type: IconTypes.Default,
111
113
  }}
@@ -128,7 +130,7 @@ export const rotationEnumValues = getStorybookEnumValues(
128
130
  export const iconRow = (icon, iconType = IconNames, opts = {}) => {
129
131
  // We'll use this setup function to render all the icons in a list item.
130
132
  // Some icons display better with a dark background.
131
- const styles = { padding: "1rem" };
133
+ const styles = { display: "block" };
132
134
  const {
133
135
  size = IconSizes.Large,
134
136
  iconRotation = IconRotationTypes.Rotate0,
@@ -138,6 +140,7 @@ export const iconRow = (icon, iconType = IconNames, opts = {}) => {
138
140
  let key = icon;
139
141
  if (icon.indexOf("Negative") !== -1 || color.indexOf("white") !== -1) {
140
142
  styles.backgroundColor = "#000";
143
+ styles.padding = "1rem";
141
144
  }
142
145
  // The following is just to fix duplicate React key issues.
143
146
  if (iconRotation !== IconRotationTypes.Rotate0) {
@@ -150,7 +153,11 @@ export const iconRow = (icon, iconType = IconNames, opts = {}) => {
150
153
  key += `-${size}`;
151
154
  }
152
155
  return (
153
- <li key={key} style={{ marginBottom: "var(--nypl-space-s)" }}>
156
+ <li
157
+ key={key}
158
+ style={{ marginBottom: "var(--nypl-space-l)", textAlign: "center" }}
159
+ >
160
+ <Heading level={HeadingLevels.Four}>{displayValue}</Heading>
154
161
  <span style={styles}>
155
162
  <Icon
156
163
  name={iconType[icon]}
@@ -159,7 +166,6 @@ export const iconRow = (icon, iconType = IconNames, opts = {}) => {
159
166
  color={color}
160
167
  />
161
168
  </span>
162
- {displayValue}
163
169
  </li>
164
170
  );
165
171
  };
@@ -168,30 +174,36 @@ export const rotations = [];
168
174
  export const colors = [];
169
175
  export const sizes = [];
170
176
  for (const icon in IconNames) {
171
- icons.push(iconRow(icon, IconNames, { displayValue: `IconNames.${icon}` }));
177
+ icons.push(
178
+ iconRow(icon, IconNames, {
179
+ displayValue: `IconNames.${icon}`,
180
+ size: IconSizes.ExtraExtraLarge,
181
+ })
182
+ );
172
183
  }
173
184
  for (const iconRotation in IconRotationTypes) {
174
185
  rotations.push(
175
186
  iconRow("Arrow", IconNames, {
176
- size: IconSizes.Large,
177
- iconRotation: IconRotationTypes[iconRotation],
178
187
  displayValue: `IconRotationTypes.${iconRotation}`,
188
+ iconRotation: IconRotationTypes[iconRotation],
189
+ size: IconSizes.ExtraExtraLarge,
179
190
  })
180
191
  );
181
192
  }
182
193
  for (const iconColor in IconColors) {
183
194
  colors.push(
184
- iconRow("Download", IconNames, {
195
+ iconRow("ErrorFilled", IconNames, {
185
196
  color: IconColors[iconColor],
186
197
  displayValue: `IconColors.${iconColor}`,
198
+ size: IconSizes.ExtraExtraLarge,
187
199
  })
188
200
  );
189
201
  }
190
202
  for (const iconSize in IconSizes) {
191
203
  sizes.push(
192
- iconRow("Arrow", IconNames, {
193
- size: IconSizes[iconSize],
204
+ iconRow("ActionCheckCircle", IconNames, {
194
205
  displayValue: `IconSizes.${iconSize}`,
206
+ size: IconSizes[iconSize],
195
207
  })
196
208
  );
197
209
  }
@@ -214,13 +226,20 @@ Passing an `iconRotation` prop with a value from `IconRotationTypes` allows
214
226
  the icon to be rotated when it is rendered. The `IconRotationTypes` enum
215
227
  can be found in `src/components/Icons/IconTypes.tsx`.
216
228
 
229
+ Note: All of the examples below have been rendered with the `size` prop set to
230
+ `IconSizes.ExtraExtraLarge`.
231
+
217
232
  ```jsx
218
233
  // Example
219
- <Icon name={IconNames.Arrow} iconRotation={IconRotationTypes.Rotate180} />
234
+ <Icon
235
+ iconRotation={IconRotationTypes.Rotate180}
236
+ name={IconNames.Arrow}
237
+ size={IconSizes.ExtraExtraLarge}
238
+ />
220
239
  ```
221
240
 
222
241
  <Canvas>
223
- <Story name="Rotation Types">{allIconsType(rotations)}</Story>
242
+ <Story name="Icon Rotation">{allIconsType(rotations)}</Story>
224
243
  </Canvas>
225
244
 
226
245
  ## IconColors Types
@@ -228,13 +247,20 @@ can be found in `src/components/Icons/IconTypes.tsx`.
228
247
  Update an SVG icon by passing a `color` prop with a value from `IconColors`.
229
248
  The `IconColors` enum can be found in `src/components/Icons/IconTypes.tsx`.
230
249
 
250
+ Note: All of the examples below have been rendered with the `size` prop set to
251
+ `IconSizes.ExtraExtraLarge`.
252
+
231
253
  ```jsx
232
254
  // Example
233
- <Icon name={IconNames.Speaker_notes} color={IconColors.BrandPrimary} />
255
+ <Icon
256
+ color={IconColors.BrandPrimary}
257
+ name={IconNames.ErrorFilled}
258
+ size={IconSizes.ExtraExtraLarge}
259
+ />
234
260
  ```
235
261
 
236
262
  <Canvas>
237
- <Story name="Color Types">{allIconsType(colors)}</Story>
263
+ <Story name="Icon Colors">{allIconsType(colors)}</Story>
238
264
  </Canvas>
239
265
 
240
266
  ## IconSizes Types
@@ -242,13 +268,16 @@ The `IconColors` enum can be found in `src/components/Icons/IconTypes.tsx`.
242
268
  Update an SVG icon by passing a `size` prop with a value from `IconSizes`.
243
269
  The `IconSizes` enum can be found in`src/components/Icons/IconTypes.tsx`.
244
270
 
271
+ Note: `IconSizes.Default` sets the width to `100%` and the rendered icon will
272
+ expand to fill the full width of the parent element.
273
+
245
274
  ```jsx
246
275
  // Example
247
- <Icon name={IconNames.Clock} size={IconSizes.ExtraExtraLarge} />
276
+ <Icon name={IconNames.ActionCheckCircle} size={IconSizes.ExtraExtraLarge} />
248
277
  ```
249
278
 
250
279
  <Canvas>
251
- <Story name="Sizes Types">{allIconsType(sizes)}</Story>
280
+ <Story name="Icon Sizes">{allIconsType(sizes)}</Story>
252
281
  </Canvas>
253
282
 
254
283
  ## All Display Icons
@@ -256,8 +285,11 @@ The `IconSizes` enum can be found in`src/components/Icons/IconTypes.tsx`.
256
285
  The following icons are for generic purposes. All the available icon names can
257
286
  be found in the `IconNames` enum in `src/components/Icons/IconTypes.tsx`.
258
287
 
288
+ Note: All of the examples below have been rendered with the `size` prop set to
289
+ `IconSizes.ExtraExtraLarge`.
290
+
259
291
  <Canvas withToolbar>
260
- <Story name="All Display Icons">{allIconsType(icons)}</Story>
292
+ <Story name="All Icons">{allIconsType(icons)}</Story>
261
293
  </Canvas>
262
294
 
263
295
  ## Custom Icons
@@ -27,7 +27,8 @@ describe("Icon", () => {
27
27
  </Icon>
28
28
  );
29
29
  expect(warn).toHaveBeenCalledWith(
30
- "Icon accepts either a `name` prop or an `svg` element child, not both."
30
+ "NYPL Reservoir Icon: Pass in either a `name` prop or an `svg` element " +
31
+ "child. Do not pass both."
31
32
  );
32
33
  });
33
34
 
@@ -35,7 +36,17 @@ describe("Icon", () => {
35
36
  const warn = jest.spyOn(console, "warn");
36
37
  render(<Icon />);
37
38
  expect(warn).toHaveBeenCalledWith(
38
- "Icon: Pass an icon `name` prop or an SVG child to ensure an icon appears."
39
+ "NYPL Reservoir Icon: Pass an icon `name` prop or an SVG child to " +
40
+ "ensure an icon appears."
41
+ );
42
+ });
43
+
44
+ it("consoles a warning if name is not passed and a child is but it's not an SVG element", () => {
45
+ const warn = jest.spyOn(console, "warn");
46
+ render(<Icon>Not an SVG</Icon>);
47
+ expect(warn).toHaveBeenCalledWith(
48
+ "NYPL Reservoir Icon: An `svg` element must be passed to the `Icon` " +
49
+ "component as its child."
39
50
  );
40
51
  });
41
52
 
@@ -54,7 +54,7 @@ export default function Icon(props: React.PropsWithChildren<IconProps>) {
54
54
  iconRotation = IconRotationTypes.Rotate0,
55
55
  id = generateUUID(),
56
56
  name,
57
- size = IconSizes.Medium,
57
+ size = IconSizes.Default,
58
58
  title = `${name} icon`,
59
59
  type = IconTypes.Default,
60
60
  } = props;
@@ -77,12 +77,14 @@ export default function Icon(props: React.PropsWithChildren<IconProps>) {
77
77
  // Component prop validation
78
78
  if (name && children) {
79
79
  console.warn(
80
- "Icon accepts either a `name` prop or an `svg` element child, not both."
80
+ "NYPL Reservoir Icon: Pass in either a `name` prop or an `svg` element " +
81
+ "child. Do not pass both."
81
82
  );
82
83
  return null;
83
84
  } else if (!name && !children) {
84
85
  console.warn(
85
- "Icon: Pass an icon `name` prop or an SVG child to ensure an icon appears."
86
+ "NYPL Reservoir Icon: Pass an icon `name` prop or an SVG child to " +
87
+ "ensure an icon appears."
86
88
  );
87
89
  return null;
88
90
  }
@@ -105,14 +107,17 @@ export default function Icon(props: React.PropsWithChildren<IconProps>) {
105
107
  // Apply icon props to the SVG child.
106
108
  if (
107
109
  (children as JSX.Element).type === "svg" ||
108
- (children as JSX.Element).props.type === "svg" ||
109
- (children as JSX.Element).props.mdxType === "svg"
110
+ (children as JSX.Element).props?.type === "svg" ||
111
+ (children as JSX.Element).props?.mdxType === "svg"
110
112
  ) {
111
113
  childSVG = React.cloneElement(children as JSX.Element, {
112
114
  ...iconProps,
113
115
  });
114
116
  } else {
115
- console.warn("You must pass an `svg` element to the `Icon` component.");
117
+ console.warn(
118
+ "NYPL Reservoir Icon: An `svg` element must be passed to the `Icon` " +
119
+ "component as its child."
120
+ );
116
121
  }
117
122
 
118
123
  return <Box __css={styles}>{childSVG}</Box>;
@@ -40,6 +40,7 @@ export enum IconColors {
40
40
  }
41
41
 
42
42
  export enum IconSizes {
43
+ Default = "default",
43
44
  Small = "small",
44
45
  Medium = "medium",
45
46
  Large = "large",