@nypl/design-system-react-components 0.25.8 → 0.25.9

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 (250) hide show
  1. package/CHANGELOG.md +45 -1
  2. package/README.md +1 -1
  3. package/dist/components/Button/Button.d.ts +6 -6
  4. package/dist/components/Button/ButtonTypes.d.ts +0 -1
  5. package/dist/components/Card/Card.d.ts +6 -4
  6. package/dist/components/Checkbox/Checkbox.d.ts +3 -2
  7. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +3 -2
  8. package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +8 -2
  9. package/dist/components/DatePicker/DatePicker.d.ts +3 -2
  10. package/dist/components/Form/Form.d.ts +2 -2
  11. package/dist/components/Heading/Heading.d.ts +7 -3
  12. package/dist/components/Heading/HeadingTypes.d.ts +6 -6
  13. package/dist/components/HelperErrorText/HelperErrorText.d.ts +5 -2
  14. package/dist/components/HorizontalRule/HorizontalRule.d.ts +2 -2
  15. package/dist/components/Icons/Icon.d.ts +4 -4
  16. package/dist/components/Icons/IconSvgs.d.ts +0 -21
  17. package/dist/components/Icons/IconTypes.d.ts +0 -23
  18. package/dist/components/Image/Image.d.ts +11 -3
  19. package/dist/components/Logo/Logo.d.ts +28 -0
  20. package/dist/components/Logo/LogoSvgs.d.ts +18 -0
  21. package/dist/components/Logo/LogoTypes.d.ts +30 -0
  22. package/dist/components/Modal/Modal.d.ts +0 -4
  23. package/dist/components/Notification/Notification.d.ts +2 -2
  24. package/dist/components/Placeholder/Placeholder.d.ts +3 -5
  25. package/dist/components/Radio/Radio.d.ts +6 -5
  26. package/dist/components/RadioGroup/RadioGroup.d.ts +3 -2
  27. package/dist/components/SearchBar/SearchBar.d.ts +10 -2
  28. package/dist/components/Select/Select.d.ts +3 -2
  29. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +8 -4
  30. package/dist/components/Slider/Slider.d.ts +3 -2
  31. package/dist/components/StatusBadge/StatusBadge.d.ts +2 -1
  32. package/dist/components/StructuredContent/StructuredContent.d.ts +41 -0
  33. package/dist/components/StructuredContent/StructuredContentTypes.d.ts +5 -0
  34. package/dist/components/Table/Table.d.ts +23 -0
  35. package/dist/components/Template/Template.d.ts +8 -3
  36. package/dist/components/Text/Text.d.ts +2 -2
  37. package/dist/components/TextInput/TextInput.d.ts +4 -3
  38. package/dist/components/Toggle/Toggle.d.ts +3 -2
  39. package/dist/components/VideoPlayer/VideoPlayer.d.ts +14 -5
  40. package/dist/design-system-react-components.cjs.development.js +5630 -5692
  41. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  42. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  43. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  44. package/dist/design-system-react-components.esm.js +4304 -4362
  45. package/dist/design-system-react-components.esm.js.map +1 -1
  46. package/dist/index.d.ts +6 -4
  47. package/dist/styles.css +2 -2
  48. package/dist/theme/components/button.d.ts +0 -12
  49. package/dist/theme/components/card.d.ts +14 -2
  50. package/dist/theme/components/customTable.d.ts +47 -0
  51. package/dist/theme/components/fieldset.d.ts +2 -2
  52. package/dist/theme/components/global.d.ts +1 -1
  53. package/dist/theme/components/heading.d.ts +4 -0
  54. package/dist/theme/components/label.d.ts +1 -1
  55. package/dist/theme/components/link.d.ts +14 -1
  56. package/dist/theme/components/list.d.ts +0 -2
  57. package/dist/theme/components/logo.d.ts +4 -0
  58. package/dist/theme/components/searchBar.d.ts +7 -13
  59. package/dist/theme/components/select.d.ts +1 -0
  60. package/dist/theme/components/structuredContent.d.ts +33 -0
  61. package/dist/theme/components/template.d.ts +10 -10
  62. package/dist/theme/components/textInput.d.ts +2 -0
  63. package/dist/theme/components/toggle.d.ts +8 -5
  64. package/dist/utils/utils.d.ts +10 -0
  65. package/package.json +1 -2
  66. package/src/__tests__/utils/utils.test.ts +23 -1
  67. package/src/components/Accordion/Accordion.stories.mdx +14 -12
  68. package/src/components/Autosuggest/Autosuggest.stories.mdx +2 -1
  69. package/src/components/Autosuggest/Autosuggest.stories.tsx +24 -48
  70. package/src/components/Autosuggest/_Autosuggest.scss +2 -6
  71. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +30 -11
  72. package/src/components/Button/Button.stories.mdx +93 -48
  73. package/src/components/Button/Button.test.tsx +0 -12
  74. package/src/components/Button/Button.tsx +7 -7
  75. package/src/components/Button/ButtonTypes.tsx +0 -1
  76. package/src/components/Button/__snapshots__/Button.test.tsx.snap +0 -12
  77. package/src/components/Card/Card.stories.mdx +186 -71
  78. package/src/components/Card/Card.test.tsx +45 -22
  79. package/src/components/Card/Card.tsx +17 -5
  80. package/src/components/Card/__snapshots__/Card.test.tsx.snap +8 -2
  81. package/src/components/Chakra/Box.stories.mdx +3 -3
  82. package/src/components/Chakra/Center.stories.mdx +5 -5
  83. package/src/components/Chakra/Grid.stories.mdx +3 -3
  84. package/src/components/Chakra/Stack.stories.mdx +2 -2
  85. package/src/components/Checkbox/Checkbox.stories.mdx +37 -15
  86. package/src/components/Checkbox/Checkbox.tsx +13 -8
  87. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +48 -16
  88. package/src/components/CheckboxGroup/CheckboxGroup.tsx +14 -10
  89. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +6 -3
  90. package/src/components/ComponentWrapper/ComponentWrapper.test.tsx +151 -0
  91. package/src/components/ComponentWrapper/ComponentWrapper.tsx +36 -23
  92. package/src/components/ComponentWrapper/__snapshots__/ComponentWrapper.test.tsx.snap +85 -0
  93. package/src/components/DatePicker/DatePicker.stories.mdx +63 -18
  94. package/src/components/DatePicker/DatePicker.tsx +10 -6
  95. package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +36 -18
  96. package/src/components/Fieldset/Fieldset.stories.mdx +19 -8
  97. package/src/components/Form/Form.stories.mdx +49 -41
  98. package/src/components/Form/Form.tsx +5 -4
  99. package/src/components/Grid/SimpleGrid.stories.mdx +26 -26
  100. package/src/components/Heading/Heading.stories.mdx +59 -23
  101. package/src/components/Heading/Heading.test.tsx +82 -18
  102. package/src/components/Heading/Heading.tsx +31 -31
  103. package/src/components/Heading/HeadingTypes.tsx +6 -6
  104. package/src/components/Heading/__snapshots__/Heading.test.tsx.snap +71 -0
  105. package/src/components/HelperErrorText/HelperErrorText.stories.mdx +55 -27
  106. package/src/components/HelperErrorText/HelperErrorText.test.tsx +42 -15
  107. package/src/components/HelperErrorText/HelperErrorText.tsx +24 -24
  108. package/src/components/HelperErrorText/__snapshots__/HelperErrorText.test.tsx.snap +41 -4
  109. package/src/components/Hero/Hero.stories.mdx +72 -53
  110. package/src/components/HorizontalRule/HorizontalRule.stories.mdx +9 -8
  111. package/src/components/HorizontalRule/HorizontalRule.tsx +2 -4
  112. package/src/components/Icons/Icon.stories.mdx +77 -76
  113. package/src/components/Icons/Icon.tsx +4 -5
  114. package/src/components/Icons/IconSvgs.tsx +0 -42
  115. package/src/components/Icons/IconTypes.tsx +0 -24
  116. package/src/components/Image/Image.stories.mdx +66 -18
  117. package/src/components/Image/Image.tsx +21 -10
  118. package/src/components/Label/Label.stories.mdx +20 -19
  119. package/src/components/Link/Link.stories.mdx +102 -51
  120. package/src/components/Link/Link.test.tsx +38 -8
  121. package/src/components/Link/Link.tsx +19 -12
  122. package/src/components/Link/__snapshots__/Link.test.tsx.snap +60 -0
  123. package/src/components/List/List.stories.mdx +36 -24
  124. package/src/components/Logo/Logo.stories.mdx +220 -0
  125. package/src/components/Logo/Logo.test.tsx +98 -0
  126. package/src/components/Logo/Logo.tsx +97 -0
  127. package/src/components/Logo/LogoSvgs.tsx +34 -0
  128. package/src/components/Logo/LogoTypes.tsx +32 -0
  129. package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +71 -0
  130. package/src/components/Modal/Modal.stories.mdx +20 -5
  131. package/src/components/Modal/Modal.tsx +2 -8
  132. package/src/components/Notification/Notification.stories.mdx +61 -38
  133. package/src/components/Notification/Notification.tsx +9 -4
  134. package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +4 -0
  135. package/src/components/Pagination/Pagination.stories.mdx +17 -6
  136. package/src/components/Pagination/Pagination.tsx +1 -1
  137. package/src/components/Placeholder/Placeholder.tsx +7 -14
  138. package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +72 -43
  139. package/src/components/Radio/Radio.stories.mdx +39 -19
  140. package/src/components/Radio/Radio.tsx +13 -9
  141. package/src/components/RadioGroup/RadioGroup.stories.mdx +50 -16
  142. package/src/components/RadioGroup/RadioGroup.tsx +15 -11
  143. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +6 -3
  144. package/src/components/SearchBar/SearchBar.Test.tsx +58 -10
  145. package/src/components/SearchBar/SearchBar.stories.mdx +109 -30
  146. package/src/components/SearchBar/SearchBar.tsx +53 -32
  147. package/src/components/Select/Select.stories.mdx +48 -14
  148. package/src/components/Select/Select.tsx +16 -10
  149. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +50 -16
  150. package/src/components/SkeletonLoader/SkeletonLoader.tsx +8 -4
  151. package/src/components/Slider/Slider.stories.mdx +72 -22
  152. package/src/components/Slider/Slider.tsx +15 -10
  153. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +60 -30
  154. package/src/components/StatusBadge/StatusBadge.stories.mdx +33 -18
  155. package/src/components/StatusBadge/StatusBadge.tsx +2 -1
  156. package/src/components/StructuredContent/StructuredContent.stories.mdx +427 -0
  157. package/src/components/StructuredContent/StructuredContent.test.tsx +376 -0
  158. package/src/components/StructuredContent/StructuredContent.tsx +153 -0
  159. package/src/components/StructuredContent/StructuredContentTypes.tsx +5 -0
  160. package/src/components/StructuredContent/__snapshots__/StructuredContent.test.tsx.snap +283 -0
  161. package/src/components/StyleGuide/Bidirectionality.stories.mdx +32 -83
  162. package/src/components/StyleGuide/Breakpoints.stories.mdx +1 -11
  163. package/src/components/StyleGuide/Buttons.stories.mdx +3 -18
  164. package/src/components/StyleGuide/ColorCard.tsx +1 -2
  165. package/src/components/StyleGuide/Colors.stories.mdx +3 -11
  166. package/src/components/StyleGuide/DesignTokens.stories.mdx +3 -8
  167. package/src/components/StyleGuide/Forms.stories.mdx +2 -10
  168. package/src/components/StyleGuide/Iconography.stories.mdx +8 -34
  169. package/src/components/StyleGuide/Spacing.stories.mdx +3 -14
  170. package/src/components/StyleGuide/Typography.stories.mdx +64 -76
  171. package/src/components/Table/Table.stories.mdx +66 -0
  172. package/src/components/Table/Table.test.tsx +60 -0
  173. package/src/components/Table/Table.tsx +116 -0
  174. package/src/components/Tabs/Tabs.stories.mdx +19 -13
  175. package/src/components/Tabs/Tabs.test.tsx +1 -1
  176. package/src/components/Template/Template.stories.mdx +56 -47
  177. package/src/components/Template/Template.test.tsx +65 -5
  178. package/src/components/Template/Template.tsx +35 -5
  179. package/src/components/Template/__snapshots__/Template.test.tsx.snap +76 -0
  180. package/src/components/Text/Text.stories.mdx +33 -11
  181. package/src/components/Text/Text.tsx +2 -2
  182. package/src/components/TextInput/TextInput.stories.mdx +84 -17
  183. package/src/components/TextInput/TextInput.test.tsx +96 -0
  184. package/src/components/TextInput/TextInput.tsx +12 -8
  185. package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +240 -0
  186. package/src/components/Toggle/Toggle.stories.mdx +33 -9
  187. package/src/components/Toggle/Toggle.tsx +14 -9
  188. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +64 -14
  189. package/src/components/VideoPlayer/VideoPlayer.tsx +17 -7
  190. package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +12 -6
  191. package/src/docs/Chakra.stories.mdx +5 -8
  192. package/src/docs/Intro.stories.mdx +2 -2
  193. package/src/index.ts +5 -4
  194. package/src/styles/base/_03-base.scss +1 -1
  195. package/src/styles/base/_place-holder.scss +7 -7
  196. package/src/styles.scss +1 -5
  197. package/src/theme/components/breadcrumb.ts +3 -3
  198. package/src/theme/components/button.ts +5 -12
  199. package/src/theme/components/card.ts +5 -2
  200. package/src/theme/components/checkbox.ts +1 -1
  201. package/src/theme/components/customTable.ts +50 -0
  202. package/src/theme/components/datePicker.ts +1 -1
  203. package/src/theme/components/global.ts +6 -6
  204. package/src/theme/components/heading.ts +13 -11
  205. package/src/theme/components/helperErrorText.ts +1 -1
  206. package/src/theme/components/image.ts +1 -1
  207. package/src/theme/components/link.ts +17 -5
  208. package/src/theme/components/list.ts +1 -3
  209. package/src/theme/components/logo.ts +54 -0
  210. package/src/theme/components/notification.ts +1 -1
  211. package/src/theme/components/searchBar.ts +7 -13
  212. package/src/theme/components/select.ts +1 -0
  213. package/src/theme/components/statusBadge.ts +1 -1
  214. package/src/theme/components/structuredContent.ts +54 -0
  215. package/src/theme/components/template.ts +10 -10
  216. package/src/theme/components/text.ts +6 -6
  217. package/src/theme/components/textInput.ts +1 -0
  218. package/src/theme/components/toggle.ts +9 -5
  219. package/src/theme/components/videoPlayer.ts +0 -2
  220. package/src/theme/foundations/global.ts +2 -2
  221. package/src/theme/foundations/typography.ts +84 -12
  222. package/src/theme/index.ts +6 -0
  223. package/src/utils/componentCategories.ts +1 -1
  224. package/src/utils/utils.ts +17 -0
  225. package/dist/__tests__/utils/bem.test.d.ts +0 -1
  226. package/dist/components/CardEdition/CardEdition.d.ts +0 -21
  227. package/dist/components/CardEdition/CardEdition.stories.d.ts +0 -27
  228. package/dist/components/Input/Input.d.ts +0 -36
  229. package/dist/components/Input/Input.stories.d.ts +0 -29
  230. package/dist/components/Input/InputTypes.d.ts +0 -6
  231. package/dist/components/StyleGuide/UIDocCard.d.ts +0 -11
  232. package/dist/helpers/CSSVariablesHelper.d.ts +0 -3
  233. package/dist/helpers/getCSSVariable.d.ts +0 -1
  234. package/dist/interfaces.d.ts +0 -3
  235. package/dist/utils/bem.d.ts +0 -1
  236. package/src/__tests__/utils/bem.test.ts +0 -37
  237. package/src/components/CardEdition/CardEdition.stories.tsx +0 -122
  238. package/src/components/CardEdition/CardEdition.test.tsx +0 -395
  239. package/src/components/CardEdition/CardEdition.tsx +0 -60
  240. package/src/components/CardEdition/_CardEdition.scss +0 -137
  241. package/src/components/Input/Input.stories.tsx +0 -133
  242. package/src/components/Input/Input.test.tsx +0 -266
  243. package/src/components/Input/Input.tsx +0 -81
  244. package/src/components/Input/InputTypes.tsx +0 -8
  245. package/src/components/Input/_Input.scss +0 -78
  246. package/src/components/StyleGuide/UIDocCard.tsx +0 -36
  247. package/src/helpers/CSSVariablesHelper.tsx +0 -34
  248. package/src/helpers/getCSSVariable.tsx +0 -5
  249. package/src/interfaces.ts +0 -3
  250. package/src/utils/bem.ts +0 -44
