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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (307) hide show
  1. package/CHANGELOG.md +98 -1
  2. package/README.md +46 -11
  3. package/dist/components/Accordion/Accordion.d.ts +14 -14
  4. package/dist/components/Autosuggest/Autosuggest.stories.d.ts +1 -0
  5. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +11 -14
  6. package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +6 -0
  7. package/dist/components/Button/Button.d.ts +6 -13
  8. package/dist/components/Button/ButtonTypes.d.ts +5 -3
  9. package/dist/components/Card/Card.d.ts +59 -10
  10. package/dist/components/Card/CardTypes.d.ts +19 -0
  11. package/dist/components/CardEdition/CardEdition.d.ts +21 -0
  12. package/dist/components/{StyleGuide/Colors.stories.d.ts → CardEdition/CardEdition.stories.d.ts} +5 -2
  13. package/dist/components/Checkbox/Checkbox.d.ts +21 -16
  14. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +43 -0
  15. package/dist/components/CheckboxGroup/CheckboxGroupLayoutTypes.d.ts +4 -0
  16. package/dist/components/DatePicker/DatePicker.d.ts +79 -0
  17. package/dist/components/DatePicker/DatePickerTypes.d.ts +5 -0
  18. package/dist/components/Form/Form.d.ts +16 -8
  19. package/dist/components/Form/FormTypes.d.ts +2 -0
  20. package/dist/components/Grid/GridTypes.d.ts +9 -0
  21. package/dist/components/Grid/SimpleGrid.d.ts +14 -0
  22. package/dist/components/Heading/Heading.d.ts +9 -11
  23. package/dist/components/Heading/{HeadingDisplaySizes.d.ts → HeadingTypes.d.ts} +8 -0
  24. package/dist/components/HelperErrorText/HelperErrorText.stories.d.ts +2 -1
  25. package/dist/components/Hero/Hero.d.ts +19 -14
  26. package/dist/components/Hero/HeroTypes.d.ts +10 -5
  27. package/dist/components/Icons/Icon.d.ts +13 -16
  28. package/dist/components/Icons/IconSvgs.d.ts +4 -0
  29. package/dist/components/Icons/IconTypes.d.ts +78 -60
  30. package/dist/components/Image/Image.stories.d.ts +2 -1
  31. package/dist/components/Label/Label.d.ts +10 -26
  32. package/dist/components/Link/Link.d.ts +8 -12
  33. package/dist/components/List/List.stories.d.ts +1 -0
  34. package/dist/components/Radio/Radio.d.ts +30 -24
  35. package/dist/components/RadioGroup/RadioGroup.d.ts +40 -0
  36. package/dist/components/RadioGroup/RadioGroupLayoutTypes.d.ts +4 -0
  37. package/dist/components/SearchBar/SearchBar.d.ts +45 -27
  38. package/dist/components/Select/Select.d.ts +34 -35
  39. package/dist/components/Select/SelectTypes.d.ts +4 -0
  40. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +1 -1
  41. package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +2 -2
  42. package/dist/components/StatusBadge/StatusBadge.d.ts +8 -6
  43. package/dist/components/StatusBadge/StatusBadgeTypes.d.ts +5 -0
  44. package/dist/components/Tabs/Tabs.d.ts +25 -0
  45. package/dist/components/Template/Template.d.ts +91 -0
  46. package/dist/components/Text/Text.d.ts +16 -0
  47. package/dist/components/Text/TextTypes.d.ts +6 -0
  48. package/dist/components/TextInput/TextInput.d.ts +37 -30
  49. package/dist/components/TextInput/TextInputTypes.d.ts +5 -0
  50. package/dist/design-system-react-components.cjs.development.js +4102 -917
  51. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  52. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  53. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  54. package/dist/design-system-react-components.esm.js +4023 -920
  55. package/dist/design-system-react-components.esm.js.map +1 -1
  56. package/dist/index.d.ts +23 -5
  57. package/dist/resources.scss +133 -24
  58. package/dist/styles.css +1 -1
  59. package/dist/theme/components/accordion.d.ts +25 -0
  60. package/dist/theme/components/breadcrumb.d.ts +90 -0
  61. package/dist/theme/components/button.d.ts +109 -0
  62. package/dist/theme/components/checkbox.d.ts +91 -0
  63. package/dist/theme/components/customCheckboxGroup.d.ts +18 -0
  64. package/dist/theme/components/customRadioGroup.d.ts +18 -0
  65. package/dist/theme/components/global.d.ts +55 -0
  66. package/dist/theme/components/globalMixins.d.ts +15 -0
  67. package/dist/theme/components/heading.d.ts +110 -0
  68. package/dist/theme/components/hero.d.ts +492 -0
  69. package/dist/theme/components/icon.d.ts +13 -0
  70. package/dist/theme/components/label.d.ts +16 -0
  71. package/dist/theme/components/link.d.ts +45 -0
  72. package/dist/theme/components/radio.d.ts +95 -0
  73. package/dist/theme/components/searchBar.d.ts +20 -0
  74. package/dist/theme/components/select.d.ts +58 -0
  75. package/dist/theme/components/statusBadge.d.ts +25 -0
  76. package/dist/theme/components/tabs.d.ts +85 -0
  77. package/dist/theme/components/template.d.ts +105 -0
  78. package/dist/theme/components/text.d.ts +20 -0
  79. package/dist/theme/components/textInput.d.ts +105 -0
  80. package/dist/theme/foundations/breakpoints.d.ts +23 -0
  81. package/dist/theme/foundations/colors.d.ts +3 -0
  82. package/dist/theme/foundations/global.d.ts +23 -0
  83. package/dist/theme/foundations/shadows.d.ts +4 -0
  84. package/dist/theme/foundations/spacing.d.ts +77 -0
  85. package/dist/theme/foundations/typography.d.ts +8 -0
  86. package/dist/theme/index.d.ts +20 -0
  87. package/dist/theme/provider.d.ts +5 -0
  88. package/dist/theme/types.d.ts +1 -0
  89. package/dist/utils/utils.d.ts +6 -0
  90. package/package.json +9 -2
  91. package/src/components/Accordion/Accordion.stories.mdx +233 -33
  92. package/src/components/Accordion/Accordion.test.tsx +135 -19
  93. package/src/components/Accordion/Accordion.tsx +81 -56
  94. package/src/components/Autosuggest/Autosuggest.stories.mdx +4 -3
  95. package/src/components/Autosuggest/Autosuggest.stories.tsx +1 -1
  96. package/src/components/Autosuggest/_Autosuggest.scss +2 -2
  97. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +57 -56
  98. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +31 -25
  99. package/src/components/Breadcrumbs/Breadcrumbs.tsx +71 -73
  100. package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +6 -0
  101. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +100 -0
  102. package/src/components/Button/Button.stories.mdx +125 -138
  103. package/src/components/Button/Button.test.tsx +65 -11
  104. package/src/components/Button/Button.tsx +72 -68
  105. package/src/components/Button/ButtonTypes.tsx +4 -2
  106. package/src/components/Button/_Button.scss +7 -92
  107. package/src/components/Button/__snapshots__/Button.test.tsx.snap +58 -3
  108. package/src/components/Card/Card.stories.mdx +694 -0
  109. package/src/components/Card/Card.test.tsx +97 -102
  110. package/src/components/Card/Card.tsx +182 -31
  111. package/src/components/Card/CardTypes.tsx +21 -0
  112. package/src/components/Card/_Card.scss +234 -49
  113. package/src/components/{Card/Card.stories.tsx → CardEdition/CardEdition.stories.tsx} +32 -22
  114. package/src/components/CardEdition/CardEdition.test.tsx +395 -0
  115. package/src/components/CardEdition/CardEdition.tsx +60 -0
  116. package/src/components/CardEdition/_CardEdition.scss +138 -0
  117. package/src/components/Chakra/Box.stories.mdx +57 -0
  118. package/src/components/Chakra/Center.stories.mdx +99 -0
  119. package/src/components/Chakra/Grid.stories.mdx +79 -0
  120. package/src/components/Chakra/Stack.stories.mdx +93 -0
  121. package/src/components/Checkbox/Checkbox.stories.mdx +57 -35
  122. package/src/components/Checkbox/Checkbox.test.tsx +117 -147
  123. package/src/components/Checkbox/Checkbox.tsx +76 -50
  124. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +325 -0
  125. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +249 -0
  126. package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +345 -0
  127. package/src/components/CheckboxGroup/CheckboxGroup.tsx +148 -0
  128. package/src/components/CheckboxGroup/CheckboxGroupLayoutTypes.tsx +4 -0
  129. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +1360 -0
  130. package/src/components/DatePicker/DatePicker.stories.mdx +284 -0
  131. package/src/components/DatePicker/DatePicker.test.tsx +657 -0
  132. package/src/components/DatePicker/DatePicker.tsx +396 -0
  133. package/src/components/DatePicker/DatePickerTypes.tsx +5 -0
  134. package/src/components/DatePicker/_DatePicker.scss +76 -0
  135. package/src/components/Form/Form.stories.mdx +130 -27
  136. package/src/components/Form/Form.test.tsx +78 -36
  137. package/src/components/Form/Form.tsx +53 -19
  138. package/src/components/Form/FormTypes.tsx +3 -0
  139. package/src/components/Form/__snapshots__/Form.test.tsx.snap +38 -0
  140. package/src/components/Grid/GridTypes.tsx +9 -0
  141. package/src/components/Grid/SimpleGrid.stories.mdx +275 -0
  142. package/src/components/Grid/SimpleGrid.test.tsx +66 -0
  143. package/src/components/Grid/SimpleGrid.tsx +37 -0
  144. package/src/components/Grid/__snapshots__/SimpleGrid.test.tsx.snap +8 -0
  145. package/src/components/Heading/Heading.stories.mdx +63 -33
  146. package/src/components/Heading/Heading.test.tsx +24 -16
  147. package/src/components/Heading/Heading.tsx +54 -38
  148. package/src/components/Heading/{HeadingDisplaySizes.tsx → HeadingTypes.tsx} +9 -0
  149. package/src/components/HelperErrorText/HelperErrorText.stories.tsx +2 -1
  150. package/src/components/HelperErrorText/_HelperErrorText.scss +1 -1
  151. package/src/components/Hero/Hero.stories.mdx +195 -85
  152. package/src/components/Hero/Hero.test.tsx +544 -113
  153. package/src/components/Hero/Hero.tsx +80 -93
  154. package/src/components/Hero/HeroTypes.tsx +17 -5
  155. package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +307 -0
  156. package/src/components/HorizontalRule/HorizontalRule.stories.mdx +6 -1
  157. package/src/components/HorizontalRule/_HorizontalRule.scss +1 -1
  158. package/src/components/Icons/Icon.stories.mdx +89 -74
  159. package/src/components/Icons/Icon.test.tsx +30 -22
  160. package/src/components/Icons/Icon.tsx +63 -61
  161. package/src/components/Icons/IconSvgs.tsx +8 -0
  162. package/src/components/Icons/IconTypes.tsx +80 -60
  163. package/src/components/Image/Image.stories.tsx +2 -1
  164. package/src/components/Input/_Input.scss +2 -2
  165. package/src/components/Label/Label.stories.mdx +77 -0
  166. package/src/components/Label/Label.test.tsx +43 -12
  167. package/src/components/Label/Label.tsx +28 -45
  168. package/src/components/Label/__snapshots__/Label.test.tsx.snap +41 -0
  169. package/src/components/Link/Link.stories.mdx +47 -41
  170. package/src/components/Link/Link.test.tsx +33 -44
  171. package/src/components/Link/Link.tsx +114 -100
  172. package/src/components/List/List.stories.mdx +7 -3
  173. package/src/components/List/List.stories.tsx +14 -9
  174. package/src/components/List/List.test.tsx +12 -8
  175. package/src/components/List/List.tsx +9 -7
  176. package/src/components/List/_List.scss +3 -3
  177. package/src/components/Modal/Modal.stories.mdx +7 -3
  178. package/src/components/Modal/_Modal.scss +1 -1
  179. package/src/components/Notification/Notification.stories.mdx +99 -65
  180. package/src/components/Notification/Notification.test.tsx +3 -16
  181. package/src/components/Notification/Notification.tsx +12 -12
  182. package/src/components/Notification/_Notification.scss +5 -4
  183. package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +1 -1
  184. package/src/components/Pagination/Pagination.stories.mdx +7 -1
  185. package/src/components/Pagination/Pagination.test.tsx +16 -10
  186. package/src/components/Radio/Radio.stories.mdx +57 -46
  187. package/src/components/Radio/Radio.test.tsx +92 -138
  188. package/src/components/Radio/Radio.tsx +70 -69
  189. package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +250 -0
  190. package/src/components/RadioGroup/RadioGroup.stories.mdx +247 -0
  191. package/src/components/RadioGroup/RadioGroup.test.tsx +327 -0
  192. package/src/components/RadioGroup/RadioGroup.tsx +154 -0
  193. package/src/components/RadioGroup/RadioGroupLayoutTypes.tsx +4 -0
  194. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +1101 -0
  195. package/src/components/SearchBar/SearchBar.Test.tsx +151 -16
  196. package/src/components/SearchBar/SearchBar.stories.mdx +196 -224
  197. package/src/components/SearchBar/SearchBar.tsx +151 -46
  198. package/src/components/Select/Select.stories.mdx +193 -168
  199. package/src/components/Select/Select.test.tsx +129 -324
  200. package/src/components/Select/Select.tsx +120 -160
  201. package/src/components/Select/SelectTypes.tsx +4 -0
  202. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +18 -29
  203. package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +7 -7
  204. package/src/components/SkeletonLoader/SkeletonLoader.tsx +4 -2
  205. package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +2 -2
  206. package/src/components/SkeletonLoader/_SkeletonLoader.scss +3 -3
  207. package/src/components/StatusBadge/StatusBadge.stories.mdx +91 -0
  208. package/src/components/StatusBadge/StatusBadge.test.tsx +35 -7
  209. package/src/components/StatusBadge/StatusBadge.tsx +24 -25
  210. package/src/components/StatusBadge/StatusBadgeTypes.tsx +5 -0
  211. package/src/components/StatusBadge/__snapshots__/StatusBadge.test.tsx.snap +28 -0
  212. package/src/components/StyleGuide/Bidirectionality.stories.mdx +112 -90
  213. package/src/components/StyleGuide/Buttons.stories.mdx +98 -100
  214. package/src/components/StyleGuide/Colors.stories.mdx +336 -0
  215. package/src/components/StyleGuide/Forms.stories.mdx +85 -0
  216. package/src/components/StyleGuide/Iconography.stories.mdx +86 -93
  217. package/src/components/StyleGuide/Spacing.stories.mdx +0 -1
  218. package/src/components/StyleGuide/Typography.stories.mdx +164 -166
  219. package/src/components/StyleGuide/UIDocCard.tsx +4 -4
  220. package/src/components/Tabs/Tabs.stories.mdx +221 -0
  221. package/src/components/Tabs/Tabs.test.tsx +264 -0
  222. package/src/components/Tabs/Tabs.tsx +220 -0
  223. package/src/components/Template/Template.stories.mdx +574 -0
  224. package/src/components/Template/Template.test.tsx +124 -0
  225. package/src/components/Template/Template.tsx +226 -0
  226. package/src/components/Text/Text.stories.mdx +70 -0
  227. package/src/components/Text/Text.test.tsx +63 -0
  228. package/src/components/Text/Text.tsx +55 -0
  229. package/src/components/Text/TextTypes.tsx +6 -0
  230. package/src/components/Text/__snapshots__/Text.test.tsx.snap +33 -0
  231. package/src/components/TextInput/TextInput.stories.mdx +90 -90
  232. package/src/components/TextInput/TextInput.test.tsx +103 -83
  233. package/src/components/TextInput/TextInput.tsx +108 -91
  234. package/src/components/TextInput/TextInputTypes.tsx +6 -0
  235. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +2 -1
  236. package/src/components/VideoPlayer/VideoPlayer.tsx +4 -2
  237. package/src/components/VideoPlayer/_VideoPlayer.scss +1 -1
  238. package/src/docs/Chakra.stories.mdx +341 -0
  239. package/src/docs/Intro.stories.mdx +31 -24
  240. package/src/index.ts +70 -5
  241. package/src/styles/01-colors/_colors-brand.scss +6 -4
  242. package/src/styles/01-colors/_colors-utility.scss +14 -15
  243. package/src/styles/03-space/_space-inline.scss +47 -7
  244. package/src/styles/03-space/_space-inset.scss +33 -5
  245. package/src/styles/03-space/_space-stack.scss +48 -8
  246. package/src/styles/base/_02-breakpoints.scss +5 -4
  247. package/src/styles/base/_04-base.scss +2 -1
  248. package/src/styles/base/_place-holder.scss +1 -1
  249. package/src/styles/base/_typography.scss +1 -29
  250. package/src/styles.scss +22 -25
  251. package/src/theme/components/accordion.ts +30 -0
  252. package/src/theme/components/breadcrumb.ts +77 -0
  253. package/src/theme/components/button.ts +125 -0
  254. package/src/theme/components/checkbox.ts +107 -0
  255. package/src/theme/components/customCheckboxGroup.ts +12 -0
  256. package/src/theme/components/customRadioGroup.ts +12 -0
  257. package/src/theme/components/global.ts +71 -0
  258. package/src/theme/components/globalMixins.ts +16 -0
  259. package/src/theme/components/heading.ts +72 -0
  260. package/src/theme/components/hero.ts +239 -0
  261. package/src/theme/components/icon.ts +79 -0
  262. package/src/theme/components/label.ts +17 -0
  263. package/src/theme/components/link.ts +47 -0
  264. package/src/theme/components/radio.ts +106 -0
  265. package/src/theme/components/searchBar.ts +21 -0
  266. package/src/theme/components/select.ts +50 -0
  267. package/src/theme/components/statusBadge.ts +27 -0
  268. package/src/theme/components/tabs.ts +79 -0
  269. package/src/theme/components/template.ts +114 -0
  270. package/src/theme/components/text.ts +31 -0
  271. package/src/theme/components/textInput.ts +61 -0
  272. package/src/theme/foundations/breakpoints.ts +24 -0
  273. package/src/theme/foundations/colors.ts +208 -0
  274. package/src/theme/foundations/global.ts +26 -0
  275. package/src/theme/foundations/shadows.ts +5 -0
  276. package/src/theme/foundations/spacing.ts +85 -0
  277. package/src/theme/foundations/typography.ts +35 -0
  278. package/src/theme/index.ts +88 -0
  279. package/src/theme/provider.tsx +9 -0
  280. package/src/theme/types.ts +1 -0
  281. package/src/utils/componentCategories.ts +56 -21
  282. package/src/utils/utils.ts +13 -0
  283. package/dist/components/Accordion/Accordion.stories.d.ts +0 -5
  284. package/dist/components/Card/Card.stories.d.ts +0 -27
  285. package/dist/components/Label/Label.stories.d.ts +0 -12
  286. package/dist/components/StatusBadge/StatusBadge.stories.d.ts +0 -8
  287. package/dist/components/Template/Template.stories.d.ts +0 -29
  288. package/src/components/Accordion/Accordion.stories.tsx +0 -65
  289. package/src/components/Accordion/_Accordion.scss +0 -81
  290. package/src/components/Breadcrumbs/_Breadcrumbs.scss +0 -97
  291. package/src/components/Checkbox/_Checkbox.scss +0 -97
  292. package/src/components/Form/_Form.scss +0 -28
  293. package/src/components/Heading/_Heading.scss +0 -163
  294. package/src/components/Hero/_Hero.scss +0 -256
  295. package/src/components/Icons/_Icons.scss +0 -116
  296. package/src/components/Label/Label.stories.tsx +0 -30
  297. package/src/components/Label/_Label.scss +0 -22
  298. package/src/components/Link/_Link.scss +0 -73
  299. package/src/components/Radio/_Radio.scss +0 -84
  300. package/src/components/SearchBar/_SearchBar.scss +0 -16
  301. package/src/components/Select/_Select.scss +0 -82
  302. package/src/components/StatusBadge/StatusBadge.stories.tsx +0 -33
  303. package/src/components/StatusBadge/_StatusBadge.scss +0 -23
  304. package/src/components/StyleGuide/Colors.stories.tsx +0 -288
  305. package/src/components/Template/Template.stories.tsx +0 -85
  306. package/src/components/Template/_Template.scss +0 -63
  307. package/src/components/TextInput/_TextInput.scss +0 -59
