@nypl/design-system-react-components 0.23.4 → 0.25.1

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 (307) hide show
  1. package/CHANGELOG.md +98 -1
  2. package/README.md +46 -11
  3. package/dist/components/Accordion/Accordion.d.ts +14 -14
  4. package/dist/components/Autosuggest/Autosuggest.stories.d.ts +1 -0
  5. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +11 -14
  6. package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +6 -0
  7. package/dist/components/Button/Button.d.ts +6 -13
  8. package/dist/components/Button/ButtonTypes.d.ts +5 -3
  9. package/dist/components/Card/Card.d.ts +59 -10
  10. package/dist/components/Card/CardTypes.d.ts +19 -0
  11. package/dist/components/CardEdition/CardEdition.d.ts +21 -0
  12. package/dist/components/{StyleGuide/Colors.stories.d.ts → CardEdition/CardEdition.stories.d.ts} +5 -2
  13. package/dist/components/Checkbox/Checkbox.d.ts +21 -16
  14. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +43 -0
  15. package/dist/components/CheckboxGroup/CheckboxGroupLayoutTypes.d.ts +4 -0
  16. package/dist/components/DatePicker/DatePicker.d.ts +79 -0
  17. package/dist/components/DatePicker/DatePickerTypes.d.ts +5 -0
  18. package/dist/components/Form/Form.d.ts +16 -8
  19. package/dist/components/Form/FormTypes.d.ts +2 -0
  20. package/dist/components/Grid/GridTypes.d.ts +9 -0
  21. package/dist/components/Grid/SimpleGrid.d.ts +14 -0
  22. package/dist/components/Heading/Heading.d.ts +9 -11
  23. package/dist/components/Heading/{HeadingDisplaySizes.d.ts → HeadingTypes.d.ts} +8 -0
  24. package/dist/components/HelperErrorText/HelperErrorText.stories.d.ts +2 -1
  25. package/dist/components/Hero/Hero.d.ts +19 -14
  26. package/dist/components/Hero/HeroTypes.d.ts +10 -5
  27. package/dist/components/Icons/Icon.d.ts +13 -16
  28. package/dist/components/Icons/IconSvgs.d.ts +4 -0
  29. package/dist/components/Icons/IconTypes.d.ts +78 -60
  30. package/dist/components/Image/Image.stories.d.ts +2 -1
  31. package/dist/components/Label/Label.d.ts +10 -26
  32. package/dist/components/Link/Link.d.ts +8 -12
  33. package/dist/components/List/List.stories.d.ts +1 -0
  34. package/dist/components/Radio/Radio.d.ts +30 -24
  35. package/dist/components/RadioGroup/RadioGroup.d.ts +40 -0
  36. package/dist/components/RadioGroup/RadioGroupLayoutTypes.d.ts +4 -0
  37. package/dist/components/SearchBar/SearchBar.d.ts +45 -27
  38. package/dist/components/Select/Select.d.ts +34 -35
  39. package/dist/components/Select/SelectTypes.d.ts +4 -0
  40. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +1 -1
  41. package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +2 -2
  42. package/dist/components/StatusBadge/StatusBadge.d.ts +8 -6
  43. package/dist/components/StatusBadge/StatusBadgeTypes.d.ts +5 -0
  44. package/dist/components/Tabs/Tabs.d.ts +25 -0
  45. package/dist/components/Template/Template.d.ts +91 -0
  46. package/dist/components/Text/Text.d.ts +16 -0
  47. package/dist/components/Text/TextTypes.d.ts +6 -0
  48. package/dist/components/TextInput/TextInput.d.ts +37 -30
  49. package/dist/components/TextInput/TextInputTypes.d.ts +5 -0
  50. package/dist/design-system-react-components.cjs.development.js +4102 -917
  51. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  52. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  53. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  54. package/dist/design-system-react-components.esm.js +4023 -920
  55. package/dist/design-system-react-components.esm.js.map +1 -1
  56. package/dist/index.d.ts +23 -5
  57. package/dist/resources.scss +133 -24
  58. package/dist/styles.css +1 -1
  59. package/dist/theme/components/accordion.d.ts +25 -0
  60. package/dist/theme/components/breadcrumb.d.ts +90 -0
  61. package/dist/theme/components/button.d.ts +109 -0
  62. package/dist/theme/components/checkbox.d.ts +91 -0
  63. package/dist/theme/components/customCheckboxGroup.d.ts +18 -0
  64. package/dist/theme/components/customRadioGroup.d.ts +18 -0
  65. package/dist/theme/components/global.d.ts +55 -0
  66. package/dist/theme/components/globalMixins.d.ts +15 -0
  67. package/dist/theme/components/heading.d.ts +110 -0
  68. package/dist/theme/components/hero.d.ts +492 -0
  69. package/dist/theme/components/icon.d.ts +13 -0
  70. package/dist/theme/components/label.d.ts +16 -0
  71. package/dist/theme/components/link.d.ts +45 -0
  72. package/dist/theme/components/radio.d.ts +95 -0
  73. package/dist/theme/components/searchBar.d.ts +20 -0
  74. package/dist/theme/components/select.d.ts +58 -0
  75. package/dist/theme/components/statusBadge.d.ts +25 -0
  76. package/dist/theme/components/tabs.d.ts +85 -0
  77. package/dist/theme/components/template.d.ts +105 -0
  78. package/dist/theme/components/text.d.ts +20 -0
  79. package/dist/theme/components/textInput.d.ts +105 -0
  80. package/dist/theme/foundations/breakpoints.d.ts +23 -0
  81. package/dist/theme/foundations/colors.d.ts +3 -0
  82. package/dist/theme/foundations/global.d.ts +23 -0
  83. package/dist/theme/foundations/shadows.d.ts +4 -0
  84. package/dist/theme/foundations/spacing.d.ts +77 -0
  85. package/dist/theme/foundations/typography.d.ts +8 -0
  86. package/dist/theme/index.d.ts +20 -0
  87. package/dist/theme/provider.d.ts +5 -0
  88. package/dist/theme/types.d.ts +1 -0
  89. package/dist/utils/utils.d.ts +6 -0
  90. package/package.json +9 -2
  91. package/src/components/Accordion/Accordion.stories.mdx +233 -33
  92. package/src/components/Accordion/Accordion.test.tsx +135 -19
  93. package/src/components/Accordion/Accordion.tsx +81 -56
  94. package/src/components/Autosuggest/Autosuggest.stories.mdx +4 -3
  95. package/src/components/Autosuggest/Autosuggest.stories.tsx +1 -1
  96. package/src/components/Autosuggest/_Autosuggest.scss +2 -2
  97. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +57 -56
  98. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +31 -25
  99. package/src/components/Breadcrumbs/Breadcrumbs.tsx +71 -73
  100. package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +6 -0
  101. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +100 -0
  102. package/src/components/Button/Button.stories.mdx +125 -138
  103. package/src/components/Button/Button.test.tsx +65 -11
  104. package/src/components/Button/Button.tsx +72 -68
  105. package/src/components/Button/ButtonTypes.tsx +4 -2
  106. package/src/components/Button/_Button.scss +7 -92
  107. package/src/components/Button/__snapshots__/Button.test.tsx.snap +58 -3
  108. package/src/components/Card/Card.stories.mdx +694 -0
  109. package/src/components/Card/Card.test.tsx +97 -102
  110. package/src/components/Card/Card.tsx +182 -31
  111. package/src/components/Card/CardTypes.tsx +21 -0
  112. package/src/components/Card/_Card.scss +234 -49
  113. package/src/components/{Card/Card.stories.tsx → CardEdition/CardEdition.stories.tsx} +32 -22
  114. package/src/components/CardEdition/CardEdition.test.tsx +395 -0
  115. package/src/components/CardEdition/CardEdition.tsx +60 -0
  116. package/src/components/CardEdition/_CardEdition.scss +138 -0
  117. package/src/components/Chakra/Box.stories.mdx +57 -0
  118. package/src/components/Chakra/Center.stories.mdx +99 -0
  119. package/src/components/Chakra/Grid.stories.mdx +79 -0
  120. package/src/components/Chakra/Stack.stories.mdx +93 -0
  121. package/src/components/Checkbox/Checkbox.stories.mdx +57 -35
  122. package/src/components/Checkbox/Checkbox.test.tsx +117 -147
  123. package/src/components/Checkbox/Checkbox.tsx +76 -50
  124. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +325 -0
  125. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +249 -0
  126. package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +345 -0
  127. package/src/components/CheckboxGroup/CheckboxGroup.tsx +148 -0
  128. package/src/components/CheckboxGroup/CheckboxGroupLayoutTypes.tsx +4 -0
  129. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +1360 -0
  130. package/src/components/DatePicker/DatePicker.stories.mdx +284 -0
  131. package/src/components/DatePicker/DatePicker.test.tsx +657 -0
  132. package/src/components/DatePicker/DatePicker.tsx +396 -0
  133. package/src/components/DatePicker/DatePickerTypes.tsx +5 -0
  134. package/src/components/DatePicker/_DatePicker.scss +76 -0
  135. package/src/components/Form/Form.stories.mdx +130 -27
  136. package/src/components/Form/Form.test.tsx +78 -36
  137. package/src/components/Form/Form.tsx +53 -19
  138. package/src/components/Form/FormTypes.tsx +3 -0
  139. package/src/components/Form/__snapshots__/Form.test.tsx.snap +38 -0
  140. package/src/components/Grid/GridTypes.tsx +9 -0
  141. package/src/components/Grid/SimpleGrid.stories.mdx +275 -0
  142. package/src/components/Grid/SimpleGrid.test.tsx +66 -0
  143. package/src/components/Grid/SimpleGrid.tsx +37 -0
  144. package/src/components/Grid/__snapshots__/SimpleGrid.test.tsx.snap +8 -0
  145. package/src/components/Heading/Heading.stories.mdx +63 -33
  146. package/src/components/Heading/Heading.test.tsx +24 -16
  147. package/src/components/Heading/Heading.tsx +54 -38
  148. package/src/components/Heading/{HeadingDisplaySizes.tsx → HeadingTypes.tsx} +9 -0
  149. package/src/components/HelperErrorText/HelperErrorText.stories.tsx +2 -1
  150. package/src/components/HelperErrorText/_HelperErrorText.scss +1 -1
  151. package/src/components/Hero/Hero.stories.mdx +195 -85
  152. package/src/components/Hero/Hero.test.tsx +544 -113
  153. package/src/components/Hero/Hero.tsx +80 -93
  154. package/src/components/Hero/HeroTypes.tsx +17 -5
  155. package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +307 -0
  156. package/src/components/HorizontalRule/HorizontalRule.stories.mdx +6 -1
  157. package/src/components/HorizontalRule/_HorizontalRule.scss +1 -1
  158. package/src/components/Icons/Icon.stories.mdx +89 -74
  159. package/src/components/Icons/Icon.test.tsx +30 -22
  160. package/src/components/Icons/Icon.tsx +63 -61
  161. package/src/components/Icons/IconSvgs.tsx +8 -0
  162. package/src/components/Icons/IconTypes.tsx +80 -60
  163. package/src/components/Image/Image.stories.tsx +2 -1
  164. package/src/components/Input/_Input.scss +2 -2
  165. package/src/components/Label/Label.stories.mdx +77 -0
  166. package/src/components/Label/Label.test.tsx +43 -12
  167. package/src/components/Label/Label.tsx +28 -45
  168. package/src/components/Label/__snapshots__/Label.test.tsx.snap +41 -0
  169. package/src/components/Link/Link.stories.mdx +47 -41
  170. package/src/components/Link/Link.test.tsx +33 -44
  171. package/src/components/Link/Link.tsx +114 -100
  172. package/src/components/List/List.stories.mdx +7 -3
  173. package/src/components/List/List.stories.tsx +14 -9
  174. package/src/components/List/List.test.tsx +12 -8
  175. package/src/components/List/List.tsx +9 -7
  176. package/src/components/List/_List.scss +3 -3
  177. package/src/components/Modal/Modal.stories.mdx +7 -3
  178. package/src/components/Modal/_Modal.scss +1 -1
  179. package/src/components/Notification/Notification.stories.mdx +99 -65
  180. package/src/components/Notification/Notification.test.tsx +3 -16
  181. package/src/components/Notification/Notification.tsx +12 -12
  182. package/src/components/Notification/_Notification.scss +5 -4
  183. package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +1 -1
  184. package/src/components/Pagination/Pagination.stories.mdx +7 -1
  185. package/src/components/Pagination/Pagination.test.tsx +16 -10
  186. package/src/components/Radio/Radio.stories.mdx +57 -46
  187. package/src/components/Radio/Radio.test.tsx +92 -138
  188. package/src/components/Radio/Radio.tsx +70 -69
  189. package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +250 -0
  190. package/src/components/RadioGroup/RadioGroup.stories.mdx +247 -0
  191. package/src/components/RadioGroup/RadioGroup.test.tsx +327 -0
  192. package/src/components/RadioGroup/RadioGroup.tsx +154 -0
  193. package/src/components/RadioGroup/RadioGroupLayoutTypes.tsx +4 -0
  194. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +1101 -0
  195. package/src/components/SearchBar/SearchBar.Test.tsx +151 -16
  196. package/src/components/SearchBar/SearchBar.stories.mdx +196 -224
  197. package/src/components/SearchBar/SearchBar.tsx +151 -46
  198. package/src/components/Select/Select.stories.mdx +193 -168
  199. package/src/components/Select/Select.test.tsx +129 -324
  200. package/src/components/Select/Select.tsx +120 -160
  201. package/src/components/Select/SelectTypes.tsx +4 -0
  202. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +18 -29
  203. package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +7 -7
  204. package/src/components/SkeletonLoader/SkeletonLoader.tsx +4 -2
  205. package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +2 -2
  206. package/src/components/SkeletonLoader/_SkeletonLoader.scss +3 -3
  207. package/src/components/StatusBadge/StatusBadge.stories.mdx +91 -0
  208. package/src/components/StatusBadge/StatusBadge.test.tsx +35 -7
  209. package/src/components/StatusBadge/StatusBadge.tsx +24 -25
  210. package/src/components/StatusBadge/StatusBadgeTypes.tsx +5 -0
  211. package/src/components/StatusBadge/__snapshots__/StatusBadge.test.tsx.snap +28 -0
  212. package/src/components/StyleGuide/Bidirectionality.stories.mdx +112 -90
  213. package/src/components/StyleGuide/Buttons.stories.mdx +98 -100
  214. package/src/components/StyleGuide/Colors.stories.mdx +336 -0
  215. package/src/components/StyleGuide/Forms.stories.mdx +85 -0
  216. package/src/components/StyleGuide/Iconography.stories.mdx +86 -93
  217. package/src/components/StyleGuide/Spacing.stories.mdx +0 -1
  218. package/src/components/StyleGuide/Typography.stories.mdx +164 -166
  219. package/src/components/StyleGuide/UIDocCard.tsx +4 -4
  220. package/src/components/Tabs/Tabs.stories.mdx +221 -0
  221. package/src/components/Tabs/Tabs.test.tsx +264 -0
  222. package/src/components/Tabs/Tabs.tsx +220 -0
  223. package/src/components/Template/Template.stories.mdx +574 -0
  224. package/src/components/Template/Template.test.tsx +124 -0
  225. package/src/components/Template/Template.tsx +226 -0
  226. package/src/components/Text/Text.stories.mdx +70 -0
  227. package/src/components/Text/Text.test.tsx +63 -0
  228. package/src/components/Text/Text.tsx +55 -0
  229. package/src/components/Text/TextTypes.tsx +6 -0
  230. package/src/components/Text/__snapshots__/Text.test.tsx.snap +33 -0
  231. package/src/components/TextInput/TextInput.stories.mdx +90 -90
  232. package/src/components/TextInput/TextInput.test.tsx +103 -83
  233. package/src/components/TextInput/TextInput.tsx +108 -91
  234. package/src/components/TextInput/TextInputTypes.tsx +6 -0
  235. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +2 -1
  236. package/src/components/VideoPlayer/VideoPlayer.tsx +4 -2
  237. package/src/components/VideoPlayer/_VideoPlayer.scss +1 -1
  238. package/src/docs/Chakra.stories.mdx +341 -0
  239. package/src/docs/Intro.stories.mdx +31 -24
  240. package/src/index.ts +70 -5
  241. package/src/styles/01-colors/_colors-brand.scss +6 -4
  242. package/src/styles/01-colors/_colors-utility.scss +14 -15
  243. package/src/styles/03-space/_space-inline.scss +47 -7
  244. package/src/styles/03-space/_space-inset.scss +33 -5
  245. package/src/styles/03-space/_space-stack.scss +48 -8
  246. package/src/styles/base/_02-breakpoints.scss +5 -4
  247. package/src/styles/base/_04-base.scss +2 -1
  248. package/src/styles/base/_place-holder.scss +1 -1
  249. package/src/styles/base/_typography.scss +1 -29
  250. package/src/styles.scss +22 -25
  251. package/src/theme/components/accordion.ts +30 -0
  252. package/src/theme/components/breadcrumb.ts +77 -0
  253. package/src/theme/components/button.ts +125 -0
  254. package/src/theme/components/checkbox.ts +107 -0
  255. package/src/theme/components/customCheckboxGroup.ts +12 -0
  256. package/src/theme/components/customRadioGroup.ts +12 -0
  257. package/src/theme/components/global.ts +71 -0
  258. package/src/theme/components/globalMixins.ts +16 -0
  259. package/src/theme/components/heading.ts +72 -0
  260. package/src/theme/components/hero.ts +239 -0
  261. package/src/theme/components/icon.ts +79 -0
  262. package/src/theme/components/label.ts +17 -0
  263. package/src/theme/components/link.ts +47 -0
  264. package/src/theme/components/radio.ts +106 -0
  265. package/src/theme/components/searchBar.ts +21 -0
  266. package/src/theme/components/select.ts +50 -0
  267. package/src/theme/components/statusBadge.ts +27 -0
  268. package/src/theme/components/tabs.ts +79 -0
  269. package/src/theme/components/template.ts +114 -0
  270. package/src/theme/components/text.ts +31 -0
  271. package/src/theme/components/textInput.ts +61 -0
  272. package/src/theme/foundations/breakpoints.ts +24 -0
  273. package/src/theme/foundations/colors.ts +208 -0
  274. package/src/theme/foundations/global.ts +26 -0
  275. package/src/theme/foundations/shadows.ts +5 -0
  276. package/src/theme/foundations/spacing.ts +85 -0
  277. package/src/theme/foundations/typography.ts +35 -0
  278. package/src/theme/index.ts +88 -0
  279. package/src/theme/provider.tsx +9 -0
  280. package/src/theme/types.ts +1 -0
  281. package/src/utils/componentCategories.ts +56 -21
  282. package/src/utils/utils.ts +13 -0
  283. package/dist/components/Accordion/Accordion.stories.d.ts +0 -5
  284. package/dist/components/Card/Card.stories.d.ts +0 -27
  285. package/dist/components/Label/Label.stories.d.ts +0 -12
  286. package/dist/components/StatusBadge/StatusBadge.stories.d.ts +0 -8
  287. package/dist/components/Template/Template.stories.d.ts +0 -29
  288. package/src/components/Accordion/Accordion.stories.tsx +0 -65
  289. package/src/components/Accordion/_Accordion.scss +0 -81
  290. package/src/components/Breadcrumbs/_Breadcrumbs.scss +0 -97
  291. package/src/components/Checkbox/_Checkbox.scss +0 -97
  292. package/src/components/Form/_Form.scss +0 -28
  293. package/src/components/Heading/_Heading.scss +0 -163
  294. package/src/components/Hero/_Hero.scss +0 -256
  295. package/src/components/Icons/_Icons.scss +0 -116
  296. package/src/components/Label/Label.stories.tsx +0 -30
  297. package/src/components/Label/_Label.scss +0 -22
  298. package/src/components/Link/_Link.scss +0 -73
  299. package/src/components/Radio/_Radio.scss +0 -84
  300. package/src/components/SearchBar/_SearchBar.scss +0 -16
  301. package/src/components/Select/_Select.scss +0 -82
  302. package/src/components/StatusBadge/StatusBadge.stories.tsx +0 -33
  303. package/src/components/StatusBadge/_StatusBadge.scss +0 -23
  304. package/src/components/StyleGuide/Colors.stories.tsx +0 -288
  305. package/src/components/Template/Template.stories.tsx +0 -85
  306. package/src/components/Template/_Template.scss +0 -63
  307. package/src/components/TextInput/_TextInput.scss +0 -59
