@nypl/design-system-react-components 0.27.0 → 0.28.0

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 (298) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/components/Accordion/Accordion.d.ts +1 -1
  3. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -5
  4. package/dist/components/Button/Button.d.ts +2 -10
  5. package/dist/components/ButtonGroup/ButtonGroup.d.ts +22 -0
  6. package/dist/components/Card/Card.d.ts +2 -2
  7. package/dist/components/Checkbox/Checkbox.d.ts +10 -8
  8. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
  9. package/dist/components/DatePicker/DatePicker.d.ts +1 -1
  10. package/dist/components/Form/Form.d.ts +2 -2
  11. package/dist/components/Grid/SimpleGrid.d.ts +6 -3
  12. package/dist/components/Heading/Heading.d.ts +2 -5
  13. package/dist/components/HelperErrorText/HelperErrorText.d.ts +1 -5
  14. package/dist/components/Hero/Hero.d.ts +13 -9
  15. package/dist/components/Icons/Icon.d.ts +6 -5
  16. package/dist/components/Icons/IconSvgs.d.ts +21 -21
  17. package/dist/components/Image/Image.d.ts +8 -5
  18. package/dist/components/Link/Link.d.ts +1 -9
  19. package/dist/components/List/List.d.ts +7 -11
  20. package/dist/components/Logo/Logo.d.ts +2 -5
  21. package/dist/components/Logo/LogoSvgs.d.ts +39 -39
  22. package/dist/components/Notification/Notification.d.ts +1 -1
  23. package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +2 -1
  24. package/dist/components/RadioGroup/RadioGroup.d.ts +1 -1
  25. package/dist/components/SearchBar/SearchBar.d.ts +3 -2
  26. package/dist/components/Select/Select.d.ts +2 -5
  27. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -4
  28. package/dist/components/SkipNavigation/SkipNavigation.d.ts +17 -0
  29. package/dist/components/StatusBadge/StatusBadge.d.ts +2 -3
  30. package/dist/components/StructuredContent/StructuredContent.d.ts +2 -2
  31. package/dist/components/Table/Table.d.ts +1 -1
  32. package/dist/components/Template/Template.d.ts +2 -0
  33. package/dist/components/Text/Text.d.ts +1 -1
  34. package/dist/components/TextInput/TextInput.d.ts +21 -9
  35. package/dist/components/Toggle/Toggle.d.ts +1 -5
  36. package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
  37. package/dist/design-system-react-components.cjs.development.js +856 -1155
  38. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  39. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  40. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  41. package/dist/design-system-react-components.esm.js +858 -1220
  42. package/dist/design-system-react-components.esm.js.map +1 -1
  43. package/dist/helpers/types.d.ts +1 -0
  44. package/dist/index.d.ts +26 -47
  45. package/dist/theme/components/buttonGroup.d.ts +11 -0
  46. package/dist/theme/components/card.d.ts +104 -8
  47. package/dist/theme/components/componentWrapper.d.ts +4 -3
  48. package/dist/theme/components/customTable.d.ts +11 -14
  49. package/dist/theme/components/fieldset.d.ts +4 -3
  50. package/dist/theme/components/helperErrorText.d.ts +4 -3
  51. package/dist/theme/components/hero.d.ts +1 -1
  52. package/dist/theme/components/horizontalRule.d.ts +4 -3
  53. package/dist/theme/components/icon.d.ts +47743 -1
  54. package/dist/theme/components/image.d.ts +563 -10
  55. package/dist/theme/components/label.d.ts +4 -3
  56. package/dist/theme/components/list.d.ts +6 -7
  57. package/dist/theme/components/logo.d.ts +474 -1
  58. package/dist/theme/components/notification.d.ts +20 -16
  59. package/dist/theme/components/progressIndicator.d.ts +6 -4
  60. package/dist/theme/components/select.d.ts +4 -4
  61. package/dist/theme/components/skeletonLoader.d.ts +14 -10
  62. package/dist/theme/components/skipNavigation.d.ts +22 -0
  63. package/dist/theme/components/slider.d.ts +7 -6
  64. package/dist/theme/components/structuredContent.d.ts +10 -9
  65. package/dist/theme/components/text.d.ts +7 -1
  66. package/dist/theme/components/toggle.d.ts +6 -4
  67. package/dist/theme/provider.d.ts +2 -4
  68. package/dist/utils/componentCategories.d.ts +1 -1
  69. package/dist/utils/interfaces.d.ts +5 -0
  70. package/dist/utils/utils.d.ts +2 -18
  71. package/package.json +2 -2
  72. package/src/__tests__/setup.ts +3 -3
  73. package/src/__tests__/utils/utils.test.ts +1 -23
  74. package/src/components/AccessibilityGuide/SkipNavigation.stories.mdx +22 -14
  75. package/src/components/Accordion/Accordion.stories.mdx +43 -44
  76. package/src/components/Accordion/Accordion.test.tsx +5 -13
  77. package/src/components/Accordion/Accordion.tsx +14 -18
  78. package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +6 -6
  79. package/src/components/Autosuggest/Autosuggest.stories.mdx +1 -1
  80. package/src/components/Autosuggest/Autosuggest.stories.tsx +23 -25
  81. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +21 -37
  82. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +4 -17
  83. package/src/components/Breadcrumbs/Breadcrumbs.tsx +18 -21
  84. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +1 -100
  85. package/src/components/Button/Button.stories.mdx +89 -126
  86. package/src/components/Button/Button.test.tsx +16 -30
  87. package/src/components/Button/Button.tsx +14 -20
  88. package/src/components/ButtonGroup/ButtonGroup.stories.mdx +147 -0
  89. package/src/components/ButtonGroup/ButtonGroup.test.tsx +141 -0
  90. package/src/components/ButtonGroup/ButtonGroup.tsx +99 -0
  91. package/src/components/ButtonGroup/__snapshots__/ButtonGroup.test.tsx.snap +117 -0
  92. package/src/components/Card/Card.stories.mdx +143 -177
  93. package/src/components/Card/Card.test.tsx +36 -97
  94. package/src/components/Card/Card.tsx +78 -74
  95. package/src/components/Chakra/Box.stories.mdx +2 -6
  96. package/src/components/Chakra/Center.stories.mdx +5 -23
  97. package/src/components/Chakra/Flex.stories.mdx +4 -6
  98. package/src/components/Chakra/Stack.stories.mdx +9 -10
  99. package/src/components/Checkbox/Checkbox.stories.mdx +1 -1
  100. package/src/components/Checkbox/Checkbox.test.tsx +2 -2
  101. package/src/components/Checkbox/Checkbox.tsx +20 -13
  102. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +6 -17
  103. package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +1 -7
  104. package/src/components/CheckboxGroup/CheckboxGroup.tsx +33 -29
  105. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +0 -11
  106. package/src/components/ComponentWrapper/ComponentWrapper.tsx +3 -10
  107. package/src/components/DatePicker/DatePicker.stories.mdx +23 -37
  108. package/src/components/DatePicker/DatePicker.test.tsx +21 -19
  109. package/src/components/DatePicker/DatePicker.tsx +57 -49
  110. package/src/components/Form/Form.stories.mdx +46 -31
  111. package/src/components/Form/Form.test.tsx +1 -18
  112. package/src/components/Form/Form.tsx +7 -7
  113. package/src/components/Grid/SimpleGrid.stories.mdx +73 -49
  114. package/src/components/Grid/SimpleGrid.test.tsx +7 -9
  115. package/src/components/Grid/SimpleGrid.tsx +14 -11
  116. package/src/components/Heading/Heading.stories.mdx +27 -72
  117. package/src/components/Heading/Heading.test.tsx +18 -44
  118. package/src/components/Heading/Heading.tsx +7 -10
  119. package/src/components/HelperErrorText/HelperErrorText.stories.mdx +1 -3
  120. package/src/components/HelperErrorText/HelperErrorText.tsx +1 -5
  121. package/src/components/Hero/Hero.stories.mdx +219 -216
  122. package/src/components/Hero/Hero.test.tsx +107 -223
  123. package/src/components/Hero/Hero.tsx +63 -61
  124. package/src/components/Icons/Icon.stories.mdx +172 -118
  125. package/src/components/Icons/Icon.test.tsx +8 -16
  126. package/src/components/Icons/Icon.tsx +75 -29
  127. package/src/components/Icons/IconSvgs.tsx +42 -42
  128. package/src/components/Image/Image.stories.mdx +45 -132
  129. package/src/components/Image/Image.test.tsx +16 -31
  130. package/src/components/Image/Image.tsx +28 -12
  131. package/src/components/Link/Link.stories.mdx +30 -80
  132. package/src/components/Link/Link.test.tsx +25 -53
  133. package/src/components/Link/Link.tsx +43 -56
  134. package/src/components/Link/__snapshots__/Link.test.tsx.snap +1 -2
  135. package/src/components/List/List.stories.mdx +20 -31
  136. package/src/components/List/List.test.tsx +24 -43
  137. package/src/components/List/List.tsx +25 -36
  138. package/src/components/Logo/Logo.stories.mdx +94 -50
  139. package/src/components/Logo/Logo.test.tsx +10 -19
  140. package/src/components/Logo/Logo.tsx +50 -17
  141. package/src/components/Logo/LogoSvgs.tsx +78 -78
  142. package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +4 -4
  143. package/src/components/Modal/Modal.stories.mdx +8 -9
  144. package/src/components/Modal/Modal.test.tsx +5 -10
  145. package/src/components/Modal/Modal.tsx +1 -1
  146. package/src/components/Notification/Notification.stories.mdx +10 -28
  147. package/src/components/Notification/Notification.test.tsx +9 -12
  148. package/src/components/Notification/Notification.tsx +34 -37
  149. package/src/components/Pagination/Pagination.stories.mdx +2 -2
  150. package/src/components/Pagination/Pagination.tsx +15 -10
  151. package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +27 -53
  152. package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +9 -10
  153. package/src/components/ProgressIndicator/ProgressIndicator.tsx +17 -21
  154. package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +0 -10
  155. package/src/components/Radio/Radio.stories.mdx +1 -1
  156. package/src/components/Radio/Radio.tsx +9 -6
  157. package/src/components/RadioGroup/RadioGroup.stories.mdx +15 -16
  158. package/src/components/RadioGroup/RadioGroup.test.tsx +2 -8
  159. package/src/components/RadioGroup/RadioGroup.tsx +28 -24
  160. package/src/components/SearchBar/SearchBar.stories.mdx +1 -1
  161. package/src/components/SearchBar/SearchBar.test.tsx +1 -1
  162. package/src/components/SearchBar/SearchBar.tsx +14 -22
  163. package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +0 -12
  164. package/src/components/Select/Select.stories.mdx +8 -23
  165. package/src/components/Select/Select.test.tsx +6 -7
  166. package/src/components/Select/Select.tsx +13 -26
  167. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +17 -56
  168. package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +7 -21
  169. package/src/components/SkeletonLoader/SkeletonLoader.tsx +9 -8
  170. package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +33 -33
  171. package/src/components/SkipNavigation/SkipNavigation.stories.mdx +90 -0
  172. package/src/components/SkipNavigation/SkipNavigation.test.tsx +63 -0
  173. package/src/components/SkipNavigation/SkipNavigation.tsx +51 -0
  174. package/src/components/SkipNavigation/__snapshots__/SkipNavigation.test.tsx.snap +130 -0
  175. package/src/components/Slider/Slider.stories.mdx +19 -53
  176. package/src/components/Slider/Slider.test.tsx +2 -2
  177. package/src/components/Slider/Slider.tsx +10 -12
  178. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +2 -9
  179. package/src/components/StatusBadge/StatusBadge.stories.mdx +6 -21
  180. package/src/components/StatusBadge/StatusBadge.test.tsx +2 -3
  181. package/src/components/StatusBadge/StatusBadge.tsx +3 -10
  182. package/src/components/StructuredContent/StructuredContent.stories.mdx +30 -58
  183. package/src/components/StructuredContent/StructuredContent.test.tsx +42 -44
  184. package/src/components/StructuredContent/StructuredContent.tsx +9 -18
  185. package/src/components/StyleGuide/Bidirectionality.stories.mdx +9 -23
  186. package/src/components/StyleGuide/Buttons.stories.mdx +62 -62
  187. package/src/components/StyleGuide/ColorCard.tsx +2 -4
  188. package/src/components/StyleGuide/Colors.stories.mdx +7 -8
  189. package/src/components/StyleGuide/DesignTokens.stories.mdx +5 -7
  190. package/src/components/StyleGuide/Forms.stories.mdx +0 -1
  191. package/src/components/StyleGuide/Iconography.stories.mdx +59 -77
  192. package/src/components/StyleGuide/Spacing.stories.mdx +0 -1
  193. package/src/components/StyleGuide/Typography.stories.mdx +15 -18
  194. package/src/components/Table/Table.stories.mdx +85 -1
  195. package/src/components/Table/Table.test.tsx +57 -1
  196. package/src/components/Table/Table.tsx +7 -4
  197. package/src/components/Table/__snapshots__/Table.test.tsx.snap +121 -0
  198. package/src/components/Tabs/Tabs.stories.mdx +1 -1
  199. package/src/components/Tabs/Tabs.test.tsx +2 -2
  200. package/src/components/Tabs/Tabs.tsx +26 -27
  201. package/src/components/Template/Template.stories.mdx +49 -54
  202. package/src/components/Template/Template.tsx +9 -3
  203. package/src/components/Text/Text.stories.mdx +5 -11
  204. package/src/components/Text/Text.test.tsx +3 -6
  205. package/src/components/Text/Text.tsx +3 -5
  206. package/src/components/TextInput/TextInput.stories.mdx +10 -22
  207. package/src/components/TextInput/TextInput.test.tsx +32 -62
  208. package/src/components/TextInput/TextInput.tsx +61 -30
  209. package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +1 -0
  210. package/src/components/Toggle/Toggle.stories.mdx +5 -16
  211. package/src/components/Toggle/Toggle.test.tsx +2 -3
  212. package/src/components/Toggle/Toggle.tsx +9 -10
  213. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +13 -29
  214. package/src/components/VideoPlayer/VideoPlayer.test.tsx +18 -23
  215. package/src/components/VideoPlayer/VideoPlayer.tsx +13 -10
  216. package/src/docs/Chakra.stories.mdx +14 -11
  217. package/src/docs/Welcome.stories.mdx +23 -43
  218. package/src/helpers/types.ts +1 -0
  219. package/src/hooks/tests/useNYPLTheme.test.tsx +1 -1
  220. package/src/hooks/useNYPLTheme.stories.mdx +3 -6
  221. package/src/index.ts +51 -45
  222. package/src/theme/components/buttonGroup.ts +10 -0
  223. package/src/theme/components/card.ts +50 -15
  224. package/src/theme/components/componentWrapper.ts +5 -1
  225. package/src/theme/components/customTable.ts +8 -2
  226. package/src/theme/components/fieldset.ts +5 -1
  227. package/src/theme/components/helperErrorText.ts +5 -1
  228. package/src/theme/components/hero.ts +2 -2
  229. package/src/theme/components/horizontalRule.ts +5 -1
  230. package/src/theme/components/icon.ts +7 -1
  231. package/src/theme/components/image.ts +14 -3
  232. package/src/theme/components/label.ts +5 -1
  233. package/src/theme/components/list.ts +8 -2
  234. package/src/theme/components/logo.ts +5 -1
  235. package/src/theme/components/notification.ts +38 -14
  236. package/src/theme/components/progressIndicator.ts +10 -5
  237. package/src/theme/components/select.ts +5 -2
  238. package/src/theme/components/skeletonLoader.ts +8 -2
  239. package/src/theme/components/skipNavigation.ts +26 -0
  240. package/src/theme/components/slider.ts +13 -1
  241. package/src/theme/components/structuredContent.ts +11 -1
  242. package/src/theme/components/text.ts +12 -5
  243. package/src/theme/components/toggle.ts +9 -3
  244. package/src/theme/index.ts +4 -0
  245. package/src/theme/provider.tsx +1 -1
  246. package/src/utils/componentCategories.ts +13 -5
  247. package/src/utils/interfaces.ts +5 -0
  248. package/src/utils/utils.ts +2 -32
  249. package/dist/components/Accordion/AccordionTypes.d.ts +0 -5
  250. package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +0 -8
  251. package/dist/components/Button/ButtonTypes.d.ts +0 -8
  252. package/dist/components/DatePicker/DatePickerTypes.d.ts +0 -5
  253. package/dist/components/Form/FormTypes.d.ts +0 -2
  254. package/dist/components/Grid/GridTypes.d.ts +0 -9
  255. package/dist/components/Heading/HeadingTypes.d.ts +0 -14
  256. package/dist/components/Hero/HeroTypes.d.ts +0 -12
  257. package/dist/components/Icons/IconTypes.d.ts +0 -77
  258. package/dist/components/Image/ImageTypes.d.ts +0 -22
  259. package/dist/components/Link/LinkTypes.d.ts +0 -8
  260. package/dist/components/List/ListTypes.d.ts +0 -5
  261. package/dist/components/Logo/LogoTypes.d.ts +0 -54
  262. package/dist/components/Notification/NotificationTypes.d.ts +0 -5
  263. package/dist/components/ProgressIndicator/ProgressIndicatorTypes.d.ts +0 -8
  264. package/dist/components/Select/SelectTypes.d.ts +0 -8
  265. package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +0 -5
  266. package/dist/components/StatusBadge/StatusBadgeTypes.d.ts +0 -5
  267. package/dist/components/StructuredContent/StructuredContentTypes.d.ts +0 -5
  268. package/dist/components/Text/TextTypes.d.ts +0 -6
  269. package/dist/components/TextInput/TextInputTypes.d.ts +0 -25
  270. package/dist/components/Toggle/ToggleTypes.d.ts +0 -4
  271. package/dist/components/VideoPlayer/VideoPlayerTypes.d.ts +0 -9
  272. package/dist/helpers/enums.d.ts +0 -4
  273. package/dist/utils/siteSections.d.ts +0 -2
  274. package/src/components/Accordion/AccordionTypes.tsx +0 -5
  275. package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +0 -8
  276. package/src/components/Button/ButtonTypes.tsx +0 -8
  277. package/src/components/DatePicker/DatePickerTypes.tsx +0 -5
  278. package/src/components/Form/FormTypes.tsx +0 -3
  279. package/src/components/Grid/GridTypes.tsx +0 -9
  280. package/src/components/Heading/HeadingTypes.tsx +0 -15
  281. package/src/components/Hero/HeroTypes.tsx +0 -20
  282. package/src/components/Icons/IconTypes.tsx +0 -83
  283. package/src/components/Image/ImageTypes.ts +0 -24
  284. package/src/components/Link/LinkTypes.tsx +0 -8
  285. package/src/components/List/ListTypes.tsx +0 -5
  286. package/src/components/Logo/LogoTypes.tsx +0 -56
  287. package/src/components/Notification/NotificationTypes.tsx +0 -5
  288. package/src/components/ProgressIndicator/ProgressIndicatorTypes.ts +0 -8
  289. package/src/components/Select/SelectTypes.tsx +0 -10
  290. package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +0 -5
  291. package/src/components/StatusBadge/StatusBadgeTypes.tsx +0 -5
  292. package/src/components/StructuredContent/StructuredContentTypes.tsx +0 -5
  293. package/src/components/Text/TextTypes.tsx +0 -6
  294. package/src/components/TextInput/TextInputTypes.tsx +0 -48
  295. package/src/components/Toggle/ToggleTypes.tsx +0 -4
  296. package/src/components/VideoPlayer/VideoPlayerTypes.tsx +0 -10
  297. package/src/helpers/enums.ts +0 -4
  298. package/src/utils/siteSections.ts +0 -10
