@nypl/design-system-react-components 0.25.0 → 0.25.4

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 (392) hide show
  1. package/CHANGELOG.md +142 -1
  2. package/README.md +98 -50
  3. package/dist/components/Accordion/Accordion.d.ts +14 -14
  4. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +15 -14
  5. package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +6 -0
  6. package/dist/components/Button/Button.d.ts +13 -8
  7. package/dist/components/Button/ButtonTypes.d.ts +3 -1
  8. package/dist/components/Card/Card.d.ts +36 -52
  9. package/dist/components/Card/CardTypes.d.ts +2 -17
  10. package/dist/components/Checkbox/Checkbox.d.ts +17 -13
  11. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +45 -0
  12. package/dist/components/CheckboxGroup/CheckboxGroupLayoutTypes.d.ts +4 -0
  13. package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +15 -0
  14. package/dist/components/DatePicker/DatePicker.d.ts +37 -35
  15. package/dist/components/Fieldset/Fieldset.d.ts +25 -0
  16. package/dist/components/Form/Form.d.ts +13 -8
  17. package/dist/components/Form/FormTypes.d.ts +2 -8
  18. package/dist/components/Grid/GridTypes.d.ts +9 -0
  19. package/dist/components/Grid/SimpleGrid.d.ts +14 -0
  20. package/dist/components/Heading/Heading.d.ts +4 -4
  21. package/dist/components/HelperErrorText/HelperErrorText.d.ts +17 -14
  22. package/dist/components/Hero/Hero.d.ts +19 -14
  23. package/dist/components/Hero/HeroTypes.d.ts +10 -5
  24. package/dist/components/HorizontalRule/HorizontalRule.d.ts +10 -9
  25. package/dist/components/Icons/Icon.d.ts +19 -14
  26. package/dist/components/Icons/IconSvgs.d.ts +11 -0
  27. package/dist/components/Icons/IconTypes.d.ts +89 -64
  28. package/dist/components/Image/Image.d.ts +19 -9
  29. package/dist/components/Image/ImageTypes.d.ts +20 -0
  30. package/dist/components/Label/Label.d.ts +5 -17
  31. package/dist/components/Link/Link.d.ts +12 -12
  32. package/dist/components/List/List.d.ts +19 -14
  33. package/dist/components/Notification/Notification.d.ts +37 -16
  34. package/dist/components/Pagination/Pagination.d.ts +16 -13
  35. package/dist/components/Pagination/Pagination.stories.d.ts +2 -0
  36. package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +29 -0
  37. package/dist/components/ProgressIndicator/ProgressIndicatorTypes.d.ts +8 -0
  38. package/dist/components/Radio/Radio.d.ts +2 -0
  39. package/dist/components/RadioGroup/RadioGroup.d.ts +4 -2
  40. package/dist/components/SearchBar/SearchBar.d.ts +45 -27
  41. package/dist/components/Select/Select.d.ts +34 -35
  42. package/dist/components/Select/SelectTypes.d.ts +4 -0
  43. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +18 -14
  44. package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +2 -2
  45. package/dist/components/Slider/Slider.d.ts +57 -0
  46. package/dist/components/StatusBadge/StatusBadge.d.ts +8 -6
  47. package/dist/components/StatusBadge/StatusBadgeTypes.d.ts +5 -0
  48. package/dist/components/StyleGuide/ColorCard.d.ts +12 -0
  49. package/dist/components/Tabs/Tabs.d.ts +1 -1
  50. package/dist/components/Template/Template.d.ts +91 -0
  51. package/dist/components/Text/Text.d.ts +16 -0
  52. package/dist/components/Text/TextTypes.d.ts +6 -0
  53. package/dist/components/TextInput/TextInput.d.ts +44 -31
  54. package/dist/components/TextInput/TextInputTypes.d.ts +5 -0
  55. package/dist/components/VideoPlayer/VideoPlayer.d.ts +6 -8
  56. package/dist/components/VideoPlayer/VideoPlayerTypes.d.ts +2 -2
  57. package/dist/design-system-react-components.cjs.development.js +6473 -2630
  58. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  59. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  60. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  61. package/dist/design-system-react-components.esm.js +6463 -2631
  62. package/dist/design-system-react-components.esm.js.map +1 -1
  63. package/dist/hooks/tests/useCarouselStyles.test.d.ts +1 -0
  64. package/dist/hooks/useCarouselStyles.d.ts +16 -0
  65. package/dist/hooks/useNYPLTheme.d.ts +54 -0
  66. package/dist/hooks/useWindowSize.d.ts +10 -0
  67. package/dist/index.d.ts +19 -7
  68. package/dist/resources.scss +180 -170
  69. package/dist/styles.css +1 -1
  70. package/dist/theme/components/accordion.d.ts +25 -0
  71. package/dist/theme/components/breadcrumb.d.ts +90 -0
  72. package/dist/theme/components/button.d.ts +39 -15
  73. package/dist/theme/components/card.d.ts +168 -0
  74. package/dist/theme/components/checkbox.d.ts +12 -8
  75. package/dist/theme/components/checkboxGroup.d.ts +12 -0
  76. package/dist/theme/components/componentWrapper.d.ts +11 -0
  77. package/dist/theme/components/datePicker.d.ts +16 -0
  78. package/dist/theme/components/fieldset.d.ts +27 -0
  79. package/dist/theme/components/global.d.ts +65 -0
  80. package/dist/theme/components/globalMixins.d.ts +23 -0
  81. package/dist/theme/components/heading.d.ts +55 -20
  82. package/dist/theme/components/helperErrorText.d.ts +10 -0
  83. package/dist/theme/components/hero.d.ts +493 -0
  84. package/dist/theme/components/horizontalRule.d.ts +14 -0
  85. package/dist/theme/components/icon.d.ts +13 -0
  86. package/dist/theme/components/image.d.ts +31 -0
  87. package/dist/theme/components/label.d.ts +18 -0
  88. package/dist/theme/components/link.d.ts +49 -0
  89. package/dist/theme/components/list.d.ts +89 -0
  90. package/dist/theme/components/notification.d.ts +75 -0
  91. package/dist/theme/components/pagination.d.ts +19 -0
  92. package/dist/theme/components/progressIndicator.d.ts +50 -0
  93. package/dist/theme/components/radio.d.ts +8 -7
  94. package/dist/theme/components/radioGroup.d.ts +12 -0
  95. package/dist/theme/components/searchBar.d.ts +20 -0
  96. package/dist/theme/components/select.d.ts +67 -0
  97. package/dist/theme/components/skeletonLoader.d.ts +98 -0
  98. package/dist/theme/components/slider.d.ts +51 -0
  99. package/dist/theme/components/statusBadge.d.ts +25 -0
  100. package/dist/theme/components/tabs.d.ts +63 -12
  101. package/dist/theme/components/template.d.ts +105 -0
  102. package/dist/theme/components/text.d.ts +20 -0
  103. package/dist/theme/components/textInput.d.ts +112 -0
  104. package/dist/theme/components/videoPlayer.d.ts +40 -0
  105. package/dist/theme/foundations/breakpoints.d.ts +8 -8
  106. package/dist/theme/foundations/global.d.ts +8 -0
  107. package/dist/theme/foundations/radii.d.ts +5 -0
  108. package/dist/theme/foundations/shadows.d.ts +4 -0
  109. package/dist/theme/foundations/spacing.d.ts +16 -16
  110. package/dist/utils/utils.d.ts +6 -0
  111. package/package.json +72 -82
  112. package/src/__tests__/setup.ts +2 -2
  113. package/src/components/Accordion/Accordion.stories.mdx +223 -34
  114. package/src/components/Accordion/Accordion.test.tsx +135 -19
  115. package/src/components/Accordion/Accordion.tsx +81 -56
  116. package/src/components/Autosuggest/Autosuggest.stories.mdx +4 -4
  117. package/src/components/Autosuggest/Autosuggest.stories.tsx +3 -2
  118. package/src/components/Autosuggest/_Autosuggest.scss +5 -5
  119. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +48 -50
  120. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +54 -25
  121. package/src/components/Breadcrumbs/Breadcrumbs.tsx +75 -73
  122. package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +6 -0
  123. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +298 -0
  124. package/src/components/Button/Button.stories.mdx +45 -36
  125. package/src/components/Button/Button.test.tsx +37 -11
  126. package/src/components/Button/Button.tsx +22 -34
  127. package/src/components/Button/ButtonTypes.tsx +2 -0
  128. package/src/components/Button/__snapshots__/Button.test.tsx.snap +50 -8
  129. package/src/components/Card/Card.stories.mdx +314 -273
  130. package/src/components/Card/Card.test.tsx +157 -91
  131. package/src/components/Card/Card.tsx +195 -145
  132. package/src/components/Card/CardTypes.tsx +2 -19
  133. package/src/components/Card/__snapshots__/Card.test.tsx.snap +410 -0
  134. package/src/components/CardEdition/CardEdition.stories.tsx +26 -53
  135. package/src/components/CardEdition/CardEdition.test.tsx +23 -31
  136. package/src/components/CardEdition/_CardEdition.scss +22 -23
  137. package/src/components/Chakra/Box.stories.mdx +15 -16
  138. package/src/components/Chakra/Center.stories.mdx +56 -24
  139. package/src/components/Chakra/Grid.stories.mdx +92 -0
  140. package/src/components/Chakra/Stack.stories.mdx +38 -21
  141. package/src/components/Checkbox/Checkbox.stories.mdx +33 -11
  142. package/src/components/Checkbox/Checkbox.test.tsx +47 -2
  143. package/src/components/Checkbox/Checkbox.tsx +44 -41
  144. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +92 -7
  145. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +329 -0
  146. package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +372 -0
  147. package/src/components/CheckboxGroup/CheckboxGroup.tsx +152 -0
  148. package/src/components/CheckboxGroup/CheckboxGroupLayoutTypes.tsx +4 -0
  149. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +1326 -0
  150. package/src/components/ComponentWrapper/ComponentWrapper.tsx +63 -0
  151. package/src/components/DatePicker/DatePicker.stories.mdx +163 -62
  152. package/src/components/DatePicker/DatePicker.test.tsx +264 -64
  153. package/src/components/DatePicker/DatePicker.tsx +165 -134
  154. package/src/components/DatePicker/_DatePicker.scss +33 -66
  155. package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +818 -0
  156. package/src/components/Fieldset/Fieldset.stories.mdx +55 -0
  157. package/src/components/Fieldset/Fieldset.test.tsx +125 -0
  158. package/src/components/Fieldset/Fieldset.tsx +52 -0
  159. package/src/components/Fieldset/__snapshots__/Fieldset.test.tsx.snap +68 -0
  160. package/src/components/Form/Form.stories.mdx +70 -27
  161. package/src/components/Form/Form.test.tsx +58 -45
  162. package/src/components/Form/Form.tsx +50 -21
  163. package/src/components/Form/FormTypes.tsx +3 -8
  164. package/src/components/Form/__snapshots__/Form.test.tsx.snap +24 -14
  165. package/src/components/Grid/GridTypes.tsx +9 -0
  166. package/src/components/Grid/SimpleGrid.stories.mdx +268 -0
  167. package/src/components/Grid/SimpleGrid.test.tsx +66 -0
  168. package/src/components/Grid/SimpleGrid.tsx +37 -0
  169. package/src/components/Grid/__snapshots__/SimpleGrid.test.tsx.snap +8 -0
  170. package/src/components/Heading/Heading.stories.mdx +3 -3
  171. package/src/components/Heading/Heading.tsx +12 -6
  172. package/src/components/HelperErrorText/HelperErrorText.stories.mdx +124 -0
  173. package/src/components/HelperErrorText/HelperErrorText.test.tsx +39 -44
  174. package/src/components/HelperErrorText/HelperErrorText.tsx +37 -39
  175. package/src/components/HelperErrorText/__snapshots__/HelperErrorText.test.tsx.snap +25 -0
  176. package/src/components/Hero/Hero.stories.mdx +198 -121
  177. package/src/components/Hero/Hero.test.tsx +537 -107
  178. package/src/components/Hero/Hero.tsx +79 -92
  179. package/src/components/Hero/HeroTypes.tsx +18 -5
  180. package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +307 -0
  181. package/src/components/HorizontalRule/HorizontalRule.stories.mdx +8 -6
  182. package/src/components/HorizontalRule/HorizontalRule.test.tsx +33 -28
  183. package/src/components/HorizontalRule/HorizontalRule.tsx +27 -29
  184. package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +27 -9
  185. package/src/components/Icons/Icon.stories.mdx +94 -77
  186. package/src/components/Icons/Icon.test.tsx +48 -22
  187. package/src/components/Icons/Icon.tsx +78 -61
  188. package/src/components/Icons/IconSvgs.tsx +22 -0
  189. package/src/components/Icons/IconTypes.tsx +91 -64
  190. package/src/components/Image/Image.stories.mdx +220 -0
  191. package/src/components/Image/Image.test.tsx +131 -29
  192. package/src/components/Image/Image.tsx +84 -56
  193. package/src/components/Image/ImageTypes.ts +22 -0
  194. package/src/components/Image/__snapshots__/Image.test.tsx.snap +190 -0
  195. package/src/components/Input/Input.stories.tsx +23 -67
  196. package/src/components/Input/Input.test.tsx +4 -4
  197. package/src/components/Input/_Input.scss +23 -14
  198. package/src/components/Label/Label.stories.mdx +28 -7
  199. package/src/components/Label/Label.test.tsx +43 -12
  200. package/src/components/Label/Label.tsx +21 -34
  201. package/src/components/Label/__snapshots__/Label.test.tsx.snap +41 -0
  202. package/src/components/Link/Link.stories.mdx +41 -41
  203. package/src/components/Link/Link.test.tsx +33 -44
  204. package/src/components/Link/Link.tsx +117 -100
  205. package/src/components/List/List.stories.mdx +124 -51
  206. package/src/components/List/List.test.tsx +142 -63
  207. package/src/components/List/List.tsx +89 -93
  208. package/src/components/List/__snapshots__/List.test.tsx.snap +109 -0
  209. package/src/components/Modal/Modal.stories.mdx +3 -3
  210. package/src/components/Modal/_Modal.scss +2 -2
  211. package/src/components/Notification/Notification.stories.mdx +119 -111
  212. package/src/components/Notification/Notification.test.tsx +102 -126
  213. package/src/components/Notification/Notification.tsx +157 -161
  214. package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +159 -8
  215. package/src/components/Pagination/Pagination.stories.mdx +26 -27
  216. package/src/components/Pagination/Pagination.stories.tsx +11 -16
  217. package/src/components/Pagination/Pagination.test.tsx +276 -140
  218. package/src/components/Pagination/Pagination.tsx +174 -154
  219. package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +285 -0
  220. package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +292 -0
  221. package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +225 -0
  222. package/src/components/ProgressIndicator/ProgressIndicator.tsx +126 -0
  223. package/src/components/ProgressIndicator/ProgressIndicatorTypes.ts +8 -0
  224. package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +357 -0
  225. package/src/components/Radio/Radio.test.tsx +20 -4
  226. package/src/components/Radio/Radio.tsx +6 -3
  227. package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +3 -0
  228. package/src/components/RadioGroup/RadioGroup.stories.mdx +4 -5
  229. package/src/components/RadioGroup/RadioGroup.test.tsx +24 -1
  230. package/src/components/RadioGroup/RadioGroup.tsx +21 -29
  231. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +42 -72
  232. package/src/components/SearchBar/SearchBar.Test.tsx +170 -16
  233. package/src/components/SearchBar/SearchBar.stories.mdx +294 -219
  234. package/src/components/SearchBar/SearchBar.tsx +161 -46
  235. package/src/components/Select/Select.stories.mdx +188 -170
  236. package/src/components/Select/Select.test.tsx +132 -375
  237. package/src/components/Select/Select.tsx +121 -165
  238. package/src/components/Select/SelectTypes.tsx +5 -0
  239. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +33 -76
  240. package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +97 -177
  241. package/src/components/SkeletonLoader/SkeletonLoader.tsx +75 -70
  242. package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +2 -2
  243. package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +739 -0
  244. package/src/components/Slider/Slider.stories.mdx +529 -0
  245. package/src/components/Slider/Slider.test.tsx +653 -0
  246. package/src/components/Slider/Slider.tsx +303 -0
  247. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +1946 -0
  248. package/src/components/StatusBadge/StatusBadge.stories.mdx +91 -0
  249. package/src/components/StatusBadge/StatusBadge.test.tsx +35 -7
  250. package/src/components/StatusBadge/StatusBadge.tsx +24 -25
  251. package/src/components/StatusBadge/StatusBadgeTypes.tsx +5 -0
  252. package/src/components/StatusBadge/__snapshots__/StatusBadge.test.tsx.snap +28 -0
  253. package/src/components/StyleGuide/Bidirectionality.stories.mdx +17 -17
  254. package/src/components/StyleGuide/Breakpoints.stories.mdx +34 -10
  255. package/src/components/StyleGuide/Buttons.stories.mdx +102 -86
  256. package/src/components/StyleGuide/ColorCard.tsx +46 -0
  257. package/src/components/StyleGuide/Colors.stories.mdx +196 -0
  258. package/src/components/StyleGuide/DesignTokens.stories.mdx +170 -0
  259. package/src/components/StyleGuide/Forms.stories.mdx +9 -7
  260. package/src/components/StyleGuide/Iconography.stories.mdx +119 -127
  261. package/src/components/StyleGuide/Spacing.stories.mdx +31 -23
  262. package/src/components/StyleGuide/Typography.stories.mdx +202 -189
  263. package/src/components/StyleGuide/UIDocCard.tsx +1 -1
  264. package/src/components/Tabs/Tabs.stories.mdx +73 -11
  265. package/src/components/Tabs/Tabs.tsx +88 -67
  266. package/src/components/Template/Template.stories.mdx +572 -0
  267. package/src/components/Template/Template.test.tsx +124 -0
  268. package/src/components/Template/Template.tsx +226 -0
  269. package/src/components/Text/Text.stories.mdx +70 -0
  270. package/src/components/Text/Text.test.tsx +63 -0
  271. package/src/components/Text/Text.tsx +55 -0
  272. package/src/components/Text/TextTypes.tsx +6 -0
  273. package/src/components/Text/__snapshots__/Text.test.tsx.snap +33 -0
  274. package/src/components/TextInput/TextInput.stories.mdx +89 -90
  275. package/src/components/TextInput/TextInput.test.tsx +84 -85
  276. package/src/components/TextInput/TextInput.tsx +121 -95
  277. package/src/components/TextInput/TextInputTypes.tsx +8 -0
  278. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +17 -4
  279. package/src/components/VideoPlayer/VideoPlayer.test.tsx +54 -53
  280. package/src/components/VideoPlayer/VideoPlayer.tsx +50 -51
  281. package/src/components/VideoPlayer/VideoPlayerTypes.tsx +2 -2
  282. package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +91 -0
  283. package/src/docs/Chakra.stories.mdx +246 -65
  284. package/src/docs/Intro.stories.mdx +18 -13
  285. package/src/hooks/tests/useCarouselStyles.test.ts +140 -0
  286. package/src/hooks/tests/useNYPLTheme.test.tsx +36 -0
  287. package/src/hooks/useCarouselStyles.ts +34 -0
  288. package/src/hooks/useNYPLTheme.ts +67 -0
  289. package/src/hooks/useWindowSize.ts +40 -0
  290. package/src/index.ts +39 -16
  291. package/src/resources.scss +5 -5
  292. package/src/styles/base/{_02-breakpoints.scss → _01-breakpoints.scss} +9 -10
  293. package/src/styles/base/{_03-mixins.scss → _02-mixins.scss} +16 -5
  294. package/src/styles/base/_03-base.scss +25 -0
  295. package/src/styles/base/{_05-focus.scss → _04-focus.scss} +0 -15
  296. package/src/styles/base/_place-holder.scss +14 -3
  297. package/src/styles/{03-space → space}/_space-inline.scss +14 -14
  298. package/src/styles/{03-space → space}/_space-inset.scss +10 -10
  299. package/src/styles/space/_space-stack.scss +116 -0
  300. package/src/styles.scss +13 -62
  301. package/src/theme/components/accordion.ts +30 -0
  302. package/src/theme/components/breadcrumb.ts +77 -0
  303. package/src/theme/components/button.ts +91 -71
  304. package/src/theme/components/card.ts +174 -0
  305. package/src/theme/components/checkbox.ts +22 -29
  306. package/src/theme/components/checkboxGroup.ts +8 -0
  307. package/src/theme/components/componentWrapper.ts +10 -0
  308. package/src/theme/components/datePicker.ts +17 -0
  309. package/src/theme/components/fieldset.ts +18 -0
  310. package/src/theme/components/global.ts +82 -0
  311. package/src/theme/components/globalMixins.ts +24 -0
  312. package/src/theme/components/heading.ts +25 -13
  313. package/src/theme/components/helperErrorText.ts +9 -0
  314. package/src/theme/components/hero.ts +240 -0
  315. package/src/theme/components/horizontalRule.ts +13 -0
  316. package/src/theme/components/icon.ts +79 -0
  317. package/src/theme/components/image.ts +116 -0
  318. package/src/theme/components/label.ts +10 -0
  319. package/src/theme/components/link.ts +51 -0
  320. package/src/theme/components/list.ts +73 -0
  321. package/src/theme/components/notification.ts +93 -0
  322. package/src/theme/components/pagination.ts +20 -0
  323. package/src/theme/components/progressIndicator.ts +62 -0
  324. package/src/theme/components/radio.ts +22 -33
  325. package/src/theme/components/radioGroup.ts +8 -0
  326. package/src/theme/components/searchBar.ts +21 -0
  327. package/src/theme/components/select.ts +53 -0
  328. package/src/theme/components/skeletonLoader.ts +107 -0
  329. package/src/theme/components/slider.ts +79 -0
  330. package/src/theme/components/statusBadge.ts +26 -0
  331. package/src/theme/components/tabs.ts +102 -69
  332. package/src/theme/components/template.ts +114 -0
  333. package/src/theme/components/text.ts +31 -0
  334. package/src/theme/components/textInput.ts +62 -0
  335. package/src/theme/components/videoPlayer.ts +49 -0
  336. package/src/theme/foundations/breakpoints.ts +8 -8
  337. package/src/theme/foundations/colors.ts +29 -13
  338. package/src/theme/foundations/global.ts +8 -0
  339. package/src/theme/foundations/radii.ts +6 -0
  340. package/src/theme/foundations/shadows.ts +5 -0
  341. package/src/theme/foundations/spacing.ts +24 -24
  342. package/src/theme/index.ts +74 -13
  343. package/src/utils/componentCategories.ts +12 -5
  344. package/src/utils/utils.ts +13 -0
  345. package/dist/components/Accordion/Accordion.stories.d.ts +0 -6
  346. package/dist/components/HelperErrorText/HelperErrorText.stories.d.ts +0 -16
  347. package/dist/components/Image/Image.stories.d.ts +0 -18
  348. package/dist/components/List/List.stories.d.ts +0 -7
  349. package/dist/components/StatusBadge/StatusBadge.stories.d.ts +0 -8
  350. package/dist/components/StyleGuide/Colors.stories.d.ts +0 -25
  351. package/dist/components/Template/Template.stories.d.ts +0 -30
  352. package/dist/theme/components/customRadioGroup.d.ts +0 -17
  353. package/src/components/Accordion/Accordion.stories.tsx +0 -66
  354. package/src/components/Accordion/_Accordion.scss +0 -81
  355. package/src/components/Breadcrumbs/_Breadcrumbs.scss +0 -97
  356. package/src/components/Button/_Button.scss +0 -56
  357. package/src/components/Card/_Card.scss +0 -308
  358. package/src/components/Form/_Form.scss +0 -67
  359. package/src/components/HelperErrorText/HelperErrorText.stories.tsx +0 -48
  360. package/src/components/HelperErrorText/_HelperErrorText.scss +0 -9
  361. package/src/components/Hero/_Hero.scss +0 -256
  362. package/src/components/HorizontalRule/_HorizontalRule.scss +0 -15
  363. package/src/components/Icons/_Icons.scss +0 -116
  364. package/src/components/Image/Image.stories.tsx +0 -54
  365. package/src/components/Image/_Image.scss +0 -38
  366. package/src/components/Label/_Label.scss +0 -22
  367. package/src/components/Link/_Link.scss +0 -73
  368. package/src/components/List/List.stories.tsx +0 -139
  369. package/src/components/List/_List.scss +0 -76
  370. package/src/components/Notification/_Notification.scss +0 -110
  371. package/src/components/Pagination/_Pagination.scss +0 -40
  372. package/src/components/SearchBar/_SearchBar.scss +0 -16
  373. package/src/components/Select/_Select.scss +0 -82
  374. package/src/components/SkeletonLoader/_SkeletonLoader.scss +0 -142
  375. package/src/components/StatusBadge/StatusBadge.stories.tsx +0 -34
  376. package/src/components/StatusBadge/_StatusBadge.scss +0 -23
  377. package/src/components/StyleGuide/Colors.stories.tsx +0 -289
  378. package/src/components/Template/Template.stories.tsx +0 -86
  379. package/src/components/Template/_Template.scss +0 -63
  380. package/src/components/TextInput/_TextInput.scss +0 -59
  381. package/src/components/VideoPlayer/_VideoPlayer.scss +0 -38
  382. package/src/styles/01-colors/_colors-brand.scss +0 -56
  383. package/src/styles/01-colors/_colors-utility.scss +0 -65
  384. package/src/styles/02-typography/_type-scale.css +0 -11
  385. package/src/styles/02-typography/_type-weight.css +0 -7
  386. package/src/styles/02-typography/_typefaces.css +0 -4
  387. package/src/styles/03-space/_space-stack.scss +0 -116
  388. package/src/styles/03-space/_space.css +0 -30
  389. package/src/styles/base/_04-base.scss +0 -19
  390. package/src/styles/base/_card-grid.scss +0 -78
  391. package/src/styles/base/_typography.scss +0 -11
  392. package/src/theme/components/customRadioGroup.ts +0 -18
