@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.
- package/CHANGELOG.md +98 -1
- package/README.md +46 -11
- package/dist/components/Accordion/Accordion.d.ts +14 -14
- package/dist/components/Autosuggest/Autosuggest.stories.d.ts +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +11 -14
- package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +6 -0
- package/dist/components/Button/Button.d.ts +6 -13
- package/dist/components/Button/ButtonTypes.d.ts +5 -3
- package/dist/components/Card/Card.d.ts +59 -10
- package/dist/components/Card/CardTypes.d.ts +19 -0
- package/dist/components/CardEdition/CardEdition.d.ts +21 -0
- package/dist/components/{StyleGuide/Colors.stories.d.ts → CardEdition/CardEdition.stories.d.ts} +5 -2
- package/dist/components/Checkbox/Checkbox.d.ts +21 -16
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +43 -0
- package/dist/components/CheckboxGroup/CheckboxGroupLayoutTypes.d.ts +4 -0
- package/dist/components/DatePicker/DatePicker.d.ts +79 -0
- package/dist/components/DatePicker/DatePickerTypes.d.ts +5 -0
- package/dist/components/Form/Form.d.ts +16 -8
- package/dist/components/Form/FormTypes.d.ts +2 -0
- package/dist/components/Grid/GridTypes.d.ts +9 -0
- package/dist/components/Grid/SimpleGrid.d.ts +14 -0
- package/dist/components/Heading/Heading.d.ts +9 -11
- package/dist/components/Heading/{HeadingDisplaySizes.d.ts → HeadingTypes.d.ts} +8 -0
- package/dist/components/HelperErrorText/HelperErrorText.stories.d.ts +2 -1
- package/dist/components/Hero/Hero.d.ts +19 -14
- package/dist/components/Hero/HeroTypes.d.ts +10 -5
- package/dist/components/Icons/Icon.d.ts +13 -16
- package/dist/components/Icons/IconSvgs.d.ts +4 -0
- package/dist/components/Icons/IconTypes.d.ts +78 -60
- package/dist/components/Image/Image.stories.d.ts +2 -1
- package/dist/components/Label/Label.d.ts +10 -26
- package/dist/components/Link/Link.d.ts +8 -12
- package/dist/components/List/List.stories.d.ts +1 -0
- package/dist/components/Radio/Radio.d.ts +30 -24
- package/dist/components/RadioGroup/RadioGroup.d.ts +40 -0
- package/dist/components/RadioGroup/RadioGroupLayoutTypes.d.ts +4 -0
- package/dist/components/SearchBar/SearchBar.d.ts +45 -27
- package/dist/components/Select/Select.d.ts +34 -35
- package/dist/components/Select/SelectTypes.d.ts +4 -0
- package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +1 -1
- package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +2 -2
- package/dist/components/StatusBadge/StatusBadge.d.ts +8 -6
- package/dist/components/StatusBadge/StatusBadgeTypes.d.ts +5 -0
- package/dist/components/Tabs/Tabs.d.ts +25 -0
- package/dist/components/Template/Template.d.ts +91 -0
- package/dist/components/Text/Text.d.ts +16 -0
- package/dist/components/Text/TextTypes.d.ts +6 -0
- package/dist/components/TextInput/TextInput.d.ts +37 -30
- package/dist/components/TextInput/TextInputTypes.d.ts +5 -0
- package/dist/design-system-react-components.cjs.development.js +4102 -917
- package/dist/design-system-react-components.cjs.development.js.map +1 -1
- package/dist/design-system-react-components.cjs.production.min.js +1 -1
- package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
- package/dist/design-system-react-components.esm.js +4023 -920
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/index.d.ts +23 -5
- package/dist/resources.scss +133 -24
- package/dist/styles.css +1 -1
- package/dist/theme/components/accordion.d.ts +25 -0
- package/dist/theme/components/breadcrumb.d.ts +90 -0
- package/dist/theme/components/button.d.ts +109 -0
- package/dist/theme/components/checkbox.d.ts +91 -0
- package/dist/theme/components/customCheckboxGroup.d.ts +18 -0
- package/dist/theme/components/customRadioGroup.d.ts +18 -0
- package/dist/theme/components/global.d.ts +55 -0
- package/dist/theme/components/globalMixins.d.ts +15 -0
- package/dist/theme/components/heading.d.ts +110 -0
- package/dist/theme/components/hero.d.ts +492 -0
- package/dist/theme/components/icon.d.ts +13 -0
- package/dist/theme/components/label.d.ts +16 -0
- package/dist/theme/components/link.d.ts +45 -0
- package/dist/theme/components/radio.d.ts +95 -0
- package/dist/theme/components/searchBar.d.ts +20 -0
- package/dist/theme/components/select.d.ts +58 -0
- package/dist/theme/components/statusBadge.d.ts +25 -0
- package/dist/theme/components/tabs.d.ts +85 -0
- package/dist/theme/components/template.d.ts +105 -0
- package/dist/theme/components/text.d.ts +20 -0
- package/dist/theme/components/textInput.d.ts +105 -0
- package/dist/theme/foundations/breakpoints.d.ts +23 -0
- package/dist/theme/foundations/colors.d.ts +3 -0
- package/dist/theme/foundations/global.d.ts +23 -0
- package/dist/theme/foundations/shadows.d.ts +4 -0
- package/dist/theme/foundations/spacing.d.ts +77 -0
- package/dist/theme/foundations/typography.d.ts +8 -0
- package/dist/theme/index.d.ts +20 -0
- package/dist/theme/provider.d.ts +5 -0
- package/dist/theme/types.d.ts +1 -0
- package/dist/utils/utils.d.ts +6 -0
- package/package.json +9 -2
- package/src/components/Accordion/Accordion.stories.mdx +233 -33
- package/src/components/Accordion/Accordion.test.tsx +135 -19
- package/src/components/Accordion/Accordion.tsx +81 -56
- package/src/components/Autosuggest/Autosuggest.stories.mdx +4 -3
- package/src/components/Autosuggest/Autosuggest.stories.tsx +1 -1
- package/src/components/Autosuggest/_Autosuggest.scss +2 -2
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +57 -56
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +31 -25
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +71 -73
- package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +6 -0
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +100 -0
- package/src/components/Button/Button.stories.mdx +125 -138
- package/src/components/Button/Button.test.tsx +65 -11
- package/src/components/Button/Button.tsx +72 -68
- package/src/components/Button/ButtonTypes.tsx +4 -2
- package/src/components/Button/_Button.scss +7 -92
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +58 -3
- package/src/components/Card/Card.stories.mdx +694 -0
- package/src/components/Card/Card.test.tsx +97 -102
- package/src/components/Card/Card.tsx +182 -31
- package/src/components/Card/CardTypes.tsx +21 -0
- package/src/components/Card/_Card.scss +234 -49
- package/src/components/{Card/Card.stories.tsx → CardEdition/CardEdition.stories.tsx} +32 -22
- package/src/components/CardEdition/CardEdition.test.tsx +395 -0
- package/src/components/CardEdition/CardEdition.tsx +60 -0
- package/src/components/CardEdition/_CardEdition.scss +138 -0
- package/src/components/Chakra/Box.stories.mdx +57 -0
- package/src/components/Chakra/Center.stories.mdx +99 -0
- package/src/components/Chakra/Grid.stories.mdx +79 -0
- package/src/components/Chakra/Stack.stories.mdx +93 -0
- package/src/components/Checkbox/Checkbox.stories.mdx +57 -35
- package/src/components/Checkbox/Checkbox.test.tsx +117 -147
- package/src/components/Checkbox/Checkbox.tsx +76 -50
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +325 -0
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +249 -0
- package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +345 -0
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +148 -0
- package/src/components/CheckboxGroup/CheckboxGroupLayoutTypes.tsx +4 -0
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +1360 -0
- package/src/components/DatePicker/DatePicker.stories.mdx +284 -0
- package/src/components/DatePicker/DatePicker.test.tsx +657 -0
- package/src/components/DatePicker/DatePicker.tsx +396 -0
- package/src/components/DatePicker/DatePickerTypes.tsx +5 -0
- package/src/components/DatePicker/_DatePicker.scss +76 -0
- package/src/components/Form/Form.stories.mdx +130 -27
- package/src/components/Form/Form.test.tsx +78 -36
- package/src/components/Form/Form.tsx +53 -19
- package/src/components/Form/FormTypes.tsx +3 -0
- package/src/components/Form/__snapshots__/Form.test.tsx.snap +38 -0
- package/src/components/Grid/GridTypes.tsx +9 -0
- package/src/components/Grid/SimpleGrid.stories.mdx +275 -0
- package/src/components/Grid/SimpleGrid.test.tsx +66 -0
- package/src/components/Grid/SimpleGrid.tsx +37 -0
- package/src/components/Grid/__snapshots__/SimpleGrid.test.tsx.snap +8 -0
- package/src/components/Heading/Heading.stories.mdx +63 -33
- package/src/components/Heading/Heading.test.tsx +24 -16
- package/src/components/Heading/Heading.tsx +54 -38
- package/src/components/Heading/{HeadingDisplaySizes.tsx → HeadingTypes.tsx} +9 -0
- package/src/components/HelperErrorText/HelperErrorText.stories.tsx +2 -1
- package/src/components/HelperErrorText/_HelperErrorText.scss +1 -1
- package/src/components/Hero/Hero.stories.mdx +195 -85
- package/src/components/Hero/Hero.test.tsx +544 -113
- package/src/components/Hero/Hero.tsx +80 -93
- package/src/components/Hero/HeroTypes.tsx +17 -5
- package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +307 -0
- package/src/components/HorizontalRule/HorizontalRule.stories.mdx +6 -1
- package/src/components/HorizontalRule/_HorizontalRule.scss +1 -1
- package/src/components/Icons/Icon.stories.mdx +89 -74
- package/src/components/Icons/Icon.test.tsx +30 -22
- package/src/components/Icons/Icon.tsx +63 -61
- package/src/components/Icons/IconSvgs.tsx +8 -0
- package/src/components/Icons/IconTypes.tsx +80 -60
- package/src/components/Image/Image.stories.tsx +2 -1
- package/src/components/Input/_Input.scss +2 -2
- package/src/components/Label/Label.stories.mdx +77 -0
- package/src/components/Label/Label.test.tsx +43 -12
- package/src/components/Label/Label.tsx +28 -45
- package/src/components/Label/__snapshots__/Label.test.tsx.snap +41 -0
- package/src/components/Link/Link.stories.mdx +47 -41
- package/src/components/Link/Link.test.tsx +33 -44
- package/src/components/Link/Link.tsx +114 -100
- package/src/components/List/List.stories.mdx +7 -3
- package/src/components/List/List.stories.tsx +14 -9
- package/src/components/List/List.test.tsx +12 -8
- package/src/components/List/List.tsx +9 -7
- package/src/components/List/_List.scss +3 -3
- package/src/components/Modal/Modal.stories.mdx +7 -3
- package/src/components/Modal/_Modal.scss +1 -1
- package/src/components/Notification/Notification.stories.mdx +99 -65
- package/src/components/Notification/Notification.test.tsx +3 -16
- package/src/components/Notification/Notification.tsx +12 -12
- package/src/components/Notification/_Notification.scss +5 -4
- package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +1 -1
- package/src/components/Pagination/Pagination.stories.mdx +7 -1
- package/src/components/Pagination/Pagination.test.tsx +16 -10
- package/src/components/Radio/Radio.stories.mdx +57 -46
- package/src/components/Radio/Radio.test.tsx +92 -138
- package/src/components/Radio/Radio.tsx +70 -69
- package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +250 -0
- package/src/components/RadioGroup/RadioGroup.stories.mdx +247 -0
- package/src/components/RadioGroup/RadioGroup.test.tsx +327 -0
- package/src/components/RadioGroup/RadioGroup.tsx +154 -0
- package/src/components/RadioGroup/RadioGroupLayoutTypes.tsx +4 -0
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +1101 -0
- package/src/components/SearchBar/SearchBar.Test.tsx +151 -16
- package/src/components/SearchBar/SearchBar.stories.mdx +196 -224
- package/src/components/SearchBar/SearchBar.tsx +151 -46
- package/src/components/Select/Select.stories.mdx +193 -168
- package/src/components/Select/Select.test.tsx +129 -324
- package/src/components/Select/Select.tsx +120 -160
- package/src/components/Select/SelectTypes.tsx +4 -0
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +18 -29
- package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +7 -7
- package/src/components/SkeletonLoader/SkeletonLoader.tsx +4 -2
- package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +2 -2
- package/src/components/SkeletonLoader/_SkeletonLoader.scss +3 -3
- package/src/components/StatusBadge/StatusBadge.stories.mdx +91 -0
- package/src/components/StatusBadge/StatusBadge.test.tsx +35 -7
- package/src/components/StatusBadge/StatusBadge.tsx +24 -25
- package/src/components/StatusBadge/StatusBadgeTypes.tsx +5 -0
- package/src/components/StatusBadge/__snapshots__/StatusBadge.test.tsx.snap +28 -0
- package/src/components/StyleGuide/Bidirectionality.stories.mdx +112 -90
- package/src/components/StyleGuide/Buttons.stories.mdx +98 -100
- package/src/components/StyleGuide/Colors.stories.mdx +336 -0
- package/src/components/StyleGuide/Forms.stories.mdx +85 -0
- package/src/components/StyleGuide/Iconography.stories.mdx +86 -93
- package/src/components/StyleGuide/Spacing.stories.mdx +0 -1
- package/src/components/StyleGuide/Typography.stories.mdx +164 -166
- package/src/components/StyleGuide/UIDocCard.tsx +4 -4
- package/src/components/Tabs/Tabs.stories.mdx +221 -0
- package/src/components/Tabs/Tabs.test.tsx +264 -0
- package/src/components/Tabs/Tabs.tsx +220 -0
- package/src/components/Template/Template.stories.mdx +574 -0
- package/src/components/Template/Template.test.tsx +124 -0
- package/src/components/Template/Template.tsx +226 -0
- package/src/components/Text/Text.stories.mdx +70 -0
- package/src/components/Text/Text.test.tsx +63 -0
- package/src/components/Text/Text.tsx +55 -0
- package/src/components/Text/TextTypes.tsx +6 -0
- package/src/components/Text/__snapshots__/Text.test.tsx.snap +33 -0
- package/src/components/TextInput/TextInput.stories.mdx +90 -90
- package/src/components/TextInput/TextInput.test.tsx +103 -83
- package/src/components/TextInput/TextInput.tsx +108 -91
- package/src/components/TextInput/TextInputTypes.tsx +6 -0
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +2 -1
- package/src/components/VideoPlayer/VideoPlayer.tsx +4 -2
- package/src/components/VideoPlayer/_VideoPlayer.scss +1 -1
- package/src/docs/Chakra.stories.mdx +341 -0
- package/src/docs/Intro.stories.mdx +31 -24
- package/src/index.ts +70 -5
- package/src/styles/01-colors/_colors-brand.scss +6 -4
- package/src/styles/01-colors/_colors-utility.scss +14 -15
- package/src/styles/03-space/_space-inline.scss +47 -7
- package/src/styles/03-space/_space-inset.scss +33 -5
- package/src/styles/03-space/_space-stack.scss +48 -8
- package/src/styles/base/_02-breakpoints.scss +5 -4
- package/src/styles/base/_04-base.scss +2 -1
- package/src/styles/base/_place-holder.scss +1 -1
- package/src/styles/base/_typography.scss +1 -29
- package/src/styles.scss +22 -25
- package/src/theme/components/accordion.ts +30 -0
- package/src/theme/components/breadcrumb.ts +77 -0
- package/src/theme/components/button.ts +125 -0
- package/src/theme/components/checkbox.ts +107 -0
- package/src/theme/components/customCheckboxGroup.ts +12 -0
- package/src/theme/components/customRadioGroup.ts +12 -0
- package/src/theme/components/global.ts +71 -0
- package/src/theme/components/globalMixins.ts +16 -0
- package/src/theme/components/heading.ts +72 -0
- package/src/theme/components/hero.ts +239 -0
- package/src/theme/components/icon.ts +79 -0
- package/src/theme/components/label.ts +17 -0
- package/src/theme/components/link.ts +47 -0
- package/src/theme/components/radio.ts +106 -0
- package/src/theme/components/searchBar.ts +21 -0
- package/src/theme/components/select.ts +50 -0
- package/src/theme/components/statusBadge.ts +27 -0
- package/src/theme/components/tabs.ts +79 -0
- package/src/theme/components/template.ts +114 -0
- package/src/theme/components/text.ts +31 -0
- package/src/theme/components/textInput.ts +61 -0
- package/src/theme/foundations/breakpoints.ts +24 -0
- package/src/theme/foundations/colors.ts +208 -0
- package/src/theme/foundations/global.ts +26 -0
- package/src/theme/foundations/shadows.ts +5 -0
- package/src/theme/foundations/spacing.ts +85 -0
- package/src/theme/foundations/typography.ts +35 -0
- package/src/theme/index.ts +88 -0
- package/src/theme/provider.tsx +9 -0
- package/src/theme/types.ts +1 -0
- package/src/utils/componentCategories.ts +56 -21
- package/src/utils/utils.ts +13 -0
- package/dist/components/Accordion/Accordion.stories.d.ts +0 -5
- package/dist/components/Card/Card.stories.d.ts +0 -27
- package/dist/components/Label/Label.stories.d.ts +0 -12
- package/dist/components/StatusBadge/StatusBadge.stories.d.ts +0 -8
- package/dist/components/Template/Template.stories.d.ts +0 -29
- package/src/components/Accordion/Accordion.stories.tsx +0 -65
- package/src/components/Accordion/_Accordion.scss +0 -81
- package/src/components/Breadcrumbs/_Breadcrumbs.scss +0 -97
- package/src/components/Checkbox/_Checkbox.scss +0 -97
- package/src/components/Form/_Form.scss +0 -28
- package/src/components/Heading/_Heading.scss +0 -163
- package/src/components/Hero/_Hero.scss +0 -256
- package/src/components/Icons/_Icons.scss +0 -116
- package/src/components/Label/Label.stories.tsx +0 -30
- package/src/components/Label/_Label.scss +0 -22
- package/src/components/Link/_Link.scss +0 -73
- package/src/components/Radio/_Radio.scss +0 -84
- package/src/components/SearchBar/_SearchBar.scss +0 -16
- package/src/components/Select/_Select.scss +0 -82
- package/src/components/StatusBadge/StatusBadge.stories.tsx +0 -33
- package/src/components/StatusBadge/_StatusBadge.scss +0 -23
- package/src/components/StyleGuide/Colors.stories.tsx +0 -288
- package/src/components/Template/Template.stories.tsx +0 -85
- package/src/components/Template/_Template.scss +0 -63
- 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;
|
|
@@ -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 "./
|
|
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
|
-
<
|
|
46
|
+
<Canvas withToolbar>
|
|
40
47
|
<Story
|
|
41
48
|
name="Heading Props"
|
|
42
49
|
args={{
|
|
43
|
-
id: "
|
|
44
|
-
|
|
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
|
-
</
|
|
56
|
+
</Canvas>
|
|
51
57
|
|
|
52
58
|
<ArgsTable story="Heading Props" />
|
|
53
59
|
|
|
54
60
|
## Default Heading Styles
|
|
55
61
|
|
|
56
|
-
<
|
|
62
|
+
<Canvas>
|
|
57
63
|
<Story name="Default Heading Styles">
|
|
58
64
|
<div>
|
|
59
|
-
<Heading
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
<Heading
|
|
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
|
-
</
|
|
97
|
+
</Canvas>
|
|
68
98
|
|
|
69
99
|
## DisplaySize Styles
|
|
70
100
|
|
|
71
|
-
<
|
|
101
|
+
<Canvas>
|
|
72
102
|
<Story name="DisplaySize Styles">
|
|
73
103
|
<div>
|
|
74
104
|
<Heading
|
|
75
|
-
id="
|
|
76
|
-
level={
|
|
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="
|
|
82
|
-
level={
|
|
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="
|
|
88
|
-
level={
|
|
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="
|
|
94
|
-
level={
|
|
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
|
-
</
|
|
130
|
+
</Canvas>
|
|
101
131
|
|
|
102
132
|
## Heading with Bold
|
|
103
133
|
|
|
104
|
-
<
|
|
134
|
+
<Canvas>
|
|
105
135
|
<Story name="Heading with Bold">
|
|
106
|
-
<Heading id="headingWithBold" level={
|
|
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
|
-
</
|
|
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
|
-
<
|
|
148
|
+
<Canvas>
|
|
119
149
|
<Story name="Headings with Links">
|
|
120
150
|
<Heading
|
|
121
|
-
id="
|
|
122
|
-
level={
|
|
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="
|
|
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
|
-
</
|
|
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 "./
|
|
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={
|
|
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={
|
|
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={
|
|
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={
|
|
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={
|
|
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={
|
|
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(
|
|
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={
|
|
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")
|
|
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={
|
|
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={
|
|
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 })).
|
|
111
|
-
"
|
|
112
|
-
|
|
113
|
-
);
|
|
119
|
+
expect(screen.getByRole("heading", { level: 1 })).toHaveStyle({
|
|
120
|
+
"font-size": "2em",
|
|
121
|
+
});
|
|
114
122
|
});
|
|
115
123
|
});
|