@@ -3,13 +3,13 @@ import {
3
3
  Story,
4
4
  Canvas,
5
5
  ArgsTable,
6
- Preview,
7
6
  Description,
8
7
  } from "@storybook/addon-docs/blocks";
9
8
  import { withDesign } from "storybook-addon-designs";
10
9
 
11
10
  import Icon from "./Icon";
12
11
  import {
12
+ IconAlign,
13
13
  IconNames,
14
14
  LogoNames,
15
15
  IconColors,
@@ -19,9 +19,10 @@ import {
19
19
  import iconSvgs from "./IconSvgs";
20
20
  import List from "../List/List";
21
21
  import { ListTypes } from "../List/ListTypes";
22
+ import { getCategory } from "../../utils/componentCategories";
22
23
 
23
24
  <Meta
24
- title="Icon"
25
+ title={getCategory("Icon")}
25
26
  component={Icon}
26
27
  decorators={[withDesign]}
27
28
  parameters={{
@@ -32,91 +33,109 @@ import { ListTypes } from "../List/ListTypes";
32
33
  },
33
34
  jest: ["Icon.test.tsx"],
34
35
  }}
36
+ argTypes={{
37
+ children: { table: { disable: true } },
38
+ className: { table: { disable: true } },
39
+ id: { table: { disable: true } },
40
+ }}
35
41
  />
36
42
 
37
43
  # Icon
38
44
 
45
+ | Component Version | DS Version |
46
+ | ----------------- | ---------- |
47
+ | Added | `0.0.4` |
48
+ | Latest | `0.25.1` |
49
+
39
50
  <Description of={Icon} />
40
51
 
41
- <Preview withToolbar style={{ backgroundColor: "#fafafa" }}>
52
+ <Canvas withToolbar>
42
53
  <Story
43
54
  name="Icon Props Control"
44
55
  args={{
45
- name: "check",
46
- color: IconColors.ui_black,
47
- size: IconSizes.xlarge,
48
- iconRotation: IconRotationTypes.rotate0,
56
+ align: "None",
57
+ color: "UiBlack",
49
58
  decorative: true,
50
- titleText: "An example icon",
59
+ iconRotation: "Rotate0",
60
+ name: "Check",
61
+ size: "ExtraLarge",
51
62
  }}
52
63
  argTypes={{
53
- color: {
64
+ align: {
54
65
  control: {
55
66
  type: "select",
56
- options: IconColors,
57
67
  },
68
+ options: Object.keys(IconAlign),
58
69
  },
59
- size: {
70
+ color: {
60
71
  control: {
61
72
  type: "select",
62
- options: IconSizes,
63
73
  },
74
+ options: Object.keys(IconColors),
64
75
  },
65
76
  iconRotation: {
66
77
  control: {
67
78
  type: "select",
68
- options: IconRotationTypes,
69
79
  },
80
+ options: Object.keys(IconRotationTypes),
70
81
  },
71
- blockName: {
72
- table: {
73
- disable: true,
82
+ name: {
83
+ control: {
84
+ type: "select",
74
85
  },
86
+ options: Object.keys(IconNames),
75
87
  },
76
- modifiers: {
77
- table: {
78
- disable: true,
88
+ size: {
89
+ control: {
90
+ type: "select",
79
91
  },
92
+ options: Object.keys(IconSizes),
80
93
  },
81
94
  }}
82
95
  >
83
- {(args) => <Icon {...args} />}
96
+ {(args) => (
97
+ <Icon
98
+ align={IconAlign[args.align]}
99
+ color={IconColors[args.color]}
100
+ iconRotation={IconRotationTypes[args.iconRotation]}
101
+ name={IconNames[args.name]}
102
+ size={IconSizes[args.size]}
103
+ />
104
+ )}
84
105
  </Story>
85
- </Preview>
106
+ </Canvas>
86
107
 
87
108
  <ArgsTable story="Icon Props Control" />
88
109
 
89
- export const iconRow = (icon, opts = {}) => {
110
+ export const iconRow = (icon, iconType = IconNames, opts = {}) => {
90
111
  // We'll use this setup function to render all the icons in a list item.
91
112
  // Some icons display better with a dark background.
92
113
  const styles = { padding: "1rem" };
93
114
  const {
94
- size = IconSizes.large,
95
- iconRotation = IconRotationTypes.rotate0,
96
- color = IconColors.ui_black,
115
+ size = IconSizes.Large,
116
+ iconRotation = IconRotationTypes.Rotate0,
117
+ color = IconColors.UiBlack,
97
118
  displayValue = icon,
98
119
  } = opts;
99
120
  let key = icon;
100
- if (icon.indexOf("_negative") !== -1) {
121
+ if (icon.indexOf("Negative") !== -1 || color.indexOf("white") !== -1) {
101
122
  styles.backgroundColor = "#000";
102
- styles.display = "inline-block";
103
123
  }
104
124
  // The following is just to fix duplicate React key issues.
105
- if (iconRotation !== IconRotationTypes.rotate0) {
125
+ if (iconRotation !== IconRotationTypes.Rotate0) {
106
126
  key += `-${iconRotation}`;
107
127
  }
108
- if (color !== IconColors.ui_black) {
128
+ if (color !== IconColors.UiBlack) {
109
129
  key += `-${color}`;
110
130
  }
111
- if (size !== IconSizes.large) {
131
+ if (size !== IconSizes.Large) {
112
132
  key += `-${size}`;
113
133
  }
114
134
  return (
115
135
  <li key={key} style={{ marginBottom: "var(--space-s)" }}>
116
136
  <span style={styles}>
117
137
  <Icon
118
- name={icon}
119
- decorative={true}
138
+ name={iconType[icon]}
120
139
  size={size}
121
140
  iconRotation={iconRotation}
122
141
  color={color}
@@ -132,33 +151,33 @@ export const rotations = [];
132
151
  export const colors = [];
133
152
  export const sizes = [];
134
153
  for (const icon in IconNames) {
135
- icons.push(iconRow(icon));
154
+ icons.push(iconRow(icon, IconNames));
136
155
  }
137
156
  for (const logo in LogoNames) {
138
- logos.push(iconRow(logo, { iconSize: IconSizes.xlarge }));
157
+ logos.push(iconRow(logo, LogoNames, { iconSize: IconSizes.ExtraLarge }));
139
158
  }
140
159
  for (const iconRotation in IconRotationTypes) {
141
160
  rotations.push(
142
- iconRow(IconNames.arrow, {
143
- size: IconSizes.large,
161
+ iconRow("Arrow", IconNames, {
162
+ size: IconSizes.Large,
144
163
  iconRotation: IconRotationTypes[iconRotation],
145
- displayValue: IconRotationTypes[iconRotation],
164
+ displayValue: iconRotation,
146
165
  })
147
166
  );
148
167
  }
149
168
  for (const iconColor in IconColors) {
150
169
  colors.push(
151
- iconRow(IconNames.download, {
170
+ iconRow("Download", IconNames, {
152
171
  color: IconColors[iconColor],
153
- displayValue: IconColors[iconColor],
172
+ displayValue: iconColor,
154
173
  })
155
174
  );
156
175
  }
157
176
  for (const iconSize in IconSizes) {
158
177
  sizes.push(
159
- iconRow(IconNames.arrow, {
178
+ iconRow("Arrow", IconNames, {
160
179
  size: IconSizes[iconSize],
161
- displayValue: IconSizes[iconSize],
180
+ displayValue: iconSize,
162
181
  })
163
182
  );
164
183
  }
@@ -173,59 +192,51 @@ Passing an `iconRotation` prop with a value from `IconRotationTypes` allows
173
192
  the icon to be rotated when it is rendered. The `IconRotationTypes` enum
174
193
  can be found in `src/components/Icons/IconTypes.tsx`.
175
194
 
176
- ```js
195
+ ```jsx
177
196
  // Example
178
- <Icon
179
- name={IconNames.arrow}
180
- decorative={true}
181
- iconRotation={IconRotationTypes.rotate180}
182
- />
197
+ <Icon name={IconNames.Arrow} iconRotation={IconRotationTypes.Rotate180} />
183
198
  ```
184
199
 
185
- <Preview>
200
+ <Canvas>
186
201
  <Story name="Rotation Types">{allIconsType(rotations)}</Story>
187
- </Preview>
202
+ </Canvas>
188
203
 
189
204
  ## IconColors Types
190
205
 
191
206
  Update an SVG icon by passing a `color` prop with a value from `IconColors`.
192
- The `IconColors` enum can be found in`src/components/Icons/IconTypes.tsx`.
207
+ The `IconColors` enum can be found in `src/components/Icons/IconTypes.tsx`.
193
208
 
194
- ```js
209
+ ```jsx
195
210
  // Example
196
- <Icon
197
- name={IconNames.speaker_notes}
198
- decorative={true}
199
- color={IconColors.brand_primary}
200
- />
211
+ <Icon name={IconNames.Speaker_notes} color={IconColors.BrandPrimary} />
201
212
  ```
202
213
 
203
- <Preview>
214
+ <Canvas>
204
215
  <Story name="Color Types">{allIconsType(colors)}</Story>
205
- </Preview>
216
+ </Canvas>
206
217
 
207
218
  ## IconSizes Types
208
219
 
209
220
  Update an SVG icon by passing a `size` prop with a value from `IconSizes`.
210
221
  The `IconSizes` enum can be found in`src/components/Icons/IconTypes.tsx`.
211
222
 
212
- ```js
223
+ ```jsx
213
224
  // Example
214
- <Icon name={IconNames.clock} decorative={true} size={IconSizes.xxlarge} />
225
+ <Icon name={IconNames.Clock} size={IconSizes.ExtraExtraLarge} />
215
226
  ```
216
227
 
217
- <Preview>
228
+ <Canvas>
218
229
  <Story name="Sizes Types">{allIconsType(sizes)}</Story>
219
- </Preview>
230
+ </Canvas>
220
231
 
221
232
  ## All Display Icons
222
233
 
223
234
  The following icons are for generic purposes. All the available logo names can
224
235
  be found in the `IconNames` enum in `src/components/Icons/IconTypes.tsx`.
225
236
 
226
- <Preview withToolbar>
237
+ <Canvas withToolbar>
227
238
  <Story name="All Display Icons">{allIconsType(icons)}</Story>
228
- </Preview>
239
+ </Canvas>
229
240
 
230
241
  ## All Logo Icons
231
242
 
@@ -235,28 +246,32 @@ The following icons are meant to be used for logos for different libraries
235
246
  and products. All the available logo names can
236
247
  be found in the `LogoNames` enum in `src/components/Icons/IconTypes.tsx`.
237
248
 
238
- <Preview withToolbar>
249
+ <Canvas withToolbar>
239
250
  <Story name="All Logo Icons">{allIconsType(logos)}</Story>
240
- </Preview>
251
+ </Canvas>
241
252
 
242
253
  ## Custom Icons
243
254
 
244
255
  If you'd like to pass a custom svg to your application, you can pass it a
245
256
  child to the `Icon` component.
246
257
 
247
- ```js
248
- <Icon {...args}>
249
- <svg ...><!-- the direct svg here --></svg>
258
+ ```jsx
259
+ <Icon {...props}>
260
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 750 750" fill="#6BE9D8">
261
+ <g>
262
+ <path d="M709.9 399.9c-4.5-145.7-115.8-169.6-151.1-170.3-4.2-.1-6.7-4.9-4.2-8.4L632 110.6c3.4-4.8 2.4-11.7-2.3-15.3-15.9-12-36.3-21.4-60.3-28.8-4.3-1.3-8.6 2-8.5 6.5 1.2 50.5-27.6 114.3-36.5 132.9-1 2-3.9 1.9-4.8-.1C485.1 124 397.7 95.1 327.9 104.4c-71.3 9.5-101.6 26.5-163.5 96.6-61.9 70.1-80.2 260.7-82.1 309.4C80.4 559 40 617.1 40 617.1c154 81.4 340.9 68.2 402.2 61.9 44.4-4.6 68.5-21.8 78.5-30.9 2.5-2.3 1.4-6.6-2-7.3-73.8-15.7-80.7-37.2-94.8-63.5-14.5-27.1 8.2-135.7 104.2-108.6 79.6 22.5 51.5 114.9 39.6 145.8-1.4 3.7 2.4 7.3 6 5.6 34-16.5 140.5-79.5 136.2-220.2zM234.7 181.3c17.7-17 69-56.7 167.1-38 99.8 18.9 98.5 109.5 80.4 141.7-2.3 4.1-7 4.5-8.8.1-11.1-27.7-45.5-97.4-112-108-61.8-9.8-105.6 1.7-124.2 8.3-2.5.8-4.4-2.3-2.5-4.1zm-60.2 72l16.9-27.4c5.1-8.3 13.2-14.3 22.6-16.6 16.3-4.1 33-6.9 49.5-8.9 40.3-4.8 79.4-2.1 116.7 15.1 17.4 8 33.6 18.2 46.1 32.9 11.4 13.4 19 29.6 23.7 46.5 1.8 6.3 3.2 12.8 4.3 19.3.6 3.2-.1 6.6-1.7 9.4l-15.8 27.1c-1.7 3-6.1 2.4-7.1-.9-6.7-22-17.9-43.9-32.8-61-12.6-14.4-29.1-23.5-46.1-31.6-12.2-5.8-24.9-10.5-38-13.6-35.3-8.4-71.9-4.4-106.3 5.9-9.2 2.8-18.3 5.9-27.2 9.5-2.3.9-4.9-.7-5.2-3.2-.2-1 0-1.8.4-2.5zm-21.9 64.2l11.7-40.8c1.2-4.3 5-7.5 9.5-7.9l5.2-.5s87.8-25.9 160.4 9.8c56.9 28 68.3 78.8 70.5 99.5.6 5.5-1.4 11-5.3 14.8L389 407.5c-3.8 3.7-10.2 2.2-12-2.8-6-17.2-13.8-34.1-23.5-49.3-5.8-9.1-12.7-18.3-21.6-24.6-16.2-11.5-36.5-19.2-55.7-23.9-14.4-3.6-29.3-4.8-44.1-3.8-12.9.8-25.6 3.2-38 6.7-7.2 2-14.3 4.4-21.3 7.1-3.8 1.5-7.6 3-11.3 4.7-.6.2-1.9.7-3.4 1.3-3.2 1.1-6.5-2-5.5-5.4zM410 465.8c4.4 2 5.8 7.5 3 11.4l-14.8 20.7c-3.5 4.9-9.9 6.6-15.4 4.3l-25.5-10.9c-4.5-1.9-5.5-7.8-1.9-11.1l17.3-15.7c5.8-5.7 14.6-9.1 22-5.8l15.3 7.1zm-270.3-96.3l4.5-23.6c1.2-6.5 5.7-11.9 11.8-14.3 15.7-6.2 50.5-14.3 109.2-.1 62.6 15.1 83.4 66.2 90 91.6 2.2 8.5-.7 17.5-7.5 23.1l-13.4 11.1c-4.2 3.4-10.5 1.5-12-3.7-5.3-18.5-21.2-54.5-66.1-73.7-45.5-19.5-88.3-9.3-107.8-2.6-4.8 1.5-9.7-2.8-8.7-7.8zm-4.4 29.7c.1-5.4 4.2-9.9 9.6-10.6 30.7-3.8 127.8-7.6 155.8 89.7 1.6 5.4-.5 11.3-5.2 14.4l-15.1 10.1c-5 3.4-11.9 1.2-14-4.5-9.5-26-40.2-85.6-119.7-68.3-6.2 1.3-12-3.4-11.9-9.7l.5-21.1zm-9.1 72.9l3.3-19.1c1.4-8.3 9-14.1 17.4-13.1 21.2 2.4 60.2 11.5 85.5 44.9 5.8 7.7 9.2 16.8 10 26.4l.3 3.4c.6 7.1-2.7 14-8.7 18l-12.1 8.2c-4.4 3-10.5 1.2-12.6-3.7l-8.2-24.4c-3.5-10.4-11-19.1-20.8-24.1l-11.1-5.6c-6.7-3.4-14.2-5-21.7-4.5l-14.8.9c-4 .2-7.1-3.4-6.5-7.3zm-15.5 55.7l9.4-30.7c1.8-5.9 8-9.2 13.9-7.4 18.3 5.6 53.5 21.9 54.3 65.2 0 2.7-1.3 5.1-3.6 6.4-8.5 4.9-26.8 12.9-27.8 12-1.2-1.1.8-42.6-39.7-37.7-1.2.1-2.5-.1-3.6-.7-2.5-1.3-3.8-4.3-2.9-7.1zm63.8 100.5c-1.1 6.4-7.4 10.5-13.7 8.9l-85.5-21.9c-3.9-1-5.7-5.5-3.6-8.9l31.4-51.7c1.8-3 5.5-4.5 8.9-3.4 8.3 2.6 22.4 9 24.4 23.2.6 4.3-.9 8.7-4 11.8-1.4 1.4-3 2.5-4.8 3.2l-26.8 10.4c-2.1.8-2.6 3.5-1 5 .6.5 1.3.8 2.1.8l19.5-.2c3.7 0 7.4-.4 11.1-1 12.8-2.1 47-5 42 23.8zm72.1 12.7c-2.3 2.8-5 5.9-8.8 6.3-1.5.2-2.9 0-4.4-.2-1.5-.2-2.9-.2-4.4-.3l-10.5-.9c-3.8-.3-7.5-.7-11.3-1.2-2.9-.3-5.8-.7-8.6-1.2-4-.7-6.6-4.7-5.4-8.6 2.5-8.6 4.2-23.7-8.4-37.6-2-2.2-1.4-5.8 1.2-7.3l24.8-14.1c3.6-2.1 8-2.1 11.6-.1 8.2 4.5 22.3 14.1 29 28.8 5.4 12.1 3.4 26.2-4.8 36.4zm67 3.1c-4.2 4.1-9.8 6.5-15.7 6.8l-24.2 1.1c-4.2.2-7.1-4.2-5.3-8 8.1-17 20.6-55.5-19.4-76.9-3-1.6-3.3-5.9-.4-7.8l15.3-10.2c4.7-3.2 10.8-3.5 15.8-.7 22.8 12.3 80.6 50.2 33.9 95.7zm118.2-5.2c3.5 2.7 1.6 8.2-2.8 8.3l-77.5.8c-4.8.1-8.1-5-6-9.3 30.8-64.1-17.7-97.3-37.5-107.6-3.5-1.8-4-6.7-.9-9.1l9.6-7.7c7.2-5.7 16.7-7.7 25.6-5.4 14.1 3.7 26.1 11.8 33.7 18 5.4 4.4 8.6 10.9 8.8 17.9.9 51.1 29.9 80.9 47 94.1zm76.6-205c-12.4 0-36.1 1.2-52.5 10.2-4.7 2.6-10.2 3.1-15.4 1.7l-26.8-7.4c-4-1.1-5.6-5.9-3-9.2l14.9-18.8c5.2-7.1 13-11.6 21.6-10.2 17.4 2.9 46.3 10.1 63.6 27.4 2.6 2.3 1 6.3-2.4 6.3zm115 112c-1.7 2.2-5 2.2-6.8 0l-.1-.1c-1.8-2.3-7.3-138.3-146.4-168.7-5.4-1.2-7.7-7.5-4.3-11.9l19.6-25.6c4.6-6 12.2-8.9 19.7-7.5 28.1 5.5 95.7 25.7 120.5 96.6 29.5 84.5 13.9 96.8-2.2 117.2zm46.4-88.4c-.8 4.1-6.6 4.2-7.5.1-9.8-43.6-44.3-150.3-147.6-150.8-4.4 0-7.2-4.8-5-8.6l17.6-31.4c4.4-7.9 19.3-9.1 28.1-7 41.1 9.9 143 47.6 114.4 197.7z" />
263
+ </g>
264
+ </svg>
250
265
  </Icon>
251
266
  ```
252
267
 
253
- <Preview>
268
+ <Canvas>
254
269
  <Story
255
270
  name="Custom Icons"
256
271
  args={{
257
- color: IconColors.ui_black,
258
- size: IconSizes.xxxlarge,
259
- iconRotation: IconRotationTypes.rotate0,
272
+ color: IconColors.UiBlack,
273
+ size: IconSizes.ExtraExtraExtraLarge,
274
+ iconRotation: IconRotationTypes.Rotate0,
260
275
  decorative: true,
261
276
  }}
262
277
  >
@@ -274,4 +289,4 @@ child to the `Icon` component.
274
289
  </Icon>
275
290
  )}
276
291
  </Story>
277
- </Preview>
292
+ </Canvas>
@@ -7,38 +7,46 @@ import { IconNames } from "./IconTypes";
7
7
 
8
8
  describe("Icon Accessibility", () => {
9
9
  it("passes axe accessibility test", async () => {
10
- const { container } = render(
11
- <Icon name={IconNames.download} decorative={true} />
12
- );
10
+ const { container } = render(<Icon name={IconNames.Download} />);
13
11
  expect(await axe(container)).toHaveNoViolations();
14
12
  });
15
13
  });
16
14
 
17
15
  describe("Icon", () => {
18
- it("throws an error if both name and children are passed to Icon", () => {
19
- expect(() =>
20
- render(
21
- <Icon name={IconNames.download} decorative={true}>
22
- <svg viewBox="0 0 24 14" xmlns="http://www.w3.org/2000/svg">
23
- <path
24
- fillRule="evenodd"
25
- clipRule="evenodd"
26
- d="M10.526 12.871L.263 1.676 1.737.324 12 11.52 22.263.324l1.474 1.352L13.474 12.87a2 2 0 01-2.948 0z"
27
- />
28
- </svg>
29
- </Icon>
30
- )
31
- ).toThrowError("Icon accepts either a name or children, not both");
16
+ it("consoles a warning if both name and children are passed to Icon", () => {
17
+ const warn = jest.spyOn(console, "warn");
18
+ render(
19
+ <Icon name={IconNames.Download} decorative={true}>
20
+ <svg viewBox="0 0 24 14" xmlns="http://www.w3.org/2000/svg">
21
+ <path
22
+ fillRule="evenodd"
23
+ clipRule="evenodd"
24
+ d="M10.526 12.871L.263 1.676 1.737.324 12 11.52 22.263.324l1.474 1.352L13.474 12.87a2 2 0 01-2.948 0z"
25
+ />
26
+ </svg>
27
+ </Icon>
28
+ );
29
+ expect(warn).toHaveBeenCalledWith(
30
+ "Icon accepts either a `name` prop or an `svg` element child, not both."
31
+ );
32
+ });
33
+
34
+ it("consoles a warning if both name and children are not passed", () => {
35
+ const warn = jest.spyOn(console, "warn");
36
+ render(<Icon />);
37
+ expect(warn).toHaveBeenCalledWith(
38
+ "Pass an icon `name` prop or an SVG child to `Icon` to ensure an icon appears."
39
+ );
32
40
  });
33
41
 
34
42
  it("renders an icon based on the icon `name` prop", () => {
35
- const utils = render(<Icon name={IconNames.download} decorative={true} />);
36
- expect(utils.container.querySelector(".icon")).toBeInTheDocument();
43
+ const { container } = render(<Icon name={IconNames.Download} />);
44
+ expect(container.querySelector("svg")).toBeInTheDocument();
37
45
  });
38
46
 
39
47
  it("renders an icon based on the child", () => {
40
- const utils = render(
41
- <Icon decorative={true}>
48
+ const { container } = render(
49
+ <Icon>
42
50
  <svg viewBox="0 0 24 14" xmlns="http://www.w3.org/2000/svg">
43
51
  <path
44
52
  fillRule="evenodd"
@@ -48,6 +56,6 @@ describe("Icon", () => {
48
56
  </svg>
49
57
  </Icon>
50
58
  );
51
- expect(utils.container.querySelector(".icon")).toBeInTheDocument();
59
+ expect(container.querySelector("svg")).toBeInTheDocument();
52
60
  });
53
61
  });
@@ -1,39 +1,38 @@
1
- /* eslint-disable camelcase */
2
1
  import * as React from "react";
3
- import bem from "../../utils/bem";
4
- import generateUUID from "../../helpers/generateUUID";
2
+ import { Icon as ChakraIcon, Box, useStyleConfig } from "@chakra-ui/react";
5
3
 
4
+ import generateUUID from "../../helpers/generateUUID";
6
5
  import {
7
- IconRotationTypes,
8
- IconNames,
9
- LogoNames,
6
+ IconAlign,
10
7
  IconColors,
8
+ IconNames,
9
+ IconRotationTypes,
11
10
  IconSizes,
11
+ IconTypes,
12
+ LogoNames,
12
13
  } from "./IconTypes";
13
-
14
14
  import iconSvgs from "./IconSvgs";
15
15
 
16
16
  export interface IconProps {
17
- /** Additional attributes to pass to the `<svg>` tag. */
18
- attributes?: { [key: string]: any };
19
- /** BlockName for use with BEM. See how to work with blockNames and BEM here: http://getbem.com/introduction/ */
20
- blockName?: string;
21
- /** Modifiers array for use with BEM. See how to work with modifiers and BEM here: http://getbem.com/introduction/ */
22
- modifiers?: string[];
17
+ /** Aligns the icon. */
18
+ align?: IconAlign;
23
19
  /** className that appears in addition to "icon" */
24
20
  className?: string;
25
- /** Icons designated as decorative will be ignored by screenreaders */
21
+ /** Overrides default icon color (black). */
22
+ color?: IconColors;
23
+ /** Icons designated as decorative will be ignored by screenreaders. True
24
+ * by default. */
26
25
  decorative?: boolean;
27
- /** This text will be added as a child `<title>` element inside the `<svg>` tag. It is recommended to do this for increased accessibility. */
28
- titleText?: string;
29
26
  /** Rotates the icon clockwise in increments of 90deg */
30
27
  iconRotation?: IconRotationTypes;
31
- /** Overrides default icon color (black). */
32
- color?: IconColors;
33
- /** Sets the icon size. */
34
- size?: IconSizes;
28
+ /** ID that other components can cross reference for accessibility purposes */
29
+ id?: string;
35
30
  /** The name of the icon you want to use. */
36
31
  name?: IconNames | LogoNames;
32
+ /** Sets the icon size. */
33
+ size?: IconSizes;
34
+ /** Sets the icon variant type. */
35
+ type?: IconTypes;
37
36
  }
38
37
 
39
38
  /**
@@ -41,63 +40,66 @@ export interface IconProps {
41
40
  */
42
41
  export default function Icon(props: React.PropsWithChildren<IconProps>) {
43
42
  const {
44
- blockName,
45
- decorative = false,
43
+ align = "none",
44
+ children,
46
45
  className,
47
- titleText,
48
- iconRotation,
49
- color,
50
- size,
51
- modifiers = [],
46
+ color = IconColors.UiBlack,
47
+ decorative = true,
48
+ iconRotation = IconRotationTypes.Rotate0,
49
+ id = generateUUID(),
52
50
  name,
53
- children,
54
- attributes = [],
51
+ size = IconSizes.Medium,
52
+ type = IconTypes.Default,
55
53
  } = props;
56
-
57
- if (iconRotation) {
58
- modifiers.push(iconRotation);
59
- }
60
-
61
- if (color) {
62
- modifiers.push(color);
63
- }
64
-
65
- if (size) {
66
- modifiers.push(size);
67
- }
68
-
69
- const iconID = generateUUID();
54
+ const styles = useStyleConfig("Icon", {
55
+ align,
56
+ color,
57
+ iconRotation,
58
+ size,
59
+ variant: type,
60
+ });
70
61
  const iconProps = {
71
- className: bem("icon", modifiers, blockName, [className]),
72
- id: iconID,
73
- role: "img",
74
- title: titleText || null,
75
62
  "aria-hidden": decorative,
76
- ...attributes,
63
+ className,
64
+ id,
65
+ role: "img",
77
66
  };
78
-
79
- // Apply icon props to SVG that was passed as a child.
80
- const renderChildren = () =>
81
- React.Children.map(children, (child) =>
82
- React.cloneElement(child as JSX.Element, { ...iconProps })
83
- );
67
+ let childSVG = null;
84
68
 
85
69
  // Component prop validation
86
70
  if (name && children) {
87
- throw new Error("Icon accepts either a name or children, not both");
71
+ console.warn(
72
+ "Icon accepts either a `name` prop or an `svg` element child, not both."
73
+ );
74
+ return null;
88
75
  } else if (!name && !children) {
89
76
  console.warn(
90
- "Pass a name or any children to Icon to ensure an icon appears"
77
+ "Pass an icon `name` prop or an SVG child to `Icon` to ensure an icon appears."
91
78
  );
79
+ return null;
92
80
  }
93
81
 
94
82
  // The user wants to render an existing icon. Load the icon and render it
95
- // as a component. Otherwise, we're just going to render the children that
96
- // were passed to this component.
83
+ // as a component through Chakra's Icon component. Otherwise, we're going to
84
+ // render the SVG child with NYPL-theme styling.
97
85
  if (name) {
98
- const SvgComponent = iconSvgs[name];
99
- return <SvgComponent {...iconProps} />;
86
+ const SvgComponent: any = iconSvgs[name];
87
+ return <ChakraIcon as={SvgComponent} {...iconProps} __css={styles} />;
88
+ }
89
+
90
+ // If no `name` prop was passed, we expect a child SVG element to be passed.
91
+ // Apply icon props to the SVG child.
92
+ if (
93
+ (children as JSX.Element).type === "svg" ||
94
+ (children as JSX.Element).props.type === "svg" ||
95
+ (children as JSX.Element).props.mdxType === "svg"
96
+ ) {
97
+ childSVG = React.cloneElement(children as JSX.Element, {
98
+ ...iconProps,
99
+ });
100
+ } else {
101
+ console.warn("You must pass an `svg` element to the `Icon` component.");
100
102
  }
101
103
 
102
- return <>{renderChildren()}</>;
104
+ return <Box __css={styles}>{childSVG}</Box>;
103
105
  }
@@ -34,6 +34,10 @@ import simplye_color from "../../../icons/svg/simplye_color.svg";
34
34
  import snfl_negative from "../../../icons/svg/snfl_negative.svg";
35
35
  import snfl_positive from "../../../icons/svg/snfl_positive.svg";
36
36
  import speaker_notes from "../../../icons/svg/speaker_notes.svg";
37
+ import utility_account_filled from "../../../icons/svg/utility_account_filled.svg";
38
+ import utility_account_unfilled from "../../../icons/svg/utility_account_unfilled.svg";
39
+ import utility_hamburger from "../../../icons/svg/utility_hamburger.svg";
40
+ import utility_search from "../../../icons/svg/search.svg";
37
41
 
38
42
  export default {
39
43
  accessibility_full,
@@ -71,4 +75,8 @@ export default {
71
75
  snfl_negative,
72
76
  snfl_positive,
73
77
  speaker_notes,
78
+ utility_account_filled,
79
+ utility_account_unfilled,
80
+ utility_hamburger,
81
+ utility_search,
74
82
  };