@@ -4,7 +4,7 @@ export enum VideoPlayerTypes {
4
4
  }
5
5
 
6
6
  export enum VideoPlayerAspectRatios {
7
- FourByThree = "four-by-three",
8
- SixteenByNine = "sixteen-by-nine",
7
+ FourByThree = "fourByThree",
8
+ SixteenByNine = "sixteenByNine",
9
9
  Square = "square",
10
10
  }
@@ -0,0 +1,91 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`VideoPlayer renders the UI snapshot correctly 1`] = `
4
+ <div
5
+ className="css-0"
6
+ data-testid="video-player-component"
7
+ id="video-player-without-text"
8
+ >
9
+ <div
10
+ className="css-0"
11
+ >
12
+ <div
13
+ className="css-0"
14
+ >
15
+ <iframe
16
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture"
17
+ allowFullScreen={true}
18
+ className="css-0"
19
+ frameBorder="0"
20
+ src="https://player.vimeo.com/video/474719268?autoplay=0&loop=0"
21
+ title="Vimeo video player"
22
+ />
23
+ </div>
24
+ </div>
25
+ </div>
26
+ `;
27
+
28
+ exports[`VideoPlayer renders the UI snapshot correctly 2`] = `
29
+ <div
30
+ className="css-0"
31
+ data-testid="video-player-component"
32
+ id="video-player-with-text"
33
+ >
34
+ <div
35
+ className="css-0"
36
+ >
37
+ <h2
38
+ className="chakra-heading css-0"
39
+ id="video-player-with-text-componentWrapper-heading"
40
+ >
41
+ VideoPlayer Heading
42
+ </h2>
43
+ <p
44
+ className="chakra-text css-0"
45
+ >
46
+ VideoPlayer description
47
+ </p>
48
+ <div
49
+ className="css-0"
50
+ >
51
+ <iframe
52
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture"
53
+ allowFullScreen={true}
54
+ className="css-0"
55
+ frameBorder="0"
56
+ src="https://player.vimeo.com/video/474719268?autoplay=0&loop=0"
57
+ title="Vimeo video player"
58
+ />
59
+ </div>
60
+ <div
61
+ className="css-0"
62
+ >
63
+ <div
64
+ aria-atomic={true}
65
+ aria-live="off"
66
+ className=" css-0"
67
+ data-isinvalid={false}
68
+ id="video-player-with-text-componentWrapper-helperText"
69
+ >
70
+ VideoPlayer helper test.
71
+ </div>
72
+ </div>
73
+ </div>
74
+ </div>
75
+ `;
76
+
77
+ exports[`VideoPlayer renders the UI snapshot correctly 3`] = `
78
+ <div
79
+ className="css-0"
80
+ data-testid="video-player-component"
81
+ id="video-player-error"
82
+ >
83
+ <span
84
+ dangerouslySetInnerHTML={
85
+ Object {
86
+ "__html": "<strong>Error:</strong> This video player has not been configured properly. Please contact the site administrator.",
87
+ }
88
+ }
89
+ />
90
+ </div>
91
+ `;
@@ -10,6 +10,7 @@ import { Meta } from "@storybook/addon-docs/blocks";
10
10
  | 2. [DSProvider](#dsprovider) |
11
11
  | 3. [Components](#components) |
12
12
  | 4. [Styling](#styling) |
13
+ | 5. [Hooks](#hooks) |
13
14
  | 5. [Testing](#testing) |
14
15
 
15
16
  ## Why Chakra UI?
@@ -37,19 +38,23 @@ We recommend to read Chakra's own [documentation](https://chakra-ui.com/docs/get
37
38
  to get up to speed on it. This file will provide information on how it is used
38
39
  in the DS but we rely on Chakra's documentation.
39
40
 
41
+ If you need help updating to a newer version of the NYPL Design System, check out
42
+ our [Chakra Migration Guide](https://github.com/NYPL/nypl-design-system/blob/development/CHAKRA_MIGRATION_GUIDE.md).
43
+
40
44
  ## DSProvider
41
45
 
42
- While the Chakra UI integration into the DS is a work-in-progress, there is one
43
- necessary step consuming applications need to take for component styles to
44
- properly render. Consuming applications need to wrap all the DS components with
45
- a simple provider component. Fortunately, this only needs to be done once at
46
- the top level of the consuming application.
46
+ In order to use DS components in a consuming application, there is a necessary
47
+ step that must be done for component styles to properly render. Consuming
48
+ applications need to wrap all the DS components with a simple provider
49
+ component. Fortunately, this only needs to be done once at the top level of the
50
+ consuming application.
47
51
 
48
52
  Once the following is completed, DS components that internally use Chakra UI
49
53
  will render styles properly. Internally, the `DSProvider` is built on top of
50
- Chakra's `ChakraProvider` with NYPL's custom theme.
54
+ Chakra's `ChakraProvider` component with NYPL's custom theme as input. This sets
55
+ up the style context to propogate through all the children nodes in the DOM tree.
51
56
 
52
- ```jsx
57
+ ```tsx
53
58
  // your main application file
54
59
  import { DSProvider } from "@nypl/design-system-react-components";
55
60
 
@@ -76,14 +81,14 @@ appropriately. Unfortunately, this only works within the `Story` component.
76
81
  When rendering components in documentation examples within a `Canvas` component,
77
82
  wrap the elements in the `DSProvider` component.
78
83
 
79
- ```jsx
84
+ ```tsx
80
85
  // These buttons are not a part of a "story" but still appear only
81
86
  // in the documentation.
82
87
  <Canvas>
83
88
  <DSProvider>
84
89
  <ButtonGroup>
85
- <Button disabled={false}>Enabled</Button>
86
- <Button disabled={true}>Disabled</Button>
90
+ <Button isDisabled={false}>Enabled</Button>
91
+ <Button isDisabled>Disabled</Button>
87
92
  </ButtonGroup>
88
93
  </DSProvider>
89
94
  </Canvas>
@@ -91,12 +96,12 @@ wrap the elements in the `DSProvider` component.
91
96
 
92
97
  ## Components
93
98
 
94
- The current work-in-progress is to use Chakra components to compose DS
95
- components that align directly or to compose DS-specific components with Chakra.
96
- For example, both the DS and Chakra have a `Button` component so we will use
97
- Chakra's `Button` component to compose the DS `Button` component. However, the
98
- DS has a `Hero` component that is not already built by Chakra. In this case,
99
- the DS `Hero` component will internally use `Chakra` components.
99
+ Although Chakra is integrated into the DS repo, we are still working to compose
100
+ DS components with Chakra components or patterns. For example, both the DS and
101
+ Chakra have a `Button` component so we will use Chakra's `Button` component to
102
+ compose the DS `Button` component. However, the DS has a `Hero` component that
103
+ is not already built by Chakra. In this case, the DS `Hero` component will
104
+ internally use `Chakra` components such as `Box`.
100
105
 
101
106
  ### Components Composed with Chakra
102
107
 
@@ -111,14 +116,14 @@ components that internally are composed with Chakra components.
111
116
 
112
117
  Components built from Chakra rename the component with the `Chakra` name prefix.
113
118
 
114
- ```jsx
119
+ ```tsx
115
120
  import { Tabs as ChakraTabs, useStyleConfig } from "@chakra-ui/react";
116
121
  ```
117
122
 
118
123
  In this example, the `ChakraTabs` component is returned with NYPL specific
119
124
  functionality, styles, and other requirements.
120
125
 
121
- ```jsx
126
+ ```tsx
122
127
  function Tabs(props) {
123
128
  // ...
124
129
  const styles = useStyleConfig("Tabs", { variant: props.tabsType });
@@ -136,12 +141,13 @@ function Tabs(props) {
136
141
 
137
142
  #### Patterns
138
143
 
139
- The NYPL DS uses the [CSS BEM](http://getbem.com/introduction/) pattern to structure
140
- and write CSS. We are moving away from this and re-writing SCSS classes into
141
- Javascript objects that work with Chakra's theme. Instead of creating a variant
142
- for a component with a class name, now the `type` prop is used. Internally, the
143
- `type` prop will be mapped to a Chakra theme variant that will provide all the
144
- necessary styles.
144
+ The NYPL DS uses the [CSS BEM](http://getbem.com/introduction/) pattern to
145
+ structure and write CSS, but it is slowly being phased out. We are moving away
146
+ from this and re-writing SCSS classes into Javascript objects that work with
147
+ Chakra's theme. Instead of creating a variant for a component with a class name,
148
+ now different props or internal logic are used to get the appropriate variant.
149
+ Internally, the right variant will be mapped to a Chakra theme variant that will
150
+ provide all the necessary styles.
145
151
 
146
152
  For the `Button` component, for example, we would convert a SCSS class rule such
147
153
  as `.button-outline` to a Javascript object (more on this in the [Anatomy of a
@@ -152,25 +158,32 @@ Component Styling Object](#anatomy-of-a-component-styling-object) section).
152
158
  Some components are directly exported from Chakra. These components can be found
153
159
  in the `/src/index.ts` file. Note that not _all_ Chakra components are re-exported
154
160
  because we want to limit what developers should use in consuming applications.
161
+ They include:
162
+
163
+ - `Box`, `Center`, `Circle`, `Grid`, `GridItem`, `HStack`, `Square`, `Stack`, `VStack`
155
164
 
156
165
  Note: These components are harder to have snapshot tests for because, internally,
157
166
  these components autogenerate ids and class names on every new render. We can't
158
167
  override them so snapshot tests will fail.
159
168
 
169
+ Update: Newer Chakra UI versions have mostly fixed this issue. Still, since
170
+ Chakra components have already been tested, we don't necessarily want or need
171
+ to test them ourselves.
172
+
160
173
  ## Styling
161
174
 
162
175
  As mentioned in the [Components composed with Chakra](#components-composed-with-chakra)
163
- section, we are moving away from using the BEM structure to using Javascript objects
164
- to extend Chakra's theme.
176
+ section, we are moving away from using the BEM structure to using Javascript
177
+ objects to extend Chakra's theme.
165
178
 
166
179
  The NYPL DS' theme file can be found at `src/theme/index.ts`. This creates a new
167
180
  theme that extends Chakra's theme and is set in the `DSProvider` component. Note
168
181
  that the example below is the general structure of the `theme` object but the DS
169
182
  `theme` object has values already set so it may look different. You would generally
170
- only work and add new object values in the `components` attribute for new
183
+ only work and add new object values in the `components` obejct key for new
171
184
  components and their theme or variants.
172
185
 
173
- ```jsx
186
+ ```ts
174
187
  const theme = extendTheme({
175
188
  styles: { ... },
176
189
  breakpoints: { ... },
@@ -191,7 +204,7 @@ For in-depth information, read Chakra's [Component Style documentation](https://
191
204
  Component theme files can be found in the `src/theme/components/` directory.
192
205
  Here is an example using the `Button` component.
193
206
 
194
- ```jsx
207
+ ```ts
195
208
  // The basic structure for all component style objects.
196
209
  const Button = {
197
210
  baseStyle: {},
@@ -204,33 +217,35 @@ const Button = {
204
217
  A current variant class rule can be converted to a Javascript object and go in
205
218
  the `variants` object as in the following example.
206
219
 
207
- ```jsx
220
+ ```scss
208
221
  // Button.scss
209
222
  // This is the "Secondary" variant.
210
223
  .button--outline {
211
224
  @include button-base;
212
225
 
213
- background-color: var(--ui-white);
214
- border: 1px solid var(--ui-gray-light);
226
+ background-color: var(--nypl-colors-ui-white);
227
+ border: 1px solid var(--nypl-colors-ui-gray-light-cool);
215
228
  color: inherit;
216
229
 
217
230
  &:hover {
218
- background-color: var(--ui-gray-xxlight);
231
+ background-color: var(--nypl-colors-ui-gray-xx-light-cool);
219
232
  }
220
233
  }
234
+ ```
221
235
 
222
- // Button.ts
236
+ ```ts
237
+ // button.ts
223
238
  const Button = {
224
- baseStyles: { ... },
239
+ baseStyle: { ... },
225
240
  sizes: { ... },
226
241
  variants: {
227
242
  secondary: {
228
243
  bg: "ui.white",
229
244
  border: "1px solid",
230
- borderColor: "ui.gray.light",
245
+ borderColor: "ui.gray.light-cool",
231
246
  color: "inherit",
232
247
  _hover: {
233
- bg: "ui.gray.xxlight",
248
+ bg: "ui.gray.xx-light-cool",
234
249
  },
235
250
  },
236
251
  // ... other variants,
@@ -241,13 +256,82 @@ const Button = {
241
256
 
242
257
  Now this variant can be rendered:
243
258
 
244
- ```jsx
259
+ ```tsx
245
260
  <Button buttonType={ButtonTypes.Secondary}>Press me</Button>
246
261
  ```
247
262
 
248
263
  ### Breakpoints
249
264
 
250
- TODO:
265
+ There are currently five (5) breakpoint values used in the DS:
266
+
267
+ | Key Name | EM/PX value |
268
+ | -------- | ----------- |
269
+ | sm | 20em/320px |
270
+ | md | 38em/600px |
271
+ | lg | 60em/960px |
272
+ | xl | 80em/1280px |
273
+ | 2xl | 96em/1536px |
274
+
275
+ There are two ways to set breakpoint values for a style rule: the array method
276
+ and the object method. We prefer the object method and recommend to use the
277
+ object method since it is easier to read and readily know what values take
278
+ effect at defined breakpoint values. Note that the Chakra `"base"` key value is
279
+ the same as `"sm"`.
280
+
281
+ #### Object Method
282
+
283
+ We recommend and follow this pattern in the DS. As an example, let's say we want
284
+ to increase the width of the `Button` component as the device width increases.
285
+ We start at value "100px" and increase by "50px" at every breakpoint. In the
286
+ `button.ts` style file, we can define it as in the example below:
287
+
288
+ ```ts
289
+ // button.ts
290
+ const Button = {
291
+ baseStyle: {
292
+ width: {
293
+ base: "100px",
294
+ md: "150px",
295
+ lg: "200px",
296
+ xl: "250px",
297
+ "2xl": "300px",
298
+ },
299
+ },
300
+ // ...
301
+ };
302
+ ```
303
+
304
+ You do not have to define every breakpoint. If you only want to change the width
305
+ of the `Button` at the `lg` breakpoint, it can be defined as:
306
+
307
+ ```ts
308
+ // button.ts
309
+ const Button = {
310
+ baseStyle: {
311
+ width: {
312
+ base: "100px",
313
+ lg: "200px",
314
+ },
315
+ },
316
+ // ...
317
+ };
318
+ ```
319
+
320
+ #### Array Method
321
+
322
+ We do not recommend this pattern because it is harder to read and implicit on
323
+ breakpoint values. Following the same example as the one above, the width of the
324
+ `Button` component can be updated wiht all five values in an array:
325
+
326
+ ```ts
327
+ // button.ts
328
+ const Button = {
329
+ baseStyle: {
330
+ width: ["100px", "150px", "200px", "250px", "300px"],
331
+ },
332
+ // ...
333
+ };
334
+ ```
251
335
 
252
336
  ### Colors
253
337
 
@@ -255,7 +339,7 @@ All available colors can be found in `src/theme/foundations/colors.ts`. Chakra
255
339
  autogenerates the `colors` object into CSS variables. We will rely on these
256
340
  variables rather than creating our own.
257
341
 
258
- ```jsx
342
+ ```tsx
259
343
  const colors: Colors = {
260
344
  // ui fills
261
345
  ui: {
@@ -280,17 +364,13 @@ const colors: Colors = {
280
364
 
281
365
  In the shorten object example above, the following will be generated by Chakra:
282
366
 
283
- | Theme object value | CSS variable |
284
- | -------------------------------------- | -------------------------------------------- |
285
- | `colors.ui.focus` | `--chakra-colors-ui-focus` |
286
- | `colors.ui.link.primary` | `--chakra-colors-ui-link-primary` |
287
- | `colors.ui.link.secondary` | `--chakra-colors-ui-link-secondary` |
288
- | `colors.section["whats-on"].primary` | `--chakra-colors-section-whats-on-primary` |
289
- | `colors.section["whats-on"].secondary` | `--chakra-colors-section-whats-on-secondary` |
290
-
291
- The current prefix is `--chakra` but we expect to update that soon. DS specified
292
- CSS variables are still exported but we will remove those in favor of the CSS
293
- variables provided by Chakra for ease of use.
367
+ | Theme object value | CSS variable |
368
+ | -------------------------------------- | ------------------------------------------ |
369
+ | `colors.ui.focus` | `--nypl-colors-ui-focus` |
370
+ | `colors.ui.link.primary` | `--nypl-colors-ui-link-primary` |
371
+ | `colors.ui.link.secondary` | `--nypl-colors-ui-link-secondary` |
372
+ | `colors.section["whats-on"].primary` | `--nypl-colors-section-whats-on-primary` |
373
+ | `colors.section["whats-on"].secondary` | `--nypl-colors-section-whats-on-secondary` |
294
374
 
295
375
  Note: while each Chakra color has number range values from 50 to 900 (such as
296
376
  `red.400`, `blue.600`, etc) and each one is based on the color coming from
@@ -301,16 +381,16 @@ DS' Figma documentation, we recommend NOT to use them.
301
381
  All the spacing values can be found in the `src/theme/foundations/spacing.ts`
302
382
  file. While Chakra provides many values, only use the eight DS defined values.
303
383
 
304
- | Chakra Value | DS Variable |
305
- | ------------ | ----------- |
306
- | 1 | --space-xxs |
307
- | 2 | --space-xs |
308
- | 4 | --space-s |
309
- | 6 | --space-m |
310
- | 8 | --space-l |
311
- | 12 | --space-xl |
312
- | 16 | --space-xxl |
313
- | 24 | --space-xxl |
384
+ | NYPL name Value | Chakra Value | DS Variable |
385
+ | --------------- | ------------ | ----------------- |
386
+ | xxs | 1 | --nypl-space-xxs |
387
+ | xs | 2 | --nypl-space-xs |
388
+ | s | 4 | --nypl-space-s |
389
+ | m | 6 | --nypl-space-m |
390
+ | l | 8 | --nypl-space-l |
391
+ | xl | 12 | --nypl-space-xl |
392
+ | xxl | 16 | --nypl-space-xxl |
393
+ | xxxl | 24 | --nypl-space-xxxl |
314
394
 
315
395
  For example, to make all `button`s have a `padding: 8px 16px` value:
316
396
 
@@ -318,8 +398,8 @@ For example, to make all `button`s have a `padding: 8px 16px` value:
318
398
  // src/theme/components/button.ts
319
399
  const Button = {
320
400
  baseStyle: {
321
- py: 2, // var(--space-xs) which results in a value of 8px or 0.5rem
322
- px: 4, // var(--space-s) which results in a value of 16px or 1rem
401
+ py: "xs", // var(--nypl-space-xs) which results in a value of 8px or 0.5rem.
402
+ px: "s", // var(--nypl-space-s) which results in a value of 16px or 1rem.
323
403
  // ... other styles
324
404
  },
325
405
  sizes: { ... },
@@ -334,8 +414,109 @@ All typography values can be found in the `src/theme/foundations/typography.ts`
334
414
  file. These values declare the font family, font sizes, and font weights to use
335
415
  for all text.
336
416
 
417
+ ## Hooks
418
+
419
+ The following hooks are available to use and can be imported from
420
+ `@nypl/design-system-react-components`.
421
+
422
+ ### useNYPLTheme
423
+
424
+ If your application does not use CSS or SCSS files and you want to write
425
+ CSS-in-JS styles in your React components, the `useNYPLTheme` hook will provide
426
+ you with NYPL-specific style values. This hook depends on the `DSProvider`
427
+ component and if the function is used outside of this wrapper component, then
428
+ the theme object will be empty.
429
+
430
+ After importing and rendering the `DSProvider` wrapper component, as explained
431
+ in the [DSProvider](#dsprovider) section, your children components can use this
432
+ hook function.
433
+
434
+ ```tsx
435
+ import { useNYPLTheme } from "@nypl/design-system-react-components";
436
+ // ...
437
+
438
+ const theme = useNYPLTheme();
439
+ ```
440
+
441
+ The `theme` variable will be a JS object with style values discussed in the
442
+ sections above. This will allow you to use NYPL-specific styles in your
443
+ components through CSS-in-JS.
444
+
445
+ ```ts
446
+ // theme:
447
+ {
448
+ breakpoints: { ... },
449
+ colors: {
450
+ brand: { ... },
451
+ section: { ... },
452
+ transparent: { ... },
453
+ ui: { ... },
454
+ },
455
+ fontSizes: { ... },
456
+ fontWeights: { ... },
457
+ fonts: { ... },
458
+ radii: { ... },
459
+ space: { ... },
460
+ }
461
+ ```
462
+
463
+ #### Usage
464
+
465
+ _Note: more patterns will be added._
466
+
467
+ 1. NYPL DS Components
468
+
469
+ All DS components _should_ be used with their current styles. If a DS component
470
+ needs an updated style, first contact the Design System and UX teams about this
471
+ update. If you really _need_ to update a style and there is no available
472
+ variant, then you can add styles directly to the `additionalStyles` prop. At the
473
+ moment, not all DS components have this prop or feature.
474
+
475
+ For example, if the `Heading` component should render the text in NYPL's green
476
+ color used for "success primary" and add a bold font weight, then you can do
477
+ the following:
478
+
479
+ ```tsx
480
+ const theme = useNYPLTheme();
481
+
482
+ // ...
483
+ return (
484
+ <div>
485
+ <Heading
486
+ level={2}
487
+ additionalStyles={{
488
+ color: theme.colors.ui.sucess.primary,
489
+ fontWeight: theme.fontWeights.bold,
490
+ }}
491
+ >
492
+ Get a Digital Library Card Today in a Few Easy Steps
493
+ </Heading>
494
+
495
+ {/* Other components */}
496
+ </div>
497
+ );
498
+ ```
499
+
500
+ Of course, you can destructure the `theme` object to only get the object keys
501
+ you need for your component (this is a general example). Log the object to the
502
+ console to see all the available styles.
503
+
504
+ 2. HTML Components
505
+
506
+ Use the `style` attribute in HTML components to add inline styles.
507
+
508
+ ```tsx
509
+ <p style={{ color: theme.colors.ui.success.primary }}>
510
+ If you are 13 or older and live, work, attend school, or pay property taxes in
511
+ New York State, you can get a free digital library card right now using this
512
+ online form. Visitors to New York State can also use this form to apply for a
513
+ temporary card.
514
+ </p>
515
+ ```
516
+
337
517
  ## Testing
338
518
 
339
519
  Do not re-test Chakra components that are re-exported since they are already
340
- tested in the `@chakra-ui/react` package. We do expect all new components composed
341
- from Chakra to have tests for functionality and styling (such as snapshots).
520
+ tested in the `@chakra-ui/react` package. We do expect all new components
521
+ composed from Chakra to have tests for functionality and styling
522
+ (such as snapshots).
@@ -4,24 +4,29 @@ import { HeroTypes } from "../components/Hero/HeroTypes.tsx";
4
4
  import Heading from "../components/Heading/Heading.tsx";
5
5
  import Image from "../components/Image/Image.tsx";
6
6
  import getCSSVariable from "../helpers/getCSSVariable";
7
+ import DSProvider from "../theme/provider";
7
8
 
8
9
  <Meta title="Introduction" />
9
10
 
10
11
  # NYPL Design System
11
12
 
12
- <Hero
13
- heroType={HeroTypes.FiftyFifty}
14
- subHeaderText="With 92 locations across the Bronx, Manhattan, and Staten Island, The New York Public Library is an essential part of neighborhoods across the city. Visit us today."
15
- image={
16
- <Image
17
- src="https://cdn-d8.nypl.org/s3fs-public/styles/2_1_960/public/2020-07/SASB_06_29_2020_Lions_mask-00207%20copy_0.jpeg?h=c8e955ed&itok=n_GLQgoe"
18
- blockName="hero"
19
- alt=""
20
- />
21
- }
22
- backgroundColor={getCSSVariable("--section-books-and-more-primary")}
23
- foregroundColor={getCSSVariable("--ui-white")}
24
- />
13
+ export const heroBackgroundColor = `var(--nypl-colors-section-books-and-more-primary)`;
14
+ export const heroForegroundColor = `var(--nypl-colors-ui-white)`;
15
+
16
+ <DSProvider>
17
+ <Hero
18
+ heroType={HeroTypes.FiftyFifty}
19
+ subHeaderText="With 92 locations across the Bronx, Manhattan, and Staten Island, The New York Public Library is an essential part of neighborhoods across the city. Visit us today."
20
+ image={
21
+ <Image
22
+ src="https://cdn-d8.nypl.org/s3fs-public/styles/2_1_960/public/2020-07/SASB_06_29_2020_Lions_mask-00207%20copy_0.jpeg?h=c8e955ed&itok=n_GLQgoe"
23
+ alt=""
24
+ />
25
+ }
26
+ backgroundColor={heroBackgroundColor}
27
+ foregroundColor={heroForegroundColor}
28
+ />
29
+ </DSProvider>
25
30
 
26
31
  <br />
27
32