@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
|
@@ -3,16 +3,16 @@ import {
|
|
|
3
3
|
Story,
|
|
4
4
|
Canvas,
|
|
5
5
|
ArgsTable,
|
|
6
|
-
Preview,
|
|
7
6
|
Description,
|
|
8
7
|
} from "@storybook/addon-docs/blocks";
|
|
9
8
|
import { withDesign } from "storybook-addon-designs";
|
|
10
9
|
|
|
11
10
|
import Breadcrumbs from "./Breadcrumbs";
|
|
11
|
+
import { ColorVariants } from "./BreadcrumbsTypes";
|
|
12
|
+
import DSProvider from "../../theme/provider";
|
|
12
13
|
import Heading from "../Heading/Heading";
|
|
13
14
|
import { HeadingLevels } from "../Heading/HeadingTypes";
|
|
14
15
|
import Link from "../Link/Link";
|
|
15
|
-
import sections from "../../utils/siteSections";
|
|
16
16
|
import { getCategory } from "../../utils/componentCategories";
|
|
17
17
|
|
|
18
18
|
<Meta
|
|
@@ -23,14 +23,13 @@ import { getCategory } from "../../utils/componentCategories";
|
|
|
23
23
|
design: {
|
|
24
24
|
type: "figma",
|
|
25
25
|
url:
|
|
26
|
-
"https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/
|
|
26
|
+
"https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Main?node-id=10766%3A1031",
|
|
27
27
|
},
|
|
28
28
|
jest: ["Breadcrumbs.test.tsx"],
|
|
29
29
|
}}
|
|
30
30
|
argTypes={{
|
|
31
|
-
|
|
31
|
+
id: { table: { disable: true } },
|
|
32
32
|
className: { table: { disable: true } },
|
|
33
|
-
modifiers: { table: { disable: true } },
|
|
34
33
|
}}
|
|
35
34
|
/>
|
|
36
35
|
|
|
@@ -39,72 +38,63 @@ import { getCategory } from "../../utils/componentCategories";
|
|
|
39
38
|
| Component Version | DS Version |
|
|
40
39
|
| ----------------- | ---------- |
|
|
41
40
|
| Added | `0.0.3` |
|
|
42
|
-
| Latest | `0.
|
|
41
|
+
| Latest | `0.25.1` |
|
|
43
42
|
|
|
44
43
|
<Description of={Breadcrumbs} />
|
|
45
44
|
|
|
46
45
|
The `Breadcrumbs` component is a navigation element that provides a breadcrumb path that reflects the site structure and allows a user to navigate to any page available in the breadcrumb hierarchy.
|
|
47
46
|
|
|
48
|
-
<
|
|
47
|
+
<Canvas withToolbar>
|
|
49
48
|
<Story
|
|
50
|
-
name="
|
|
49
|
+
name="Breadcrumbs Props"
|
|
51
50
|
args={{
|
|
52
|
-
|
|
51
|
+
breadcrumbsData: [
|
|
53
52
|
{ url: "#", text: "Parent" },
|
|
54
53
|
{ url: "#", text: "Child" },
|
|
55
54
|
{ url: "#", text: "Grandchild" },
|
|
56
55
|
],
|
|
56
|
+
id: "init-breadcrumbs",
|
|
57
57
|
}}
|
|
58
58
|
>
|
|
59
59
|
{(args) => <Breadcrumbs {...args} />}
|
|
60
60
|
</Story>
|
|
61
|
-
</
|
|
61
|
+
</Canvas>
|
|
62
62
|
|
|
63
|
-
<ArgsTable story="
|
|
63
|
+
<ArgsTable story="Breadcrumbs Props" />
|
|
64
64
|
|
|
65
65
|
### Long Titles
|
|
66
66
|
|
|
67
67
|
<Canvas>
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
68
|
+
<DSProvider>
|
|
69
|
+
<Breadcrumbs
|
|
70
|
+
breadcrumbsData={[
|
|
71
|
+
{ url: "#", text: "Parent with a Long Name" },
|
|
72
|
+
{ url: "#", text: "Child with an Even Longer Name" },
|
|
73
|
+
{
|
|
74
|
+
url: "#",
|
|
75
|
+
text: "Grandchild with an Exceptionally Long Name",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
url: "#",
|
|
79
|
+
text:
|
|
80
|
+
"Great-Grandchild with the Longest Name That Will Wrap onto the Second Line of the Breadcrumb Component Under the Right Circumstances",
|
|
81
|
+
},
|
|
82
|
+
]}
|
|
83
|
+
/>
|
|
84
|
+
</DSProvider>
|
|
83
85
|
</Canvas>
|
|
84
86
|
|
|
85
87
|
## Color Variations
|
|
86
88
|
|
|
87
|
-
The `Breadcrumbs` component background color
|
|
89
|
+
The `Breadcrumbs` component background color can be set using the `colorVariant` prop and the `ColorVariants` enum. If the `colorVariant` prop is omitted, the default background color is `black`.
|
|
88
90
|
|
|
89
|
-
<
|
|
90
|
-
<Story
|
|
91
|
-
name="Color Variations"
|
|
92
|
-
args={{
|
|
93
|
-
breadcrumbs: [
|
|
94
|
-
{ url: "#", text: "Parent" },
|
|
95
|
-
{ url: "#", text: "Child" },
|
|
96
|
-
{
|
|
97
|
-
url: "#",
|
|
98
|
-
text: "Grandchild",
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
}}
|
|
102
|
-
>
|
|
91
|
+
<Canvas>
|
|
92
|
+
<Story name="Color Variations" args={{}}>
|
|
103
93
|
{(args) => (
|
|
104
94
|
<div className="nypl--books-and-more">
|
|
105
95
|
<Heading level={HeadingLevels.Three}>Books and More</Heading>
|
|
106
96
|
<Breadcrumbs
|
|
107
|
-
|
|
97
|
+
breadcrumbsData={[
|
|
108
98
|
{ url: "#", text: "Parent" },
|
|
109
99
|
{ url: "#", text: "Child" },
|
|
110
100
|
{
|
|
@@ -112,17 +102,18 @@ The `Breadcrumbs` component background color will match the secondary section co
|
|
|
112
102
|
text: "Grandchild",
|
|
113
103
|
},
|
|
114
104
|
]}
|
|
105
|
+
colorVariant={ColorVariants.BooksAndMore}
|
|
115
106
|
/>
|
|
116
107
|
</div>
|
|
117
108
|
)}
|
|
118
109
|
</Story>
|
|
119
|
-
</
|
|
110
|
+
</Canvas>
|
|
120
111
|
|
|
121
112
|
<Canvas>
|
|
122
|
-
<
|
|
113
|
+
<DSProvider>
|
|
123
114
|
<Heading level={HeadingLevels.Three}>Locations</Heading>
|
|
124
115
|
<Breadcrumbs
|
|
125
|
-
|
|
116
|
+
breadcrumbsData={[
|
|
126
117
|
{ url: "#", text: "Parent" },
|
|
127
118
|
{ url: "#", text: "Child" },
|
|
128
119
|
{
|
|
@@ -130,15 +121,16 @@ The `Breadcrumbs` component background color will match the secondary section co
|
|
|
130
121
|
text: "Grandchild",
|
|
131
122
|
},
|
|
132
123
|
]}
|
|
124
|
+
colorVariant={ColorVariants.Locations}
|
|
133
125
|
/>
|
|
134
|
-
</
|
|
126
|
+
</DSProvider>
|
|
135
127
|
</Canvas>
|
|
136
128
|
|
|
137
129
|
<Canvas>
|
|
138
|
-
<
|
|
130
|
+
<DSProvider>
|
|
139
131
|
<Heading level={HeadingLevels.Three}>Research</Heading>
|
|
140
132
|
<Breadcrumbs
|
|
141
|
-
|
|
133
|
+
breadcrumbsData={[
|
|
142
134
|
{ url: "#", text: "Parent" },
|
|
143
135
|
{ url: "#", text: "Child" },
|
|
144
136
|
{
|
|
@@ -146,15 +138,16 @@ The `Breadcrumbs` component background color will match the secondary section co
|
|
|
146
138
|
text: "Grandchild",
|
|
147
139
|
},
|
|
148
140
|
]}
|
|
141
|
+
colorVariant={ColorVariants.Research}
|
|
149
142
|
/>
|
|
150
|
-
</
|
|
143
|
+
</DSProvider>
|
|
151
144
|
</Canvas>
|
|
152
145
|
|
|
153
146
|
<Canvas>
|
|
154
|
-
<
|
|
147
|
+
<DSProvider>
|
|
155
148
|
<Heading level={HeadingLevels.Three}>What's On</Heading>
|
|
156
149
|
<Breadcrumbs
|
|
157
|
-
|
|
150
|
+
breadcrumbsData={[
|
|
158
151
|
{ url: "#", text: "Parent" },
|
|
159
152
|
{ url: "#", text: "Child" },
|
|
160
153
|
{
|
|
@@ -162,6 +155,7 @@ The `Breadcrumbs` component background color will match the secondary section co
|
|
|
162
155
|
text: "Grandchild",
|
|
163
156
|
},
|
|
164
157
|
]}
|
|
158
|
+
colorVariant={ColorVariants.WhatsOn}
|
|
165
159
|
/>
|
|
166
|
-
</
|
|
160
|
+
</DSProvider>
|
|
167
161
|
</Canvas>
|
|
@@ -1,62 +1,68 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import renderer from "react-test-renderer";
|
|
3
4
|
import { axe } from "jest-axe";
|
|
4
5
|
|
|
5
6
|
import Breadcrumbs from "./Breadcrumbs";
|
|
6
7
|
|
|
7
8
|
describe("Breadcrumbs Accessibility", () => {
|
|
8
|
-
const
|
|
9
|
+
const breadcrumbsData = [
|
|
9
10
|
{ url: "#string1", text: "string1" },
|
|
10
11
|
{ url: "#string2", text: "string2" },
|
|
11
12
|
];
|
|
12
13
|
it("passes axe accessibility test", async () => {
|
|
13
14
|
const { container } = render(
|
|
14
|
-
<Breadcrumbs
|
|
15
|
+
<Breadcrumbs breadcrumbsData={breadcrumbsData} />
|
|
15
16
|
);
|
|
16
17
|
expect(await axe(container)).toHaveNoViolations();
|
|
17
18
|
});
|
|
18
19
|
});
|
|
19
20
|
|
|
20
|
-
describe("Breadcrumbs", () => {
|
|
21
|
-
|
|
21
|
+
describe("Breadcrumbs Snapshot", () => {
|
|
22
|
+
it("Renders the UI snapshot correctly", () => {
|
|
23
|
+
const breadcrumbsData = [
|
|
24
|
+
{ url: "#string1", text: "string1" },
|
|
25
|
+
{ url: "#string2", text: "string2" },
|
|
26
|
+
{ url: "#string3", text: "string3" },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const breadcrumbsSnapshot = renderer
|
|
30
|
+
.create(
|
|
31
|
+
<Breadcrumbs id="breadcrumbs-test" breadcrumbsData={breadcrumbsData} />
|
|
32
|
+
)
|
|
33
|
+
.toJSON();
|
|
34
|
+
|
|
35
|
+
expect(breadcrumbsSnapshot).toMatchSnapshot();
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe("Breadcrumbs Testing", () => {
|
|
40
|
+
const breadcrumbsData = [
|
|
22
41
|
{ url: "#string1", text: "string1" },
|
|
23
42
|
{ url: "#string2", text: "string2" },
|
|
24
|
-
|
|
25
|
-
const breadcrumbComponent = [
|
|
26
|
-
<a key="link1" href="#component1">
|
|
27
|
-
<span>component1</span>
|
|
28
|
-
</a>,
|
|
29
|
-
<a key="link2" href="#component2">
|
|
30
|
-
component2
|
|
31
|
-
</a>,
|
|
43
|
+
{ url: "#string3", text: "string3" },
|
|
32
44
|
];
|
|
33
45
|
|
|
34
46
|
it("Renders a tag with custom text", () => {
|
|
35
|
-
render(<Breadcrumbs
|
|
47
|
+
render(<Breadcrumbs breadcrumbsData={breadcrumbsData} />);
|
|
36
48
|
|
|
49
|
+
// The last breadcrumb (the active page) is not a link.
|
|
37
50
|
expect(screen.getAllByRole("link")).toHaveLength(2);
|
|
38
51
|
expect(screen.getAllByRole("link")[0]).toHaveTextContent("string1");
|
|
39
52
|
expect(screen.getAllByRole("link")[1]).toHaveTextContent("string2");
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
it("Renders breadcrumb when passed components", () => {
|
|
43
|
-
render(<Breadcrumbs breadcrumbs={breadcrumbComponent} />);
|
|
44
|
-
|
|
45
|
-
expect(screen.getAllByRole("link")).toHaveLength(2);
|
|
46
|
-
expect(screen.getAllByRole("link")[0]).toHaveTextContent("component1");
|
|
47
|
-
expect(screen.getAllByRole("link")[1]).toHaveTextContent("component2");
|
|
53
|
+
expect(screen.getByText(/string3/)).toBeInTheDocument();
|
|
48
54
|
});
|
|
49
55
|
|
|
50
56
|
it("Renders icon", () => {
|
|
51
57
|
const { container } = render(
|
|
52
|
-
<Breadcrumbs
|
|
58
|
+
<Breadcrumbs breadcrumbsData={breadcrumbsData} />
|
|
53
59
|
);
|
|
54
|
-
expect(container.querySelector(".
|
|
60
|
+
expect(container.querySelector(".breadcrumbs-icon")).toBeInTheDocument();
|
|
55
61
|
});
|
|
56
62
|
|
|
57
63
|
it("Throws error when nothing is passed into Breadcrumb", () => {
|
|
58
|
-
expect(() => render(<Breadcrumbs
|
|
59
|
-
"
|
|
64
|
+
expect(() => render(<Breadcrumbs breadcrumbsData={[]} />)).toThrowError(
|
|
65
|
+
"You must use the `breadcrumbsData` prop to pass a data object to the Breadcrumbs component. That prop is current empty."
|
|
60
66
|
);
|
|
61
67
|
});
|
|
62
68
|
});
|
|
@@ -1,92 +1,90 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
Breadcrumb as ChakraBreadcrumb,
|
|
4
|
+
BreadcrumbItem,
|
|
5
|
+
BreadcrumbLink,
|
|
6
|
+
useStyleConfig,
|
|
7
|
+
} from "@chakra-ui/react";
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
import generateUUID from "../../helpers/generateUUID";
|
|
10
|
+
import { ColorVariants } from "./BreadcrumbsTypes";
|
|
11
|
+
import Icon from "../Icons/Icon";
|
|
12
|
+
import {
|
|
13
|
+
IconNames,
|
|
14
|
+
IconRotationTypes,
|
|
15
|
+
IconSizes,
|
|
16
|
+
IconTypes,
|
|
17
|
+
} from "../Icons/IconTypes";
|
|
18
|
+
import { getVariant } from "../../utils/utils";
|
|
7
19
|
|
|
8
|
-
|
|
9
|
-
|
|
20
|
+
export interface BreadcrumbsDataProps {
|
|
21
|
+
url: string;
|
|
22
|
+
text: string | React.ReactNode;
|
|
10
23
|
}
|
|
11
24
|
|
|
12
25
|
export interface BreadcrumbProps {
|
|
13
|
-
/** BlockName for use with BEM. See how to work with blockNames and BEM here: http://getbem.com/introduction/ */
|
|
14
|
-
blockName?: string;
|
|
15
26
|
/** Breadcrumb links as an array */
|
|
16
|
-
|
|
27
|
+
breadcrumbsData: BreadcrumbsDataProps[];
|
|
17
28
|
/** className you can add in addition to 'input' */
|
|
18
29
|
className?: string;
|
|
19
|
-
/**
|
|
20
|
-
|
|
30
|
+
/** ID that other components can cross reference for accessibility purposes */
|
|
31
|
+
id?: string;
|
|
32
|
+
/** Used to control how the `Hero` component will be rendered. */
|
|
33
|
+
colorVariant?: ColorVariants;
|
|
21
34
|
}
|
|
22
35
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
constructor(props: BreadcrumbProps) {
|
|
27
|
-
super(props);
|
|
36
|
+
const getElementsFromData = (data, breadcrumbsID) => {
|
|
37
|
+
if (!data?.length) {
|
|
38
|
+
return {};
|
|
28
39
|
}
|
|
29
40
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
const breadcrumbItems = data.map((breadcrumbData, index) => (
|
|
42
|
+
<BreadcrumbItem
|
|
43
|
+
key={index}
|
|
44
|
+
isCurrentPage={index === data.length - 1 ? true : false}
|
|
45
|
+
>
|
|
46
|
+
<BreadcrumbLink href={breadcrumbData.url}>
|
|
47
|
+
{index === data.length - 2 && (
|
|
48
|
+
<Icon
|
|
49
|
+
name={IconNames.Arrow}
|
|
50
|
+
size={IconSizes.Small}
|
|
51
|
+
iconRotation={IconRotationTypes.Rotate90}
|
|
52
|
+
id={`${breadcrumbsID}__backarrow`}
|
|
53
|
+
className="breadcrumbs-icon"
|
|
54
|
+
type={IconTypes.Breadcrumbs}
|
|
55
|
+
/>
|
|
56
|
+
)}
|
|
57
|
+
<span className="breadcrumb-label">{breadcrumbData.text}</span>
|
|
58
|
+
</BreadcrumbLink>
|
|
59
|
+
</BreadcrumbItem>
|
|
60
|
+
));
|
|
34
61
|
|
|
35
|
-
|
|
62
|
+
return breadcrumbItems;
|
|
63
|
+
};
|
|
36
64
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
65
|
+
function Breadcrumbs(props: React.PropsWithChildren<BreadcrumbProps>) {
|
|
66
|
+
const {
|
|
67
|
+
breadcrumbsData,
|
|
68
|
+
className,
|
|
69
|
+
colorVariant,
|
|
70
|
+
id = generateUUID(),
|
|
71
|
+
} = props;
|
|
72
|
+
const variant = getVariant(colorVariant, ColorVariants);
|
|
45
73
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
{item.text}
|
|
50
|
-
</a>
|
|
51
|
-
) : (
|
|
52
|
-
item.text
|
|
53
|
-
);
|
|
54
|
-
} else {
|
|
55
|
-
const props = {
|
|
56
|
-
className: bem("link", [], baseClass),
|
|
57
|
-
};
|
|
58
|
-
linkComponent = React.createElement(
|
|
59
|
-
item.type,
|
|
60
|
-
{ ...props, ...item.props },
|
|
61
|
-
item.props.children
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
breadcrumbItems.push(
|
|
65
|
-
<li
|
|
66
|
-
key={`${baseClass}-${index}`}
|
|
67
|
-
className={bem("item", [], baseClass)}
|
|
68
|
-
>
|
|
69
|
-
{last && (
|
|
70
|
-
<Icon
|
|
71
|
-
name={IconNames.arrow}
|
|
72
|
-
blockName={baseClass}
|
|
73
|
-
modifiers={["small"]}
|
|
74
|
-
decorative={true}
|
|
75
|
-
/>
|
|
76
|
-
)}
|
|
77
|
-
{linkComponent}
|
|
78
|
-
</li>
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<nav
|
|
84
|
-
className={bem(baseClass, modifiers, blockName, [className])}
|
|
85
|
-
role="navigation"
|
|
86
|
-
aria-label="Breadcrumbs"
|
|
87
|
-
>
|
|
88
|
-
<ul className={bem("list", [], baseClass)}>{breadcrumbItems}</ul>
|
|
89
|
-
</nav>
|
|
74
|
+
if (!breadcrumbsData || breadcrumbsData.length === 0) {
|
|
75
|
+
throw new Error(
|
|
76
|
+
"You must use the `breadcrumbsData` prop to pass a data object to the Breadcrumbs component. That prop is current empty."
|
|
90
77
|
);
|
|
91
78
|
}
|
|
79
|
+
|
|
80
|
+
const styles = useStyleConfig("Breadcrumb", { variant });
|
|
81
|
+
const breadcrumbItems = getElementsFromData(breadcrumbsData, id);
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<ChakraBreadcrumb className={className} __css={styles} id={id}>
|
|
85
|
+
{breadcrumbItems}
|
|
86
|
+
</ChakraBreadcrumb>
|
|
87
|
+
);
|
|
92
88
|
}
|
|
89
|
+
|
|
90
|
+
export default Breadcrumbs;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 1`] = `
|
|
4
|
+
<nav
|
|
5
|
+
aria-label="breadcrumb"
|
|
6
|
+
className="chakra-breadcrumb css-0"
|
|
7
|
+
id="breadcrumbs-test"
|
|
8
|
+
>
|
|
9
|
+
<ol
|
|
10
|
+
className="chakra-breadcrumb__list css-0"
|
|
11
|
+
>
|
|
12
|
+
<li
|
|
13
|
+
className="chakra-breadcrumb__list-item css-18biwo"
|
|
14
|
+
>
|
|
15
|
+
<a
|
|
16
|
+
className="chakra-breadcrumb__link css-0"
|
|
17
|
+
href="#string1"
|
|
18
|
+
>
|
|
19
|
+
<span
|
|
20
|
+
className="breadcrumb-label"
|
|
21
|
+
>
|
|
22
|
+
string1
|
|
23
|
+
</span>
|
|
24
|
+
</a>
|
|
25
|
+
<span
|
|
26
|
+
className="css-t4q1nq"
|
|
27
|
+
role="presentation"
|
|
28
|
+
>
|
|
29
|
+
/
|
|
30
|
+
</span>
|
|
31
|
+
</li>
|
|
32
|
+
<li
|
|
33
|
+
className="chakra-breadcrumb__list-item css-18biwo"
|
|
34
|
+
>
|
|
35
|
+
<a
|
|
36
|
+
className="chakra-breadcrumb__link css-0"
|
|
37
|
+
href="#string2"
|
|
38
|
+
>
|
|
39
|
+
<svg
|
|
40
|
+
aria-hidden={true}
|
|
41
|
+
className="chakra-icon breadcrumbs-icon css-onkibi"
|
|
42
|
+
focusable={false}
|
|
43
|
+
id="breadcrumbs-test__backarrow"
|
|
44
|
+
role="img"
|
|
45
|
+
viewBox="0 0 24 24"
|
|
46
|
+
>
|
|
47
|
+
<g
|
|
48
|
+
stroke="currentColor"
|
|
49
|
+
strokeWidth="1.5"
|
|
50
|
+
>
|
|
51
|
+
<path
|
|
52
|
+
d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
|
|
53
|
+
fill="none"
|
|
54
|
+
strokeLinecap="round"
|
|
55
|
+
/>
|
|
56
|
+
<path
|
|
57
|
+
d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
|
|
58
|
+
fill="currentColor"
|
|
59
|
+
strokeLinecap="round"
|
|
60
|
+
/>
|
|
61
|
+
<circle
|
|
62
|
+
cx="12"
|
|
63
|
+
cy="12"
|
|
64
|
+
fill="none"
|
|
65
|
+
r="11.25"
|
|
66
|
+
strokeMiterlimit="10"
|
|
67
|
+
/>
|
|
68
|
+
</g>
|
|
69
|
+
</svg>
|
|
70
|
+
<span
|
|
71
|
+
className="breadcrumb-label"
|
|
72
|
+
>
|
|
73
|
+
string2
|
|
74
|
+
</span>
|
|
75
|
+
</a>
|
|
76
|
+
<span
|
|
77
|
+
className="css-t4q1nq"
|
|
78
|
+
role="presentation"
|
|
79
|
+
>
|
|
80
|
+
/
|
|
81
|
+
</span>
|
|
82
|
+
</li>
|
|
83
|
+
<li
|
|
84
|
+
className="chakra-breadcrumb__list-item css-18biwo"
|
|
85
|
+
>
|
|
86
|
+
<span
|
|
87
|
+
aria-current="page"
|
|
88
|
+
className="chakra-breadcrumb__link css-0"
|
|
89
|
+
href="#string3"
|
|
90
|
+
>
|
|
91
|
+
<span
|
|
92
|
+
className="breadcrumb-label"
|
|
93
|
+
>
|
|
94
|
+
string3
|
|
95
|
+
</span>
|
|
96
|
+
</span>
|
|
97
|
+
</li>
|
|
98
|
+
</ol>
|
|
99
|
+
</nav>
|
|
100
|
+
`;
|