@@ -1,10 +1,10 @@
1
1
  import {
2
- Meta,
3
- Story,
4
- Canvas,
5
2
  ArgsTable,
3
+ Canvas,
6
4
  Description,
7
- } from "@storybook/addon-docs/blocks";
5
+ Meta,
6
+ Story,
7
+ } from "@storybook/addon-docs";
8
8
  import { withDesign } from "storybook-addon-designs";
9
9
 
10
10
  import { Tabs, TabList, Tab, TabPanels, TabPanel } from "./Tabs";
@@ -18,17 +18,21 @@ import DSProvider from "../../theme/provider";
18
18
  parameters={{
19
19
  design: {
20
20
  type: "figma",
21
- url:
22
- "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Main?node-id=36835%3A26464",
21
+ url: "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Main?node-id=36835%3A26464",
23
22
  },
24
23
  jest: ["Tabs.test.tsx"],
25
24
  }}
26
25
  argTypes={{
27
26
  children: { table: { disable: true } },
28
- id: { table: { disable: true } },
29
- className: { table: { disable: true } },
30
- data: { table: { disable: true } },
31
- onChange: { table: { disable: true } },
27
+ contentData: { control: false },
28
+ defaultIndex: {
29
+ table: { defaultValue: { summary: 0 } },
30
+ },
31
+ id: { control: false },
32
+ onChange: { control: false },
33
+ useHash: {
34
+ table: { defaultValue: { summary: false } },
35
+ },
32
36
  }}
