@nypl/design-system-react-components 0.25.0 → 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 +30 -0
- package/dist/components/Accordion/Accordion.d.ts +14 -14
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +11 -14
- package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +6 -0
- package/dist/components/Button/ButtonTypes.d.ts +2 -1
- package/dist/components/Card/Card.d.ts +1 -1
- package/dist/components/Card/CardTypes.d.ts +2 -2
- 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 +3 -3
- package/dist/components/Form/Form.d.ts +13 -8
- package/dist/components/Form/FormTypes.d.ts +2 -8
- 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 +4 -4
- 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/IconTypes.d.ts +78 -64
- package/dist/components/Label/Label.d.ts +5 -17
- package/dist/components/Link/Link.d.ts +8 -12
- package/dist/components/SearchBar/SearchBar.d.ts +45 -27
- package/dist/components/Select/Select.d.ts +32 -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/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 +32 -31
- package/dist/components/TextInput/TextInputTypes.d.ts +5 -0
- package/dist/design-system-react-components.cjs.development.js +2597 -1170
- 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 +2580 -1173
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/index.d.ts +8 -1
- 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 +17 -7
- package/dist/theme/components/checkbox.d.ts +7 -7
- package/dist/theme/components/customCheckboxGroup.d.ts +18 -0
- package/dist/theme/components/customRadioGroup.d.ts +4 -3
- 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 +50 -20
- 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 +8 -7
- 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 +9 -9
- 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/global.d.ts +3 -0
- package/dist/theme/foundations/shadows.d.ts +4 -0
- package/dist/utils/utils.d.ts +6 -0
- package/package.json +3 -2
- package/src/components/Accordion/Accordion.stories.mdx +227 -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 +1 -1
- package/src/components/Autosuggest/Autosuggest.stories.tsx +1 -1
- package/src/components/Autosuggest/_Autosuggest.scss +2 -2
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +46 -52
- 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 +31 -27
- package/src/components/Button/Button.test.tsx +17 -5
- package/src/components/Button/ButtonTypes.tsx +1 -0
- package/src/components/Button/_Button.scss +3 -27
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +11 -0
- package/src/components/Card/Card.stories.mdx +24 -20
- package/src/components/Card/Card.test.tsx +13 -19
- package/src/components/Card/Card.tsx +1 -1
- package/src/components/Card/CardTypes.tsx +2 -2
- package/src/components/Card/_Card.scss +1 -1
- package/src/components/CardEdition/CardEdition.stories.tsx +11 -6
- package/src/components/CardEdition/CardEdition.test.tsx +23 -31
- package/src/components/CardEdition/_CardEdition.scss +2 -2
- package/src/components/Chakra/Center.stories.mdx +31 -14
- package/src/components/Chakra/Grid.stories.mdx +79 -0
- package/src/components/Chakra/Stack.stories.mdx +4 -4
- package/src/components/Checkbox/Checkbox.tsx +9 -12
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +2 -5
- 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.test.tsx +4 -4
- package/src/components/DatePicker/DatePicker.tsx +13 -13
- package/src/components/DatePicker/_DatePicker.scss +1 -0
- package/src/components/Form/Form.stories.mdx +46 -21
- package/src/components/Form/Form.test.tsx +58 -45
- package/src/components/Form/Form.tsx +49 -21
- package/src/components/Form/FormTypes.tsx +3 -8
- package/src/components/Form/__snapshots__/Form.test.tsx.snap +24 -14
- 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 +1 -0
- package/src/components/Heading/Heading.tsx +12 -6
- package/src/components/HelperErrorText/_HelperErrorText.scss +1 -1
- package/src/components/Hero/Hero.stories.mdx +188 -121
- package/src/components/Hero/Hero.test.tsx +537 -107
- package/src/components/Hero/Hero.tsx +79 -92
- package/src/components/Hero/HeroTypes.tsx +17 -5
- package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +307 -0
- package/src/components/HorizontalRule/_HorizontalRule.scss +1 -1
- package/src/components/Icons/Icon.stories.mdx +83 -74
- package/src/components/Icons/Icon.test.tsx +30 -22
- package/src/components/Icons/Icon.tsx +63 -61
- package/src/components/Icons/IconTypes.tsx +80 -64
- package/src/components/Input/_Input.scss +2 -2
- package/src/components/Label/Label.stories.mdx +28 -7
- package/src/components/Label/Label.test.tsx +43 -12
- package/src/components/Label/Label.tsx +21 -34
- package/src/components/Label/__snapshots__/Label.test.tsx.snap +41 -0
- package/src/components/Link/Link.stories.mdx +41 -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 +0 -2
- package/src/components/List/List.stories.tsx +5 -5
- package/src/components/List/_List.scss +3 -3
- package/src/components/Modal/_Modal.scss +1 -1
- package/src/components/Notification/Notification.stories.mdx +12 -1
- package/src/components/Notification/Notification.test.tsx +3 -16
- package/src/components/Notification/Notification.tsx +9 -10
- package/src/components/Notification/_Notification.scss +4 -4
- package/src/components/Pagination/Pagination.test.tsx +16 -10
- package/src/components/RadioGroup/RadioGroup.stories.mdx +1 -1
- package/src/components/RadioGroup/RadioGroup.tsx +2 -10
- package/src/components/SearchBar/SearchBar.Test.tsx +151 -16
- package/src/components/SearchBar/SearchBar.stories.mdx +189 -219
- package/src/components/SearchBar/SearchBar.tsx +151 -46
- package/src/components/Select/Select.stories.mdx +188 -170
- package/src/components/Select/Select.test.tsx +125 -380
- package/src/components/Select/Select.tsx +118 -165
- package/src/components/Select/SelectTypes.tsx +4 -0
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +13 -25
- 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 +16 -16
- package/src/components/StyleGuide/Buttons.stories.mdx +15 -15
- package/src/components/StyleGuide/Colors.stories.mdx +336 -0
- package/src/components/StyleGuide/Iconography.stories.mdx +88 -90
- package/src/components/StyleGuide/UIDocCard.tsx +1 -1
- package/src/components/Tabs/Tabs.tsx +7 -9
- 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 +89 -90
- package/src/components/TextInput/TextInput.test.tsx +65 -86
- package/src/components/TextInput/TextInput.tsx +101 -95
- package/src/components/TextInput/TextInputTypes.tsx +6 -0
- package/src/components/VideoPlayer/_VideoPlayer.scss +1 -1
- package/src/docs/Chakra.stories.mdx +4 -4
- package/src/docs/Intro.stories.mdx +15 -13
- package/src/index.ts +20 -0
- package/src/styles/01-colors/_colors-brand.scss +6 -0
- package/src/styles/01-colors/_colors-utility.scss +14 -12
- package/src/styles/base/_04-base.scss +2 -1
- package/src/styles/base/_place-holder.scss +1 -1
- package/src/styles.scss +10 -12
- package/src/theme/components/accordion.ts +30 -0
- package/src/theme/components/breadcrumb.ts +77 -0
- package/src/theme/components/button.ts +77 -63
- package/src/theme/components/checkbox.ts +15 -27
- package/src/theme/components/customCheckboxGroup.ts +12 -0
- package/src/theme/components/customRadioGroup.ts +4 -10
- package/src/theme/components/global.ts +71 -0
- package/src/theme/components/globalMixins.ts +16 -0
- package/src/theme/components/heading.ts +15 -8
- 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 +20 -31
- 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 +72 -69
- 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/colors.ts +29 -13
- package/src/theme/foundations/global.ts +3 -0
- package/src/theme/foundations/shadows.ts +5 -0
- package/src/theme/index.ts +37 -7
- package/src/utils/componentCategories.ts +8 -2
- package/src/utils/utils.ts +13 -0
- package/dist/components/Accordion/Accordion.stories.d.ts +0 -6
- package/dist/components/StatusBadge/StatusBadge.stories.d.ts +0 -8
- package/dist/components/StyleGuide/Colors.stories.d.ts +0 -25
- package/dist/components/Template/Template.stories.d.ts +0 -30
- package/src/components/Accordion/Accordion.stories.tsx +0 -66
- package/src/components/Accordion/_Accordion.scss +0 -81
- package/src/components/Breadcrumbs/_Breadcrumbs.scss +0 -97
- package/src/components/Form/_Form.scss +0 -67
- package/src/components/Hero/_Hero.scss +0 -256
- package/src/components/Icons/_Icons.scss +0 -116
- package/src/components/Label/_Label.scss +0 -22
- package/src/components/Link/_Link.scss +0 -73
- package/src/components/SearchBar/_SearchBar.scss +0 -16
- package/src/components/Select/_Select.scss +0 -82
- package/src/components/StatusBadge/StatusBadge.stories.tsx +0 -34
- package/src/components/StatusBadge/_StatusBadge.scss +0 -23
- package/src/components/StyleGuide/Colors.stories.tsx +0 -289
- package/src/components/Template/Template.stories.tsx +0 -86
- 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;
|
|
@@ -10,8 +10,6 @@ import {
|
|
|
10
10
|
import { HeadingDisplaySizes, HeadingLevels } from "./HeadingTypes";
|
|
11
11
|
|
|
12
12
|
export interface HeadingProps {
|
|
13
|
-
/** BlockName for use with BEM. See how to work with blockNames and BEM here: http://getbem.com/introduction/ */
|
|
14
|
-
blockName?: string;
|
|
15
13
|
/** Optional className that appears in addition to `heading` */
|
|
16
14
|
className?: string;
|
|
17
15
|
/** Optional size used to override the default styles of the semantic HTML `<h>` elements */
|
|
@@ -20,8 +18,8 @@ export interface HeadingProps {
|
|
|
20
18
|
id?: string;
|
|
21
19
|
/** Optional number 1-6 used to create the `<h*>` tag; if prop is not passed, `Heading` will default to `<h2>` */
|
|
22
20
|
level?: HeadingLevels;
|
|
23
|
-
/**
|
|
24
|
-
|
|
21
|
+
/** Optionally pass in additional Chakra-based styles. */
|
|
22
|
+
sx?: { [key: string]: any };
|
|
25
23
|
/** Inner text of the `<h*>` element */
|
|
26
24
|
text?: string;
|
|
27
25
|
/** Optional URL that header points to; when `url` prop is passed to `Heading`, a child `<a>` element is created and the heading text becomes an active link */
|
|
@@ -49,13 +47,16 @@ function Heading(props: React.PropsWithChildren<HeadingProps>) {
|
|
|
49
47
|
displaySize,
|
|
50
48
|
id,
|
|
51
49
|
level = HeadingLevels.Two,
|
|
50
|
+
sx = {},
|
|
52
51
|
text,
|
|
53
52
|
url,
|
|
54
53
|
urlClass,
|
|
55
54
|
} = props;
|
|
56
|
-
|
|
57
55
|
const variant = displaySize ? getVariant(displaySize) : `h${level}`;
|
|
58
56
|
const styles = useStyleConfig("Heading", { variant });
|
|
57
|
+
// Combine native base styles with any additional styles.
|
|
58
|
+
// This is used only in the `Hero` component, for now.
|
|
59
|
+
const finalStyles = { ...styles, ...sx };
|
|
59
60
|
const asHeading: any = `h${level}`;
|
|
60
61
|
|
|
61
62
|
if (level < 1 || level > 6) {
|
|
@@ -87,7 +88,12 @@ function Heading(props: React.PropsWithChildren<HeadingProps>) {
|
|
|
87
88
|
);
|
|
88
89
|
|
|
89
90
|
return (
|
|
90
|
-
<ChakraHeading
|
|
91
|
+
<ChakraHeading
|
|
92
|
+
id={id}
|
|
93
|
+
as={asHeading}
|
|
94
|
+
sx={finalStyles}
|
|
95
|
+
className={className}
|
|
96
|
+
>
|
|
91
97
|
{content}
|
|
92
98
|
</ChakraHeading>
|
|
93
99
|
);
|