@nypl/design-system-react-components 0.26.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 (306) hide show
  1. package/CHANGELOG.md +56 -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/Modal/Modal.d.ts +28 -8
  23. package/dist/components/Notification/Notification.d.ts +1 -1
  24. package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +2 -1
  25. package/dist/components/RadioGroup/RadioGroup.d.ts +1 -1
  26. package/dist/components/SearchBar/SearchBar.d.ts +3 -2
  27. package/dist/components/Select/Select.d.ts +2 -5
  28. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -4
  29. package/dist/components/SkipNavigation/SkipNavigation.d.ts +17 -0
  30. package/dist/components/StatusBadge/StatusBadge.d.ts +2 -3
  31. package/dist/components/StructuredContent/StructuredContent.d.ts +2 -2
  32. package/dist/components/Table/Table.d.ts +1 -1
  33. package/dist/components/Template/Template.d.ts +2 -0
  34. package/dist/components/Text/Text.d.ts +1 -1
  35. package/dist/components/TextInput/TextInput.d.ts +21 -9
  36. package/dist/components/Toggle/Toggle.d.ts +1 -5
  37. package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
  38. package/dist/design-system-react-components.cjs.development.js +977 -1213
  39. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  40. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  41. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  42. package/dist/design-system-react-components.esm.js +976 -1276
  43. package/dist/design-system-react-components.esm.js.map +1 -1
  44. package/dist/helpers/types.d.ts +1 -0
  45. package/dist/index.d.ts +27 -48
  46. package/dist/styles.css +1 -1
  47. package/dist/theme/components/buttonGroup.d.ts +11 -0
  48. package/dist/theme/components/card.d.ts +104 -8
  49. package/dist/theme/components/componentWrapper.d.ts +4 -3
  50. package/dist/theme/components/customTable.d.ts +11 -14
  51. package/dist/theme/components/fieldset.d.ts +4 -3
  52. package/dist/theme/components/helperErrorText.d.ts +4 -3
  53. package/dist/theme/components/hero.d.ts +1 -1
  54. package/dist/theme/components/horizontalRule.d.ts +4 -3
  55. package/dist/theme/components/icon.d.ts +47743 -1
  56. package/dist/theme/components/image.d.ts +563 -10
  57. package/dist/theme/components/label.d.ts +4 -3
  58. package/dist/theme/components/list.d.ts +6 -7
  59. package/dist/theme/components/logo.d.ts +474 -1
  60. package/dist/theme/components/notification.d.ts +20 -16
  61. package/dist/theme/components/progressIndicator.d.ts +6 -4
  62. package/dist/theme/components/select.d.ts +4 -10
  63. package/dist/theme/components/skeletonLoader.d.ts +14 -10
  64. package/dist/theme/components/skipNavigation.d.ts +22 -0
  65. package/dist/theme/components/slider.d.ts +7 -6
  66. package/dist/theme/components/structuredContent.d.ts +10 -9
  67. package/dist/theme/components/text.d.ts +7 -1
  68. package/dist/theme/components/toggle.d.ts +6 -4
  69. package/dist/theme/provider.d.ts +2 -4
  70. package/dist/utils/componentCategories.d.ts +1 -1
  71. package/dist/utils/interfaces.d.ts +5 -0
  72. package/dist/utils/utils.d.ts +2 -18
  73. package/package.json +15 -16
  74. package/src/__tests__/setup.ts +3 -3
  75. package/src/__tests__/utils/utils.test.ts +1 -23
  76. package/src/components/AccessibilityGuide/SkipNavigation.stories.mdx +22 -14
  77. package/src/components/Accordion/Accordion.stories.mdx +43 -44
  78. package/src/components/Accordion/Accordion.test.tsx +5 -13
  79. package/src/components/Accordion/Accordion.tsx +14 -18
  80. package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +6 -6
  81. package/src/components/Autosuggest/Autosuggest.stories.mdx +1 -1
  82. package/src/components/Autosuggest/Autosuggest.stories.tsx +23 -25
  83. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +21 -37
  84. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +4 -17
  85. package/src/components/Breadcrumbs/Breadcrumbs.tsx +18 -21
  86. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +1 -100
  87. package/src/components/Button/Button.stories.mdx +89 -126
  88. package/src/components/Button/Button.test.tsx +16 -30
  89. package/src/components/Button/Button.tsx +14 -20
  90. package/src/components/ButtonGroup/ButtonGroup.stories.mdx +147 -0
  91. package/src/components/ButtonGroup/ButtonGroup.test.tsx +141 -0
  92. package/src/components/ButtonGroup/ButtonGroup.tsx +99 -0
  93. package/src/components/ButtonGroup/__snapshots__/ButtonGroup.test.tsx.snap +117 -0
  94. package/src/components/Card/Card.stories.mdx +143 -177
  95. package/src/components/Card/Card.test.tsx +36 -97
  96. package/src/components/Card/Card.tsx +78 -74
  97. package/src/components/Card/__snapshots__/Card.test.tsx.snap +1 -1
  98. package/src/components/Chakra/Box.stories.mdx +2 -6
  99. package/src/components/Chakra/Center.stories.mdx +5 -23
  100. package/src/components/Chakra/Flex.stories.mdx +4 -6
  101. package/src/components/Chakra/Stack.stories.mdx +9 -10
  102. package/src/components/Checkbox/Checkbox.stories.mdx +1 -1
  103. package/src/components/Checkbox/Checkbox.test.tsx +2 -2
  104. package/src/components/Checkbox/Checkbox.tsx +20 -13
  105. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +9 -9
  106. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +6 -17
  107. package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +1 -7
  108. package/src/components/CheckboxGroup/CheckboxGroup.tsx +33 -29
  109. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +24 -35
  110. package/src/components/ComponentWrapper/ComponentWrapper.tsx +3 -10
  111. package/src/components/DatePicker/DatePicker.stories.mdx +23 -37
  112. package/src/components/DatePicker/DatePicker.test.tsx +21 -19
  113. package/src/components/DatePicker/DatePicker.tsx +57 -49
  114. package/src/components/Form/Form.stories.mdx +46 -31
  115. package/src/components/Form/Form.test.tsx +1 -18
  116. package/src/components/Form/Form.tsx +7 -7
  117. package/src/components/Grid/SimpleGrid.stories.mdx +73 -49
  118. package/src/components/Grid/SimpleGrid.test.tsx +7 -9
  119. package/src/components/Grid/SimpleGrid.tsx +14 -11
  120. package/src/components/Heading/Heading.stories.mdx +27 -72
  121. package/src/components/Heading/Heading.test.tsx +18 -44
  122. package/src/components/Heading/Heading.tsx +7 -10
  123. package/src/components/HelperErrorText/HelperErrorText.stories.mdx +1 -3
  124. package/src/components/HelperErrorText/HelperErrorText.tsx +1 -5
  125. package/src/components/Hero/Hero.stories.mdx +219 -216
  126. package/src/components/Hero/Hero.test.tsx +107 -223
  127. package/src/components/Hero/Hero.tsx +63 -61
  128. package/src/components/Icons/Icon.stories.mdx +172 -118
  129. package/src/components/Icons/Icon.test.tsx +8 -16
  130. package/src/components/Icons/Icon.tsx +75 -29
  131. package/src/components/Icons/IconSvgs.tsx +42 -42
  132. package/src/components/Image/Image.stories.mdx +45 -132
  133. package/src/components/Image/Image.test.tsx +16 -31
  134. package/src/components/Image/Image.tsx +28 -12
  135. package/src/components/Link/Link.stories.mdx +30 -94
  136. package/src/components/Link/Link.test.tsx +25 -75
  137. package/src/components/Link/Link.tsx +43 -56
  138. package/src/components/Link/__snapshots__/Link.test.tsx.snap +1 -2
  139. package/src/components/List/List.stories.mdx +20 -31
  140. package/src/components/List/List.test.tsx +24 -43
  141. package/src/components/List/List.tsx +25 -36
  142. package/src/components/Logo/Logo.stories.mdx +94 -50
  143. package/src/components/Logo/Logo.test.tsx +10 -19
  144. package/src/components/Logo/Logo.tsx +50 -17
  145. package/src/components/Logo/LogoSvgs.tsx +78 -78
  146. package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +4 -4
  147. package/src/components/Modal/Modal.stories.mdx +245 -139
  148. package/src/components/Modal/Modal.test.tsx +147 -10
  149. package/src/components/Modal/Modal.tsx +140 -20
  150. package/src/components/Modal/__snapshots__/Modal.test.tsx.snap +25 -0
  151. package/src/components/Notification/Notification.stories.mdx +10 -28
  152. package/src/components/Notification/Notification.test.tsx +9 -12
  153. package/src/components/Notification/Notification.tsx +34 -37
  154. package/src/components/Pagination/Pagination.stories.mdx +3 -4
  155. package/src/components/Pagination/Pagination.tsx +15 -10
  156. package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +27 -53
  157. package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +9 -10
  158. package/src/components/ProgressIndicator/ProgressIndicator.tsx +17 -21
  159. package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +0 -10
  160. package/src/components/Radio/Radio.stories.mdx +1 -1
  161. package/src/components/Radio/Radio.tsx +9 -6
  162. package/src/components/RadioGroup/RadioGroup.stories.mdx +15 -16
  163. package/src/components/RadioGroup/RadioGroup.test.tsx +2 -8
  164. package/src/components/RadioGroup/RadioGroup.tsx +28 -24
  165. package/src/components/SearchBar/SearchBar.stories.mdx +1 -1
  166. package/src/components/SearchBar/SearchBar.test.tsx +1 -1
  167. package/src/components/SearchBar/SearchBar.tsx +14 -22
  168. package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +1 -13
  169. package/src/components/Select/Select.stories.mdx +10 -25
  170. package/src/components/Select/Select.test.tsx +6 -7
  171. package/src/components/Select/Select.tsx +28 -35
  172. package/src/components/Select/__snapshots__/Select.test.tsx.snap +24 -24
  173. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +17 -56
  174. package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +7 -21
  175. package/src/components/SkeletonLoader/SkeletonLoader.tsx +9 -8
  176. package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +33 -33
  177. package/src/components/SkipNavigation/SkipNavigation.stories.mdx +90 -0
  178. package/src/components/SkipNavigation/SkipNavigation.test.tsx +63 -0
  179. package/src/components/SkipNavigation/SkipNavigation.tsx +51 -0
  180. package/src/components/SkipNavigation/__snapshots__/SkipNavigation.test.tsx.snap +130 -0
  181. package/src/components/Slider/Slider.stories.mdx +19 -53
  182. package/src/components/Slider/Slider.test.tsx +2 -2
  183. package/src/components/Slider/Slider.tsx +10 -12
  184. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +2 -9
  185. package/src/components/StatusBadge/StatusBadge.stories.mdx +6 -21
  186. package/src/components/StatusBadge/StatusBadge.test.tsx +2 -3
  187. package/src/components/StatusBadge/StatusBadge.tsx +3 -10
  188. package/src/components/StructuredContent/StructuredContent.stories.mdx +30 -58
  189. package/src/components/StructuredContent/StructuredContent.test.tsx +42 -44
  190. package/src/components/StructuredContent/StructuredContent.tsx +9 -18
  191. package/src/components/StyleGuide/Bidirectionality.stories.mdx +9 -23
  192. package/src/components/StyleGuide/Buttons.stories.mdx +62 -62
  193. package/src/components/StyleGuide/ColorCard.tsx +2 -4
  194. package/src/components/StyleGuide/Colors.stories.mdx +7 -8
  195. package/src/components/StyleGuide/DesignTokens.stories.mdx +5 -7
  196. package/src/components/StyleGuide/Forms.stories.mdx +0 -1
  197. package/src/components/StyleGuide/Iconography.stories.mdx +59 -77
  198. package/src/components/StyleGuide/Spacing.stories.mdx +0 -1
  199. package/src/components/StyleGuide/Typography.stories.mdx +15 -18
  200. package/src/components/Table/Table.stories.mdx +85 -1
  201. package/src/components/Table/Table.test.tsx +57 -1
  202. package/src/components/Table/Table.tsx +7 -4
  203. package/src/components/Table/__snapshots__/Table.test.tsx.snap +121 -0
  204. package/src/components/Tabs/Tabs.stories.mdx +1 -1
  205. package/src/components/Tabs/Tabs.test.tsx +2 -2
  206. package/src/components/Tabs/Tabs.tsx +26 -27
  207. package/src/components/Template/Template.stories.mdx +49 -54
  208. package/src/components/Template/Template.tsx +9 -3
  209. package/src/components/Text/Text.stories.mdx +5 -11
  210. package/src/components/Text/Text.test.tsx +3 -6
  211. package/src/components/Text/Text.tsx +3 -5
  212. package/src/components/TextInput/TextInput.stories.mdx +10 -22
  213. package/src/components/TextInput/TextInput.test.tsx +32 -62
  214. package/src/components/TextInput/TextInput.tsx +61 -30
  215. package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +1 -0
  216. package/src/components/Toggle/Toggle.stories.mdx +5 -16
  217. package/src/components/Toggle/Toggle.test.tsx +2 -3
  218. package/src/components/Toggle/Toggle.tsx +9 -10
  219. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +13 -29
  220. package/src/components/VideoPlayer/VideoPlayer.test.tsx +18 -23
  221. package/src/components/VideoPlayer/VideoPlayer.tsx +13 -10
  222. package/src/docs/Chakra.stories.mdx +14 -11
  223. package/src/docs/Welcome.stories.mdx +23 -43
  224. package/src/helpers/types.ts +1 -0
  225. package/src/hooks/tests/useNYPLTheme.test.tsx +1 -1
  226. package/src/hooks/useNYPLTheme.stories.mdx +3 -6
  227. package/src/index.ts +52 -46
  228. package/src/styles.scss +0 -1
  229. package/src/theme/components/buttonGroup.ts +10 -0
  230. package/src/theme/components/card.ts +50 -15
  231. package/src/theme/components/componentWrapper.ts +5 -1
  232. package/src/theme/components/customTable.ts +8 -2
  233. package/src/theme/components/fieldset.ts +5 -1
  234. package/src/theme/components/helperErrorText.ts +5 -1
  235. package/src/theme/components/hero.ts +2 -2
  236. package/src/theme/components/horizontalRule.ts +5 -1
  237. package/src/theme/components/icon.ts +7 -1
  238. package/src/theme/components/image.ts +14 -3
  239. package/src/theme/components/label.ts +5 -1
  240. package/src/theme/components/list.ts +8 -2
  241. package/src/theme/components/logo.ts +5 -1
  242. package/src/theme/components/notification.ts +38 -14
  243. package/src/theme/components/progressIndicator.ts +10 -5
  244. package/src/theme/components/select.ts +5 -6
  245. package/src/theme/components/skeletonLoader.ts +8 -2
  246. package/src/theme/components/skipNavigation.ts +26 -0
  247. package/src/theme/components/slider.ts +13 -1
  248. package/src/theme/components/structuredContent.ts +11 -1
  249. package/src/theme/components/text.ts +12 -5
  250. package/src/theme/components/toggle.ts +9 -3
  251. package/src/theme/index.ts +4 -0
  252. package/src/theme/provider.tsx +1 -1
  253. package/src/utils/componentCategories.ts +13 -5
  254. package/src/utils/interfaces.ts +5 -0
  255. package/src/utils/utils.ts +2 -32
  256. package/dist/components/Accordion/AccordionTypes.d.ts +0 -5
  257. package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +0 -8
  258. package/dist/components/Button/ButtonTypes.d.ts +0 -8
  259. package/dist/components/DatePicker/DatePickerTypes.d.ts +0 -5
  260. package/dist/components/Form/FormTypes.d.ts +0 -2
  261. package/dist/components/Grid/GridTypes.d.ts +0 -9
  262. package/dist/components/Heading/HeadingTypes.d.ts +0 -14
  263. package/dist/components/Hero/HeroTypes.d.ts +0 -12
  264. package/dist/components/Icons/IconTypes.d.ts +0 -77
  265. package/dist/components/Image/ImageTypes.d.ts +0 -22
  266. package/dist/components/Link/LinkTypes.d.ts +0 -8
  267. package/dist/components/List/ListTypes.d.ts +0 -5
  268. package/dist/components/Logo/LogoTypes.d.ts +0 -54
  269. package/dist/components/Notification/NotificationTypes.d.ts +0 -5
  270. package/dist/components/ProgressIndicator/ProgressIndicatorTypes.d.ts +0 -8
  271. package/dist/components/Select/SelectTypes.d.ts +0 -8
  272. package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +0 -5
  273. package/dist/components/StatusBadge/StatusBadgeTypes.d.ts +0 -5
  274. package/dist/components/StructuredContent/StructuredContentTypes.d.ts +0 -5
  275. package/dist/components/Text/TextTypes.d.ts +0 -6
  276. package/dist/components/TextInput/TextInputTypes.d.ts +0 -25
  277. package/dist/components/Toggle/ToggleTypes.d.ts +0 -4
  278. package/dist/components/VideoPlayer/VideoPlayerTypes.d.ts +0 -9
  279. package/dist/helpers/enums.d.ts +0 -4
  280. package/dist/utils/siteSections.d.ts +0 -2
  281. package/src/components/Accordion/AccordionTypes.tsx +0 -5
  282. package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +0 -8
  283. package/src/components/Button/ButtonTypes.tsx +0 -8
  284. package/src/components/DatePicker/DatePickerTypes.tsx +0 -5
  285. package/src/components/Form/FormTypes.tsx +0 -3
  286. package/src/components/Grid/GridTypes.tsx +0 -9
  287. package/src/components/Heading/HeadingTypes.tsx +0 -15
  288. package/src/components/Hero/HeroTypes.tsx +0 -20
  289. package/src/components/Icons/IconTypes.tsx +0 -83
  290. package/src/components/Image/ImageTypes.ts +0 -24
  291. package/src/components/Link/LinkTypes.tsx +0 -8
  292. package/src/components/List/ListTypes.tsx +0 -5
  293. package/src/components/Logo/LogoTypes.tsx +0 -56
  294. package/src/components/Modal/_Modal.scss +0 -18
  295. package/src/components/Notification/NotificationTypes.tsx +0 -5
  296. package/src/components/ProgressIndicator/ProgressIndicatorTypes.ts +0 -8
  297. package/src/components/Select/SelectTypes.tsx +0 -10
  298. package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +0 -5
  299. package/src/components/StatusBadge/StatusBadgeTypes.tsx +0 -5
  300. package/src/components/StructuredContent/StructuredContentTypes.tsx +0 -5
  301. package/src/components/Text/TextTypes.tsx +0 -6
  302. package/src/components/TextInput/TextInputTypes.tsx +0 -48
  303. package/src/components/Toggle/ToggleTypes.tsx +0 -4
  304. package/src/components/VideoPlayer/VideoPlayerTypes.tsx +0 -10
  305. package/src/helpers/enums.ts +0 -4
  306. package/src/utils/siteSections.ts +0 -10