33
37
  />
34
38
 
@@ -89,18 +93,20 @@ export const animalCrossing = [
89
93
 
90
94
  <Canvas withToolbar>
91
95
  <Story
92
- name="Basic with props"
96
+ name="Tabs with Controls"
93
97
  args={{
98
+ contentData: animalCrossing,
94
99
  defaultIndex: 0,
100
+ id: "tabs-id",
101
+ onChange: undefined,
95
102
  useHash: false,
96
- contentData: animalCrossing,
97
103
  }}
98
104
  >
99
105
  {(args) => <Tabs {...args} />}
100
106
  </Story>
101
107
  </Canvas>
102
108
 
103
- <ArgsTable story="Basic with props" />
109
+ <ArgsTable story="Tabs with Controls" />
104
110
 
105
111
  ## Composing with a Data Object
106
112
 
@@ -208,7 +208,7 @@ describe("Tabs", () => {
208
208
  expect(selectedIndex).toEqual(1);
209
209
  });
210
210
 
211
- it("should throw warning when both the 'data' probp and children are passed", () => {
211
+ it("should throw warning when both the 'data' prop and children are passed", () => {
212
212
  const warn = jest.spyOn(console, "warn");
213
213
  render(
214
214
  <Tabs contentData={animalCrossing}>
@@ -1,12 +1,32 @@
1
1
  import {
2
- Meta,
3
- Story,
4
- Canvas,
5
2
  ArgsTable,
3
+ Canvas,
6
4
  Description,
7
- } from "@storybook/addon-docs/blocks";
5
+ Meta,
6
+ Story,
7
+ } from "@storybook/addon-docs";
8
8
  import { withDesign } from "storybook-addon-designs";
9
9
 
10
+ import Accordion from "../Accordion/Accordion";
11
+ import { faqContent } from "../Accordion/Accordion.stories.mdx";
12
+ import Breadcrumbs from "../Breadcrumbs/Breadcrumbs";
13
+ import Button from "../Button/Button";
14
+ import Card, { CardHeading, CardContent, CardActions } from "../Card/Card";
15
+ import Form, { FormRow, FormField } from "../Form/Form";
16
+ import Heading from "../Heading/Heading";
17
+ import { HeadingLevels } from "../Heading/HeadingTypes";
18
+ import Hero from "../Hero/Hero";
19
+ import HorizontalRule from "../HorizontalRule/HorizontalRule";
20
+ import { HeroTypes } from "../Hero/HeroTypes";
21
+ import Image from "../Image/Image";
22
+ import { ImageRatios, ImageSizes } from "../Image/ImageTypes";
23
+ import Link from "../Link/Link";
24
+ import Notification, {
25
+ NotificationContent,
26
+ NotificationHeading,
27
+ NotificationProps,
28
+ } from "../Notification/Notification";
29
+ import Placeholder from "../Placeholder/Placeholder";
10
30
  import {
11
31
  Template,
12
32
  TemplateHeader,
@@ -18,27 +38,7 @@ import {
18
38
  TemplateFooter,
19
39
  TemplateAppContainer,
20
40
  } from "./Template";
21
- import Placeholder from "../Placeholder/Placeholder";
22
- import Hero from "../Hero/Hero";
23
- import { HeroTypes } from "../Hero/HeroTypes";
24
- import Image from "../Image/Image";
25
- import { ImageRatios, ImageSizes } from "../Image/ImageTypes";
26
- import Breadcrumbs from "../Breadcrumbs/Breadcrumbs";
27
- import HorizontalRule from "../HorizontalRule/HorizontalRule";
28
- import Heading from "../Heading/Heading";
29
- import { HeadingLevels } from "../Heading/HeadingTypes";
30
- import Notification, {
31
- NotificationContent,
32
- NotificationHeading,
33
- NotificationProps,
34
- } from "../Notification/Notification";
35
- import Form, { FormRow, FormField } from "../Form/Form";
36
41
  import TextInput from "../TextInput/TextInput";
37
- import Button from "../Button/Button";
38
- import Link from "../Link/Link";
39
- import Card, { CardHeading, CardContent, CardActions } from "../Card/Card";
40
- import Accordion from "../Accordion/Accordion";
41
- import { faqContent } from "../Accordion/Accordion.stories.mdx";
42
42
  import { NotificationTypes } from "../Notification/NotificationTypes";
43
43
  import { getCategory } from "../../utils/componentCategories";
44
44
 
@@ -59,23 +59,26 @@ import { getCategory } from "../../utils/componentCategories";
59
59
  | Component Version | DS Version |
60
60
  | ----------------- | ---------- |
61
61
  | Added | `0.3.6` |
62
- | Latest | `0.25.1` |
62
+ | Latest | `0.25.9` |
63
63
 
64
64
  ## TemplateAppContainer Component
65
65
 
66
66
  <Description of={TemplateAppContainer} />
67
67
 
68
+ If you have a custom `Footer` component that _already_ renders an HTML `<footer>`
69
+ element, set `renderFooterElement` to false so only one `<footer>` element is rendered.
70
+
68
71
  <b>This is the recommended way to render an app page template.</b>
69
72
 
70
73
  ```jsx
71
74
  import { TemplateAppContainer } from "@nypl/design-system-react-components";
72
75
 
73
76
  <TemplateAppContainer
74
- header={<Placeholder modifiers={["short"]}>NYPL Header</Placeholder>}
77
+ header={<Placeholder variant="short">NYPL Header</Placeholder>}
75
78
  breakout={
76
79
  <>
77
- <Placeholder modifiers={["short"]}>Breadcrumbs</Placeholder>
78
- <Placeholder modifiers={["short"]}>Hero</Placeholder>
80
+ <Placeholder variant="short">Breadcrumbs</Placeholder>
81
+ <Placeholder variant="short">Hero</Placeholder>
79
82
  </>
80
83
  }
81
84
  sidebar="left"
@@ -84,10 +87,10 @@ import { TemplateAppContainer } from "@nypl/design-system-react-components";
84
87
  contentPrimary={
85
88
  <>
86
89
  <Placeholder>Main Content</Placeholder>
87
- <Placeholder modifiers={["short"]}>More Content</Placeholder>
90
+ <Placeholder variant="short">More Content</Placeholder>
88
91
  </>
89
92
  }
90
- footer={<Placeholder modifiers={["short"]}>Footer</Placeholder>}
93
+ footer={<Placeholder variant="short">Footer</Placeholder>}
91
94
  />;
92
95
  ```
93
96
 
@@ -95,31 +98,36 @@ import { TemplateAppContainer } from "@nypl/design-system-react-components";
95
98
  <Story
96
99
  name="TemplateAppContainer Component"
97
100
  args={{
98
- header: <Placeholder modifiers={["short"]}>NYPL Header</Placeholder>,
99
101
  breakout: (
100
102
  <>
101
- <Placeholder modifiers={["short"]}>Breadcrumbs</Placeholder>
102
- <Placeholder modifiers={["short"]}>Hero</Placeholder>
103
+ <Placeholder variant="short">Breadcrumbs</Placeholder>
104
+ <Placeholder variant="short">Hero</Placeholder>
103
105
  </>
104
106
  ),
105
- sidebar: "left",
106
- contentTop: <Placeholder>Content Top</Placeholder>,
107
- contentSidebar: <Placeholder>Left Sidebar</Placeholder>,
108
107
  contentPrimary: (
109
108
  <>
110
109
  <Placeholder>Main Content</Placeholder>
111
- <Placeholder modifiers={["short"]}>More Content</Placeholder>
110
+ <Placeholder variant="short">More Content</Placeholder>
112
111
  </>
113
112
  ),
114
- footer: <Placeholder modifiers={["short"]}>Footer</Placeholder>,
113
+ contentSidebar: <Placeholder>Left Sidebar</Placeholder>,
114
+ contentTop: <Placeholder>Content Top</Placeholder>,
115
+ footer: <Placeholder variant="short">Footer</Placeholder>,
116
+ header: <Placeholder variant="short">NYPL Header</Placeholder>,
117
+ sidebar: "left",
118
+ renderFooterElement: true,
115
119
  }}
116
120
  argTypes={{
117
- header: { control: false },
118
121
  breakout: { control: false },
119
- contentTop: { control: false },
120
- contentSidebar: { control: false },
121
122
  contentPrimary: { control: false },
123
+ contentSidebar: { control: false },
124
+ contentTop: { control: false },
122
125
  footer: { control: false },
126
+ header: { control: false },
127
+ sidebar: {
128
+ control: false,
129
+ table: { defaultValue: { summary: "none" } },
130
+ },
123
131
  }}
124
132
  >
125
133
  {(args) => <TemplateAppContainer {...args} />}
@@ -159,7 +167,7 @@ import {
159
167
  </TemplateBreakout>
160
168
  </TemplateHeader>
161
169
 
162
- <TemplateContent>
170
+ <TemplateContent sidebar="...">
163
171
  <TemplateContentTop>
164
172
  // ...
165
173
  </TemplateContentTop>
@@ -188,15 +196,16 @@ import {
188
196
  contentTop: { table: { disable: true } },
189
197
  footer: { table: { disable: true } },
190
198
  header: { table: { disable: true } },
199
+ sidebar: { description: "Only used in Storybook." },
191
200
  }}
192
201
  >
193
202
  {(args) => (
194
203
  <Template>
195
204
  <TemplateHeader>
196
- <Placeholder modifiers={["short"]}>NYPL Header</Placeholder>
205
+ <Placeholder variant="short">NYPL Header</Placeholder>
197
206
  <TemplateBreakout>
198
- <Placeholder modifiers={["short"]}>Breadcrumbs</Placeholder>
199
- <Placeholder modifiers={["short"]}>Hero</Placeholder>
207
+ <Placeholder variant="short">Breadcrumbs</Placeholder>
208
+ <Placeholder variant="short">Hero</Placeholder>
200
209
  </TemplateBreakout>
201
210
  </TemplateHeader>
202
211
  <TemplateContent sidebar={args.sidebar}>
@@ -210,7 +219,7 @@ import {
210
219
  )}
211
220
  <TemplateContentPrimary>
212
221
  <Placeholder>Main Content</Placeholder>
213
- <Placeholder modifiers={["short"]}>More Content</Placeholder>
222
+ <Placeholder variant="short">More Content</Placeholder>
214
223
  </TemplateContentPrimary>
215
224
  {args.sidebar === "right" && (
216
225
  <TemplateContentSidebar>
@@ -219,7 +228,7 @@ import {
219
228
  )}
220
229
  </TemplateContent>
221
230
  <TemplateFooter>
222
- <Placeholder modifiers={["short"]}>Footer</Placeholder>
231
+ <Placeholder variant="short">Footer</Placeholder>
223
232
  </TemplateFooter>
224
233
  </Template>
225
234
  )}
@@ -1,6 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { render, screen } from "@testing-library/react";
3
3
  import { axe } from "jest-axe";
4
+ import renderer from "react-test-renderer";
4
5
 
5
6
  import {
6
7
  Template,
@@ -15,11 +16,11 @@ import {
15
16
  } from "./Template";
16
17
  import Placeholder from "../Placeholder/Placeholder";
17
18
 
18
- const header = <Placeholder modifiers={["short"]}>NYPL Header</Placeholder>;
19
+ const header = <Placeholder variant="short">NYPL Header</Placeholder>;
19
20
  const breakout = (
20
21
  <>
21
- <Placeholder modifiers={["short"]}>Breadcrumbs</Placeholder>
22
- <Placeholder modifiers={["short"]}>Hero</Placeholder>
22
+ <Placeholder variant="short">Breadcrumbs</Placeholder>
23
+ <Placeholder variant="short">Hero</Placeholder>
23
24
  </>
24
25
  );
25
26
  const sidebar = "left";
@@ -28,10 +29,10 @@ const contentSidebar = <Placeholder>Left Sidebar</Placeholder>;
28
29
  const contentPrimary = (
29
30
  <>
30
31
  <Placeholder>Main Content</Placeholder>
31
- <Placeholder modifiers={["short"]}>More Content</Placeholder>
32
+ <Placeholder variant="short">More Content</Placeholder>
32
33
  </>
33
34
  );
34
- const footer = <Placeholder modifiers={["short"]}>Footer</Placeholder>;
35
+ const footer = <Placeholder variant="short">Footer</Placeholder>;
35
36
 
36
37
  describe("TemplateAppContainer accessibility", () => {
37
38
  it("passes axe accessibility test", async () => {
@@ -93,6 +94,44 @@ describe("TemplateAppContainer component", () => {
93
94
  expect(screen.getByText("More Content")).toBeInTheDocument();
94
95
  expect(screen.getByText("Footer")).toBeInTheDocument();
95
96
  });
97
+
98
+ it("renders only one footer in a custom footer component", () => {
99
+ const customFooter = <footer>Custom Footer</footer>;
100
+ render(
101
+ <TemplateAppContainer
102
+ header={header}
103
+ breakout={breakout}
104
+ sidebar={sidebar}
105
+ contentTop={contentTop}
106
+ contentSidebar={contentSidebar}
107
+ contentPrimary={contentPrimary}
108
+ footer={customFooter}
109
+ renderFooterElement={false}
110
+ />
111
+ );
112
+
113
+ expect(screen.getAllByRole("contentinfo")).toHaveLength(1);
114
+ });
115
+
116
+ it("consoles a warning when a footer element was passed without setting `renderFooterElement` to false", () => {
117
+ const warn = jest.spyOn(console, "warn");
118
+ const customFooter = <footer>Custom Footer</footer>;
119
+ render(
120
+ <TemplateAppContainer
121
+ header={header}
122
+ breakout={breakout}
123
+ sidebar={sidebar}
124
+ contentTop={contentTop}
125
+ contentSidebar={contentSidebar}
126
+ contentPrimary={contentPrimary}
127
+ footer={customFooter}
128
+ />
129
+ );
130
+ expect(warn).toHaveBeenCalledWith(
131
+ "`TemplateFooter`: An HTML `footer` element was passed in. Set " +
132
+ "`renderFooterElement` to `false` to avoid nested HTML `footer` elements."
133
+ );
134
+ });
96
135
  });
97
136
 
98
137
  describe("Template components", () => {
@@ -121,4 +160,25 @@ describe("Template components", () => {
121
160
  expect(screen.getByText("More Content")).toBeInTheDocument();
122
161
  expect(screen.getByText("Footer")).toBeInTheDocument();
123
162
  });
163
+
164
+ it("Renders the UI snapshot correctly", () => {
165
+ const basic = renderer
166
+ .create(
167
+ <Template>
168
+ <TemplateHeader>
169
+ {header}
170
+ <TemplateBreakout>{breakout}</TemplateBreakout>
171
+ </TemplateHeader>
172
+ <TemplateContent sidebar={sidebar}>
173
+ <TemplateContentTop>{contentTop}</TemplateContentTop>
174
+ <TemplateContentSidebar>{contentSidebar}</TemplateContentSidebar>
175
+ <TemplateContentPrimary>{contentPrimary}</TemplateContentPrimary>
176
+ </TemplateContent>
177
+ <TemplateFooter>{footer}</TemplateFooter>
178
+ </Template>
179
+ )
180
+ .toJSON();
181
+
182
+ expect(basic).toMatchSnapshot();
183
+ });
124
184
  });
@@ -2,13 +2,19 @@ import * as React from "react";
2
2
  import { Box, useStyleConfig } from "@chakra-ui/react";
3
3
 
4
4
  export interface TemplateProps {}
5
+ export interface TemplateFooterProps {
6
+ /** Flag to render an HTML footer element. True by default. */
7
+ renderFooterElement?: boolean;
8
+ }
5
9
  export interface TemplateSidebarProps {
6
10
  /** Renders the `TemplateContentSidebar` component either on the left or
7
11
  * right side of the `TemplateContentPrimary` component. */
8
12
  sidebar?: "none" | "left" | "right";
9
13
  }
10
14
  export interface TemplateContentProps extends TemplateSidebarProps {}
11
- export interface TemplateAppContainerProps extends TemplateSidebarProps {
15
+ export interface TemplateAppContainerProps
16
+ extends TemplateFooterProps,
17
+ TemplateSidebarProps {
12
18
  /** DOM that will be rendered in the `TemplateBreakout` component section. */
13
19
  breakout?: React.ReactElement;
14
20
  /** DOM that will be rendered in the `TemplateContentPrimary` component section. */
@@ -152,10 +158,29 @@ const TemplateContentSidebar = (
152
158
  /**
153
159
  * This optional component should be the last child of the `Template`
154
160
  * component. This is rendered as an HTML `<footer>` element and spans the full
155
- * width of the page.
161
+ * width of the page. If an HTML `<footer>` element is already passed in a
162
+ * custom component, set `renderFooterElement` to `false`.
156
163
  */
157
- const TemplateFooter = (props: React.PropsWithChildren<TemplateProps>) => {
158
- return <Box as="footer">{props.children}</Box>;
164
+ const TemplateFooter = ({
165
+ children,
166
+ renderFooterElement = true,
167
+ }: React.PropsWithChildren<TemplateFooterProps>) => {
168
+ let footerElement = <>{children}</>;
169
+
170
+ // The user wants to render the `footer` HTML element.
171
+ if (renderFooterElement) {
172
+ // But give a warning if one was passed.
173
+ React.Children.map(children, (child: React.ReactElement) => {
174
+ if (child?.type === "footer" || child?.props?.mdxType === "footer") {
175
+ console.warn(
176
+ "`TemplateFooter`: An HTML `footer` element was passed in. Set " +
177
+ "`renderFooterElement` to `false` to avoid nested HTML `footer` elements."
178
+ );
179
+ }
180
+ });
181
+ footerElement = <Box as="footer">{children}</Box>;
182
+ }
183
+ return footerElement;
159
184
  };
160
185
 
161
186
  /**
@@ -176,6 +201,7 @@ const TemplateAppContainer = (
176
201
  footer,
177
202
  header,
178
203
  sidebar = "none",
204
+ renderFooterElement = true,
179
205
  } = props;
180
206
  const breakoutElem = breakout && (
181
207
  <TemplateBreakout>{breakout}</TemplateBreakout>
@@ -208,7 +234,11 @@ const TemplateAppContainer = (
208
234
 
209
235
  {sidebar === "right" && contentSidebarElem}
210
236
  </TemplateContent>
211
- {footer && <TemplateFooter>{footer}</TemplateFooter>}
237
+ {footer && (
238
+ <TemplateFooter renderFooterElement={renderFooterElement}>
239
+ {footer}
240
+ </TemplateFooter>
241
+ )}
212
242
  </Template>
213
243
  );
214
244
  };
@@ -0,0 +1,76 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Template components Renders the UI snapshot correctly 1`] = `
4
+ <div
5
+ className="nypl-ds css-0"
6
+ >
7
+ <header
8
+ className="css-0"
9
+ >
10
+ <div
11
+ className="placeholder placeholder-short"
12
+ >
13
+ NYPL Header
14
+ </div>
15
+ <div
16
+ className="css-0"
17
+ >
18
+ <div
19
+ className="placeholder placeholder-short"
20
+ >
21
+ Breadcrumbs
22
+ </div>
23
+ <div
24
+ className="placeholder placeholder-short"
25
+ >
26
+ Hero
27
+ </div>
28
+ </div>
29
+ </header>
30
+ <main
31
+ className="css-0"
32
+ >
33
+ <div
34
+ className="css-0"
35
+ >
36
+ <div
37
+ className="placeholder placeholder-undefined"
38
+ >
39
+ Content Top
40
+ </div>
41
+ </div>
42
+ <div
43
+ className="css-0"
44
+ >
45
+ <div
46
+ className="placeholder placeholder-undefined"
47
+ >
48
+ Left Sidebar
49
+ </div>
50
+ </div>
51
+ <div
52
+ className="css-0"
53
+ >
54
+ <div
55
+ className="placeholder placeholder-undefined"
56
+ >
57
+ Main Content
58
+ </div>
59
+ <div
60
+ className="placeholder placeholder-short"
61
+ >
62
+ More Content
63
+ </div>
64
+ </div>
65
+ </main>
66
+ <footer
67
+ className="css-0"
68
+ >
69
+ <div
70
+ className="placeholder placeholder-short"
71
+ >
72
+ Footer
73
+ </div>
74
+ </footer>
75
+ </div>
76
+ `;
@@ -1,14 +1,21 @@
1
1
  import {
2
- Meta,
3
- Story,
4
- Canvas,
5
2
  ArgsTable,
3
+ Canvas,
6
4
  Description,
7
- } from "@storybook/addon-docs/blocks";
5
+ Meta,
6
+ Story,
7
+ } from "@storybook/addon-docs";
8
8
  import { withDesign } from "storybook-addon-designs";
9
9
 
10
10
  import Text from "./Text";
11
+ import { TextDisplaySizes } from "./TextTypes";
11
12
  import { getCategory } from "../../utils/componentCategories";
13
+ import { getStorybookEnumValues } from "../../utils/utils";
14
+
15
+ export const enumValues = getStorybookEnumValues(
16
+ TextDisplaySizes,
17
+ "TextDisplaySizes"
18
+ );
12
19
 
13
20
  <Meta
14
21
  title={getCategory("Text")}
@@ -17,13 +24,19 @@ import { getCategory } from "../../utils/componentCategories";
17
24
  parameters={{
18
25
  design: {
19
26
  type: "figma",
20
- url:
21
- "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/?node-id=10733%3A56919",
27
+ url: "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/?node-id=10733%3A56919",
22
28
  },
23
29
  }}
24
30
  argTypes={{
25
- displaySize: { table: { disable: false } },
26
- className: { table: { disable: true } },
31
+ className: { control: false },
32
+ displaySize: {
33
+ control: { type: "select" },
34
+ options: enumValues.options,
35
+ table: { defaultValue: { summary: "TextDisplaySizes.Default" } },
36
+ },
37
+ isBold: { table: { defaultValue: { summary: false } } },
38
+ isItalic: { table: { defaultValue: { summary: false } } },
39
+ noSpace: { table: { defaultValue: { summary: false } } },
27
40
  }}
28
41
  />
29
42
 
@@ -39,10 +52,19 @@ import { getCategory } from "../../utils/componentCategories";
39
52
  The `Text` component renders a basic `<p>` element. As its name indicates, the `displaySize` prop controls the size of the text rendered in the component.
40
53
 
41
54
  <Canvas withToolbar>
42
- <Story name="Text" args={{}}>
55
+ <Story
56
+ name="Text"
57
+ args={{
58
+ className: undefined,
59
+ displaySize: "TextDisplaySizes.Default",
60
+ isBold: false,
61
+ isItalic: false,
62
+ noSpace: false,
63
+ }}
64
+ >
43
65
  {(args) => (
44
66
  <>
45
- <Text {...args}>
67
+ <Text {...args} displaySize={enumValues.getValue(args.displaySize)}>
46
68
  Animal Crossing[a] is a social simulation video game series developed
47
69
  and published by Nintendo. The series was conceptualized and created
48
70
  by Katsuya Eguchi and Hisashi Nogami. In Animal Crossing, the player
@@ -52,7 +74,7 @@ The `Text` component renders a basic `<p>` element. As its name indicates, the `
52
74
  open-ended gameplay and use of the video game console's internal clock
53
75
  and calendar to simulate real passage of time.
54
76
  </Text>
55
- <Text {...args}>
77
+ <Text {...args} displaySize={enumValues.getValue(args.displaySize)}>
56
78
  Since its initial release in 2001, five Animal Crossing games have
57
79
  been released worldwide, one each for the Nintendo 64/iQue Player
58
80
  (enhanced and reissued for the GameCube), Nintendo DS, Wii, Nintendo
@@ -6,14 +6,14 @@ import { getVariant } from "../../utils/utils";
6
6
  export interface TextProps {
7
7
  /** Additional class name to render in the `Text` component. */
8
8
  className?: string;
9
+ /** Optional prop to control the text styling */
10
+ displaySize?: TextDisplaySizes;
9
11
  /** Optional prop used to show bolded text */
10
12
  isBold?: boolean;
11
13
  /** Optional prop used to show itlicized text */
12
14
  isItalic?: boolean;
13
15
  /** Optional prop used to remove default spacing */
14
16
  noSpace?: boolean;
15
- /** Optional prop to control the text styling */
16
- displaySize?: TextDisplaySizes;
17
17
  }
18
18
 
19
19
  function Text(props: React.PropsWithChildren<TextProps>) {