@@ -4,11 +4,10 @@ import { axe } from "jest-axe";
4
4
  import renderer from "react-test-renderer";
5
5
 
6
6
  import Icon from "./Icon";
7
- import { IconNames } from "./IconTypes";
8
7
 
9
8
  describe("Icon Accessibility", () => {
10
9
  it("passes axe accessibility test", async () => {
11
- const { container } = render(<Icon name={IconNames.Download} />);
10
+ const { container } = render(<Icon name="download" />);
12
11
  expect(await axe(container)).toHaveNoViolations();
13
12
  });
14
13
  });
@@ -17,7 +16,7 @@ describe("Icon", () => {
17
16
  it("consoles a warning if both name and children are passed to Icon", () => {
18
17
  const warn = jest.spyOn(console, "warn");
19
18
  render(
20
- <Icon name={IconNames.Download} decorative={true}>
19
+ <Icon name="download" decorative={true}>
21
20
  <svg viewBox="0 0 24 14" xmlns="http://www.w3.org/2000/svg">
22
21
  <path
23
22
  fillRule="evenodd"
@@ -52,7 +51,7 @@ describe("Icon", () => {
52
51
  });
53
52
 
54
53
  it("renders an icon based on the icon `name` prop", () => {
55
- const { container } = render(<Icon name={IconNames.Download} />);
54
+ const { container } = render(<Icon name="download" />);
56
55
  expect(container.querySelector("svg")).toBeInTheDocument();
57
56
  });
58
57
 
@@ -61,13 +60,13 @@ describe("Icon", () => {
61
60
  // In order to test this, we can check the `title` attribute in the svg
62
61
  // element itself. Inspect the `Icon` in Storybook to see the `title` element.
63
62
  it("renders a title element", () => {
64
- const { container, rerender } = render(<Icon name={IconNames.Download} />);
63
+ const { container, rerender } = render(<Icon name="download" />);
65
64
  expect(container.querySelector("svg")).toHaveAttribute(
66
65
  "title",
67
66
  "download icon"
68
67
  );
69
68
 
70
- rerender(<Icon name={IconNames.Download} title="title content" />);
69
+ rerender(<Icon name="download" title="title content" />);
71
70
  expect(container.querySelector("svg")).toHaveAttribute(
72
71
  "title",
73
72
  "title content"
@@ -90,9 +89,7 @@ describe("Icon", () => {
90
89
  });
91
90
 
92
91
  it("renders the UI snapshot correctly", () => {
93
- const basic = renderer
94
- .create(<Icon id="basic" name={IconNames.Download} />)
95
- .toJSON();
92
+ const basic = renderer.create(<Icon id="basic" name="download" />).toJSON();
96
93
  const customIcon = renderer
97
94
  .create(
98
95
  <Icon id="customIcon">
@@ -108,16 +105,11 @@ describe("Icon", () => {
108
105
  .toJSON();
109
106
  const withChakraProps = renderer
110
107
  .create(
111
- <Icon
112
- id="chakra"
113
- name={IconNames.Download}
114
- p="20px"
115
- color="ui.error.primary"
116
- />
108
+ <Icon id="chakra" name="download" p="20px" color="ui.error.primary" />
117
109
  )
118
110
  .toJSON();
119
111
  const withOtherProps = renderer
120
- .create(<Icon id="props" name={IconNames.Download} data-testid="props" />)
112
+ .create(<Icon id="props" name="download" data-testid="props" />)
121
113
  .toJSON();
122
114
 
123
115
  expect(basic).toMatchSnapshot();
@@ -6,19 +6,76 @@ import {
6
6
  } from "@chakra-ui/react";
7
7
  import * as React from "react";
8
8
 
9
- import {
10
- IconAlign,
11
- IconColors,
12
- IconNames,
13
- IconRotationTypes,
14
- IconSizes,
15
- IconTypes,
16
- } from "./IconTypes";
17
9
  import iconSvgs from "./IconSvgs";
18
10
 
11
+ export type IconAlign = "left" | "right" | "none";
12
+ export type IconColors =
13
+ | "ui.black"
14
+ | "ui.white"
15
+ | "brand.primary"
16
+ | "brand.secondary"
17
+ | "section.blogs.primary"
18
+ | "section.blogs.secondary"
19
+ | "section.books-and-more.primary"
20
+ | "section.books-and-more.secondary"
21
+ | "section.education.primary"
22
+ | "section.education.secondary"
23
+ | "section.locations.primary"
24
+ | "section.locations.secondary"
25
+ | "section.research.primary"
26
+ | "section.research.secondary"
27
+ | "section.research-library.lpa"
28
+ | "section.research-library.schomburg"
29
+ | "section.research-library.schwartzman"
30
+ | "section.whats-on.primary"
31
+ | "section.whats-on.secondary";
32
+ export type IconNames =
33
+ | "accessibilityFull"
34
+ | "accessibilityPartial"
35
+ | "actionCheckCircle"
36
+ | "actionHelpDefault"
37
+ | "actionHelpOutline"
38
+ | "actionLaunch"
39
+ | "alertNotificationImportant"
40
+ | "arrow"
41
+ | "check"
42
+ | "clock"
43
+ | "close"
44
+ | "download"
45
+ | "errorFilled"
46
+ | "errorOutline"
47
+ | "fileTypeAudio"
48
+ | "fileTypeDoc"
49
+ | "fileTypeGenericDoc"
50
+ | "fileTypeImage"
51
+ | "fileTypePdf"
52
+ | "fileTypeSpreadsheet"
53
+ | "fileTypeVideo"
54
+ | "headset"
55
+ | "minus"
56
+ | "plus"
57
+ | "search"
58
+ | "speakerNotes"
59
+ | "utilityAccountFilled"
60
+ | "utilityAccountUnfilled"
61
+ | "utilityHamburger"
62
+ | "utilitySearch";
63
+ export type IconRotationTypes =
64
+ | "rotate0"
65
+ | "rotate90"
66
+ | "rotate180"
67
+ | "rotate270";
68
+ export type IconSizes =
69
+ | "default"
70
+ | "small"
71
+ | "medium"
72
+ | "large"
73
+ | "xlarge"
74
+ | "xxlarge"
75
+ | "xxxlarge";
76
+ export type IconTypes = "default" | "breadcrumbs";
77
+
19
78
  export interface IconProps {
20
- /** Optionally pass in additional Chakra-based styles. */
21
- additionalStyles?: { [key: string]: any };
22
79
  /** Aligns the icon. */
23
80
  align?: IconAlign;
24
81
  /** Optional className that will be added to the parent element */
@@ -50,18 +107,17 @@ export interface IconProps {
50
107
  export const Icon = chakra(
51
108
  (props: React.PropsWithChildren<IconProps>) => {
52
109
  const {
53
- additionalStyles = {},
54
- align = IconAlign.None,
110
+ align = "none",
55
111
  children,
56
112
  className,
57
- color = IconColors.UiBlack,
113
+ color = "ui.black",
58
114
  decorative = true,
59
- iconRotation = IconRotationTypes.Rotate0,
115
+ iconRotation = "rotate0",
60
116
  id,
61
117
  name,
62
- size = IconSizes.Default,
118
+ size = "default",
63
119
  title = `${name} icon`,
64
- type = IconTypes.Default,
120
+ type = "default",
65
121
  ...rest
66
122
  } = props;
67
123
  const styles = useStyleConfig("Icon", {
@@ -101,13 +157,7 @@ export const Icon = chakra(
101
157
  // render the SVG child with NYPL-theme styling.
102
158
  if (name) {
103
159
  const SvgComponent: any = iconSvgs[name];
104
- return (
105
- <ChakraIcon
106
- as={SvgComponent}
107
- {...iconProps}
108
- __css={{ ...styles, ...additionalStyles }}
109
- />
110
- );
160
+ return <ChakraIcon as={SvgComponent} {...iconProps} __css={styles} />;
111
161
  }
112
162
 
113
163
  // If no `name` prop was passed, we expect a child SVG element to be passed.
@@ -127,14 +177,10 @@ export const Icon = chakra(
127
177
  );
128
178
  }
129
179
 
130
- return (
131
- <Box __css={styles} {...rest}>
132
- {childSVG}
133
- </Box>
134
- );
180
+ return <Box __css={styles}>{childSVG}</Box>;
135
181
  },
136
182
  // Pass all custom props to Chakra and override, e.g. we want the
137
- // DS color prop to use the DS enum and not color strings.
183
+ // DS color value set and not color strings.
138
184
  { shouldForwardProp: () => true }
139
185
  );
140
186
 
@@ -1,64 +1,64 @@
1
1
  /* eslint-disable camelcase */
2
- import accessibility_full from "../../../icons/svg/accessibility_full.svg";
3
- import accessibility_partial from "../../../icons/svg/accessibility_partial.svg";
4
- import action_check_circle from "../../../icons/svg/action_check_circle.svg";
5
- import action_help_default from "../../../icons/svg/action_help_default.svg";
6
- import action_help_outline from "../../../icons/svg/action_help_outline.svg";
7
- import action_launch from "../../../icons/svg/action_launch.svg";
8
- import alert_notification_important from "../../../icons/svg/alert_notification_important.svg";
2
+ import accessibilityFull from "../../../icons/svg/accessibility-full.svg";
3
+ import accessibilityPartial from "../../../icons/svg/accessibility-partial.svg";
4
+ import actionCheckCircle from "../../../icons/svg/action-check-circle.svg";
5
+ import actionHelpDefault from "../../../icons/svg/action-help-default.svg";
6
+ import actionHelpOutline from "../../../icons/svg/action-help-outline.svg";
7
+ import actionLaunch from "../../../icons/svg/action-launch.svg";
8
+ import alertNotificationImportant from "../../../icons/svg/alert-notification-important.svg";
9
9
  import arrow from "../../../icons/svg/arrow.svg";
10
10
  import check from "../../../icons/svg/check.svg";
11
11
  import clock from "../../../icons/svg/clock.svg";
12
12
  import close from "../../../icons/svg/close.svg";
13
- import file_type_audio from "../../../icons/svg/file_type_audio.svg";
14
- import file_type_doc from "../../../icons/svg/file_type_doc.svg";
15
- import file_type_generic_doc from "../../../icons/svg/file_type_generic_doc.svg";
16
- import file_type_image from "../../../icons/svg/file_type_image.svg";
17
- import file_type_pdf from "../../../icons/svg/file_type_pdf.svg";
18
- import file_type_spreadsheet from "../../../icons/svg/file_type_spreadsheet.svg";
19
- import file_type_video from "../../../icons/svg/file_type_video.svg";
13
+ import fileTypeAudio from "../../../icons/svg/file-type-audio.svg";
14
+ import fileTypeDoc from "../../../icons/svg/file-type-doc.svg";
15
+ import fileTypeGenericDoc from "../../../icons/svg/file-type-generic-doc.svg";
16
+ import fileTypeImage from "../../../icons/svg/file-type-image.svg";
17
+ import fileTypePdf from "../../../icons/svg/file-type-pdf.svg";
18
+ import fileTypeSpreadsheet from "../../../icons/svg/file-type-spreadsheet.svg";
19
+ import fileTypeVideo from "../../../icons/svg/file-type-video.svg";
20
20
  import download from "../../../icons/svg/download.svg";
21
- import error_filled from "../../../icons/svg/error_filled.svg";
22
- import error_outline from "../../../icons/svg/error_outline.svg";
21
+ import errorFilled from "../../../icons/svg/error-filled.svg";
22
+ import errorOutline from "../../../icons/svg/error-outline.svg";
23
23
  import headset from "../../../icons/svg/headset.svg";
24
24
  import minus from "../../../icons/svg/minus.svg";
25
25
  import plus from "../../../icons/svg/plus.svg";
26
26
  import search from "../../../icons/svg/search.svg";
27
- import speaker_notes from "../../../icons/svg/speaker_notes.svg";
28
- import utility_account_filled from "../../../icons/svg/utility_account_filled.svg";
29
- import utility_account_unfilled from "../../../icons/svg/utility_account_unfilled.svg";
30
- import utility_hamburger from "../../../icons/svg/utility_hamburger.svg";
31
- import utility_search from "../../../icons/svg/search.svg";
27
+ import speakerNotes from "../../../icons/svg/speaker-notes.svg";
28
+ import utilityAccountFilled from "../../../icons/svg/utility-account-filled.svg";
29
+ import utilityAccountUnfilled from "../../../icons/svg/utility-account-unfilled.svg";
30
+ import utilityHamburger from "../../../icons/svg/utility-hamburger.svg";
31
+ import utilitySearch from "../../../icons/svg/search.svg";
32
32
 
33
33
  export default {
34
- accessibility_full,
35
- accessibility_partial,
36
- action_check_circle,
37
- action_help_default,
38
- action_help_outline,
39
- action_launch,
40
- alert_notification_important,
34
+ accessibilityFull,
35
+ accessibilityPartial,
36
+ actionCheckCircle,
37
+ actionHelpDefault,
38
+ actionHelpOutline,
39
+ actionLaunch,
40
+ alertNotificationImportant,
41
41
  arrow,
42
42
  check,
43
43
  clock,
44
44
  close,
45
45
  download,
46
- error_filled,
47
- error_outline,
48
- file_type_audio,
49
- file_type_doc,
50
- file_type_generic_doc,
51
- file_type_image,
52
- file_type_pdf,
53
- file_type_spreadsheet,
54
- file_type_video,
46
+ errorFilled,
47
+ errorOutline,
48
+ fileTypeAudio,
49
+ fileTypeDoc,
50
+ fileTypeGenericDoc,
51
+ fileTypeImage,
52
+ fileTypePdf,
53
+ fileTypeSpreadsheet,
54
+ fileTypeVideo,
55
55
  headset,
56
56
  minus,
57
57
  plus,
58
58
  search,
59
- speaker_notes,
60
- utility_account_filled,
61
- utility_account_unfilled,
62
- utility_hamburger,
63
- utility_search,
59
+ speakerNotes,
60
+ utilityAccountFilled,
61
+ utilityAccountUnfilled,
62
+ utilityHamburger,
63
+ utilitySearch,
64
64
  };
@@ -9,19 +9,9 @@ import {
9
9
  import { withDesign } from "storybook-addon-designs";
10
10
 
11
11
  import Heading from "../Heading/Heading";
12
- import { HeadingLevels } from "../Heading/HeadingTypes";
13
12
  import Image from "./Image";
14
- import { ImageRatios, ImageSizes, ImageTypes } from "./ImageTypes";
15
13
  import SimpleGrid from "../Grid/SimpleGrid";
16
14
  import { getCategory } from "../../utils/componentCategories";
17
- import { getStorybookEnumValues } from "../../utils/utils";
18
-
19
- export const ratiosEnumValues = getStorybookEnumValues(
20
- ImageRatios,
21
- "ImageRatios"
22
- );
23
- export const sizesEnumValues = getStorybookEnumValues(ImageSizes, "ImageSizes");
24
- export const typesEnumValues = getStorybookEnumValues(ImageTypes, "ImageTypes");
25
15
 
26
16
  export const imageBlockStyles = {
27
17
  margin: "auto",
@@ -51,9 +41,7 @@ export const imageBlockStyles = {
51
41
  "Alternate text description of the image. Needed for accessibility purposes.",
52
42
  },
53
43
  aspectRatio: {
54
- control: { type: "select" },
55
- table: { defaultValue: { summary: "ImageRatios.Original" } },
56
- options: ratiosEnumValues.options,
44
+ table: { defaultValue: { summary: "original" } },
57
45
  },
58
46
  className: {
59
47
  control: false,
@@ -61,14 +49,10 @@ export const imageBlockStyles = {
61
49
  },
62
50
  component: { control: false },
63
51
  imageType: {
64
- control: { type: "select" },
65
- table: { defaultValue: { summary: "ImageTypes.Default" } },
66
- options: typesEnumValues.options,
52
+ table: { defaultValue: { summary: "default" } },
67
53
  },
68
54
  size: {
69
- control: { type: "select" },
70
- table: { defaultValue: { summary: "ImageSizes.Default" } },
71
- options: sizesEnumValues.options,
55
+ table: { defaultValue: { summary: "default" } },
72
56
  },
73
57
  src: {
74
58
  description:
@@ -82,7 +66,7 @@ export const imageBlockStyles = {
82
66
  | Component Version | DS Version |
83
67
  | ----------------- | ---------- |
84
68
  | Added | `0.0.6` |
85
- | Latest | `0.26.0` |
69
+ | Latest | `0.28.0` |
86
70
 
87
71
  ## Table of Contents
88
72
 
@@ -111,24 +95,17 @@ If you want a simple HTML `img` element then don't pass in values for the
111
95
  additionalImageStyles: undefined,
112
96
  additionalWrapperStyles: undefined,
113
97
  alt: "Alt text",
114
- aspectRatio: "ImageRatios.TwoByOne",
98
+ aspectRatio: "twoByOne",
115
99
  caption: "Image caption",
116
100
  className: undefined,
117
101
  component: undefined,
118
102
  credit: "Image credit",
119
- imageType: "ImageTypes.Default",
120
- size: "ImageSizes.Medium",
103
+ imageType: "default",
104
+ size: "medium",
121
105
  src: "https://placeimg.com/400/300/animals",
122
106
  }}
123
107
  >
124
- {(args) => (
125
- <Image
126
- {...args}
127
- aspectRatio={ratiosEnumValues.getValue(args.aspectRatio)}
128
- imageType={typesEnumValues.getValue(args.imageType)}
129
- size={sizesEnumValues.getValue(args.size)}
130
- />
131
- )}
108
+ {(args) => <Image {...args} />}
132
109
  </Story>
133
110
  </Canvas>
134
111
 
@@ -158,11 +135,11 @@ then an `img` element will be rendered with or without wrapper style divs.
158
135
  name="Figure and figcaption"
159
136
  args={{
160
137
  alt: "Alt text",
161
- aspectRatio: ImageRatios.ThreeByTwo,
138
+ aspectRatio: "threeByTwo",
162
139
  caption: "Image caption",
163
140
  credit: "Image credit",
164
- imageType: ImageTypes.Default,
165
- size: ImageSizes.Medium,
141
+ imageType: "default",
142
+ size: "medium",
166
143
  src: "https://placeimg.com/400/300/animals",
167
144
  }}
168
145
  argTypes={{
@@ -186,76 +163,52 @@ Use the `size` prop to set the desired size with the `ImageSizes` enum.
186
163
  <Story name="Image Sizes">
187
164
  <SimpleGrid columns={1}>
188
165
  <div style={{ textAlign: "center" }}>
189
- <Heading
190
- id="ExtraExtraSmall"
191
- level={HeadingLevels.Four}
192
- text="ImageSizes.ExtraExtraSmall"
193
- />
166
+ <Heading id="ExtraExtraSmall" level="four" text="xxsmall" />
194
167
  <Image
195
168
  alt="Alt text"
196
169
  caption="64px"
197
- size={ImageSizes.ExtraExtraSmall}
170
+ size="xxsmall"
198
171
  src="https://placeimg.com/400/300/animals"
199
172
  />
200
173
  </div>
201
174
  <div style={{ textAlign: "center" }}>
202
- <Heading
203
- id="ExtraSmall"
204
- level={HeadingLevels.Four}
205
- text="ImageSizes.ExtraSmall"
206
- />
175
+ <Heading id="ExtraSmall" level="four" text="xsmall" />
207
176
  <Image
208
177
  alt="Alt text"
209
178
  caption="96px"
210
- size={ImageSizes.ExtraSmall}
179
+ size="xsmall"
211
180
  src="https://placeimg.com/400/300/animals"
212
181
  />
213
182
  </div>
214
183
  <div style={{ textAlign: "center" }}>
215
- <Heading
216
- id="Small"
217
- level={HeadingLevels.Four}
218
- text="ImageSizes.Small"
219
- />
184
+ <Heading id="Small" level="four" text="small" />
220
185
  <Image
221
186
  alt="Alt text"
222
187
  caption="165px"
223
- size={ImageSizes.Small}
188
+ size="small"
224
189
  src="https://placeimg.com/400/300/animals"
225
190
  />
226
191
  </div>
227
192
  <div style={{ textAlign: "center" }}>
228
- <Heading
229
- id="Medium"
230
- level={HeadingLevels.Four}
231
- text="ImageSizes.Medium"
232
- />
193
+ <Heading id="Medium" level="four" text="medium" />
233
194
  <Image
234
195
  alt="Alt text"
235
196
  caption="225px"
236
- size={ImageSizes.Medium}
197
+ size="medium"
237
198
  src="https://placeimg.com/400/300/animals"
238
199
  />
239
200
  </div>
240
201
  <div style={{ textAlign: "center" }}>
241
- <Heading
242
- id="Large"
243
- level={HeadingLevels.Four}
244
- text="ImageSizes.Large"
245
- />
202
+ <Heading id="Large" level="four" text="large" />
246
203
  <Image
247
204
  alt="Alt text"
248
205
  caption="360px"
249
- size={ImageSizes.Large}
206
+ size="large"
250
207
  src="https://placeimg.com/400/300/animals"
251
208
  />
252
209
  </div>
253
210
  <div style={{ textAlign: "center" }}>
254
- <Heading
255
- id="Default"
256
- level={HeadingLevels.Four}
257
- text="ImageSizes.Default"
258
- />
211
+ <Heading id="Default" level="four" text="default" />
259
212
  <Image
260
213
  alt="Alt text"
261
214
  caption="100%"
@@ -278,98 +231,66 @@ in an element with a fixed width value.
278
231
  <Story name="Image Aspect Ratios">
279
232
  <SimpleGrid columns={1}>
280
233
  <div style={imageBlockStyles}>
281
- <Heading
282
- id="fourbythree"
283
- level={HeadingLevels.Four}
284
- text="ImageRatios.FourByThree"
285
- />
234
+ <Heading id="fourbythree" level="four" text="fourByThree" />
286
235
  <Image
287
236
  alt="Alt text"
288
- aspectRatio={ImageRatios.FourByThree}
237
+ aspectRatio="fourByThree"
289
238
  src="https://placeimg.com/400/300/animals"
290
239
  />
291
240
  </div>
292
241
  <div style={imageBlockStyles}>
293
- <Heading
294
- id="onebytwo"
295
- level={HeadingLevels.Four}
296
- text="ImageRatios.OneByTwo"
297
- />
242
+ <Heading id="onebytwo" level="four" text="oneByTwo" />
298
243
  <Image
299
244
  alt="Alt text"
300
- aspectRatio={ImageRatios.OneByTwo}
245
+ aspectRatio="oneByTwo"
301
246
  src="https://placeimg.com/400/300/animals"
302
247
  />
303
248
  </div>
304
249
  <div style={imageBlockStyles}>
305
- <Heading
306
- id="original"
307
- level={HeadingLevels.Four}
308
- text="ImageRatios.Original"
309
- />
250
+ <Heading id="original" level="four" text="original" />
310
251
  <Image
311
252
  alt="Alt text"
312
- aspectRatio={ImageRatios.Original}
253
+ aspectRatio="original"
313
254
  src="https://placeimg.com/400/300/animals"
314
255
  />
315
256
  </div>
316
257
  <div style={imageBlockStyles}>
317
- <Heading
318
- id="sixteenbynine"
319
- level={HeadingLevels.Four}
320
- text="ImageRatios.SixteenByNine"
321
- />
258
+ <Heading id="sixteenbynine" level="four" text="sixteenByNine" />
322
259
  <Image
323
260
  alt="Alt text"
324
- aspectRatio={ImageRatios.SixteenByNine}
261
+ aspectRatio="sixteenByNine"
325
262
  src="https://placeimg.com/400/300/animals"
326
263
  />
327
264
  </div>
328
265
  <div style={imageBlockStyles}>
329
- <Heading
330
- id="square"
331
- level={HeadingLevels.Four}
332
- text="ImageRatios.Square"
333
- />
266
+ <Heading id="square" level="four" text="square" />
334
267
  <Image
335
268
  alt="Alt text"
336
- aspectRatio={ImageRatios.Square}
269
+ aspectRatio="square"
337
270
  src="https://placeimg.com/400/300/animals"
338
271
  />
339
272
  </div>
340
273
  <div style={imageBlockStyles}>
341
- <Heading
342
- id="threebyfour"
343
- level={HeadingLevels.Four}
344
- text="ImageRatios.ThreeByFour"
345
- />
274
+ <Heading id="threebyfour" level="four" text="threeByFour" />
346
275
  <Image
347
276
  alt="Alt text"
348
- aspectRatio={ImageRatios.ThreeByFour}
277
+ aspectRatio="threeByFour"
349
278
  src="https://placeimg.com/400/300/animals"
350
279
  />
351
280
  </div>
352
281
  <div style={imageBlockStyles}>
353
- <Heading
354
- id="threebytwo"
355
- level={HeadingLevels.Four}
356
- text="ImageRatios.ThreeByTwo"
357
- />
282
+ <Heading id="threebytwo" level="four" text="threeByTwo" />
358
283
  <Image
359
284
  alt="Alt text"
360
- aspectRatio={ImageRatios.ThreeByTwo}
285
+ aspectRatio="threeByTwo"
361
286
  src="https://placeimg.com/400/300/animals"
362
287
  />
363
288
  </div>
364
289
  <div style={imageBlockStyles}>
365
- <Heading
366
- id="twobyone"
367
- level={HeadingLevels.Four}
368
- text="ImageRatios.TwoByOne"
369
- />
290
+ <Heading id="twobyone" level="four" text="twoByOne" />
370
291
  <Image
371
292
  alt="Alt text"
372
- aspectRatio={ImageRatios.TwoByOne}
293
+ aspectRatio="twoByOne"
373
294
  src="https://placeimg.com/400/300/animals"
374
295
  />
375
296
  </div>
@@ -380,7 +301,7 @@ in an element with a fixed width value.
380
301
  ## Image Types
381
302
 
382
303
  Use the `imageType` prop to get an image variant. Note that to get a perfect
383
- circle, the `aspectRatio` prop _must_ be set to `ImageRatios.Square`.
304
+ circle, the `aspectRatio` prop _must_ be set to `"square"`.
384
305
 
385
306
  For a better viewing experience, the `Image` components below have been wrapped
386
307
  in an element with a fixed width value.
@@ -389,28 +310,20 @@ in an element with a fixed width value.
389
310
  <Story name="Image Types">
390
311
  <SimpleGrid columns={1}>
391
312
  <div style={imageBlockStyles}>
392
- <Heading
393
- id="default"
394
- level={HeadingLevels.Four}
395
- text="ImageTypes.Default"
396
- />
313
+ <Heading id="default" level="four" text="default" />
397
314
  <Image
398
315
  alt="Alt text"
399
- aspectRatio={ImageRatios.Square}
400
- imageType={ImageTypes.Default}
316
+ aspectRatio="square"
317
+ imageType="default"
401
318
  src="https://placeimg.com/400/400/animals"
402
319
  />
403
320
  </div>
404
321
  <div style={imageBlockStyles}>
405
- <Heading
406
- id="circle"
407
- level={HeadingLevels.Four}
408
- text="ImageTypes.Circle"
409
- />
322
+ <Heading id="circle" level="four" text="circle" />
410
323
  <Image
411
324
  alt="Alt text"
412
- aspectRatio={ImageRatios.Square}
413
- imageType={ImageTypes.Circle}
325
+ aspectRatio="square"
326
+ imageType="circle"
414
327
  src="https://placeimg.com/400/400/animals"
415
328
  />
416
329
  </div>