@nypl/design-system-react-components 0.25.7 → 0.25.8
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 +29 -0
- package/dist/components/Icons/IconSvgs.d.ts +1 -0
- package/dist/components/Icons/IconTypes.d.ts +1 -0
- package/dist/components/Image/ImageTypes.d.ts +3 -1
- package/dist/components/Link/LinkTypes.d.ts +1 -0
- package/dist/components/Notification/Notification.d.ts +2 -0
- package/dist/components/Select/Select.d.ts +2 -0
- package/dist/components/Toggle/Toggle.d.ts +47 -0
- package/dist/components/Toggle/ToggleSizes.d.ts +4 -0
- package/dist/components/VideoPlayer/VideoPlayer.d.ts +5 -3
- package/dist/design-system-react-components.cjs.development.js +613 -366
- 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 +606 -354
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/theme/components/notification.d.ts +8 -4
- package/dist/theme/components/toggle.d.ts +68 -0
- package/dist/theme/foundations/spacing.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/Accordion/Accordion.stories.mdx +1 -2
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +1 -1
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +10 -0
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +99 -0
- package/src/components/Button/Button.tsx +0 -1
- package/src/components/Card/Card.stories.mdx +74 -7
- package/src/components/Card/Card.tsx +9 -8
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +67 -35
- package/src/components/Chakra/Grid.stories.mdx +11 -14
- package/src/components/DatePicker/DatePicker.test.tsx +8 -6
- package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +5 -4
- package/src/components/Icons/Icon.stories.mdx +3 -2
- package/src/components/Icons/IconSvgs.tsx +2 -0
- package/src/components/Icons/IconTypes.tsx +1 -0
- package/src/components/Image/Image.stories.mdx +152 -90
- package/src/components/Image/Image.test.tsx +10 -0
- package/src/components/Image/ImageTypes.ts +2 -0
- package/src/components/Image/__snapshots__/Image.test.tsx.snap +24 -8
- package/src/components/Label/Label.stories.mdx +1 -1
- package/src/components/Link/Link.stories.mdx +2 -3
- package/src/components/Link/Link.test.tsx +71 -0
- package/src/components/Link/Link.tsx +41 -9
- package/src/components/Link/LinkTypes.tsx +1 -0
- package/src/components/Link/__snapshots__/Link.test.tsx.snap +201 -0
- package/src/components/Notification/Notification.stories.mdx +36 -3
- package/src/components/Notification/Notification.test.tsx +62 -16
- package/src/components/Notification/Notification.tsx +17 -5
- package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +117 -0
- package/src/components/Pagination/Pagination.stories.mdx +1 -2
- package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +42 -0
- package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +2 -3
- package/src/components/SearchBar/SearchBar.stories.mdx +1 -1
- package/src/components/Select/Select.stories.mdx +132 -55
- package/src/components/Select/Select.test.tsx +2 -2
- package/src/components/Select/Select.tsx +6 -2
- package/src/components/Slider/Slider.stories.mdx +3 -2
- package/src/components/Slider/Slider.test.tsx +35 -0
- package/src/components/Slider/Slider.tsx +8 -2
- package/src/components/Template/Template.stories.mdx +1 -2
- package/src/components/Toggle/Toggle.stories.mdx +176 -0
- package/src/components/Toggle/Toggle.test.tsx +140 -0
- package/src/components/Toggle/Toggle.tsx +118 -0
- package/src/components/Toggle/ToggleSizes.tsx +4 -0
- package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +255 -0
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +39 -18
- package/src/components/VideoPlayer/VideoPlayer.test.tsx +103 -1
- package/src/components/VideoPlayer/VideoPlayer.tsx +57 -17
- package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +48 -0
- package/src/index.ts +6 -0
- package/src/theme/components/breadcrumb.ts +1 -1
- package/src/theme/components/card.ts +4 -5
- package/src/theme/components/global.ts +1 -1
- package/src/theme/components/icon.ts +2 -2
- package/src/theme/components/image.ts +8 -0
- package/src/theme/components/notification.ts +8 -6
- package/src/theme/components/toggle.ts +65 -0
- package/src/theme/foundations/spacing.ts +3 -0
- package/src/theme/index.ts +2 -0
- package/src/utils/componentCategories.ts +3 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { render, screen } from "@testing-library/react";
|
|
3
3
|
import { axe } from "jest-axe";
|
|
4
|
+
import renderer from "react-test-renderer";
|
|
4
5
|
|
|
5
6
|
import Link from "./Link";
|
|
6
7
|
import { LinkTypes } from "./LinkTypes";
|
|
@@ -139,6 +140,76 @@ describe("Link", () => {
|
|
|
139
140
|
).toThrowError("Please pass only one child into `Link`.");
|
|
140
141
|
});
|
|
141
142
|
|
|
143
|
+
it("renders the UI snapshot correctly", () => {
|
|
144
|
+
const standard = renderer
|
|
145
|
+
.create(
|
|
146
|
+
<Link href="#passed-in-link" id="standard-link" type={LinkTypes.Action}>
|
|
147
|
+
Standard
|
|
148
|
+
</Link>
|
|
149
|
+
)
|
|
150
|
+
.toJSON();
|
|
151
|
+
const typeForwards = renderer
|
|
152
|
+
.create(
|
|
153
|
+
<Link
|
|
154
|
+
href="#passed-in-link"
|
|
155
|
+
id="forwards-link"
|
|
156
|
+
type={LinkTypes.Forwards}
|
|
157
|
+
>
|
|
158
|
+
Forwards
|
|
159
|
+
</Link>
|
|
160
|
+
)
|
|
161
|
+
.toJSON();
|
|
162
|
+
const typeBackwards = renderer
|
|
163
|
+
.create(
|
|
164
|
+
<Link
|
|
165
|
+
href="#passed-in-link"
|
|
166
|
+
id="backwards-link"
|
|
167
|
+
type={LinkTypes.Backwards}
|
|
168
|
+
>
|
|
169
|
+
Backwards
|
|
170
|
+
</Link>
|
|
171
|
+
)
|
|
172
|
+
.toJSON();
|
|
173
|
+
const typeExternal = renderer
|
|
174
|
+
.create(
|
|
175
|
+
<Link
|
|
176
|
+
href="#passed-in-link"
|
|
177
|
+
id="external-link"
|
|
178
|
+
type={LinkTypes.External}
|
|
179
|
+
>
|
|
180
|
+
External
|
|
181
|
+
</Link>
|
|
182
|
+
)
|
|
183
|
+
.toJSON();
|
|
184
|
+
const typeButton = renderer
|
|
185
|
+
.create(
|
|
186
|
+
<Link href="#passed-in-link" id="button-link" type={LinkTypes.Button}>
|
|
187
|
+
Button
|
|
188
|
+
</Link>
|
|
189
|
+
)
|
|
190
|
+
.toJSON();
|
|
191
|
+
const withIconChild = renderer
|
|
192
|
+
.create(
|
|
193
|
+
<Link href="#passed-in-link" id="icon-link" type={LinkTypes.Action}>
|
|
194
|
+
<Icon
|
|
195
|
+
align={IconAlign.Left}
|
|
196
|
+
className="more-link"
|
|
197
|
+
iconRotation={IconRotationTypes.Rotate0}
|
|
198
|
+
id="link-icon"
|
|
199
|
+
name={IconNames.Download}
|
|
200
|
+
/>
|
|
201
|
+
Download
|
|
202
|
+
</Link>
|
|
203
|
+
)
|
|
204
|
+
.toJSON();
|
|
205
|
+
expect(standard).toMatchSnapshot();
|
|
206
|
+
expect(typeForwards).toMatchSnapshot();
|
|
207
|
+
expect(typeBackwards).toMatchSnapshot();
|
|
208
|
+
expect(typeExternal).toMatchSnapshot();
|
|
209
|
+
expect(typeButton).toMatchSnapshot();
|
|
210
|
+
expect(withIconChild).toMatchSnapshot();
|
|
211
|
+
});
|
|
212
|
+
|
|
142
213
|
// TODO:
|
|
143
214
|
// it("Passes the ref to the input element", () => {
|
|
144
215
|
// const ref = React.createRef<HTMLAnchorElement>();
|
|
@@ -27,7 +27,7 @@ export interface LinkProps {
|
|
|
27
27
|
* Renders the `Link` children components with a direction arrow icon based
|
|
28
28
|
* on the `Backwards` or `Forwards` `LinkTypes` type.
|
|
29
29
|
*/
|
|
30
|
-
function getWithDirectionIcon(children, type: LinkTypes) {
|
|
30
|
+
function getWithDirectionIcon(children, type: LinkTypes, linkId) {
|
|
31
31
|
let iconRotation;
|
|
32
32
|
let iconAlign;
|
|
33
33
|
let icon = null;
|
|
@@ -42,12 +42,15 @@ function getWithDirectionIcon(children, type: LinkTypes) {
|
|
|
42
42
|
iconAlign = IconAlign.Right;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
const iconId = `${linkId}-icon`;
|
|
46
|
+
|
|
45
47
|
icon = (
|
|
46
48
|
<Icon
|
|
47
|
-
name={IconNames.Arrow}
|
|
48
49
|
align={iconAlign}
|
|
49
|
-
iconRotation={iconRotation}
|
|
50
50
|
className="more-link"
|
|
51
|
+
iconRotation={iconRotation}
|
|
52
|
+
id={iconId}
|
|
53
|
+
name={IconNames.Arrow}
|
|
51
54
|
/>
|
|
52
55
|
);
|
|
53
56
|
|
|
@@ -60,6 +63,25 @@ function getWithDirectionIcon(children, type: LinkTypes) {
|
|
|
60
63
|
);
|
|
61
64
|
}
|
|
62
65
|
|
|
66
|
+
function getExternalIcon(children, linkId) {
|
|
67
|
+
const iconId = `${linkId}-icon`;
|
|
68
|
+
const icon = (
|
|
69
|
+
<Icon
|
|
70
|
+
align={IconAlign.Right}
|
|
71
|
+
className="more-link"
|
|
72
|
+
id={iconId}
|
|
73
|
+
name={IconNames.ActionLaunch}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<>
|
|
79
|
+
{children}
|
|
80
|
+
{icon}
|
|
81
|
+
</>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
63
85
|
/**
|
|
64
86
|
* A component that uses an `href` prop or a child anchor element, to create
|
|
65
87
|
* an anchor element with added styling and conventions.
|
|
@@ -93,19 +115,25 @@ const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
|
|
|
93
115
|
if (
|
|
94
116
|
type === LinkTypes.Action ||
|
|
95
117
|
type === LinkTypes.Forwards ||
|
|
96
|
-
type === LinkTypes.Backwards
|
|
118
|
+
type === LinkTypes.Backwards ||
|
|
119
|
+
type === LinkTypes.External
|
|
97
120
|
) {
|
|
98
121
|
variant = "moreLink";
|
|
99
122
|
} else if (type === LinkTypes.Button) {
|
|
100
123
|
variant = "button";
|
|
101
124
|
}
|
|
102
125
|
const style = useStyleConfig("Link", { variant });
|
|
103
|
-
// Render with specific direction arrows
|
|
104
|
-
//
|
|
126
|
+
// Render with specific direction arrows if the type is
|
|
127
|
+
// Forwards or Backwards. Or render with the launch icon
|
|
128
|
+
// if the type is External. Otherwise, do not add an icon.
|
|
105
129
|
const newChildren =
|
|
106
|
-
type === LinkTypes.Forwards || type === LinkTypes.Backwards
|
|
107
|
-
|
|
108
|
-
|
|
130
|
+
((type === LinkTypes.Forwards || type === LinkTypes.Backwards) &&
|
|
131
|
+
getWithDirectionIcon(children, type, id)) ||
|
|
132
|
+
(type === LinkTypes.External && getExternalIcon(children, id)) ||
|
|
133
|
+
children;
|
|
134
|
+
|
|
135
|
+
const rel = type === LinkTypes.External ? "nofollow" : null;
|
|
136
|
+
const target = type === LinkTypes.External ? "_blank" : null;
|
|
109
137
|
|
|
110
138
|
if (!href) {
|
|
111
139
|
// React Types error makes this fail:
|
|
@@ -123,6 +151,8 @@ const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
|
|
|
123
151
|
...linkProps,
|
|
124
152
|
...childProps,
|
|
125
153
|
ref,
|
|
154
|
+
rel,
|
|
155
|
+
target,
|
|
126
156
|
},
|
|
127
157
|
[childrenToClone.props.children]
|
|
128
158
|
);
|
|
@@ -132,6 +162,8 @@ const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
|
|
|
132
162
|
as="a"
|
|
133
163
|
className={className}
|
|
134
164
|
ref={ref}
|
|
165
|
+
rel={rel}
|
|
166
|
+
target={target}
|
|
135
167
|
{...linkProps}
|
|
136
168
|
__css={{ ...style, ...additionalStyles }}
|
|
137
169
|
>
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Link renders the UI snapshot correctly 1`] = `
|
|
4
|
+
<a
|
|
5
|
+
className="css-0"
|
|
6
|
+
href="#passed-in-link"
|
|
7
|
+
id="standard-link"
|
|
8
|
+
rel={null}
|
|
9
|
+
target={null}
|
|
10
|
+
>
|
|
11
|
+
Standard
|
|
12
|
+
</a>
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
exports[`Link renders the UI snapshot correctly 2`] = `
|
|
16
|
+
<a
|
|
17
|
+
className="css-0"
|
|
18
|
+
href="#passed-in-link"
|
|
19
|
+
id="forwards-link"
|
|
20
|
+
rel={null}
|
|
21
|
+
target={null}
|
|
22
|
+
>
|
|
23
|
+
Forwards
|
|
24
|
+
<svg
|
|
25
|
+
aria-hidden={true}
|
|
26
|
+
className="chakra-icon more-link css-onkibi"
|
|
27
|
+
focusable={false}
|
|
28
|
+
id="forwards-link-icon"
|
|
29
|
+
role="img"
|
|
30
|
+
title="arrow icon"
|
|
31
|
+
viewBox="0 0 24 24"
|
|
32
|
+
>
|
|
33
|
+
<g
|
|
34
|
+
stroke="currentColor"
|
|
35
|
+
strokeWidth="1.5"
|
|
36
|
+
>
|
|
37
|
+
<path
|
|
38
|
+
d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
|
|
39
|
+
fill="none"
|
|
40
|
+
strokeLinecap="round"
|
|
41
|
+
/>
|
|
42
|
+
<path
|
|
43
|
+
d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
|
|
44
|
+
fill="currentColor"
|
|
45
|
+
strokeLinecap="round"
|
|
46
|
+
/>
|
|
47
|
+
<circle
|
|
48
|
+
cx="12"
|
|
49
|
+
cy="12"
|
|
50
|
+
fill="none"
|
|
51
|
+
r="11.25"
|
|
52
|
+
strokeMiterlimit="10"
|
|
53
|
+
/>
|
|
54
|
+
</g>
|
|
55
|
+
</svg>
|
|
56
|
+
</a>
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
exports[`Link renders the UI snapshot correctly 3`] = `
|
|
60
|
+
<a
|
|
61
|
+
className="css-0"
|
|
62
|
+
href="#passed-in-link"
|
|
63
|
+
id="backwards-link"
|
|
64
|
+
rel={null}
|
|
65
|
+
target={null}
|
|
66
|
+
>
|
|
67
|
+
<svg
|
|
68
|
+
aria-hidden={true}
|
|
69
|
+
className="chakra-icon more-link css-onkibi"
|
|
70
|
+
focusable={false}
|
|
71
|
+
id="backwards-link-icon"
|
|
72
|
+
role="img"
|
|
73
|
+
title="arrow icon"
|
|
74
|
+
viewBox="0 0 24 24"
|
|
75
|
+
>
|
|
76
|
+
<g
|
|
77
|
+
stroke="currentColor"
|
|
78
|
+
strokeWidth="1.5"
|
|
79
|
+
>
|
|
80
|
+
<path
|
|
81
|
+
d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
|
|
82
|
+
fill="none"
|
|
83
|
+
strokeLinecap="round"
|
|
84
|
+
/>
|
|
85
|
+
<path
|
|
86
|
+
d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
|
|
87
|
+
fill="currentColor"
|
|
88
|
+
strokeLinecap="round"
|
|
89
|
+
/>
|
|
90
|
+
<circle
|
|
91
|
+
cx="12"
|
|
92
|
+
cy="12"
|
|
93
|
+
fill="none"
|
|
94
|
+
r="11.25"
|
|
95
|
+
strokeMiterlimit="10"
|
|
96
|
+
/>
|
|
97
|
+
</g>
|
|
98
|
+
</svg>
|
|
99
|
+
Backwards
|
|
100
|
+
</a>
|
|
101
|
+
`;
|
|
102
|
+
|
|
103
|
+
exports[`Link renders the UI snapshot correctly 4`] = `
|
|
104
|
+
<a
|
|
105
|
+
className="css-0"
|
|
106
|
+
href="#passed-in-link"
|
|
107
|
+
id="external-link"
|
|
108
|
+
rel="nofollow"
|
|
109
|
+
target="_blank"
|
|
110
|
+
>
|
|
111
|
+
External
|
|
112
|
+
<svg
|
|
113
|
+
aria-hidden={true}
|
|
114
|
+
className="chakra-icon more-link css-onkibi"
|
|
115
|
+
focusable={false}
|
|
116
|
+
id="external-link-icon"
|
|
117
|
+
role="img"
|
|
118
|
+
title="action_launch icon"
|
|
119
|
+
viewBox="0 0 24 24"
|
|
120
|
+
>
|
|
121
|
+
<g
|
|
122
|
+
stroke="currentColor"
|
|
123
|
+
strokeWidth="1.5"
|
|
124
|
+
>
|
|
125
|
+
<path
|
|
126
|
+
d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
|
|
127
|
+
fill="none"
|
|
128
|
+
strokeLinecap="round"
|
|
129
|
+
/>
|
|
130
|
+
<path
|
|
131
|
+
d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
|
|
132
|
+
fill="currentColor"
|
|
133
|
+
strokeLinecap="round"
|
|
134
|
+
/>
|
|
135
|
+
<circle
|
|
136
|
+
cx="12"
|
|
137
|
+
cy="12"
|
|
138
|
+
fill="none"
|
|
139
|
+
r="11.25"
|
|
140
|
+
strokeMiterlimit="10"
|
|
141
|
+
/>
|
|
142
|
+
</g>
|
|
143
|
+
</svg>
|
|
144
|
+
</a>
|
|
145
|
+
`;
|
|
146
|
+
|
|
147
|
+
exports[`Link renders the UI snapshot correctly 5`] = `
|
|
148
|
+
<a
|
|
149
|
+
className="css-0"
|
|
150
|
+
href="#passed-in-link"
|
|
151
|
+
id="button-link"
|
|
152
|
+
rel={null}
|
|
153
|
+
target={null}
|
|
154
|
+
>
|
|
155
|
+
Button
|
|
156
|
+
</a>
|
|
157
|
+
`;
|
|
158
|
+
|
|
159
|
+
exports[`Link renders the UI snapshot correctly 6`] = `
|
|
160
|
+
<a
|
|
161
|
+
className="css-0"
|
|
162
|
+
href="#passed-in-link"
|
|
163
|
+
id="icon-link"
|
|
164
|
+
rel={null}
|
|
165
|
+
target={null}
|
|
166
|
+
>
|
|
167
|
+
<svg
|
|
168
|
+
aria-hidden={true}
|
|
169
|
+
className="chakra-icon more-link css-onkibi"
|
|
170
|
+
focusable={false}
|
|
171
|
+
id="link-icon"
|
|
172
|
+
role="img"
|
|
173
|
+
title="download icon"
|
|
174
|
+
viewBox="0 0 24 24"
|
|
175
|
+
>
|
|
176
|
+
<g
|
|
177
|
+
stroke="currentColor"
|
|
178
|
+
strokeWidth="1.5"
|
|
179
|
+
>
|
|
180
|
+
<path
|
|
181
|
+
d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
|
|
182
|
+
fill="none"
|
|
183
|
+
strokeLinecap="round"
|
|
184
|
+
/>
|
|
185
|
+
<path
|
|
186
|
+
d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
|
|
187
|
+
fill="currentColor"
|
|
188
|
+
strokeLinecap="round"
|
|
189
|
+
/>
|
|
190
|
+
<circle
|
|
191
|
+
cx="12"
|
|
192
|
+
cy="12"
|
|
193
|
+
fill="none"
|
|
194
|
+
r="11.25"
|
|
195
|
+
strokeMiterlimit="10"
|
|
196
|
+
/>
|
|
197
|
+
</g>
|
|
198
|
+
</svg>
|
|
199
|
+
Download
|
|
200
|
+
</a>
|
|
201
|
+
`;
|
|
@@ -27,8 +27,7 @@ import DSProvider from "../../theme/provider";
|
|
|
27
27
|
parameters={{
|
|
28
28
|
design: {
|
|
29
29
|
type: "figma",
|
|
30
|
-
url:
|
|
31
|
-
"https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/?node-id=10734%3A812",
|
|
30
|
+
url: "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/?node-id=10734%3A812",
|
|
32
31
|
},
|
|
33
32
|
jest: ["Notification.test.tsx"],
|
|
34
33
|
}}
|
|
@@ -39,7 +38,7 @@ import DSProvider from "../../theme/provider";
|
|
|
39
38
|
| Component Version | DS Version |
|
|
40
39
|
| ----------------- | ---------- |
|
|
41
40
|
| Added | `0.23.2` |
|
|
42
|
-
| Latest | `0.25.
|
|
41
|
+
| Latest | `0.25.8` |
|
|
43
42
|
|
|
44
43
|
<Description of={Notification} />
|
|
45
44
|
|
|
@@ -67,6 +66,7 @@ within a parent element.
|
|
|
67
66
|
nisi erat porttitor ligula.
|
|
68
67
|
</>
|
|
69
68
|
),
|
|
69
|
+
showIcon: true,
|
|
70
70
|
}}
|
|
71
71
|
>
|
|
72
72
|
{(args) => (
|
|
@@ -194,6 +194,39 @@ within a parent element.
|
|
|
194
194
|
</DSProvider>
|
|
195
195
|
</Canvas>
|
|
196
196
|
|
|
197
|
+
### Without Icon
|
|
198
|
+
|
|
199
|
+
The `Notification` icon can be hidden with the `showIcon` prop set to `false`.
|
|
200
|
+
|
|
201
|
+
<Canvas>
|
|
202
|
+
<DSProvider>
|
|
203
|
+
<Notification
|
|
204
|
+
notificationHeading="Standard Notification without Icon"
|
|
205
|
+
notificationContent={
|
|
206
|
+
<>
|
|
207
|
+
Cras mattis consectetur purus sit amet fermentum. Maecenas faucibus
|
|
208
|
+
mollis interdum. Morbi leo risus, porta ac consectetur ac, vestibulum
|
|
209
|
+
at eros. Cum sociis natoque penatibus et magnis dis parturient montes,
|
|
210
|
+
nascetur ridiculus mus.
|
|
211
|
+
</>
|
|
212
|
+
}
|
|
213
|
+
showIcon={false}
|
|
214
|
+
/>
|
|
215
|
+
<Notification
|
|
216
|
+
notificationContent={
|
|
217
|
+
<>
|
|
218
|
+
This is an Standard Notification without a heading or icon. Cras
|
|
219
|
+
mattis consectetur purus sit amet fermentum. Maecenas faucibus mollis
|
|
220
|
+
interdum. Morbi leo risus, porta ac consectetur ac, vestibulum at
|
|
221
|
+
eros. Cum sociis natoque penatibus et magnis dis parturient montes,
|
|
222
|
+
nascetur ridiculus mus.
|
|
223
|
+
</>
|
|
224
|
+
}
|
|
225
|
+
showIcon={false}
|
|
226
|
+
/>
|
|
227
|
+
</DSProvider>
|
|
228
|
+
</Canvas>
|
|
229
|
+
|
|
197
230
|
## Custom Icon
|
|
198
231
|
|
|
199
232
|
The default icon can be overridden by using the `icon` prop to pass a custom `Icon` component.
|
|
@@ -13,8 +13,8 @@ describe("Notification Accessibility", () => {
|
|
|
13
13
|
const { container } = render(
|
|
14
14
|
<Notification
|
|
15
15
|
id="notificationID"
|
|
16
|
-
notificationHeading="Notification Heading"
|
|
17
16
|
notificationContent={<>Notification content.</>}
|
|
17
|
+
notificationHeading="Notification Heading"
|
|
18
18
|
/>
|
|
19
19
|
);
|
|
20
20
|
expect(await axe(container)).toHaveNoViolations();
|
|
@@ -29,6 +29,18 @@ describe("Notification Accessibility", () => {
|
|
|
29
29
|
);
|
|
30
30
|
expect(await axe(container)).toHaveNoViolations();
|
|
31
31
|
});
|
|
32
|
+
|
|
33
|
+
it("passes axe accessibility test without an icon", async () => {
|
|
34
|
+
const { container } = render(
|
|
35
|
+
<Notification
|
|
36
|
+
id="notificationID"
|
|
37
|
+
notificationContent={<>Notification content.</>}
|
|
38
|
+
notificationHeading="Notification Heading"
|
|
39
|
+
showIcon={false}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
expect(await axe(container)).toHaveNoViolations();
|
|
43
|
+
});
|
|
32
44
|
});
|
|
33
45
|
|
|
34
46
|
describe("Notification", () => {
|
|
@@ -37,8 +49,8 @@ describe("Notification", () => {
|
|
|
37
49
|
utils = render(
|
|
38
50
|
<Notification
|
|
39
51
|
id="notificationID"
|
|
40
|
-
notificationHeading="Notification Heading"
|
|
41
52
|
notificationContent={<>Notification content.</>}
|
|
53
|
+
notificationHeading="Notification Heading"
|
|
42
54
|
/>
|
|
43
55
|
);
|
|
44
56
|
});
|
|
@@ -51,7 +63,20 @@ describe("Notification", () => {
|
|
|
51
63
|
expect(screen.getByText("Notification content.")).toBeInTheDocument();
|
|
52
64
|
});
|
|
53
65
|
|
|
54
|
-
it("renders
|
|
66
|
+
it("renders with an Icon", () => {
|
|
67
|
+
// The Icon's role is "img".
|
|
68
|
+
expect(screen.queryByRole("img")).toBeInTheDocument();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("does not render an Icon", () => {
|
|
72
|
+
utils.rerender(
|
|
73
|
+
<Notification
|
|
74
|
+
id="notificationID"
|
|
75
|
+
notificationContent={<>Notification content.</>}
|
|
76
|
+
notificationHeading="Notification Heading"
|
|
77
|
+
showIcon={false}
|
|
78
|
+
/>
|
|
79
|
+
);
|
|
55
80
|
// The Icon's role is "img".
|
|
56
81
|
expect(screen.queryByRole("img")).not.toBeInTheDocument();
|
|
57
82
|
});
|
|
@@ -59,18 +84,18 @@ describe("Notification", () => {
|
|
|
59
84
|
it("renders a custom Icon component", () => {
|
|
60
85
|
utils.rerender(
|
|
61
86
|
<Notification
|
|
62
|
-
id="notificationID"
|
|
63
87
|
icon={
|
|
64
88
|
<Icon
|
|
65
89
|
id="custom-icon"
|
|
90
|
+
className="custom-icon"
|
|
91
|
+
color={IconColors.BrandPrimary}
|
|
66
92
|
name={IconNames.Check}
|
|
67
93
|
size={IconSizes.Large}
|
|
68
|
-
color={IconColors.BrandPrimary}
|
|
69
|
-
className="custom-icon"
|
|
70
94
|
/>
|
|
71
95
|
}
|
|
72
|
-
|
|
96
|
+
id="notificationID"
|
|
73
97
|
notificationContent={<>Notification content.</>}
|
|
98
|
+
notificationHeading="Notification Heading"
|
|
74
99
|
/>
|
|
75
100
|
);
|
|
76
101
|
expect(utils.container.querySelector(".custom-icon")).toBeInTheDocument();
|
|
@@ -80,9 +105,9 @@ describe("Notification", () => {
|
|
|
80
105
|
utils.rerender(
|
|
81
106
|
<Notification
|
|
82
107
|
id="notificationID"
|
|
83
|
-
notificationType={NotificationTypes.Announcement}
|
|
84
|
-
notificationHeading="Notification Heading"
|
|
85
108
|
notificationContent={<>Notification content.</>}
|
|
109
|
+
notificationHeading="Notification Heading"
|
|
110
|
+
notificationType={NotificationTypes.Announcement}
|
|
86
111
|
/>
|
|
87
112
|
);
|
|
88
113
|
|
|
@@ -96,9 +121,9 @@ describe("Notification", () => {
|
|
|
96
121
|
utils.rerender(
|
|
97
122
|
<Notification
|
|
98
123
|
id="notificationID"
|
|
99
|
-
notificationType={NotificationTypes.Warning}
|
|
100
|
-
notificationHeading="Notification Heading"
|
|
101
124
|
notificationContent={<>Notification content.</>}
|
|
125
|
+
notificationHeading="Notification Heading"
|
|
126
|
+
notificationType={NotificationTypes.Warning}
|
|
102
127
|
/>
|
|
103
128
|
);
|
|
104
129
|
|
|
@@ -113,8 +138,8 @@ describe("Notification", () => {
|
|
|
113
138
|
.create(
|
|
114
139
|
<Notification
|
|
115
140
|
id="notificationID1"
|
|
116
|
-
notificationHeading="Notification Heading"
|
|
117
141
|
notificationContent={<>Notification content.</>}
|
|
142
|
+
notificationHeading="Notification Heading"
|
|
118
143
|
/>
|
|
119
144
|
)
|
|
120
145
|
.toJSON();
|
|
@@ -122,9 +147,9 @@ describe("Notification", () => {
|
|
|
122
147
|
.create(
|
|
123
148
|
<Notification
|
|
124
149
|
id="notificationID2"
|
|
125
|
-
notificationType={NotificationTypes.Announcement}
|
|
126
|
-
notificationHeading="Notification Heading"
|
|
127
150
|
notificationContent={<>Notification content.</>}
|
|
151
|
+
notificationHeading="Notification Heading"
|
|
152
|
+
notificationType={NotificationTypes.Announcement}
|
|
128
153
|
/>
|
|
129
154
|
)
|
|
130
155
|
.toJSON();
|
|
@@ -132,9 +157,9 @@ describe("Notification", () => {
|
|
|
132
157
|
.create(
|
|
133
158
|
<Notification
|
|
134
159
|
id="notificationID3"
|
|
135
|
-
notificationType={NotificationTypes.Warning}
|
|
136
|
-
notificationHeading="Notification Heading"
|
|
137
160
|
notificationContent={<>Notification content.</>}
|
|
161
|
+
notificationHeading="Notification Heading"
|
|
162
|
+
notificationType={NotificationTypes.Warning}
|
|
138
163
|
/>
|
|
139
164
|
)
|
|
140
165
|
.toJSON();
|
|
@@ -146,9 +171,30 @@ describe("Notification", () => {
|
|
|
146
171
|
/>
|
|
147
172
|
)
|
|
148
173
|
.toJSON();
|
|
174
|
+
const withoutAnIcon = renderer
|
|
175
|
+
.create(
|
|
176
|
+
<Notification
|
|
177
|
+
id="notificationID5"
|
|
178
|
+
notificationHeading="Notification Heading"
|
|
179
|
+
notificationContent={<>Notification content.</>}
|
|
180
|
+
showIcon={false}
|
|
181
|
+
/>
|
|
182
|
+
)
|
|
183
|
+
.toJSON();
|
|
184
|
+
const withoutHeadingAndIcon = renderer
|
|
185
|
+
.create(
|
|
186
|
+
<Notification
|
|
187
|
+
id="notificationID6"
|
|
188
|
+
notificationContent={<>Notification content.</>}
|
|
189
|
+
showIcon={false}
|
|
190
|
+
/>
|
|
191
|
+
)
|
|
192
|
+
.toJSON();
|
|
149
193
|
expect(standard).toMatchSnapshot();
|
|
150
194
|
expect(announcement).toMatchSnapshot();
|
|
151
195
|
expect(warning).toMatchSnapshot();
|
|
152
196
|
expect(withoutHeading).toMatchSnapshot();
|
|
197
|
+
expect(withoutAnIcon).toMatchSnapshot();
|
|
198
|
+
expect(withoutHeadingAndIcon).toMatchSnapshot();
|
|
153
199
|
});
|
|
154
200
|
});
|