@@ -1,13 +1,32 @@
1
- import { NotificationTypes } from "../../components/Notification/NotificationTypes";
1
+ import { NotificationTypes } from "../../components/Notification/Notification";
2
+
3
+ interface NotificationBaseStyle {
4
+ dismissible: boolean;
5
+ isCentered: boolean;
6
+ noMargin: boolean;
7
+ notificationType: NotificationTypes;
8
+ }
9
+ interface NotificationContentBaseStyle {
10
+ alignText: boolean;
11
+ icon: boolean;
12
+ notificationType: NotificationTypes;
13
+ }
14
+ interface NotificationHeadingBaseStyle {
15
+ icon: boolean;
16
+ isCentered: boolean;
17
+ notificationType: NotificationTypes;
18
+ }
2
19
 
3
20
  const Notification = {
4
21
  parts: ["container", "dismissibleButton", "icon"],
5
- baseStyle: ({ dismissible, isCentered, noMargin, notificationType }) => {
22
+ baseStyle: ({
23
+ dismissible,
24
+ isCentered,
25
+ noMargin,
26
+ notificationType,
27
+ }: NotificationBaseStyle) => {
6
28
  let bg = "ui.status.primary";
7
- if (
8
- notificationType === NotificationTypes.Announcement ||
9
- notificationType === NotificationTypes.Warning
10
- ) {
29
+ if (notificationType === "announcement" || notificationType === "warning") {
11
30
  bg = "ui.gray.x-light-cool";
12
31
  }
13
32
  return {
@@ -55,14 +74,15 @@ const Notification = {
55
74
 
56
75
  const NotificationContent = {
57
76
  parts: ["content"],
58
- baseStyle: ({ alignText, icon, notificationType }) => ({
77
+ baseStyle: ({
78
+ alignText,
79
+ icon,
80
+ notificationType,
81
+ }: NotificationContentBaseStyle) => ({
59
82
  display: "flex",
60
83
  justifyContent: "center",
61
84
  content: {
62
- color:
63
- notificationType === NotificationTypes.Warning
64
- ? "brand.primary"
65
- : "currentColor",
85
+ color: notificationType === "warning" ? "brand.primary" : "currentColor",
66
86
  marginTop: icon ? "xxxs" : "0",
67
87
  paddingLeft: alignText
68
88
  ? "calc(var(--nypl-space-m) + var(--nypl-space-s))"
@@ -81,11 +101,15 @@ const NotificationContent = {
81
101
 
82
102
  const NotificationHeading = {
83
103
  parts: ["heading"],
84
- baseStyle: ({ icon, isCentered, notificationType }) => {
104
+ baseStyle: ({
105
+ icon,
106
+ isCentered,
107
+ notificationType,
108
+ }: NotificationHeadingBaseStyle) => {
85
109
  let color = "ui.black";
86
- if (notificationType === NotificationTypes.Announcement) {
110
+ if (notificationType === "announcement") {
87
111
  color = "section.research.secondary";
88
- } else if (notificationType === NotificationTypes.Warning) {
112
+ } else if (notificationType === "warning") {
89
113
  color = "brand.primary";
90
114
  }
91
115
  return {
@@ -1,4 +1,9 @@
1
- import { ProgressIndicatorSizes } from "../../components/ProgressIndicator/ProgressIndicatorTypes";
1
+ import { ProgressIndicatorSizes } from "../../components/ProgressIndicator/ProgressIndicator";
2
+
3
+ interface ProgressIndicatorBaseStyle {
4
+ darkMode: boolean;
5
+ size: ProgressIndicatorSizes;
6
+ }
2
7
 
3
8
  const ProgressIndicator = {
4
9
  parts: [
@@ -8,15 +13,15 @@ const ProgressIndicator = {
8
13
  "linearContainer",
9
14
  "linearPercentage",
10
15
  ],
11
- baseStyle: ({ darkMode, size }) => {
16
+ baseStyle: ({ darkMode, size }: ProgressIndicatorBaseStyle) => {
12
17
  return {
13
18
  color: darkMode ? "ui.white" : "ui.black",
14
19
  circular: {
15
20
  // Note: we have to target the SVG HTMl elements in order
16
21
  // to override the default styles.
17
22
  svg: {
18
- height: size === ProgressIndicatorSizes.Default ? "48px" : "24px",
19
- width: size === ProgressIndicatorSizes.Default ? "48px" : "24px",
23
+ height: size === "default" ? "48px" : "24px",
24
+ width: size === "default" ? "48px" : "24px",
20
25
  display: "block",
21
26
  circle: {
22
27
  _first: {
@@ -44,7 +49,7 @@ const ProgressIndicator = {
44
49
  bg: darkMode ? "ui.gray.dark" : "ui.gray.light-cool",
45
50
  height: {
46
51
  base: "4px",
47
- md: size === ProgressIndicatorSizes.Default ? "8px" : "4px",
52
+ md: size === "default" ? "8px" : "4px",
48
53
  },
49
54
  },
50
55
  linearContainer: {
@@ -3,6 +3,10 @@ import {
3
3
  selectTextInputFocusStyles,
4
4
  } from "./global";
5
5
 
6
+ interface SelectBaseStyle {
7
+ labelPosition: string;
8
+ }
9
+
6
10
  const select = {
7
11
  backgroundColor: "ui.white",
8
12
  borderRadius: "sm",
@@ -29,19 +33,14 @@ const select = {
29
33
 
30
34
  const Select = {
31
35
  parts: ["helperText", "inline", "select"],
32
- baseStyle: ({ labelPosition, labelWidth }) => {
36
+ baseStyle: ({ labelPosition }: SelectBaseStyle) => {
33
37
  return {
34
- marginBottom: "xs",
35
38
  // The backgroundColor set to "ui.white" hides the arrow SVG icon when
36
39
  // the component is focused. The background is added for dark mode and
37
40
  // so we need to add specific selector.
38
41
  ".chakra-select__icon-wrapper": {
39
42
  zIndex: "9999",
40
43
  },
41
- helperText: {
42
- marginLeft:
43
- labelPosition === "inline" ? { md: `${labelWidth}px` } : null,
44
- },
45
44
  inline: {
46
45
  display: { md: "flex" },
47
46
  gap: { md: "var(--nypl-space-xs)" },
@@ -1,5 +1,11 @@
1
1
  import { keyframes } from "@chakra-ui/system";
2
2
 
3
+ interface SkeletonLoaderBaseStyle {
4
+ imageAspectRatio: keyof typeof imagePaddingBottomStyles;
5
+ isBordered: boolean;
6
+ showImage?: boolean;
7
+ }
8
+
3
9
  const element = {
4
10
  borderRadius: "2px",
5
11
  boxSizing: "border-box",
@@ -23,7 +29,7 @@ const imageRowHeightStyles = {
23
29
  // NYPL's skeleton loader component.
24
30
  const SkeletonLoader = {
25
31
  parts: ["section", "image", "container", "heading", "content", "button"],
26
- baseStyle: ({ imageAspectRatio, isBordered }) => {
32
+ baseStyle: ({ imageAspectRatio, isBordered }: SkeletonLoaderBaseStyle) => {
27
33
  const borderStyles = isBordered ? { ...borderRules } : {};
28
34
 
29
35
  return {
@@ -67,7 +73,7 @@ const SkeletonLoader = {
67
73
  };
68
74
  },
69
75
  variants: {
70
- row: ({ imageAspectRatio, showImage }) => ({
76
+ row: ({ imageAspectRatio, showImage }: SkeletonLoaderBaseStyle) => ({
71
77
  alignItems: "flex-start",
72
78
  display: { md: "flex" },
73
79
  image: {
@@ -0,0 +1,26 @@
1
+ const SkipNavigation = {
2
+ baseStyle: {
3
+ // Don't display links by default...
4
+ a: {
5
+ backgroundColor: "ui.white",
6
+ height: "1px",
7
+ left: "-10000px",
8
+ overflow: "hidden",
9
+ position: "absolute",
10
+ top: "auto",
11
+ width: "1px",
12
+ // Only display when the user focuses on the links.
13
+ _focus: {
14
+ border: "1px solid var(—nypl-colors-ui-gray-dark)",
15
+ height: "auto",
16
+ left: "2rem",
17
+ padding:
18
+ "var(--nypl-space-inset-extranarrow) var(--nypl-space-inset-narrow)",
19
+ top: "3rem",
20
+ width: "auto",
21
+ },
22
+ },
23
+ },
24
+ };
25
+
26
+ export default SkipNavigation;
@@ -1,3 +1,10 @@
1
+ interface CustomSliderBaseStyle {
2
+ isDisabled: boolean;
3
+ isInvalid: boolean;
4
+ showBoxes: boolean;
5
+ showValues: boolean;
6
+ }
7
+
1
8
  // Margins around the static display values.
2
9
  const staticValues = {
3
10
  marginTop: "xs",
@@ -16,7 +23,12 @@ const CustomSlider = {
16
23
  "track",
17
24
  "thumb",
18
25
  ],
19
- baseStyle: ({ isDisabled, isInvalid, showBoxes, showValues }) => {
26
+ baseStyle: ({
27
+ isDisabled,
28
+ isInvalid,
29
+ showBoxes,
30
+ showValues,
31
+ }: CustomSliderBaseStyle) => {
20
32
  let baseColor = "ui.link.primary";
21
33
  if (isInvalid) {
22
34
  baseColor = "ui.error.primary";
@@ -9,9 +9,19 @@ import {
9
9
  baseUnorderedStyles,
10
10
  } from "./list";
11
11
 
12
+ interface StructuredContentBaseStyle {
13
+ hasFigureImage: boolean;
14
+ imageAspectRatio: string;
15
+ imagePosition: string;
16
+ }
17
+
12
18
  const StructuredContent = {
13
19
  parts: ["image", "imageFigure", "imageWrapper"],
14
- baseStyle: ({ hasFigureImage, imageAspectRatio, imagePosition }) => {
20
+ baseStyle: ({
21
+ hasFigureImage,
22
+ imageAspectRatio,
23
+ imagePosition,
24
+ }: StructuredContentBaseStyle) => {
15
25
  const styles: { maxWidth?: string } = {};
16
26
  const wrapperStyles = {
17
27
  float: [
@@ -1,3 +1,10 @@
1
+ interface TextBaseStyle {
2
+ isBold: boolean;
3
+ isItalic: boolean;
4
+ noSpace: boolean;
5
+ variant: string;
6
+ }
7
+
1
8
  const variants = {
2
9
  default: {},
3
10
  caption: {
@@ -11,18 +18,18 @@ const variants = {
11
18
  },
12
19
  };
13
20
  const Text = {
14
- baseStyle: (props) => {
15
- const fontWeight = props.isBold
16
- ? props.variant === "tag" || props.variant === "mini"
21
+ baseStyle: ({ isBold, isItalic, noSpace, variant }: TextBaseStyle) => {
22
+ const fontWeight = isBold
23
+ ? variant === "tag" || variant === "mini"
17
24
  ? "medium"
18
25
  : "bold"
19
26
  : null;
20
- const fontStyle = props.isItalic ? "italic" : null;
27
+ const fontStyle = isItalic ? "italic" : null;
21
28
 
22
29
  return {
23
30
  fontStyle: fontStyle,
24
31
  fontWeight: fontWeight,
25
- marginBottom: props.noSpace ? "0 !important" : null,
32
+ marginBottom: noSpace ? "0 !important" : null,
26
33
  };
27
34
  },
28
35
  variants,
@@ -1,10 +1,16 @@
1
1
  import { cssVar } from "@chakra-ui/theme-tools";
2
- import { ToggleSizes } from "../../components/Toggle/ToggleTypes";
3
2
 
4
- const toggleBaseStyle = ({ isDisabled, size }) => {
3
+ import { ToggleSizes } from "../../components/Toggle/Toggle";
4
+
5
+ interface ToggleBaseStyle {
6
+ isDisabled: boolean;
7
+ size: ToggleSizes;
8
+ }
9
+
10
+ const toggleBaseStyle = ({ isDisabled, size }: ToggleBaseStyle) => {
5
11
  const label = { alignItems: "start", display: "flex", width: "fit-content" };
6
12
  const helperErrorText = {
7
- marginLeft: size === ToggleSizes.Default ? "xxl" : "xl",
13
+ marginLeft: size === "default" ? "xxl" : "xl",
8
14
  fontStyle: isDisabled ? "italic" : null,
9
15
  };
10
16
  return {
@@ -11,6 +11,7 @@ import typography from "./foundations/typography";
11
11
  import Accordion from "./components/accordion";
12
12
  import Breadcrumb from "./components/breadcrumb";
13
13
  import Button from "./components/button";
14
+ import ButtonGroup from "./components/buttonGroup";
14
15
  import Card from "./components/card";
15
16
  import Checkbox from "./components/checkbox";
16
17
  import ComponentWrapper from "./components/componentWrapper";
@@ -35,6 +36,7 @@ import Radio from "./components/radio";
35
36
  import RadioGroup from "./components/radioGroup";
36
37
  import SearchBar from "./components/searchBar";
37
38
  import { Skeleton, SkeletonLoader } from "./components/skeletonLoader";
39
+ import SkipNavigation from "./components/skipNavigation";
38
40
  import CustomSlider from "./components/slider";
39
41
  import StatusBadge from "./components/statusBadge";
40
42
  import StructuredContent from "./components/structuredContent";
@@ -80,6 +82,7 @@ const theme = extendTheme({
80
82
  Accordion,
81
83
  Breadcrumb,
82
84
  Button,
85
+ ButtonGroup,
83
86
  ...Card,
84
87
  Checkbox,
85
88
  CheckboxGroup,
@@ -106,6 +109,7 @@ const theme = extendTheme({
106
109
  SearchBar,
107
110
  Skeleton,
108
111
  SkeletonLoader,
112
+ SkipNavigation,
109
113
  CustomSlider,
110
114
  StatusBadge,
111
115
  StructuredContent,
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { ChakraProvider } from "@chakra-ui/react";
3
3
  import theme from "./index";
4
4
 
5
- const DSProvider = ({ children }) => (
5
+ const DSProvider = ({ children }: React.PropsWithChildren<{}>) => (
6
6
  <ChakraProvider theme={theme}>{children}</ChakraProvider>
7
7
  );
8
8
 
@@ -53,6 +53,7 @@ const categories = {
53
53
  title: "Components/Form Elements",
54
54
  components: [
55
55
  "Button",
56
+ "ButtonGroup",
56
57
  "Checkbox",
57
58
  "CheckboxGroup",
58
59
  "DatePicker",
@@ -108,7 +109,14 @@ const categories = {
108
109
  },
109
110
  navigation: {
110
111
  title: "Components/Navigation",
111
- components: ["Breadcrumbs", "Link", "Menu", "Pagination", "Subnavigation"],
112
+ components: [
113
+ "Breadcrumbs",
114
+ "Link",
115
+ "Menu",
116
+ "Pagination",
117
+ "SkipNavigation",
118
+ "Subnavigation",
119
+ ],
112
120
  },
113
121
  styleguide: {
114
122
  title: "Style Guide",
@@ -131,11 +139,11 @@ const categories = {
131
139
  },
132
140
  };
133
141
 
134
- export const getCategory = (component) => {
142
+ export const getCategory = (component: string) => {
135
143
  let catPath = component;
136
- Object.keys(categories).forEach((key) => {
137
- const t = categories[key].title;
138
- const c = categories[key].components;
144
+ Object.keys(categories).forEach((key: string) => {
145
+ const t = categories[key as keyof typeof categories].title;
146
+ const c = categories[key as keyof typeof categories].components;
139
147
  if (c.includes(component)) {
140
148
  catPath = `${t}/${component}`;
141
149
  }
@@ -0,0 +1,5 @@
1
+ export interface AriaAttributes {
2
+ "aria-label"?: string;
3
+ "aria-describedby"?: string;
4
+ "aria-labelledby"?: string;
5
+ }
@@ -15,43 +15,13 @@ export const range = (start: number, stop: number, step = 1): number[] => {
15
15
  .map((x, y) => x + y * step);
16
16
  };
17
17
 
18
- /**
19
- * Map an enum value to a component's Chakra theme variant object. If a wrong
20
- * value is passed (typically in non-Typescript scenarios), then the "fallback"
21
- * value, if provided, will be used.
22
- */
23
- export const getVariant = (variant, collection, fallback = null) => {
24
- const variantMap = {};
25
- for (const type in collection) {
26
- variantMap[collection[type]] = collection[type];
27
- }
28
- return variantMap[variant] || fallback;
29
- };
30
-
31
- /**
32
- * Given an enum object and its name, this will return (1) an array `options`
33
- * of all values with the enum name as the prefix, and (2) a function that
34
- * returns the correct enum value given a string from the `options` array.
35
- * @NOTE this is only used for Storybook documentation.
36
- */
37
- export const getStorybookEnumValues = (enumObject, name) => {
38
- const options = Object.keys(enumObject).map((key) => `${name}.${key}`);
39
- const getValue = (key) => {
40
- // In case no value is passed, return the first value from the array above
41
- // as the default. Otherwise, remove the dot from the string and get the
42
- // last part to be able to get the correct enum value.
43
- return !key ? options[0] : enumObject[key.substr(key.indexOf(".") + 1)];
44
- };
45
- return { options, getValue };
46
- };
47
-
48
18
  /**
49
19
  * Given a pagination's pageCount, this will return (1) a page number,
50
20
  * derived from the current URL, and (2) a function that, when passed to
51
21
  * Pagination component, makes the URL change and refreshes the page.
52
22
  * @NOTE this is only used for Storybook documentation.
53
23
  */
54
- export const getStorybookHrefProps = (pageCount) => {
24
+ export const getStorybookHrefProps = (pageCount: number) => {
55
25
  // This uses the `addon-queryparams` Storybook addon.
56
26
  const urlParams = new URLSearchParams(document.location.search);
57
27
  const pageParam = urlParams.get("page");
@@ -66,7 +36,7 @@ export const getStorybookHrefProps = (pageCount) => {
66
36
  const location = window.location;
67
37
  // Passing this function into `Pagination` makes the URL to change
68
38
  // and refreshes the page.
69
- const getPageHref = (selectedPage) => {
39
+ const getPageHref = (selectedPage: number) => {
70
40
  return `${location.href}&page=${selectedPage}`;
71
41
  };
72
42
 
@@ -1,5 +0,0 @@
1
- export declare enum AccordionTypes {
2
- Default = "default",
3
- Warning = "warning",
4
- Error = "error"
5
- }
@@ -1,8 +0,0 @@
1
- export declare enum BreadcrumbsTypes {
2
- Blogs = "blogs",
3
- BooksAndMore = "booksAndMore",
4
- Education = "education",
5
- Locations = "locations",
6
- Research = "research",
7
- WhatsOn = "whatsOn"
8
- }
@@ -1,8 +0,0 @@
1
- export declare enum ButtonTypes {
2
- Primary = "primary",
3
- Secondary = "secondary",
4
- Callout = "callout",
5
- Pill = "pill",
6
- Link = "link",
7
- NoBrand = "noBrand"
8
- }
@@ -1,5 +0,0 @@
1
- export declare enum DatePickerTypes {
2
- Full = "full",
3
- Month = "month",
4
- Year = "year"
5
- }
@@ -1,2 +0,0 @@
1
- import { GridGaps as FormGaps } from "../Grid/GridTypes";
2
- export { FormGaps };
@@ -1,9 +0,0 @@
1
- export declare enum GridGaps {
2
- ExtraExtraSmall = "grid.xxs",
3
- ExtraSmall = "grid.xs",
4
- Small = "grid.s",
5
- Medium = "grid.m",
6
- Large = "grid.l",
7
- ExtraLarge = "grid.xl",
8
- ExtraExtraLarge = "grid.xxl"
9
- }
@@ -1,14 +0,0 @@
1
- export declare enum HeadingSizes {
2
- Primary = "primary",
3
- Secondary = "secondary",
4
- Tertiary = "tertiary",
5
- Callout = "callout"
6
- }
7
- export declare enum HeadingLevels {
8
- One = "one",
9
- Two = "two",
10
- Three = "three",
11
- Four = "four",
12
- Five = "five",
13
- Six = "six"
14
- }
@@ -1,12 +0,0 @@
1
- export declare enum HeroTypes {
2
- Primary = "primary",
3
- Secondary = "secondary",
4
- SecondaryBooksAndMore = "secondaryBooksAndMore",
5
- SecondaryLocations = "secondaryLocations",
6
- SecondaryResearch = "secondaryResearch",
7
- SecondaryWhatsOn = "secondaryWhatsOn",
8
- Tertiary = "tertiary",
9
- Campaign = "campaign",
10
- FiftyFifty = "fiftyfifty"
11
- }
12
- export declare const HeroSecondaryTypes: HeroTypes[];
@@ -1,77 +0,0 @@
1
- export declare enum IconAlign {
2
- Left = "left",
3
- Right = "right",
4
- None = "none"
5
- }
6
- export declare enum IconTypes {
7
- Default = "default",
8
- Breadcrumbs = "breadcrumbs"
9
- }
10
- export declare enum IconRotationTypes {
11
- Rotate0 = "rotate0",
12
- Rotate90 = "rotate90",
13
- Rotate180 = "rotate180",
14
- Rotate270 = "rotate270"
15
- }
16
- export declare enum IconColors {
17
- UiBlack = "ui.black",
18
- UiWhite = "ui.white",
19
- BrandPrimary = "brand.primary",
20
- BrandSecondary = "brand.secondary",
21
- SectionBlogsPrimary = "section.blogs.primary",
22
- SectionBlogsSecondary = "section.blogs.secondary",
23
- SectionBooksAndMorePrimary = "section.books-and-more.primary",
24
- SectionBooksAndMoreSecondary = "section.books-and-more.secondary",
25
- SectionEducationPrimary = "section.education.primary",
26
- SectionEducationSecondary = "section.education.secondary",
27
- SectionLocationsPrimary = "section.locations.primary",
28
- SectionLocationsSecondary = "section.locations.secondary",
29
- SectionResearchPrimary = "section.research.primary",
30
- SectionResearchSecondary = "section.research.secondary",
31
- SectionResearchLibraryLpa = "section.research-library.lpa",
32
- SectionResearchLibrarySchomburg = "section.research-library.schomburg",
33
- SectionResearchLibrarySchwartzman = "section.research-library.schwartzman",
34
- SectionWhatsOnPrimary = "section.whats-on.primary",
35
- SectionWhatsOnSecondary = "section.whats-on.secondary"
36
- }
37
- export declare enum IconSizes {
38
- Default = "default",
39
- Small = "small",
40
- Medium = "medium",
41
- Large = "large",
42
- ExtraLarge = "xlarge",
43
- ExtraExtraLarge = "xxlarge",
44
- ExtraExtraExtraLarge = "xxxlarge"
45
- }
46
- export declare enum IconNames {
47
- AccessibilityFull = "accessibility_full",
48
- AccessibilityPartial = "accessibility_partial",
49
- ActionCheckCircle = "action_check_circle",
50
- ActionHelpDefault = "action_help_default",
51
- ActionHelpOutline = "action_help_outline",
52
- AlertNotificationImportant = "alert_notification_important",
53
- ActionLaunch = "action_launch",
54
- Arrow = "arrow",
55
- Check = "check",
56
- Clock = "clock",
57
- Close = "close",
58
- Download = "download",
59
- ErrorFilled = "error_filled",
60
- ErrorOutline = "error_outline",
61
- FileTypeAudio = "file_type_audio",
62
- FileTypeDoc = "file_type_doc",
63
- FileTypeGenericDoc = "file_type_generic_doc",
64
- FileTypeImage = "file_type_image",
65
- FileTypePdf = "file_type_pdf",
66
- FileTypeSpreadsheet = "file_type_spreadsheet",
67
- FileTypeVideo = "file_type_video",
68
- Headset = "headset",
69
- Minus = "minus",
70
- Plus = "plus",
71
- Search = "search",
72
- SpeakerNotes = "speaker_notes",
73
- UtilityAccountFilled = "utility_account_filled",
74
- UtilityAccountUnfilled = "utility_account_unfilled",
75
- UtilityHamburger = "utility_hamburger",
76
- UtilitySearch = "utility_search"
77
- }
@@ -1,22 +0,0 @@
1
- export declare enum ImageRatios {
2
- FourByThree = "fourByThree",
3
- OneByTwo = "oneByTwo",
4
- Original = "original",
5
- SixteenByNine = "sixteenByNine",
6
- Square = "square",
7
- ThreeByFour = "threeByFour",
8
- ThreeByTwo = "threeByTwo",
9
- TwoByOne = "twoByOne"
10
- }
11
- export declare enum ImageSizes {
12
- Default = "default",
13
- ExtraExtraSmall = "xxsmall",
14
- ExtraSmall = "xsmall",
15
- Small = "small",
16
- Medium = "medium",
17
- Large = "large"
18
- }
19
- export declare enum ImageTypes {
20
- Default = "default",
21
- Circle = "circle"
22
- }
@@ -1,8 +0,0 @@
1
- export declare enum LinkTypes {
2
- Action = "action",
3
- Backwards = "backwards",
4
- Button = "button",
5
- Default = "default",
6
- External = "external",
7
- Forwards = "forwards"
8
- }
@@ -1,5 +0,0 @@
1
- export declare enum ListTypes {
2
- Ordered = "ol",
3
- Unordered = "ul",
4
- Description = "dl"
5
- }