@@ -0,0 +1,275 @@
1
+ import {
2
+ Meta,
3
+ Story,
4
+ Canvas,
5
+ ArgsTable,
6
+ Description,
7
+ } from "@storybook/addon-docs/blocks";
8
+ import { withDesign } from "storybook-addon-designs";
9
+
10
+ import SimpleGrid from "./SimpleGrid";
11
+ import Card, {
12
+ CardImage,
13
+ CardHeading,
14
+ CardContent,
15
+ CardActions,
16
+ } from "../Card/Card";
17
+ import {
18
+ CardImageRatios,
19
+ CardImageSizes,
20
+ CardLayouts,
21
+ } from "../Card/CardTypes";
22
+ import { HeadingDisplaySizes, HeadingLevels } from "../Heading/HeadingTypes";
23
+ import Icon from "../Icons/Icon";
24
+ import {
25
+ IconNames,
26
+ LogoNames,
27
+ IconSizes,
28
+ IconRotationTypes,
29
+ } from "../Icons/IconTypes";
30
+ import Image from "../Image/Image";
31
+
32
+ import { getCategory } from "../../utils/componentCategories";
33
+ import DSProvider from "../../theme/provider";
34
+
35
+ <Meta
36
+ title={getCategory("SimpleGrid")}
37
+ component={SimpleGrid}
38
+ decorators={[withDesign]}
39
+ parameters={{
40
+ design: {
41
+ type: "figma",
42
+ url:
43
+ "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Main?node-id=36835%3A26613",
44
+ },
45
+ jest: ["SimpleGrid.test.tsx"],
46
+ }}
47
+ argTypes={{
48
+ columns: {
49
+ control: {
50
+ type: "number",
51
+ min: 2,
52
+ },
53
+ table: {
54
+ defaultValue: {
55
+ summary: 3,
56
+ },
57
+ },
58
+ },
59
+ gap: {
60
+ table: {
61
+ defaultValue: {
62
+ summary: "l",
63
+ },
64
+ },
65
+ },
66
+ className: { table: { disable: true } },
67
+ id: { table: { disable: true } },
68
+ }}
69
+ />
70
+
71
+ # SimpleGrid
72
+
73
+ | Component Version | DS Version |
74
+ | ----------------- | ---------- |
75
+ | Added | `0.25.1` |
76
+ | Latest | `0.25.1` |
77
+
78
+ <Description of={SimpleGrid} />
79
+
80
+ The `SimpleGrid` component is used to render UI elements in a uniform grid layout, with the column widths and grid spacing fixed throughout the grid.
81
+
82
+ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for tablet and `1` for mobile. By default, the `SimpleGrid` component uses these standards and the `columns` prop is optional. If the `columns` prop is used, the tablet breakpoint will be dropped and only the mobile breakpoint (1 item per row) will be triggered.
83
+
84
+ <Canvas withToolbar>
85
+ <Story name="SimpleGrid Props">
86
+ {(args) => (
87
+ <SimpleGrid {...args}>
88
+ <Card
89
+ imageSrc="https://placeimg.com/500/200/animals"
90
+ imageAlt="Alt text"
91
+ imageAspectRatio={CardImageRatios.TwoByOne}
92
+ >
93
+ <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
94
+ <CardContent>
95
+ Vestibulum id ligula porta felis euismod semper. Nulla vitae elit
96
+ libero, a pharetra augue.
97
+ </CardContent>
98
+ </Card>
99
+ <Card
100
+ imageSrc="https://placeimg.com/400/220/animals"
101
+ imageAlt="Alt text"
102
+ imageAspectRatio={CardImageRatios.TwoByOne}
103
+ >
104
+ <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
105
+ <CardContent>
106
+ Vestibulum id ligula porta felis euismod semper. Nulla vitae elit
107
+ libero, a pharetra augue.
108
+ </CardContent>
109
+ </Card>
110
+ <Card
111
+ imageSrc="https://placeimg.com/400/240/animals"
112
+ imageAlt="Alt text"
113
+ imageAspectRatio={CardImageRatios.TwoByOne}
114
+ >
115
+ <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
116
+ <CardContent>
117
+ Vestibulum id ligula porta felis euismod semper. Nulla vitae elit
118
+ libero, a pharetra augue.
119
+ </CardContent>
120
+ </Card>
121
+ <Card
122
+ imageSrc="https://placeimg.com/400/260/animals"
123
+ imageAlt="Alt text"
124
+ imageAspectRatio={CardImageRatios.TwoByOne}
125
+ >
126
+ <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
127
+ <CardContent>
128
+ Vestibulum id ligula porta felis euismod semper. Nulla vitae elit
129
+ libero, a pharetra augue.
130
+ </CardContent>
131
+ </Card>
132
+ <Card
133
+ imageSrc="https://placeimg.com/400/320/animals"
134
+ imageAlt="Alt text"
135
+ imageAspectRatio={CardImageRatios.TwoByOne}
136
+ >
137
+ <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
138
+ <CardContent>
139
+ Vestibulum id ligula porta felis euismod semper. Nulla vitae elit
140
+ libero, a pharetra augue.
141
+ </CardContent>
142
+ </Card>
143
+ <Card
144
+ imageSrc="https://placeimg.com/400/300/animals"
145
+ imageAlt="Alt text"
146
+ imageAspectRatio={CardImageRatios.TwoByOne}
147
+ >
148
+ <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
149
+ <CardContent>
150
+ Vestibulum id ligula porta felis euismod semper. Nulla vitae elit
151
+ libero, a pharetra augue.
152
+ </CardContent>
153
+ </Card>
154
+ </SimpleGrid>
155
+ )}
156
+ </Story>
157
+ </Canvas>
158
+
159
+ <ArgsTable story="SimpleGrid Props" />
160
+
161
+ ## Other SimpleGrid Examples
162
+
163
+ ### Icons
164
+
165
+ This example is rendering `Icon` components with the `columns` prop set to `5`.
166
+
167
+ export const icons = [];
168
+ for (const icon in IconNames) {
169
+ const iname = `Example icon: ${IconNames[icon]}`;
170
+ const iconRender = (
171
+ <Icon
172
+ name={IconNames[icon]}
173
+ size={IconSizes.ExtraExtraExtraLarge}
174
+ titleText={iname}
175
+ />
176
+ );
177
+ icons.push(iconRender);
178
+ }
179
+
180
+ <Canvas>
181
+ <Story name="Other SimpleGrid Examples">
182
+ <SimpleGrid columns={5}>{icons}</SimpleGrid>
183
+ </Story>
184
+ </Canvas>
185
+
186
+ ### Images
187
+
188
+ This example is rendering square `Image` components with the `columns` prop set to `6`.
189
+
190
+ <Canvas>
191
+ <DSProvider>
192
+ <SimpleGrid columns={6}>
193
+ <Image src="https://placeimg.com/300/300/animals?x=1" />
194
+ <Image src="https://placeimg.com/300/300/animals?x=2" />
195
+ <Image src="https://placeimg.com/300/300/animals?x=3" />
196
+ <Image src="https://placeimg.com/300/300/animals?x=4" />
197
+ <Image src="https://placeimg.com/300/300/animals?x=5" />
198
+ <Image src="https://placeimg.com/300/300/animals?x=6" />
199
+ <Image src="https://placeimg.com/300/300/animals?x=7" />
200
+ <Image src="https://placeimg.com/300/300/animals?x=8" />
201
+ <Image src="https://placeimg.com/300/300/animals?x=9" />
202
+ <Image src="https://placeimg.com/300/300/animals?x=10" />
203
+ <Image src="https://placeimg.com/300/300/animals?x=11" />
204
+ <Image src="https://placeimg.com/300/300/animals?x=12" />
205
+ <Image src="https://placeimg.com/300/300/animals?x=13" />
206
+ <Image src="https://placeimg.com/300/300/animals?x=14" />
207
+ <Image src="https://placeimg.com/300/300/animals?x=15" />
208
+ <Image src="https://placeimg.com/300/300/animals?x=16" />
209
+ <Image src="https://placeimg.com/300/300/animals?x=17" />
210
+ <Image src="https://placeimg.com/300/300/animals?x=18" />
211
+ </SimpleGrid>
212
+ </DSProvider>
213
+ </Canvas>
214
+
215
+ ### Horizontal Cards
216
+
217
+ This example is rendering horizontal `Card` components with the `columns` prop set to `1`.
218
+
219
+ <Canvas>
220
+ <DSProvider>
221
+ <SimpleGrid columns={1}>
222
+ <Card
223
+ layout={CardLayouts.Row}
224
+ border
225
+ center
226
+ imageSrc="https://placeimg.com/400/200/animals"
227
+ imageAlt="Alt text"
228
+ imageAspectRatio={CardImageRatios.FourByThree}
229
+ >
230
+ <CardHeading level={HeadingLevels.Four} id="heading1">
231
+ Card Heading
232
+ </CardHeading>
233
+ <CardContent>
234
+ Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
235
+ Sed posuere consectetur est at lobortis. Cras justo odio, dapibus ac
236
+ facilisis in, egestas eget quam.
237
+ </CardContent>
238
+ </Card>
239
+ <Card
240
+ layout={CardLayouts.Row}
241
+ border
242
+ center
243
+ imageSrc="https://placeimg.com/410/210/animals"
244
+ imageAlt="Alt text"
245
+ imageAspectRatio={CardImageRatios.FourByThree}
246
+ >
247
+ <CardHeading level={HeadingLevels.Four} id="heading2">
248
+ Card Heading
249
+ </CardHeading>
250
+ <CardContent>
251
+ Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
252
+ Sed posuere consectetur est at lobortis. Cras justo odio, dapibus ac
253
+ facilisis in, egestas eget quam.
254
+ </CardContent>
255
+ </Card>
256
+ <Card
257
+ layout={CardLayouts.Row}
258
+ border
259
+ center
260
+ imageSrc="https://placeimg.com/320/320/animals"
261
+ imageAlt="Alt text"
262
+ imageAspectRatio={CardImageRatios.FourByThree}
263
+ >
264
+ <CardHeading level={HeadingLevels.Four} id="heading3">
265
+ Card Heading
266
+ </CardHeading>
267
+ <CardContent>
268
+ Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
269
+ Sed posuere consectetur est at lobortis. Cras justo odio, dapibus ac
270
+ facilisis in, egestas eget quam.
271
+ </CardContent>
272
+ </Card>
273
+ </SimpleGrid>
274
+ </DSProvider>
275
+ </Canvas>
@@ -0,0 +1,66 @@
1
+ import * as React from "react";
2
+ import { render } from "@testing-library/react";
3
+ import { axe } from "jest-axe";
4
+ import renderer from "react-test-renderer";
5
+
6
+ import SimpleGrid from "./SimpleGrid";
7
+ import Card, { CardHeading, CardContent } from "../Card/Card";
8
+ import { CardImageRatios } from "../Card/CardTypes";
9
+ import { HeadingLevels } from "../Heading/HeadingTypes";
10
+
11
+ describe("Grid Accessibility", () => {
12
+ it("passes axe accessibility test with children components", async () => {
13
+ const { container } = render(
14
+ <SimpleGrid>
15
+ <Card
16
+ imageSrc="https://placeimg.com/500/200/animals"
17
+ imageAlt="Alt text"
18
+ imageAspectRatio={CardImageRatios.TwoByOne}
19
+ >
20
+ <CardHeading level={HeadingLevels.Two}>Card Heading</CardHeading>
21
+ <CardContent>
22
+ Vestibulum id ligula porta felis euismod semper. Nulla vitae elit
23
+ libero, a pharetra augue.
24
+ </CardContent>
25
+ </Card>
26
+ <Card
27
+ imageSrc="https://placeimg.com/400/220/animals"
28
+ imageAlt="Alt text"
29
+ imageAspectRatio={CardImageRatios.TwoByOne}
30
+ >
31
+ <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
32
+ <CardContent>
33
+ Vestibulum id ligula porta felis euismod semper. Nulla vitae elit
34
+ libero, a pharetra augue.
35
+ </CardContent>
36
+ </Card>
37
+ <Card
38
+ imageSrc="https://placeimg.com/400/240/animals"
39
+ imageAlt="Alt text"
40
+ imageAspectRatio={CardImageRatios.TwoByOne}
41
+ >
42
+ <CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
43
+ <CardContent>
44
+ Vestibulum id ligula porta felis euismod semper. Nulla vitae elit
45
+ libero, a pharetra augue.
46
+ </CardContent>
47
+ </Card>
48
+ </SimpleGrid>
49
+ );
50
+ expect(await axe(container)).toHaveNoViolations();
51
+ });
52
+ });
53
+
54
+ describe("SimpleGrid", () => {
55
+ it("Renders the SimpleGrid UI snapshot correctly", () => {
56
+ const tree = renderer.create(<SimpleGrid id="test-grid" />).toJSON();
57
+ expect(tree).toMatchSnapshot();
58
+ });
59
+
60
+ it("Renders SimpleGrid component", () => {
61
+ const utils = render(<SimpleGrid id="test-grid-render" />);
62
+ expect(
63
+ utils.container.querySelector("#test-grid-render")
64
+ ).toBeInTheDocument();
65
+ });
66
+ });
@@ -0,0 +1,37 @@
1
+ import * as React from "react";
2
+ import { SimpleGrid as ChakraSimpleGrid } from "@chakra-ui/react";
3
+ import { GridGaps } from "./GridTypes";
4
+
5
+ import generateUUID from "../../helpers/generateUUID";
6
+
7
+ export interface SimpleGridProps {
8
+ /** Additional class name. */
9
+ className?: string;
10
+ /** Optional numeric value to override the default column count; the default column count is 3 */
11
+ columns?: number;
12
+ /** Optional gap size; if omitted, the default `large` (2rem / 32px) spacing will be used; ```IMPORTANT: for standard grid layouts, this prop should not be used``` */
13
+ gap?: GridGaps;
14
+ /** ID that other components can cross reference for accessibility purposes */
15
+ id?: string;
16
+ }
17
+
18
+ function SimpleGrid(props: React.PropsWithChildren<SimpleGridProps>) {
19
+ const { children, columns, className, gap = GridGaps.Large, id } = props;
20
+
21
+ const responsiveCols = columns
22
+ ? { base: 1, md: columns }
23
+ : { base: 1, md: 2, lg: 3 };
24
+
25
+ return (
26
+ <ChakraSimpleGrid
27
+ columns={responsiveCols}
28
+ gap={gap}
29
+ id={id || generateUUID()}
30
+ className={className}
31
+ >
32
+ {children}
33
+ </ChakraSimpleGrid>
34
+ );
35
+ }
36
+
37
+ export default SimpleGrid;
@@ -0,0 +1,8 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`SimpleGrid Renders the SimpleGrid UI snapshot correctly 1`] = `
4
+ <div
5
+ className="css-1tep0ti"
6
+ id="test-grid"
7
+ />
8
+ `;
@@ -9,10 +9,11 @@ import {
9
9
  import { withDesign } from "storybook-addon-designs";
10
10
 
11
11
  import Heading from "./Heading";
12
- import { HeadingDisplaySizes } from "./HeadingDisplaySizes";
12
+ import { HeadingDisplaySizes, HeadingLevels } from "./HeadingTypes";
13
+ import { getCategory } from "../../utils/componentCategories";
13
14
 
14
15
  <Meta
15
- title="Heading"
16
+ title={getCategory("Heading")}
16
17
  component={Heading}
17
18
  decorators={[withDesign]}
18
19
  parameters={{
@@ -27,107 +28,136 @@ import { HeadingDisplaySizes } from "./HeadingDisplaySizes";
27
28
  blockName: { table: { disable: true } },
28
29
  className: { table: { disable: true } },
29
30
  modifiers: { table: { disable: true } },
31
+ sx: { table: { disable: true } },
30
32
  }}
31
33
  />
32
34
 
33
35
  # Heading
34
36
 
37
+ | Component Version | DS Version |
38
+ | ----------------- | ---------- |
39
+ | Added | `0.0.4` |
40
+ | Latest | `0.25.0` |
41
+
35
42
  <Description of={Heading} />
36
43
 
37
44
  A `Heading` component will render a standard HTML `<h>` tag (1-6). The heading's text can be passed in through a `text` prop or as a child. Default styles for semantic elements can be overwritten using the `displaySize` prop.
38
45
 
39
- <Preview withToolbar>
46
+ <Canvas withToolbar>
40
47
  <Story
41
48
  name="Heading Props"
42
49
  args={{
43
- id: "heading1",
44
- level: 1,
45
- text: "Heading 1",
50
+ id: "default-heading",
51
+ text: "Default Heading",
46
52
  }}
47
53
  >
48
54
  {(args) => <Heading {...args} />}
49
55
  </Story>
50
- </Preview>
56
+ </Canvas>
51
57
 
52
58
  <ArgsTable story="Heading Props" />
53
59
 
54
60
  ## Default Heading Styles
55
61
 
56
- <Preview>
62
+ <Canvas>
57
63
  <Story name="Default Heading Styles">
58
64
  <div>
59
- <Heading id="heading1" level={1} text="<h1> Heading 1" />
60
- <Heading id="heading2" level={2} text="<h2> Heading 2" />
61
- <Heading id="heading3" level={3} text="<h3> Heading 3" />
62
- <Heading id="heading4" level={4} text="<h4> Heading 4" />
63
- <Heading id="heading5" level={5} text="<h5> Heading 5" />
64
- <Heading id="heading6" level={6} text="<h6> Heading 6" />
65
+ <Heading
66
+ id="heading-one"
67
+ level={HeadingLevels.One}
68
+ text="<h1> Heading 1"
69
+ />
70
+ <Heading
71
+ id="heading-two"
72
+ level={HeadingLevels.Two}
73
+ text="<h2> Heading 2"
74
+ />
75
+ <Heading
76
+ id="heading-three"
77
+ level={HeadingLevels.Three}
78
+ text="<h3> Heading 3"
79
+ />
80
+ <Heading
81
+ id="heading-four"
82
+ level={HeadingLevels.Four}
83
+ text="<h4> Heading 4"
84
+ />
85
+ <Heading
86
+ id="heading-five"
87
+ level={HeadingLevels.Five}
88
+ text="<h5> Heading 5"
89
+ />
90
+ <Heading
91
+ id="heading-six"
92
+ level={HeadingLevels.Six}
93
+ text="<h6> Heading 6"
94
+ />
65
95
  </div>
66
96
  </Story>
67
- </Preview>
97
+ </Canvas>
68
98
 
69
99
  ## DisplaySize Styles
70
100
 
71
- <Preview>
101
+ <Canvas>
72
102
  <Story name="DisplaySize Styles">
73
103
  <div>
74
104
  <Heading
75
- id="heading1"
76
- level={1}
105
+ id="heading-primary"
106
+ level={HeadingLevels.One}
77
107
  displaySize={HeadingDisplaySizes.Primary}
78
108
  text="<h1> HeadingDisplaySizes.Primary"
79
109
  />
80
110
  <Heading
81
- id="heading1"
82
- level={1}
111
+ id="heading-secondary"
112
+ level={HeadingLevels.One}
83
113
  displaySize={HeadingDisplaySizes.Secondary}
84
114
  text="<h1> HeadingDisplaySizes.Secondary"
85
115
  />
86
116
  <Heading
87
- id="heading1"
88
- level={1}
117
+ id="heading-tertiary"
118
+ level={HeadingLevels.One}
89
119
  displaySize={HeadingDisplaySizes.Tertiary}
90
120
  text="<h1> HeadingDisplaySizes.Tertiary"
91
121
  />
92
122
  <Heading
93
- id="heading1"
94
- level={1}
123
+ id="heading-callout"
124
+ level={HeadingLevels.One}
95
125
  displaySize={HeadingDisplaySizes.Callout}
96
126
  text="<h1> HeadingDisplaySizes.Callout"
97
127
  />
98
128
  </div>
99
129
  </Story>
100
- </Preview>
130
+ </Canvas>
101
131
 
102
132
  ## Heading with Bold
103
133
 
104
- <Preview>
134
+ <Canvas>
105
135
  <Story name="Heading with Bold">
106
- <Heading id="headingWithBold" level={2}>
136
+ <Heading id="headingWithBold" level={HeadingLevels.One}>
107
137
  <>
108
138
  Heading with a <b>Bold</b> Word
109
139
  </>
110
140
  </Heading>
111
141
  </Story>
112
- </Preview>
142
+ </Canvas>
113
143
 
114
144
  ## Headings with Links
115
145
 
116
146
  When the `url` prop is passed to `Heading`, a child `<a>` element is created and the heading text becomes an active link.
117
147
 
118
- <Preview>
148
+ <Canvas>
119
149
  <Story name="Headings with Links">
120
150
  <Heading
121
- id="headingWithLink"
122
- level={2}
151
+ id="heading-with-link-url"
152
+ level={HeadingLevels.Two}
123
153
  text="Heading with URL Props"
124
154
  url="http://apple.com"
125
155
  urlClass="special-link"
126
156
  />
127
- <Heading id="headingWithLink" level={2}>
157
+ <Heading id="heading-with-link-child" level={HeadingLevels.Two}>
128
158
  <>
129
159
  Heading with a Word <a href="hello">Link</a>
130
160
  </>
131
161
  </Heading>
132
162
  </Story>
133
- </Preview>
163
+ </Canvas>
@@ -3,12 +3,12 @@ import { render, screen } from "@testing-library/react";
3
3
  import { axe } from "jest-axe";
4
4
 
5
5
  import Heading from "./Heading";
6
- import { HeadingDisplaySizes } from "./HeadingDisplaySizes";
6
+ import { HeadingDisplaySizes, HeadingLevels } from "./HeadingTypes";
7
7
 
8
8
  describe("Heading Accessibility", () => {
9
9
  it("passes axe accessibility test", async () => {
10
10
  const { container } = render(
11
- <Heading id="h1" level={1} text="Heading 1" />
11
+ <Heading id="h1" level={HeadingLevels.One} text="Heading 1" />
12
12
  );
13
13
  expect(await axe(container)).toHaveNoViolations();
14
14
  });
@@ -16,13 +16,13 @@ describe("Heading Accessibility", () => {
16
16
 
17
17
  describe("Heading", () => {
18
18
  it("Shows heading", () => {
19
- render(<Heading id="h1" level={1} text="Heading 1" />);
19
+ render(<Heading id="h1" level={HeadingLevels.One} text="Heading 1" />);
20
20
  expect(screen.getByRole("heading", { level: 1 })).toBeInTheDocument();
21
21
  expect(screen.getByText("Heading 1")).toBeInTheDocument();
22
22
  });
23
23
  it("Can pass heading content as child", () => {
24
24
  render(
25
- <Heading id="h1" level={2}>
25
+ <Heading id="h1" level={HeadingLevels.Two}>
26
26
  Heading 2
27
27
  </Heading>
28
28
  );
@@ -32,13 +32,13 @@ describe("Heading", () => {
32
32
 
33
33
  // TODO: check that header children are links
34
34
  // it("Throws error when invalid heading is passed as child", () => {
35
- // expect(() => render(<Heading id="h1" level={3}><span>oh no</span></Heading>))
35
+ // expect(() => render(<Heading id="h1" level={HeadingLevels.Three}><span>oh no</span></Heading>))
36
36
  // .to.throw("Headings can only be plain text or bold");
37
37
  // });
38
38
 
39
39
  it("Can pass heading content as child span", () => {
40
40
  render(
41
- <Heading id="h1" level={1}>
41
+ <Heading id="h1" level={HeadingLevels.One}>
42
42
  <span>
43
43
  Text <b>hi</b>
44
44
  </span>
@@ -49,7 +49,7 @@ describe("Heading", () => {
49
49
 
50
50
  it("uses child when both child and the text prop are passed", () => {
51
51
  render(
52
- <Heading id="h1" level={1} text="prop text">
52
+ <Heading id="h1" level={HeadingLevels.One} text="prop text">
53
53
  child text
54
54
  </Heading>
55
55
  );
@@ -57,7 +57,14 @@ describe("Heading", () => {
57
57
  });
58
58
 
59
59
  it("Has <a> tag when passed URL", () => {
60
- render(<Heading id="h1" level={1} url="fake-url" text="Heading 1" />);
60
+ render(
61
+ <Heading
62
+ id="h1"
63
+ level={HeadingLevels.One}
64
+ url="fake-url"
65
+ text="Heading 1"
66
+ />
67
+ );
61
68
 
62
69
  expect(screen.getByRole("link")).toBeInTheDocument();
63
70
  });
@@ -66,13 +73,15 @@ describe("Heading", () => {
66
73
  render(
67
74
  <Heading
68
75
  id="h1"
69
- level={1}
76
+ level={HeadingLevels.One}
70
77
  url="fake-url"
71
78
  urlClass="fake-class"
72
79
  text="Heading 1"
73
80
  />
74
81
  );
75
- expect(screen.getByRole("link")).toHaveAttribute("class", "fake-class");
82
+ expect(screen.getByRole("link").getAttribute("class")).toContain(
83
+ "fake-class"
84
+ );
76
85
  });
77
86
 
78
87
  it("Throws error when invalid heading number passed", () => {
@@ -90,7 +99,7 @@ describe("Heading", () => {
90
99
  it("Throws error when heading with many children is passed", () => {
91
100
  expect(() =>
92
101
  render(
93
- <Heading id="h1" level={4}>
102
+ <Heading id="h1" level={HeadingLevels.Four}>
94
103
  <span>too</span>
95
104
  <span>many</span>
96
105
  </Heading>
@@ -102,14 +111,13 @@ describe("Heading", () => {
102
111
  render(
103
112
  <Heading
104
113
  id="h1"
105
- level={1}
114
+ level={HeadingLevels.One}
106
115
  text="Heading with Secondary displaySize"
107
116
  displaySize={HeadingDisplaySizes.Secondary}
108
117
  />
109
118
  );
110
- expect(screen.getByRole("heading", { level: 1 })).toHaveAttribute(
111
- "class",
112
- "heading heading--secondary "
113
- );
119
+ expect(screen.getByRole("heading", { level: 1 })).toHaveStyle({
120
+ "font-size": "2em",
121
+ });
114
122
  });
115
123
  });