@nypl/design-system-react-components 0.25.3 → 0.25.7
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 +65 -0
- package/README.md +47 -11
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +4 -0
- package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +1 -0
- package/dist/components/Button/Button.d.ts +9 -6
- package/dist/components/Button/ButtonTypes.d.ts +2 -1
- package/dist/components/Card/Card.d.ts +0 -25
- package/dist/components/Icons/IconSvgs.d.ts +3 -0
- package/dist/components/Icons/IconTypes.d.ts +3 -0
- package/dist/components/Notification/Notification.d.ts +6 -4
- package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +29 -0
- package/dist/components/ProgressIndicator/ProgressIndicatorTypes.d.ts +8 -0
- package/dist/components/SearchBar/SearchBar.d.ts +3 -3
- package/dist/components/Slider/Slider.d.ts +57 -0
- package/dist/components/Tabs/Tabs.d.ts +1 -1
- package/dist/components/TextInput/TextInput.d.ts +6 -0
- package/dist/design-system-react-components.cjs.development.js +1022 -455
- 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 +1015 -444
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/resources.scss +180 -170
- package/dist/styles.css +1 -1
- package/dist/theme/components/breadcrumb.d.ts +9 -0
- package/dist/theme/components/button.d.ts +10 -0
- package/dist/theme/components/progressIndicator.d.ts +50 -0
- package/dist/theme/components/slider.d.ts +51 -0
- package/dist/theme/foundations/breakpoints.d.ts +8 -8
- package/dist/theme/foundations/global.d.ts +6 -1
- package/package.json +71 -83
- package/src/__tests__/setup.ts +2 -2
- package/src/components/Accordion/Accordion.stories.mdx +30 -34
- package/src/components/Autosuggest/Autosuggest.stories.mdx +3 -3
- package/src/components/Autosuggest/Autosuggest.stories.tsx +1 -0
- package/src/components/Autosuggest/_Autosuggest.scss +5 -5
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +24 -8
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +33 -0
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +5 -1
- package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +1 -0
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +297 -1
- package/src/components/Button/Button.stories.mdx +8 -6
- package/src/components/Button/Button.test.tsx +20 -0
- package/src/components/Button/Button.tsx +14 -23
- package/src/components/Button/ButtonTypes.tsx +1 -0
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +29 -4
- package/src/components/Card/Card.stories.mdx +1 -1
- package/src/components/Card/Card.tsx +3 -3
- package/src/components/CardEdition/CardEdition.stories.tsx +15 -47
- package/src/components/CardEdition/_CardEdition.scss +22 -23
- package/src/components/Chakra/Box.stories.mdx +14 -15
- package/src/components/Chakra/Center.stories.mdx +15 -8
- package/src/components/Chakra/Grid.stories.mdx +16 -7
- package/src/components/Chakra/Stack.stories.mdx +35 -18
- package/src/components/DatePicker/DatePicker.test.tsx +31 -30
- package/src/components/DatePicker/DatePicker.tsx +7 -4
- package/src/components/DatePicker/_DatePicker.scss +4 -4
- package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +19 -5
- package/src/components/Form/Form.stories.mdx +4 -5
- package/src/components/Grid/SimpleGrid.stories.mdx +1 -0
- package/src/components/Hero/HeroTypes.tsx +1 -0
- package/src/components/HorizontalRule/HorizontalRule.stories.mdx +2 -3
- package/src/components/Icons/Icon.stories.mdx +2 -3
- package/src/components/Icons/IconSvgs.tsx +6 -0
- package/src/components/Icons/IconTypes.tsx +3 -0
- package/src/components/Image/Image.stories.mdx +2 -3
- package/src/components/Input/Input.stories.tsx +20 -64
- package/src/components/Input/_Input.scss +23 -14
- package/src/components/Modal/Modal.stories.mdx +3 -3
- package/src/components/Modal/_Modal.scss +2 -2
- package/src/components/Notification/Notification.stories.mdx +1 -1
- package/src/components/Notification/Notification.tsx +13 -4
- package/src/components/Pagination/Pagination.stories.mdx +3 -2
- package/src/components/Pagination/Pagination.stories.tsx +1 -2
- package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +292 -0
- package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +225 -0
- package/src/components/ProgressIndicator/ProgressIndicator.tsx +126 -0
- package/src/components/ProgressIndicator/ProgressIndicatorTypes.ts +8 -0
- package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +357 -0
- package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +3 -0
- package/src/components/RadioGroup/RadioGroup.stories.mdx +2 -3
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +4 -0
- package/src/components/SearchBar/SearchBar.Test.tsx +66 -21
- package/src/components/SearchBar/SearchBar.stories.mdx +110 -11
- package/src/components/SearchBar/SearchBar.tsx +15 -5
- package/src/components/Select/SelectTypes.tsx +1 -0
- package/src/components/Slider/Slider.stories.mdx +529 -0
- package/src/components/Slider/Slider.test.tsx +653 -0
- package/src/components/Slider/Slider.tsx +303 -0
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +1946 -0
- package/src/components/StyleGuide/Bidirectionality.stories.mdx +1 -1
- package/src/components/StyleGuide/Breakpoints.stories.mdx +21 -7
- package/src/components/StyleGuide/Buttons.stories.mdx +9 -2
- package/src/components/StyleGuide/DesignTokens.stories.mdx +170 -0
- package/src/components/Tabs/Tabs.tsx +5 -5
- package/src/components/Template/Template.stories.mdx +6 -6
- package/src/components/TextInput/TextInput.stories.mdx +1 -1
- package/src/components/TextInput/TextInput.tsx +15 -2
- package/src/components/TextInput/TextInputTypes.tsx +2 -0
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +2 -3
- package/src/docs/Chakra.stories.mdx +2 -2
- package/src/index.ts +12 -6
- package/src/resources.scss +5 -5
- package/src/styles/base/{_02-breakpoints.scss → _01-breakpoints.scss} +9 -10
- package/src/styles/base/{_03-mixins.scss → _02-mixins.scss} +16 -5
- package/src/styles/base/{_04-base.scss → _03-base.scss} +7 -2
- package/src/styles/base/{_05-focus.scss → _04-focus.scss} +0 -15
- package/src/styles/base/_place-holder.scss +14 -3
- package/src/styles/{03-space → space}/_space-inline.scss +14 -14
- package/src/styles/{03-space → space}/_space-inset.scss +10 -10
- package/src/styles/space/_space-stack.scss +116 -0
- package/src/styles.scss +13 -44
- package/src/theme/components/breadcrumb.ts +10 -0
- package/src/theme/components/button.ts +10 -2
- package/src/theme/components/card.ts +11 -9
- package/src/theme/components/datePicker.ts +1 -1
- package/src/theme/components/list.ts +2 -2
- package/src/theme/components/notification.ts +5 -3
- package/src/theme/components/progressIndicator.ts +62 -0
- package/src/theme/components/skeletonLoader.ts +1 -1
- package/src/theme/components/slider.ts +79 -0
- package/src/theme/foundations/breakpoints.ts +8 -8
- package/src/theme/foundations/global.ts +6 -1
- package/src/theme/index.ts +4 -0
- package/src/utils/componentCategories.ts +3 -3
- package/src/styles/01-colors/_colors-brand.scss +0 -62
- package/src/styles/01-colors/_colors-utility.scss +0 -67
- package/src/styles/02-typography/_type-scale.css +0 -11
- package/src/styles/02-typography/_type-weight.css +0 -7
- package/src/styles/02-typography/_typefaces.css +0 -4
- package/src/styles/03-space/_space-stack.scss +0 -116
- package/src/styles/03-space/_space.css +0 -30
- package/src/styles/base/_card-grid.scss +0 -77
- package/src/styles/base/_typography.scss +0 -11
|
@@ -4,6 +4,7 @@ import renderer from "react-test-renderer";
|
|
|
4
4
|
import { axe } from "jest-axe";
|
|
5
5
|
|
|
6
6
|
import Breadcrumbs from "./Breadcrumbs";
|
|
7
|
+
import { ColorVariants } from "./BreadcrumbsTypes";
|
|
7
8
|
|
|
8
9
|
describe("Breadcrumbs Accessibility", () => {
|
|
9
10
|
const breadcrumbsData = [
|
|
@@ -31,8 +32,40 @@ describe("Breadcrumbs Snapshot", () => {
|
|
|
31
32
|
<Breadcrumbs id="breadcrumbs-test" breadcrumbsData={breadcrumbsData} />
|
|
32
33
|
)
|
|
33
34
|
.toJSON();
|
|
35
|
+
const breadcrumbsVariantColor = renderer
|
|
36
|
+
.create(
|
|
37
|
+
<Breadcrumbs
|
|
38
|
+
breadcrumbsData={breadcrumbsData}
|
|
39
|
+
colorVariant={ColorVariants.BooksAndMore}
|
|
40
|
+
id="breadcrumbs-test"
|
|
41
|
+
/>
|
|
42
|
+
)
|
|
43
|
+
.toJSON();
|
|
44
|
+
const breadcrumbsBlogsVariant = renderer
|
|
45
|
+
.create(
|
|
46
|
+
<Breadcrumbs
|
|
47
|
+
breadcrumbsData={breadcrumbsData}
|
|
48
|
+
colorVariant={ColorVariants.Blogs}
|
|
49
|
+
id="breadcrumbs-test"
|
|
50
|
+
/>
|
|
51
|
+
)
|
|
52
|
+
.toJSON();
|
|
53
|
+
const breadcrumbsAdditionalStyles = renderer
|
|
54
|
+
.create(
|
|
55
|
+
<Breadcrumbs
|
|
56
|
+
additionalStyles={{
|
|
57
|
+
bg: "var(--nypl-colors-ui-error-primary)",
|
|
58
|
+
}}
|
|
59
|
+
breadcrumbsData={breadcrumbsData}
|
|
60
|
+
id="breadcrumbs-test"
|
|
61
|
+
/>
|
|
62
|
+
)
|
|
63
|
+
.toJSON();
|
|
34
64
|
|
|
35
65
|
expect(breadcrumbsSnapshot).toMatchSnapshot();
|
|
66
|
+
expect(breadcrumbsVariantColor).toMatchSnapshot();
|
|
67
|
+
expect(breadcrumbsBlogsVariant).toMatchSnapshot();
|
|
68
|
+
expect(breadcrumbsAdditionalStyles).toMatchSnapshot();
|
|
36
69
|
});
|
|
37
70
|
});
|
|
38
71
|
|
|
@@ -23,6 +23,8 @@ export interface BreadcrumbsDataProps {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export interface BreadcrumbProps {
|
|
26
|
+
/** Optionally pass in additional Chakra-based styles. */
|
|
27
|
+
additionalStyles?: { [key: string]: any };
|
|
26
28
|
/** Breadcrumb links as an array */
|
|
27
29
|
breadcrumbsData: BreadcrumbsDataProps[];
|
|
28
30
|
/** className you can add in addition to 'input' */
|
|
@@ -64,6 +66,7 @@ const getElementsFromData = (data, breadcrumbsID) => {
|
|
|
64
66
|
|
|
65
67
|
function Breadcrumbs(props: React.PropsWithChildren<BreadcrumbProps>) {
|
|
66
68
|
const {
|
|
69
|
+
additionalStyles = {},
|
|
67
70
|
breadcrumbsData,
|
|
68
71
|
className,
|
|
69
72
|
colorVariant,
|
|
@@ -78,10 +81,11 @@ function Breadcrumbs(props: React.PropsWithChildren<BreadcrumbProps>) {
|
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
const styles = useStyleConfig("Breadcrumb", { variant });
|
|
84
|
+
const finalStyles = { ...styles, ...additionalStyles };
|
|
81
85
|
const breadcrumbItems = getElementsFromData(breadcrumbsData, id);
|
|
82
86
|
|
|
83
87
|
return (
|
|
84
|
-
<ChakraBreadcrumb className={className} __css={
|
|
88
|
+
<ChakraBreadcrumb className={className} __css={finalStyles} id={id}>
|
|
85
89
|
{breadcrumbItems}
|
|
86
90
|
</ChakraBreadcrumb>
|
|
87
91
|
);
|
|
@@ -87,7 +87,303 @@ exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 1`] = `
|
|
|
87
87
|
<span
|
|
88
88
|
aria-current="page"
|
|
89
89
|
className="chakra-breadcrumb__link css-0"
|
|
90
|
-
|
|
90
|
+
>
|
|
91
|
+
<span
|
|
92
|
+
className="breadcrumb-label"
|
|
93
|
+
>
|
|
94
|
+
string3
|
|
95
|
+
</span>
|
|
96
|
+
</span>
|
|
97
|
+
</li>
|
|
98
|
+
</ol>
|
|
99
|
+
</nav>
|
|
100
|
+
`;
|
|
101
|
+
|
|
102
|
+
exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 2`] = `
|
|
103
|
+
<nav
|
|
104
|
+
aria-label="breadcrumb"
|
|
105
|
+
className="chakra-breadcrumb css-0"
|
|
106
|
+
id="breadcrumbs-test"
|
|
107
|
+
>
|
|
108
|
+
<ol
|
|
109
|
+
className="chakra-breadcrumb__list css-0"
|
|
110
|
+
>
|
|
111
|
+
<li
|
|
112
|
+
className="chakra-breadcrumb__list-item css-18biwo"
|
|
113
|
+
>
|
|
114
|
+
<a
|
|
115
|
+
className="chakra-breadcrumb__link css-0"
|
|
116
|
+
href="#string1"
|
|
117
|
+
>
|
|
118
|
+
<span
|
|
119
|
+
className="breadcrumb-label"
|
|
120
|
+
>
|
|
121
|
+
string1
|
|
122
|
+
</span>
|
|
123
|
+
</a>
|
|
124
|
+
<span
|
|
125
|
+
className="css-t4q1nq"
|
|
126
|
+
role="presentation"
|
|
127
|
+
>
|
|
128
|
+
/
|
|
129
|
+
</span>
|
|
130
|
+
</li>
|
|
131
|
+
<li
|
|
132
|
+
className="chakra-breadcrumb__list-item css-18biwo"
|
|
133
|
+
>
|
|
134
|
+
<a
|
|
135
|
+
className="chakra-breadcrumb__link css-0"
|
|
136
|
+
href="#string2"
|
|
137
|
+
>
|
|
138
|
+
<svg
|
|
139
|
+
aria-hidden={true}
|
|
140
|
+
className="chakra-icon breadcrumbs-icon css-onkibi"
|
|
141
|
+
focusable={false}
|
|
142
|
+
id="breadcrumbs-test__backarrow"
|
|
143
|
+
role="img"
|
|
144
|
+
title="arrow icon"
|
|
145
|
+
viewBox="0 0 24 24"
|
|
146
|
+
>
|
|
147
|
+
<g
|
|
148
|
+
stroke="currentColor"
|
|
149
|
+
strokeWidth="1.5"
|
|
150
|
+
>
|
|
151
|
+
<path
|
|
152
|
+
d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
|
|
153
|
+
fill="none"
|
|
154
|
+
strokeLinecap="round"
|
|
155
|
+
/>
|
|
156
|
+
<path
|
|
157
|
+
d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
|
|
158
|
+
fill="currentColor"
|
|
159
|
+
strokeLinecap="round"
|
|
160
|
+
/>
|
|
161
|
+
<circle
|
|
162
|
+
cx="12"
|
|
163
|
+
cy="12"
|
|
164
|
+
fill="none"
|
|
165
|
+
r="11.25"
|
|
166
|
+
strokeMiterlimit="10"
|
|
167
|
+
/>
|
|
168
|
+
</g>
|
|
169
|
+
</svg>
|
|
170
|
+
<span
|
|
171
|
+
className="breadcrumb-label"
|
|
172
|
+
>
|
|
173
|
+
string2
|
|
174
|
+
</span>
|
|
175
|
+
</a>
|
|
176
|
+
<span
|
|
177
|
+
className="css-t4q1nq"
|
|
178
|
+
role="presentation"
|
|
179
|
+
>
|
|
180
|
+
/
|
|
181
|
+
</span>
|
|
182
|
+
</li>
|
|
183
|
+
<li
|
|
184
|
+
className="chakra-breadcrumb__list-item css-18biwo"
|
|
185
|
+
>
|
|
186
|
+
<span
|
|
187
|
+
aria-current="page"
|
|
188
|
+
className="chakra-breadcrumb__link css-0"
|
|
189
|
+
>
|
|
190
|
+
<span
|
|
191
|
+
className="breadcrumb-label"
|
|
192
|
+
>
|
|
193
|
+
string3
|
|
194
|
+
</span>
|
|
195
|
+
</span>
|
|
196
|
+
</li>
|
|
197
|
+
</ol>
|
|
198
|
+
</nav>
|
|
199
|
+
`;
|
|
200
|
+
|
|
201
|
+
exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 3`] = `
|
|
202
|
+
<nav
|
|
203
|
+
aria-label="breadcrumb"
|
|
204
|
+
className="chakra-breadcrumb css-0"
|
|
205
|
+
id="breadcrumbs-test"
|
|
206
|
+
>
|
|
207
|
+
<ol
|
|
208
|
+
className="chakra-breadcrumb__list css-0"
|
|
209
|
+
>
|
|
210
|
+
<li
|
|
211
|
+
className="chakra-breadcrumb__list-item css-18biwo"
|
|
212
|
+
>
|
|
213
|
+
<a
|
|
214
|
+
className="chakra-breadcrumb__link css-0"
|
|
215
|
+
href="#string1"
|
|
216
|
+
>
|
|
217
|
+
<span
|
|
218
|
+
className="breadcrumb-label"
|
|
219
|
+
>
|
|
220
|
+
string1
|
|
221
|
+
</span>
|
|
222
|
+
</a>
|
|
223
|
+
<span
|
|
224
|
+
className="css-t4q1nq"
|
|
225
|
+
role="presentation"
|
|
226
|
+
>
|
|
227
|
+
/
|
|
228
|
+
</span>
|
|
229
|
+
</li>
|
|
230
|
+
<li
|
|
231
|
+
className="chakra-breadcrumb__list-item css-18biwo"
|
|
232
|
+
>
|
|
233
|
+
<a
|
|
234
|
+
className="chakra-breadcrumb__link css-0"
|
|
235
|
+
href="#string2"
|
|
236
|
+
>
|
|
237
|
+
<svg
|
|
238
|
+
aria-hidden={true}
|
|
239
|
+
className="chakra-icon breadcrumbs-icon css-onkibi"
|
|
240
|
+
focusable={false}
|
|
241
|
+
id="breadcrumbs-test__backarrow"
|
|
242
|
+
role="img"
|
|
243
|
+
title="arrow icon"
|
|
244
|
+
viewBox="0 0 24 24"
|
|
245
|
+
>
|
|
246
|
+
<g
|
|
247
|
+
stroke="currentColor"
|
|
248
|
+
strokeWidth="1.5"
|
|
249
|
+
>
|
|
250
|
+
<path
|
|
251
|
+
d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
|
|
252
|
+
fill="none"
|
|
253
|
+
strokeLinecap="round"
|
|
254
|
+
/>
|
|
255
|
+
<path
|
|
256
|
+
d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
|
|
257
|
+
fill="currentColor"
|
|
258
|
+
strokeLinecap="round"
|
|
259
|
+
/>
|
|
260
|
+
<circle
|
|
261
|
+
cx="12"
|
|
262
|
+
cy="12"
|
|
263
|
+
fill="none"
|
|
264
|
+
r="11.25"
|
|
265
|
+
strokeMiterlimit="10"
|
|
266
|
+
/>
|
|
267
|
+
</g>
|
|
268
|
+
</svg>
|
|
269
|
+
<span
|
|
270
|
+
className="breadcrumb-label"
|
|
271
|
+
>
|
|
272
|
+
string2
|
|
273
|
+
</span>
|
|
274
|
+
</a>
|
|
275
|
+
<span
|
|
276
|
+
className="css-t4q1nq"
|
|
277
|
+
role="presentation"
|
|
278
|
+
>
|
|
279
|
+
/
|
|
280
|
+
</span>
|
|
281
|
+
</li>
|
|
282
|
+
<li
|
|
283
|
+
className="chakra-breadcrumb__list-item css-18biwo"
|
|
284
|
+
>
|
|
285
|
+
<span
|
|
286
|
+
aria-current="page"
|
|
287
|
+
className="chakra-breadcrumb__link css-0"
|
|
288
|
+
>
|
|
289
|
+
<span
|
|
290
|
+
className="breadcrumb-label"
|
|
291
|
+
>
|
|
292
|
+
string3
|
|
293
|
+
</span>
|
|
294
|
+
</span>
|
|
295
|
+
</li>
|
|
296
|
+
</ol>
|
|
297
|
+
</nav>
|
|
298
|
+
`;
|
|
299
|
+
|
|
300
|
+
exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 4`] = `
|
|
301
|
+
<nav
|
|
302
|
+
aria-label="breadcrumb"
|
|
303
|
+
className="chakra-breadcrumb css-1f2fw9u"
|
|
304
|
+
id="breadcrumbs-test"
|
|
305
|
+
>
|
|
306
|
+
<ol
|
|
307
|
+
className="chakra-breadcrumb__list css-0"
|
|
308
|
+
>
|
|
309
|
+
<li
|
|
310
|
+
className="chakra-breadcrumb__list-item css-18biwo"
|
|
311
|
+
>
|
|
312
|
+
<a
|
|
313
|
+
className="chakra-breadcrumb__link css-0"
|
|
314
|
+
href="#string1"
|
|
315
|
+
>
|
|
316
|
+
<span
|
|
317
|
+
className="breadcrumb-label"
|
|
318
|
+
>
|
|
319
|
+
string1
|
|
320
|
+
</span>
|
|
321
|
+
</a>
|
|
322
|
+
<span
|
|
323
|
+
className="css-t4q1nq"
|
|
324
|
+
role="presentation"
|
|
325
|
+
>
|
|
326
|
+
/
|
|
327
|
+
</span>
|
|
328
|
+
</li>
|
|
329
|
+
<li
|
|
330
|
+
className="chakra-breadcrumb__list-item css-18biwo"
|
|
331
|
+
>
|
|
332
|
+
<a
|
|
333
|
+
className="chakra-breadcrumb__link css-0"
|
|
334
|
+
href="#string2"
|
|
335
|
+
>
|
|
336
|
+
<svg
|
|
337
|
+
aria-hidden={true}
|
|
338
|
+
className="chakra-icon breadcrumbs-icon css-onkibi"
|
|
339
|
+
focusable={false}
|
|
340
|
+
id="breadcrumbs-test__backarrow"
|
|
341
|
+
role="img"
|
|
342
|
+
title="arrow icon"
|
|
343
|
+
viewBox="0 0 24 24"
|
|
344
|
+
>
|
|
345
|
+
<g
|
|
346
|
+
stroke="currentColor"
|
|
347
|
+
strokeWidth="1.5"
|
|
348
|
+
>
|
|
349
|
+
<path
|
|
350
|
+
d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
|
|
351
|
+
fill="none"
|
|
352
|
+
strokeLinecap="round"
|
|
353
|
+
/>
|
|
354
|
+
<path
|
|
355
|
+
d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
|
|
356
|
+
fill="currentColor"
|
|
357
|
+
strokeLinecap="round"
|
|
358
|
+
/>
|
|
359
|
+
<circle
|
|
360
|
+
cx="12"
|
|
361
|
+
cy="12"
|
|
362
|
+
fill="none"
|
|
363
|
+
r="11.25"
|
|
364
|
+
strokeMiterlimit="10"
|
|
365
|
+
/>
|
|
366
|
+
</g>
|
|
367
|
+
</svg>
|
|
368
|
+
<span
|
|
369
|
+
className="breadcrumb-label"
|
|
370
|
+
>
|
|
371
|
+
string2
|
|
372
|
+
</span>
|
|
373
|
+
</a>
|
|
374
|
+
<span
|
|
375
|
+
className="css-t4q1nq"
|
|
376
|
+
role="presentation"
|
|
377
|
+
>
|
|
378
|
+
/
|
|
379
|
+
</span>
|
|
380
|
+
</li>
|
|
381
|
+
<li
|
|
382
|
+
className="chakra-breadcrumb__list-item css-18biwo"
|
|
383
|
+
>
|
|
384
|
+
<span
|
|
385
|
+
aria-current="page"
|
|
386
|
+
className="chakra-breadcrumb__link css-0"
|
|
91
387
|
>
|
|
92
388
|
<span
|
|
93
389
|
className="breadcrumb-label"
|
|
@@ -28,8 +28,7 @@ import DSProvider from "../../theme/provider";
|
|
|
28
28
|
parameters={{
|
|
29
29
|
design: {
|
|
30
30
|
type: "figma",
|
|
31
|
-
url:
|
|
32
|
-
"https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Master?node-id=11477%3A2298",
|
|
31
|
+
url: "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Master?node-id=11477%3A2298",
|
|
33
32
|
},
|
|
34
33
|
jest: ["Button.test.tsx"],
|
|
35
34
|
}}
|
|
@@ -40,7 +39,7 @@ import DSProvider from "../../theme/provider";
|
|
|
40
39
|
| Component Version | DS Version |
|
|
41
40
|
| ----------------- | ---------- |
|
|
42
41
|
| Added | `0.0.4` |
|
|
43
|
-
| Latest | `0.25.
|
|
42
|
+
| Latest | `0.25.4` |
|
|
44
43
|
|
|
45
44
|
<Description of={Button} />
|
|
46
45
|
|
|
@@ -53,6 +52,8 @@ that can be rendered.
|
|
|
53
52
|
- `ButtonTypes.Pill` is used for equally weighted actions within cards and always in a set.
|
|
54
53
|
- `ButtonTypes.Link` is used for equally weighted actions in a text based list.
|
|
55
54
|
- `ButtonTypes.SearchBar` is a variant only used in the `SearchBar` component.
|
|
55
|
+
- `ButtonTypes.NoBrand` is a variant used when there is no brand and will display
|
|
56
|
+
the background color as black.
|
|
56
57
|
|
|
57
58
|
When one and only one `Icon` component is passed inside a `Button` component with
|
|
58
59
|
no text, it will automatically be configured to use the `"iconOnly"` type.
|
|
@@ -230,17 +231,18 @@ The different `ButtonTypes` modified by the `buttonType` prop:
|
|
|
230
231
|
<Button buttonType={ButtonTypes.Callout}>Callout</Button>
|
|
231
232
|
<Button buttonType={ButtonTypes.Pill}>Pill</Button>
|
|
232
233
|
<Button buttonType={ButtonTypes.Link}>Link</Button>
|
|
234
|
+
<Button buttonType={ButtonTypes.NoBrand}>NoBrand</Button>
|
|
233
235
|
</ButtonGroup>
|
|
234
236
|
</DSProvider>
|
|
235
237
|
</Canvas>
|
|
236
238
|
|
|
237
|
-
Modifying the `
|
|
239
|
+
Modifying the `isDisabled` prop:
|
|
238
240
|
|
|
239
241
|
<Canvas>
|
|
240
242
|
<DSProvider>
|
|
241
243
|
<ButtonGroup>
|
|
242
|
-
<Button
|
|
243
|
-
<Button
|
|
244
|
+
<Button isDisabled={false}>Enabled</Button>
|
|
245
|
+
<Button isDisabled>isDisabled</Button>
|
|
244
246
|
</ButtonGroup>
|
|
245
247
|
</DSProvider>
|
|
246
248
|
</Canvas>
|
|
@@ -107,6 +107,13 @@ describe("Button Snapshot", () => {
|
|
|
107
107
|
</Button>
|
|
108
108
|
)
|
|
109
109
|
.toJSON();
|
|
110
|
+
const disabled = renderer
|
|
111
|
+
.create(
|
|
112
|
+
<Button id="button" onClick={jest.fn()} isDisabled>
|
|
113
|
+
Disabled
|
|
114
|
+
</Button>
|
|
115
|
+
)
|
|
116
|
+
.toJSON();
|
|
110
117
|
const secondary = renderer
|
|
111
118
|
.create(
|
|
112
119
|
<Button
|
|
@@ -154,12 +161,25 @@ describe("Button Snapshot", () => {
|
|
|
154
161
|
</Button>
|
|
155
162
|
)
|
|
156
163
|
.toJSON();
|
|
164
|
+
const noBrand = renderer
|
|
165
|
+
.create(
|
|
166
|
+
<Button
|
|
167
|
+
id="button"
|
|
168
|
+
onClick={jest.fn()}
|
|
169
|
+
buttonType={ButtonTypes.NoBrand}
|
|
170
|
+
>
|
|
171
|
+
NoBrand
|
|
172
|
+
</Button>
|
|
173
|
+
)
|
|
174
|
+
.toJSON();
|
|
157
175
|
|
|
158
176
|
expect(primary).toMatchSnapshot();
|
|
177
|
+
expect(disabled).toMatchSnapshot();
|
|
159
178
|
expect(secondary).toMatchSnapshot();
|
|
160
179
|
expect(callout).toMatchSnapshot();
|
|
161
180
|
expect(pill).toMatchSnapshot();
|
|
162
181
|
expect(link).toMatchSnapshot();
|
|
163
182
|
expect(searchBar).toMatchSnapshot();
|
|
183
|
+
expect(noBrand).toMatchSnapshot();
|
|
164
184
|
});
|
|
165
185
|
});
|
|
@@ -3,6 +3,8 @@ import { Button as ChakraButton, useStyleConfig } from "@chakra-ui/react";
|
|
|
3
3
|
|
|
4
4
|
import { ButtonTypes } from "./ButtonTypes";
|
|
5
5
|
import Icon from "../Icons/Icon";
|
|
6
|
+
import { getVariant } from "../../utils/utils";
|
|
7
|
+
import generateUUID from "../../helpers/generateUUID";
|
|
6
8
|
|
|
7
9
|
type ButtonElementType = "submit" | "button" | "reset";
|
|
8
10
|
|
|
@@ -13,35 +15,24 @@ interface ButtonProps {
|
|
|
13
15
|
attributes?: { [key: string]: any };
|
|
14
16
|
/** The kind of button assigned through the `ButtonTypes` enum */
|
|
15
17
|
buttonType?: ButtonTypes;
|
|
16
|
-
/** Additional className
|
|
18
|
+
/** Additional className to use. */
|
|
17
19
|
className?: string;
|
|
18
|
-
/** Adds 'disabled' property to the button */
|
|
19
|
-
disabled?: boolean;
|
|
20
20
|
/** ID that other components can cross reference for accessibility purposes */
|
|
21
21
|
id?: string;
|
|
22
|
-
/**
|
|
22
|
+
/** Adds 'disabled' property to the button */
|
|
23
|
+
isDisabled?: boolean;
|
|
24
|
+
/** Trigger the Button's action through the `mouseDown` event handler instead
|
|
25
|
+
* of `onClick`. `false` by default. */
|
|
23
26
|
mouseDown?: boolean;
|
|
24
27
|
/** The action to perform on the `<button>`'s onClick function */
|
|
25
28
|
onClick?: (event: React.MouseEvent | React.KeyboardEvent) => void;
|
|
26
|
-
/** The
|
|
29
|
+
/** The HTML button type attribute. */
|
|
27
30
|
type?: ButtonElementType;
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
// Used to map between ButtonTypes enum values and Chakra variant options.
|
|
31
|
-
const variantMap = {};
|
|
32
|
-
for (const type in ButtonTypes) {
|
|
33
|
-
variantMap[ButtonTypes[type]] = ButtonTypes[type];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
33
|
/**
|
|
37
|
-
*
|
|
38
|
-
* value is passed (typically in non-Typescript scenarios), then the default
|
|
39
|
-
* is the "primary" variant.
|
|
34
|
+
* Renders a simple `button` element with custom variant styles.
|
|
40
35
|
*/
|
|
41
|
-
const getVariant = (buttonType) =>
|
|
42
|
-
variantMap[buttonType] || ButtonTypes.Primary;
|
|
43
|
-
|
|
44
|
-
/** Renders a simple `button` element with custom classes and modifiers. */
|
|
45
36
|
function Button(props: React.PropsWithChildren<ButtonProps>) {
|
|
46
37
|
const {
|
|
47
38
|
additionalStyles = {},
|
|
@@ -49,8 +40,8 @@ function Button(props: React.PropsWithChildren<ButtonProps>) {
|
|
|
49
40
|
buttonType,
|
|
50
41
|
children,
|
|
51
42
|
className = "",
|
|
52
|
-
|
|
53
|
-
id,
|
|
43
|
+
isDisabled,
|
|
44
|
+
id = generateUUID(),
|
|
54
45
|
mouseDown = false,
|
|
55
46
|
onClick,
|
|
56
47
|
type = "button",
|
|
@@ -59,7 +50,7 @@ function Button(props: React.PropsWithChildren<ButtonProps>) {
|
|
|
59
50
|
let childCount = 0;
|
|
60
51
|
let hasIcon = false;
|
|
61
52
|
let variant;
|
|
62
|
-
let styles;
|
|
53
|
+
let styles = {};
|
|
63
54
|
|
|
64
55
|
React.Children.map(children, (child: React.ReactElement) => {
|
|
65
56
|
childCount++;
|
|
@@ -76,7 +67,7 @@ function Button(props: React.PropsWithChildren<ButtonProps>) {
|
|
|
76
67
|
if (childCount === 1 && hasIcon) {
|
|
77
68
|
variant = "iconOnly";
|
|
78
69
|
} else {
|
|
79
|
-
variant = getVariant(buttonType);
|
|
70
|
+
variant = getVariant(buttonType, ButtonTypes, ButtonTypes.Primary);
|
|
80
71
|
}
|
|
81
72
|
|
|
82
73
|
styles = useStyleConfig("Button", { variant });
|
|
@@ -87,7 +78,7 @@ function Button(props: React.PropsWithChildren<ButtonProps>) {
|
|
|
87
78
|
data-testid="button"
|
|
88
79
|
className={className}
|
|
89
80
|
type={type}
|
|
90
|
-
|
|
81
|
+
isDisabled={isDisabled}
|
|
91
82
|
__css={{ ...styles, ...additionalStyles }}
|
|
92
83
|
{...attributes}
|
|
93
84
|
{...btnCallback}
|
|
@@ -16,11 +16,12 @@ exports[`Button Snapshot Renders the UI snapshot correctly 2`] = `
|
|
|
16
16
|
<button
|
|
17
17
|
className="chakra-button css-0"
|
|
18
18
|
data-testid="button"
|
|
19
|
+
disabled={true}
|
|
19
20
|
id="button"
|
|
20
21
|
onClick={[MockFunction]}
|
|
21
22
|
type="button"
|
|
22
23
|
>
|
|
23
|
-
|
|
24
|
+
Disabled
|
|
24
25
|
</button>
|
|
25
26
|
`;
|
|
26
27
|
|
|
@@ -32,7 +33,7 @@ exports[`Button Snapshot Renders the UI snapshot correctly 3`] = `
|
|
|
32
33
|
onClick={[MockFunction]}
|
|
33
34
|
type="button"
|
|
34
35
|
>
|
|
35
|
-
|
|
36
|
+
Seconday
|
|
36
37
|
</button>
|
|
37
38
|
`;
|
|
38
39
|
|
|
@@ -44,7 +45,7 @@ exports[`Button Snapshot Renders the UI snapshot correctly 4`] = `
|
|
|
44
45
|
onClick={[MockFunction]}
|
|
45
46
|
type="button"
|
|
46
47
|
>
|
|
47
|
-
|
|
48
|
+
Callout
|
|
48
49
|
</button>
|
|
49
50
|
`;
|
|
50
51
|
|
|
@@ -56,11 +57,23 @@ exports[`Button Snapshot Renders the UI snapshot correctly 5`] = `
|
|
|
56
57
|
onClick={[MockFunction]}
|
|
57
58
|
type="button"
|
|
58
59
|
>
|
|
59
|
-
|
|
60
|
+
Pill
|
|
60
61
|
</button>
|
|
61
62
|
`;
|
|
62
63
|
|
|
63
64
|
exports[`Button Snapshot Renders the UI snapshot correctly 6`] = `
|
|
65
|
+
<button
|
|
66
|
+
className="chakra-button css-0"
|
|
67
|
+
data-testid="button"
|
|
68
|
+
id="button"
|
|
69
|
+
onClick={[MockFunction]}
|
|
70
|
+
type="button"
|
|
71
|
+
>
|
|
72
|
+
Link
|
|
73
|
+
</button>
|
|
74
|
+
`;
|
|
75
|
+
|
|
76
|
+
exports[`Button Snapshot Renders the UI snapshot correctly 7`] = `
|
|
64
77
|
<button
|
|
65
78
|
className="chakra-button css-0"
|
|
66
79
|
data-testid="button"
|
|
@@ -71,3 +84,15 @@ exports[`Button Snapshot Renders the UI snapshot correctly 6`] = `
|
|
|
71
84
|
SearchBar
|
|
72
85
|
</button>
|
|
73
86
|
`;
|
|
87
|
+
|
|
88
|
+
exports[`Button Snapshot Renders the UI snapshot correctly 8`] = `
|
|
89
|
+
<button
|
|
90
|
+
className="chakra-button css-0"
|
|
91
|
+
data-testid="button"
|
|
92
|
+
id="button"
|
|
93
|
+
onClick={[MockFunction]}
|
|
94
|
+
type="button"
|
|
95
|
+
>
|
|
96
|
+
NoBrand
|
|
97
|
+
</button>
|
|
98
|
+
`;
|
|
@@ -544,7 +544,7 @@ Instead of passing a path for the `imageSrc` prop, you can pass a custom image c
|
|
|
544
544
|
<CardHeading level={HeadingLevels.Two} id="img1-heading1">
|
|
545
545
|
Card Component with Custom Image Component
|
|
546
546
|
</CardHeading>
|
|
547
|
-
<CardHeading level={HeadingLevels.
|
|
547
|
+
<CardHeading level={HeadingLevels.Three} id="img2-heading2">
|
|
548
548
|
Secondary Heading
|
|
549
549
|
</CardHeading>
|
|
550
550
|
<CardContent>
|
|
@@ -72,7 +72,7 @@ export interface CardProps extends CardBaseProps, CardLinkBoxProps {
|
|
|
72
72
|
* renders an `Image` component but with overriding styles specific to the
|
|
73
73
|
* `Card` component.
|
|
74
74
|
*/
|
|
75
|
-
|
|
75
|
+
function CardImage(props: React.ComponentProps<"img"> & CardImageProps) {
|
|
76
76
|
const {
|
|
77
77
|
alt,
|
|
78
78
|
center,
|
|
@@ -130,7 +130,7 @@ export function CardActions(props: React.PropsWithChildren<CardActionsProps>) {
|
|
|
130
130
|
* component to the entire `Card` component. This works together with the
|
|
131
131
|
* `CardLinkOverlay` component to provide a clickable overlay.
|
|
132
132
|
*/
|
|
133
|
-
|
|
133
|
+
function CardLinkBox({
|
|
134
134
|
children,
|
|
135
135
|
mainActionLink,
|
|
136
136
|
}: React.PropsWithChildren<CardLinkBoxProps>) {
|
|
@@ -148,7 +148,7 @@ export function CardLinkBox({
|
|
|
148
148
|
* the `Card` component while still allowing links in the `CardActions` to be
|
|
149
149
|
* clickable.
|
|
150
150
|
*/
|
|
151
|
-
|
|
151
|
+
function CardLinkOverlay({
|
|
152
152
|
children,
|
|
153
153
|
mainActionLink,
|
|
154
154
|
}: React.PropsWithChildren<CardLinkBoxProps>) {
|