@onewelcome/react-lib-components 5.2.0 → 6.0.0
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/dist/cjs/Button/BaseButton.cjs.js.map +1 -1
- package/dist/cjs/Button/BaseButton.module.cjs.js +1 -1
- package/dist/cjs/Button/Button.module.cjs.js +1 -1
- package/dist/cjs/Button/IconButton.module.cjs.js +1 -1
- package/dist/cjs/Icon/Icon.cjs.js +1 -1
- package/dist/cjs/Icon/Icon.cjs.js.map +1 -1
- package/dist/cjs/Icon/Icon.module.cjs.js +1 -1
- package/dist/cjs/Link/Link.cjs.js.map +1 -1
- package/dist/cjs/Link/Link.module.cjs.js +1 -1
- package/dist/cjs/Notifications/Snackbar/SnackbarItem/SnackbarItem.cjs.js +1 -1
- package/dist/cjs/Notifications/Snackbar/SnackbarItem/SnackbarItem.cjs.js.map +1 -1
- package/dist/cjs/Notifications/Snackbar/SnackbarItem/SnackbarItem.module.cjs.js +1 -1
- package/dist/cjs/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.cjs.js +1 -1
- package/dist/cjs/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.cjs.js.map +1 -1
- package/dist/cjs/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.cjs.js.map +1 -1
- package/dist/cjs/Notifications/Snackbar/interfaces.cjs.js +2 -0
- package/dist/cjs/Notifications/Snackbar/interfaces.cjs.js.map +1 -0
- package/dist/cjs/_BaseStyling_/BaseStyling.cjs.js +1 -1
- package/dist/cjs/_BaseStyling_/BaseStyling.cjs.js.map +1 -1
- package/dist/cjs/src/components/Button/BaseButton.d.ts +1 -1
- package/dist/cjs/src/components/Icon/Icon.d.ts +4 -1
- package/dist/cjs/src/components/Link/Link.d.ts +1 -1
- package/dist/cjs/src/components/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.d.ts +5 -5
- package/dist/cjs/src/components/Notifications/Snackbar/interfaces.d.ts +6 -0
- package/dist/cjs/src/components/Notifications/Snackbar/useSnackbar.d.ts +4 -4
- package/dist/cjs/src/components/Notifications/Snackbar/useSnackbar.test.d.ts +1 -0
- package/dist/cjs/src/components/_BaseStyling_/BaseStyling.d.ts +11 -10
- package/dist/esm/Button/BaseButton.esm.js.map +1 -1
- package/dist/esm/Button/BaseButton.module.esm.js +1 -1
- package/dist/esm/Button/Button.module.esm.js +1 -1
- package/dist/esm/Button/IconButton.module.esm.js +1 -1
- package/dist/esm/Icon/Icon.esm.js +1 -1
- package/dist/esm/Icon/Icon.esm.js.map +1 -1
- package/dist/esm/Icon/Icon.module.esm.js +1 -1
- package/dist/esm/Link/Link.esm.js.map +1 -1
- package/dist/esm/Link/Link.module.esm.js +1 -1
- package/dist/esm/Notifications/Snackbar/SnackbarItem/SnackbarItem.esm.js +1 -1
- package/dist/esm/Notifications/Snackbar/SnackbarItem/SnackbarItem.esm.js.map +1 -1
- package/dist/esm/Notifications/Snackbar/SnackbarItem/SnackbarItem.module.esm.js +1 -1
- package/dist/esm/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.esm.js +1 -1
- package/dist/esm/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.esm.js.map +1 -1
- package/dist/esm/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.esm.js.map +1 -1
- package/dist/esm/Notifications/Snackbar/interfaces.esm.js +2 -0
- package/dist/esm/Notifications/Snackbar/interfaces.esm.js.map +1 -0
- package/dist/esm/_BaseStyling_/BaseStyling.esm.js +1 -1
- package/dist/esm/_BaseStyling_/BaseStyling.esm.js.map +1 -1
- package/dist/esm/src/components/Button/BaseButton.d.ts +1 -1
- package/dist/esm/src/components/Icon/Icon.d.ts +4 -1
- package/dist/esm/src/components/Link/Link.d.ts +1 -1
- package/dist/esm/src/components/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.d.ts +5 -5
- package/dist/esm/src/components/Notifications/Snackbar/interfaces.d.ts +6 -0
- package/dist/esm/src/components/Notifications/Snackbar/useSnackbar.d.ts +4 -4
- package/dist/esm/src/components/Notifications/Snackbar/useSnackbar.test.d.ts +1 -0
- package/dist/esm/src/components/_BaseStyling_/BaseStyling.d.ts +11 -10
- package/package.json +1 -1
- package/src/components/Button/BaseButton.tsx +1 -1
- package/src/components/Button/Button.module.scss +2 -10
- package/src/components/Button/Button.test.tsx +15 -3
- package/src/components/Button/IconButton.test.tsx +0 -16
- package/src/components/Icon/Icon.module.scss +12 -0
- package/src/components/Icon/Icon.tsx +4 -1
- package/src/components/Link/Link.module.scss +12 -4
- package/src/components/Link/Link.test.tsx +11 -5
- package/src/components/Link/Link.tsx +1 -1
- package/src/components/Notifications/Snackbar/SnackbarItem/SnackbarItem.module.scss +14 -21
- package/src/components/Notifications/Snackbar/SnackbarItem/SnackbarItem.test.tsx +20 -6
- package/src/components/Notifications/Snackbar/SnackbarItem/SnackbarItem.tsx +17 -13
- package/src/components/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.test.tsx +36 -32
- package/src/components/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.tsx +43 -17
- package/src/components/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.tsx +5 -13
- package/src/components/Notifications/Snackbar/interfaces.ts +15 -0
- package/src/components/Notifications/Snackbar/useSnackbar.test.tsx +136 -0
- package/src/components/_BaseStyling_/BaseStyling.tsx +24 -22
- package/src/font/icomoon.eot +0 -0
- package/src/font/icomoon.svg +5 -2
- package/src/font/icomoon.ttf +0 -0
- package/src/font/icomoon.woff +0 -0
- package/src/font/selection.json +1 -1
- package/src/mixins.module.scss +58 -57
|
@@ -65,6 +65,9 @@ export const SnackbarItem = ({
|
|
|
65
65
|
const timerHandler = useRef<ReturnType<typeof setTimeout>>();
|
|
66
66
|
const onAnimationEnd = () => onClose(id);
|
|
67
67
|
const { ref, animationStarted, startAnimation } = useAnimation<HTMLDivElement>(onAnimationEnd);
|
|
68
|
+
const hasOnlyTitle = !content && !!title;
|
|
69
|
+
const renderTitle = title && !hasOnlyTitle;
|
|
70
|
+
const renderContentOrTitleOnly = content || hasOnlyTitle;
|
|
68
71
|
|
|
69
72
|
useRegisterSnackbarHeight(ref, id);
|
|
70
73
|
|
|
@@ -113,7 +116,6 @@ export const SnackbarItem = ({
|
|
|
113
116
|
classes["snackbar"],
|
|
114
117
|
classes[variant],
|
|
115
118
|
animationStarted ? readyclasses["slide-out"] : readyclasses["slide-in"],
|
|
116
|
-
title ? classes["has-title"] : "",
|
|
117
119
|
className ?? ""
|
|
118
120
|
].join(" ");
|
|
119
121
|
|
|
@@ -125,18 +127,20 @@ export const SnackbarItem = ({
|
|
|
125
127
|
onMouseEnter={onMouseEnter}
|
|
126
128
|
onMouseLeave={onMouseLeave}
|
|
127
129
|
>
|
|
128
|
-
<
|
|
129
|
-
|
|
130
|
-
{
|
|
131
|
-
|
|
132
|
-
{title}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
{content}
|
|
138
|
-
|
|
139
|
-
|
|
130
|
+
<div className={classes["outer-content-wrapper"]}>
|
|
131
|
+
<Icon icon={getVariantIcon()} className={classes["icon"]} />
|
|
132
|
+
<div className={classes["content-wrapper"]}>
|
|
133
|
+
{renderTitle && (
|
|
134
|
+
<Typography className={classes["title"]} variant="body-bold" tag="span">
|
|
135
|
+
{title}
|
|
136
|
+
</Typography>
|
|
137
|
+
)}
|
|
138
|
+
{renderContentOrTitleOnly && (
|
|
139
|
+
<Typography className={classes["content"]} variant="body">
|
|
140
|
+
{hasOnlyTitle ? title : content}
|
|
141
|
+
</Typography>
|
|
142
|
+
)}
|
|
143
|
+
</div>
|
|
140
144
|
</div>
|
|
141
145
|
{actionButtons.length > 0 && <div className={classes["actions"]}>{actionButtons}</div>}
|
|
142
146
|
<IconButton
|
|
@@ -78,7 +78,7 @@ const renderSnackbarProvider = (props?: Partial<Props>) => {
|
|
|
78
78
|
<button
|
|
79
79
|
data-testid="show-success"
|
|
80
80
|
onClick={() => {
|
|
81
|
-
enqueueSuccessSnackbar(successProps.title + index,
|
|
81
|
+
enqueueSuccessSnackbar({ title: successProps.title + index, ...successProps.options });
|
|
82
82
|
setIndex(index + 1);
|
|
83
83
|
}}
|
|
84
84
|
>
|
|
@@ -87,7 +87,7 @@ const renderSnackbarProvider = (props?: Partial<Props>) => {
|
|
|
87
87
|
<button
|
|
88
88
|
data-testid="show-error"
|
|
89
89
|
onClick={() => {
|
|
90
|
-
enqueueErrorSnackbar(errorProps.title + index);
|
|
90
|
+
enqueueErrorSnackbar({ title: errorProps.title + index });
|
|
91
91
|
setIndex(index + 1);
|
|
92
92
|
}}
|
|
93
93
|
>
|
|
@@ -96,7 +96,11 @@ const renderSnackbarProvider = (props?: Partial<Props>) => {
|
|
|
96
96
|
<button
|
|
97
97
|
data-testid="show-info"
|
|
98
98
|
onClick={() => {
|
|
99
|
-
enqueueSnackbar(
|
|
99
|
+
enqueueSnackbar({
|
|
100
|
+
title: infoProps.title + index,
|
|
101
|
+
content: infoProps.content,
|
|
102
|
+
...infoProps.options
|
|
103
|
+
});
|
|
100
104
|
setIndex(index + 1);
|
|
101
105
|
}}
|
|
102
106
|
>
|
|
@@ -105,7 +109,7 @@ const renderSnackbarProvider = (props?: Partial<Props>) => {
|
|
|
105
109
|
<button
|
|
106
110
|
data-testid="show-warning"
|
|
107
111
|
onClick={() => {
|
|
108
|
-
enqueueWarningSnackbar(warningProps.title + index,
|
|
112
|
+
enqueueWarningSnackbar({ title: warningProps.title + index, ...warningProps.options });
|
|
109
113
|
setIndex(index + 1);
|
|
110
114
|
}}
|
|
111
115
|
>
|
|
@@ -135,8 +139,8 @@ const renderSnackbarProvider = (props?: Partial<Props>) => {
|
|
|
135
139
|
};
|
|
136
140
|
};
|
|
137
141
|
|
|
138
|
-
describe("SnackbarProvider", () => {
|
|
139
|
-
it("
|
|
142
|
+
describe("<SnackbarProvider />", () => {
|
|
143
|
+
it("should render without crashing", () => {
|
|
140
144
|
const { container } = renderSnackbarProvider();
|
|
141
145
|
|
|
142
146
|
expect(container).toHaveTextContent("content");
|
|
@@ -176,40 +180,40 @@ describe("SnackbarProvider", () => {
|
|
|
176
180
|
|
|
177
181
|
expect(infoProps.options.actions[0].onClick).toBeCalledTimes(1);
|
|
178
182
|
});
|
|
179
|
-
});
|
|
180
183
|
|
|
181
|
-
describe("handlers", () => {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
describe("handlers", () => {
|
|
185
|
+
it("should fire onClose", async () => {
|
|
186
|
+
const onCloseHandler = jest.fn();
|
|
187
|
+
const ExampleComponent = () => {
|
|
188
|
+
const { enqueueErrorSnackbar, enqueueSuccessSnackbar } = useSnackbar();
|
|
186
189
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
190
|
+
useEffect(() => {
|
|
191
|
+
enqueueErrorSnackbar("error", undefined, { onClose: onCloseHandler, duration: 1 });
|
|
192
|
+
enqueueSuccessSnackbar("success", undefined, { onClose: onCloseHandler, duration: 1 });
|
|
193
|
+
}, []);
|
|
191
194
|
|
|
192
|
-
|
|
193
|
-
|
|
195
|
+
return <div></div>;
|
|
196
|
+
};
|
|
194
197
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
const queries = render(
|
|
199
|
+
<SnackbarProvider closeButtonTitle="close">
|
|
200
|
+
<ExampleComponent />
|
|
201
|
+
</SnackbarProvider>
|
|
202
|
+
);
|
|
200
203
|
|
|
201
|
-
|
|
202
|
-
|
|
204
|
+
const errorSnackbar = await queries.findByText(/error/i);
|
|
205
|
+
const successSnackbar = await queries.findByText(/success/i);
|
|
203
206
|
|
|
204
|
-
|
|
205
|
-
|
|
207
|
+
expect(errorSnackbar).toBeTruthy();
|
|
208
|
+
expect(successSnackbar).toBeTruthy();
|
|
206
209
|
|
|
207
|
-
|
|
208
|
-
|
|
210
|
+
const parentErrorSnackbar = errorSnackbar.closest(".snackbar")!;
|
|
211
|
+
const parentSuccessSnackbar = successSnackbar.closest(".snackbar")!;
|
|
209
212
|
|
|
210
|
-
|
|
211
|
-
|
|
213
|
+
fireEvent.animationEnd(parentErrorSnackbar);
|
|
214
|
+
fireEvent.animationEnd(parentSuccessSnackbar);
|
|
212
215
|
|
|
213
|
-
|
|
216
|
+
await waitFor(() => expect(onCloseHandler).toHaveBeenCalledTimes(2));
|
|
217
|
+
});
|
|
214
218
|
});
|
|
215
219
|
});
|
|
@@ -17,7 +17,13 @@
|
|
|
17
17
|
import React, { ReactNode, useRef, useState } from "react";
|
|
18
18
|
import { createPortal } from "react-dom";
|
|
19
19
|
import { SnackbarContextProvider } from "./SnackbarStateProvider";
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
Actions,
|
|
22
|
+
EnqueueSnackbarProps,
|
|
23
|
+
SnackbarOptionsProps,
|
|
24
|
+
Variant,
|
|
25
|
+
isNewEnqueueSnackbarInterface
|
|
26
|
+
} from "../interfaces";
|
|
21
27
|
import { Placement, SnackbarContainer } from "../SnackbarContainer/SnackbarContainer";
|
|
22
28
|
import { generateID } from "../../../../util/helper";
|
|
23
29
|
import { SnackbarItem } from "../SnackbarItem/SnackbarItem";
|
|
@@ -92,52 +98,72 @@ export const SnackbarProvider = (
|
|
|
92
98
|
};
|
|
93
99
|
|
|
94
100
|
const enqueueSnackbar = (
|
|
95
|
-
|
|
101
|
+
propsOrTitle: EnqueueSnackbarProps | string | undefined,
|
|
96
102
|
content?: string,
|
|
97
103
|
options: SnackbarOptionsProps = {}
|
|
98
104
|
): void => {
|
|
105
|
+
const newInterface = isNewEnqueueSnackbarInterface(propsOrTitle);
|
|
106
|
+
const props = newInterface ? propsOrTitle : mapToNewInterface(propsOrTitle, content, options);
|
|
99
107
|
const {
|
|
100
108
|
variant = "info",
|
|
101
109
|
actions,
|
|
102
|
-
duration = getDuration(variant, actions, content),
|
|
110
|
+
duration = getDuration(variant, actions, props.content),
|
|
103
111
|
onClose
|
|
104
|
-
} =
|
|
112
|
+
} = props;
|
|
105
113
|
const item: Item = {
|
|
106
|
-
title,
|
|
107
|
-
content,
|
|
114
|
+
title: props.title,
|
|
115
|
+
content: props.content,
|
|
108
116
|
variant,
|
|
109
|
-
className:
|
|
117
|
+
className: props.className,
|
|
110
118
|
actions,
|
|
111
119
|
duration,
|
|
112
120
|
height: 0,
|
|
113
|
-
id: generateID(15, title),
|
|
121
|
+
id: generateID(15, props.title),
|
|
114
122
|
onClose
|
|
115
123
|
};
|
|
116
124
|
addSnackbar(item);
|
|
117
125
|
};
|
|
118
126
|
|
|
119
|
-
const
|
|
127
|
+
const mapToNewInterface = (
|
|
120
128
|
title?: string,
|
|
121
129
|
content?: string,
|
|
122
|
-
options
|
|
130
|
+
options: SnackbarOptionsProps = {}
|
|
131
|
+
): EnqueueSnackbarProps => {
|
|
132
|
+
return {
|
|
133
|
+
title,
|
|
134
|
+
content,
|
|
135
|
+
...options
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const enqueueSuccessSnackbar = (
|
|
140
|
+
propsOrTitle: EnqueueSnackbarProps | string | undefined,
|
|
141
|
+
content?: string,
|
|
142
|
+
options: SnackbarOptionsProps = {}
|
|
123
143
|
): void => {
|
|
124
|
-
|
|
144
|
+
const newInterface = isNewEnqueueSnackbarInterface(propsOrTitle);
|
|
145
|
+
const props = newInterface ? propsOrTitle : mapToNewInterface(propsOrTitle, content, options);
|
|
146
|
+
enqueueSnackbar({ ...props, variant: "success" });
|
|
125
147
|
};
|
|
126
148
|
|
|
127
149
|
const enqueueErrorSnackbar = (
|
|
128
|
-
|
|
150
|
+
propsOrTitle: EnqueueSnackbarProps | string | undefined,
|
|
129
151
|
content?: string,
|
|
130
|
-
options
|
|
152
|
+
options: SnackbarOptionsProps = {}
|
|
131
153
|
): void => {
|
|
132
|
-
|
|
154
|
+
const newInterface = isNewEnqueueSnackbarInterface(propsOrTitle);
|
|
155
|
+
const props = newInterface ? propsOrTitle : mapToNewInterface(propsOrTitle, content, options);
|
|
156
|
+
enqueueSnackbar({ ...props, variant: "error" });
|
|
133
157
|
};
|
|
134
158
|
|
|
135
159
|
const enqueueWarningSnackbar = (
|
|
136
|
-
|
|
160
|
+
propsOrTitle: EnqueueSnackbarProps | string | undefined,
|
|
137
161
|
content?: string,
|
|
138
|
-
options
|
|
162
|
+
options: SnackbarOptionsProps = {}
|
|
139
163
|
): void => {
|
|
140
|
-
|
|
164
|
+
const newInterface = isNewEnqueueSnackbarInterface(propsOrTitle);
|
|
165
|
+
const props = newInterface ? propsOrTitle : mapToNewInterface(propsOrTitle, content, options);
|
|
166
|
+
enqueueSnackbar({ ...props, variant: "warning" });
|
|
141
167
|
};
|
|
142
168
|
|
|
143
169
|
const onItemClosed = (id: string) => {
|
|
@@ -15,22 +15,14 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import React, { createContext } from "react";
|
|
18
|
-
import {
|
|
18
|
+
import { DeprecatedEnqueueSnackbarType } from "../interfaces";
|
|
19
19
|
import { Item } from "./SnackbarProvider";
|
|
20
20
|
|
|
21
21
|
interface SnackbarContextProps {
|
|
22
|
-
enqueueSnackbar:
|
|
23
|
-
enqueueSuccessSnackbar:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
options?: SnackbarOptionsProps
|
|
27
|
-
) => void;
|
|
28
|
-
enqueueWarningSnackbar: (
|
|
29
|
-
title?: string,
|
|
30
|
-
content?: string,
|
|
31
|
-
options?: SnackbarOptionsProps
|
|
32
|
-
) => void;
|
|
33
|
-
enqueueErrorSnackbar: (title?: string, content?: string, options?: SnackbarOptionsProps) => void;
|
|
22
|
+
enqueueSnackbar: DeprecatedEnqueueSnackbarType;
|
|
23
|
+
enqueueSuccessSnackbar: DeprecatedEnqueueSnackbarType;
|
|
24
|
+
enqueueWarningSnackbar: DeprecatedEnqueueSnackbarType;
|
|
25
|
+
enqueueErrorSnackbar: DeprecatedEnqueueSnackbarType;
|
|
34
26
|
setSnackbarHeight: (id: string, height: number) => void;
|
|
35
27
|
snackbars: Item[];
|
|
36
28
|
}
|
|
@@ -27,3 +27,18 @@ export interface SnackbarOptionsProps {
|
|
|
27
27
|
duration?: number;
|
|
28
28
|
onClose?: () => void;
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
export interface EnqueueSnackbarProps extends SnackbarOptionsProps {
|
|
32
|
+
title?: string;
|
|
33
|
+
content?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type DeprecatedEnqueueSnackbarType = (
|
|
37
|
+
propsOrTitle: EnqueueSnackbarProps | string | undefined,
|
|
38
|
+
content?: string,
|
|
39
|
+
options?: SnackbarOptionsProps
|
|
40
|
+
) => void;
|
|
41
|
+
|
|
42
|
+
export function isNewEnqueueSnackbarInterface(args: unknown): args is EnqueueSnackbarProps {
|
|
43
|
+
return args !== null && typeof args === "object" && ("title" in args || "content" in args);
|
|
44
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2022 OneWelcome B.V.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import React from "react";
|
|
17
|
+
import { act, renderHook } from "@testing-library/react";
|
|
18
|
+
import { useSnackbar } from "./useSnackbar";
|
|
19
|
+
import { SnackbarProvider } from "./SnackbarProvider/SnackbarProvider";
|
|
20
|
+
|
|
21
|
+
describe("useNotificationContext", () => {
|
|
22
|
+
it("should return the correct context", () => {
|
|
23
|
+
const { result } = renderHook(() => useSnackbar(), {
|
|
24
|
+
wrapper: ({ children }) => (
|
|
25
|
+
<SnackbarProvider closeButtonTitle="close">{children}</SnackbarProvider>
|
|
26
|
+
)
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
expect(result.current).toEqual({
|
|
30
|
+
enqueueWarningSnackbar: expect.any(Function),
|
|
31
|
+
enqueueErrorSnackbar: expect.any(Function),
|
|
32
|
+
enqueueSuccessSnackbar: expect.any(Function),
|
|
33
|
+
enqueueSnackbar: expect.any(Function)
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should call new API", () => {
|
|
38
|
+
const { result } = renderHook(() => useSnackbar(), {
|
|
39
|
+
wrapper: ({ children }) => (
|
|
40
|
+
<SnackbarProvider closeButtonTitle="close">{children}</SnackbarProvider>
|
|
41
|
+
)
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
act(() => {
|
|
45
|
+
result.current.enqueueSnackbar({ title: "title" });
|
|
46
|
+
result.current.enqueueSnackbar({ title: "title", content: "content" });
|
|
47
|
+
result.current.enqueueSnackbar({
|
|
48
|
+
title: "title",
|
|
49
|
+
content: "content",
|
|
50
|
+
onClose: () => {},
|
|
51
|
+
actions: []
|
|
52
|
+
});
|
|
53
|
+
result.current.enqueueSnackbar({ content: "content" });
|
|
54
|
+
result.current.enqueueSnackbar({ content: "content", className: "123" });
|
|
55
|
+
result.current.enqueueSnackbar({ title: "title", variant: "error", duration: 123 });
|
|
56
|
+
|
|
57
|
+
result.current.enqueueErrorSnackbar({ title: "title" });
|
|
58
|
+
result.current.enqueueErrorSnackbar({ title: "title", content: "content" });
|
|
59
|
+
result.current.enqueueErrorSnackbar({
|
|
60
|
+
title: "title",
|
|
61
|
+
content: "content",
|
|
62
|
+
onClose: () => {},
|
|
63
|
+
actions: []
|
|
64
|
+
});
|
|
65
|
+
result.current.enqueueErrorSnackbar({ content: "content" });
|
|
66
|
+
result.current.enqueueErrorSnackbar({ content: "content", className: "123" });
|
|
67
|
+
result.current.enqueueErrorSnackbar({ title: "title", duration: 123 });
|
|
68
|
+
|
|
69
|
+
result.current.enqueueSuccessSnackbar({ title: "title" });
|
|
70
|
+
result.current.enqueueSuccessSnackbar({ title: "title", content: "content" });
|
|
71
|
+
result.current.enqueueSuccessSnackbar({
|
|
72
|
+
title: "title",
|
|
73
|
+
content: "content",
|
|
74
|
+
onClose: () => {},
|
|
75
|
+
actions: []
|
|
76
|
+
});
|
|
77
|
+
result.current.enqueueSuccessSnackbar({ content: "content" });
|
|
78
|
+
result.current.enqueueSuccessSnackbar({ content: "content", className: "123" });
|
|
79
|
+
result.current.enqueueSuccessSnackbar({ title: "title", duration: 123 });
|
|
80
|
+
|
|
81
|
+
result.current.enqueueWarningSnackbar({ title: "title" });
|
|
82
|
+
result.current.enqueueWarningSnackbar({ title: "title", content: "content" });
|
|
83
|
+
result.current.enqueueWarningSnackbar({
|
|
84
|
+
title: "title",
|
|
85
|
+
content: "content",
|
|
86
|
+
onClose: () => {},
|
|
87
|
+
actions: []
|
|
88
|
+
});
|
|
89
|
+
result.current.enqueueWarningSnackbar({ content: "content" });
|
|
90
|
+
result.current.enqueueWarningSnackbar({ content: "content", className: "123" });
|
|
91
|
+
result.current.enqueueWarningSnackbar({ title: "title", duration: 123 });
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("should call deprecated API", () => {
|
|
96
|
+
const { result } = renderHook(() => useSnackbar(), {
|
|
97
|
+
wrapper: ({ children }) => (
|
|
98
|
+
<SnackbarProvider closeButtonTitle="close">{children}</SnackbarProvider>
|
|
99
|
+
)
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
act(() => {
|
|
103
|
+
result.current.enqueueSnackbar("title");
|
|
104
|
+
result.current.enqueueSnackbar("title", "content");
|
|
105
|
+
result.current.enqueueSnackbar("title", "content", { onClose: () => {}, actions: [] });
|
|
106
|
+
result.current.enqueueSnackbar(undefined, "content");
|
|
107
|
+
result.current.enqueueSnackbar(undefined, "content", { className: "123" });
|
|
108
|
+
result.current.enqueueSnackbar("title", undefined, { variant: "error", duration: 123 });
|
|
109
|
+
|
|
110
|
+
result.current.enqueueErrorSnackbar("title");
|
|
111
|
+
result.current.enqueueErrorSnackbar("title", "content");
|
|
112
|
+
result.current.enqueueErrorSnackbar("title", "content", { onClose: () => {}, actions: [] });
|
|
113
|
+
result.current.enqueueErrorSnackbar(undefined, "content");
|
|
114
|
+
result.current.enqueueErrorSnackbar(undefined, "content", { className: "123" });
|
|
115
|
+
result.current.enqueueErrorSnackbar("title", undefined, { duration: 123 });
|
|
116
|
+
|
|
117
|
+
result.current.enqueueSuccessSnackbar("title");
|
|
118
|
+
result.current.enqueueSuccessSnackbar("title", "content");
|
|
119
|
+
result.current.enqueueSuccessSnackbar("title", "content", { onClose: () => {}, actions: [] });
|
|
120
|
+
result.current.enqueueSuccessSnackbar(undefined, "content");
|
|
121
|
+
result.current.enqueueSuccessSnackbar(undefined, "content", { className: "123" });
|
|
122
|
+
result.current.enqueueSuccessSnackbar("title", undefined, {
|
|
123
|
+
duration: 123
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
result.current.enqueueWarningSnackbar("title");
|
|
127
|
+
result.current.enqueueWarningSnackbar("title", "content");
|
|
128
|
+
result.current.enqueueWarningSnackbar("title", "content", { onClose: () => {}, actions: [] });
|
|
129
|
+
result.current.enqueueWarningSnackbar(undefined, "content");
|
|
130
|
+
result.current.enqueueWarningSnackbar(undefined, "content", { className: "123" });
|
|
131
|
+
result.current.enqueueWarningSnackbar("title", undefined, {
|
|
132
|
+
duration: 123
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -24,8 +24,9 @@ import React, { HTMLAttributes, ReactElement, useEffect, useRef, useState } from
|
|
|
24
24
|
interface CSSProperties {
|
|
25
25
|
colorFocus?: string;
|
|
26
26
|
colorPrimary?: string;
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
colorSuccess?: string;
|
|
28
|
+
colorWarning?: string;
|
|
29
|
+
colorDanger?: string;
|
|
29
30
|
colorPrimary100?: string;
|
|
30
31
|
colorPrimary300?: string;
|
|
31
32
|
colorPrimary500?: string;
|
|
@@ -76,18 +77,18 @@ interface CSSProperties {
|
|
|
76
77
|
buttonPrimaryHoverColor?: string;
|
|
77
78
|
buttonPrimaryFocusedColor?: string;
|
|
78
79
|
buttonOutlineHoverTextColor?: string;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
buttonWarningDefaultColor?: string;
|
|
84
|
-
buttonWarningHoverColor?: string;
|
|
85
|
-
buttonWarningFocusedColor?: string;
|
|
86
|
-
buttonWarningPressedColor?: string;
|
|
80
|
+
buttonSuccessDefaultColor?: string;
|
|
81
|
+
buttonSuccessHoverColor?: string;
|
|
82
|
+
buttonSuccessFocusedColor?: string;
|
|
83
|
+
buttonSuccessPressedColor?: string;
|
|
87
84
|
buttonDangerDefaultColor?: string;
|
|
88
85
|
buttonDangerHoverColor?: string;
|
|
89
86
|
buttonDangerFocusedColor?: string;
|
|
90
87
|
buttonDangerPressedColor?: string;
|
|
88
|
+
buttonWarningDefaultColor?: string;
|
|
89
|
+
buttonWarningHoverColor?: string;
|
|
90
|
+
buttonWarningFocusedColor?: string;
|
|
91
|
+
buttonWarningPressedColor?: string;
|
|
91
92
|
buttonDefaultColor?: string;
|
|
92
93
|
buttonDefaultHoverColor?: string;
|
|
93
94
|
buttonDefaultFocusedColor?: string;
|
|
@@ -238,34 +239,35 @@ export const BaseStyling = ({ children, properties = {} }: Props) => {
|
|
|
238
239
|
colorWhite: "#FFFFFF",
|
|
239
240
|
colorFocus: "var(--color-primary300)",
|
|
240
241
|
colorPrimary: "var(--color-primary500)",
|
|
241
|
-
|
|
242
|
-
|
|
242
|
+
colorSuccess: "var(--color-green500)",
|
|
243
|
+
colorWarning: "var(--color-orange500)",
|
|
244
|
+
colorDanger: "var(--color-red500)",
|
|
243
245
|
defaultPressedColor: "var(--color-blue-grey100)",
|
|
244
246
|
defaultHoverColor: "var(--color-blue-grey25)",
|
|
245
247
|
defaultLineHeight: "1.5", //FIXME: UCL-395
|
|
246
248
|
defaultBorderRadius: "0.25rem",
|
|
247
249
|
focusBorderRadius: "0.125rem",
|
|
248
|
-
buttonBorderRadius: "
|
|
250
|
+
buttonBorderRadius: "0.125rem",
|
|
249
251
|
buttonBorderWidth: "2px",
|
|
250
|
-
buttonFontSize: "
|
|
252
|
+
buttonFontSize: "0.875rem",
|
|
251
253
|
buttonBorderStyle: "solid",
|
|
252
254
|
buttonFillTextColor: "var(--light)",
|
|
253
255
|
buttonPrimaryDefaultColor: "var(--color-primary500)",
|
|
254
256
|
buttonPrimaryHoverColor: "var(--color-primary600)",
|
|
255
257
|
buttonPrimaryFocusedColor: "var(--color-primary500)",
|
|
256
258
|
buttonPrimaryPressedColor: "var(--color-primary700)",
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
buttonWarningDefaultColor: "var(--color-orange500)",
|
|
262
|
-
buttonWarningHoverColor: "var(--color-orange600)",
|
|
263
|
-
buttonWarningFocusedColor: "var(--color-orange500)",
|
|
264
|
-
buttonWarningPressedColor: "var(--color-orange700)",
|
|
259
|
+
buttonSuccessDefaultColor: "var(--color-green500)",
|
|
260
|
+
buttonSuccessHoverColor: "var(--color-green600)",
|
|
261
|
+
buttonSuccessFocusedColor: "var(--color-green500)",
|
|
262
|
+
buttonSuccessPressedColor: "var(--color-green700)",
|
|
265
263
|
buttonDangerDefaultColor: "var(--color-red500)",
|
|
266
264
|
buttonDangerHoverColor: "var(--color-red600)",
|
|
267
265
|
buttonDangerFocusedColor: "var(--color-red500)",
|
|
268
266
|
buttonDangerPressedColor: "var(--color-red700)",
|
|
267
|
+
buttonWarningDefaultColor: "var(--color-orange500)",
|
|
268
|
+
buttonWarningHoverColor: "var(--color-orange600)",
|
|
269
|
+
buttonWarningFocusedColor: "var(--color-orange500)",
|
|
270
|
+
buttonWarningPressedColor: "var(--color-orange700)",
|
|
269
271
|
buttonDefaultColor: "var(--color-blue-grey700)",
|
|
270
272
|
buttonDefaultHoverColor: "var(--color-blue-grey800)",
|
|
271
273
|
buttonDefaultFocusedColor: "var(--color-blue-grey700)",
|
package/src/font/icomoon.eot
CHANGED
|
Binary file
|
package/src/font/icomoon.svg
CHANGED
|
@@ -72,9 +72,12 @@
|
|
|
72
72
|
<glyph unicode="" glyph-name="circle" d="M512-12.8c-254.493 0-460.8 206.305-460.8 460.8 0 254.493 206.307 460.8 460.8 460.8 254.495 0 460.8-206.307 460.8-460.8 0-254.495-206.305-460.8-460.8-460.8zM512-64c282.767 0 512 229.233 512 512 0 282.77-229.233 512-512 512-282.77 0-512-229.23-512-512 0-282.767 229.23-512 512-512z" />
|
|
73
73
|
<glyph unicode="" glyph-name="table-search" d="M860.814 200.053c69.71 110.903 36.968 258.245-74.463 327.955-35.895 22.749-79.602 36.253-126.464 36.253-84.338 0-158.461-43.738-200.922-109.769l-0.569-0.947c-69.71-111.431-35.911-259.3 74.463-327.955 77.632-48.585 175.86-48.585 253.492 0l164.241-163.185 73.407 73.407-163.185 164.241zM755.192 232.797c-51.754-51.754-135.196-51.227-186.95 0-51.227 51.754-51.227 135.196 0.529 186.95 51.227 51.227 134.667 51.227 186.422 0 50.698-52.283 50.17-135.723-1.584-186.95h1.584zM844.971 933.595h-739.351c-58.333 0-105.621-47.288-105.621-105.621v0-633.73c0-58.333 47.288-105.621 105.621-105.621v0h306.83c-28.777 29.605-52.137 64.653-68.367 103.427l-0.814 2.195h-237.648v211.243h220.749c8.45 37.495 22.709 73.407 43.305 105.621h-264.053v211.243h316.865v-148.398c29.605 28.777 64.653 52.137 103.427 68.367l2.195 0.814v79.216h316.865v-105.621c42.806-27.479 78.143-62.815 104.802-104.261l0.819-1.36v316.865c0 58.333-47.288 105.621-105.621 105.621v0z" />
|
|
74
74
|
<glyph unicode="" glyph-name="StyleFilled" d="M407.718 4.801v312.847h208.565v-312.847h260.705v417.125h156.424l-521.412 469.271-521.412-469.271h156.424v-417.125h260.705z" />
|
|
75
|
-
<glyph unicode="" glyph-name="file-outline" d="
|
|
75
|
+
<glyph unicode="" glyph-name="file-outline" d="M614.4 960.001h-409.6c-56.32 0-102.4-46.080-102.4-102.4v-819.2c0-56.32 46.080-102.4 102.4-102.4h614.399c56.32 0 102.4 46.080 102.4 102.4v614.399l-307.2 307.2zM819.2 38.4h-614.399v819.2h358.401v-256h256v-563.199z" />
|
|
76
76
|
<glyph unicode="" glyph-name="file-upload-outline" d="M597.333 874.667l256-256v-512c0-47.128-38.205-85.333-85.333-85.333v0h-512c-47.128 0-85.333 38.205-85.333 85.333v0 682.667c0 47.128 38.205 85.333 85.333 85.333v0h341.333zM768 106.667v469.333h-213.333v213.333h-298.667v-682.667h512zM512 448l170.667-170.667h-106.667v-128h-128v128h-106.667l170.667 170.667z" />
|
|
77
|
-
<glyph unicode="" glyph-name="file-download-outline" d="
|
|
77
|
+
<glyph unicode="" glyph-name="file-download-outline" d="M614.4 960.001l307.2-307.2v-614.4c0-56.554-45.846-102.4-102.4-102.4v0h-614.4c-56.554 0-102.4 45.846-102.4 102.4v0 819.201c0 56.554 45.846 102.4 102.4 102.4v0h409.6zM819.2 38.4v563.2h-256v256h-358.401v-819.201h614.4zM512 89.599l-204.8 204.8h128v153.6h153.6v-153.6h128l-204.8-204.8z" />
|
|
78
78
|
<glyph unicode="" glyph-name="error-circle" d="M512.001 959.999c-282.624 0-512.001-229.376-512.001-512.001s229.376-511.998 512.001-511.998c282.626 0 511.999 229.374 511.999 511.998s-229.374 512.001-511.999 512.001zM563.201 191.996h-102.4v102.402h102.4v-102.402zM563.201 396.799h-102.4v307.2h102.4v-307.2z" />
|
|
79
|
+
<glyph unicode="" glyph-name="upload" d="M933.648 598.588h-240.942v361.412h-361.412v-361.412h-240.942l421.648-421.648 421.648 421.648zM451.764 478.116v361.412h120.47v-361.412h70.475l-130.711-130.711-130.711 130.711h70.475zM90.352 56.47h843.294v-120.47h-843.294v120.47z" />
|
|
80
|
+
<glyph unicode="" glyph-name="reply" d="M98.011 739.109l366.202-157.014-366.689 48.762 0.488 108.251zM463.726 313.905l-366.202-157.014v108.251l366.202 48.762zM0.488 886.857l-0.488-341.334 731.429-97.523-731.429-97.523 0.488-341.334 1023.512 438.857-1023.512 438.857z" />
|
|
81
|
+
<glyph unicode="" glyph-name="save" d="M796.445 959.998h-682.667c-63.147 0-113.777-51.2-113.777-113.777v-796.444c0-62.577 50.631-113.777 113.777-113.777h796.444c62.577 0 113.777 51.2 113.777 113.777v682.667l-227.556 227.556zM910.224 49.775h-796.444v796.444h635.449l160.996-160.996v-635.449zM512.001 447.998c-94.436 0-170.667-76.231-170.667-170.667s76.231-170.667 170.667-170.667c94.436 0 170.667 76.231 170.667 170.667s-76.231 170.667-170.667 170.667zM170.668 789.331h512v-227.556h-512v227.556z" />
|
|
79
82
|
<glyph unicode="" glyph-name="eye-blocked" d="M945.942 945.942c-18.746 18.744-49.136 18.744-67.882 0l-202.164-202.164c-51.938 15.754-106.948 24.222-163.896 24.222-223.318 0-416.882-130.042-512-320 41.122-82.124 100.648-153.040 173.022-207.096l-158.962-158.962c-18.746-18.746-18.746-49.136 0-67.882 9.372-9.374 21.656-14.060 33.94-14.060s24.568 4.686 33.942 14.058l864 864c18.744 18.746 18.744 49.138 0 67.884zM416 640c42.24 0 78.082-27.294 90.92-65.196l-121.724-121.724c-37.902 12.838-65.196 48.68-65.196 90.92 0 53.020 42.98 96 96 96zM110.116 448c38.292 60.524 89.274 111.924 149.434 150.296 3.918 2.5 7.876 4.922 11.862 7.3-9.962-27.328-15.412-56.822-15.412-87.596 0-54.89 17.286-105.738 46.7-147.418l-60.924-60.924c-52.446 36.842-97.202 83.882-131.66 138.342zM768 518c0 27.166-4.256 53.334-12.102 77.898l-321.808-321.808c24.568-7.842 50.742-12.090 77.91-12.090 141.382 0 256 114.618 256 256zM830.026 670.026l-69.362-69.362c1.264-0.786 2.53-1.568 3.786-2.368 60.162-38.374 111.142-89.774 149.434-150.296-38.292-60.522-89.274-111.922-149.436-150.296-75.594-48.218-162.89-73.704-252.448-73.704-38.664 0-76.902 4.76-113.962 14.040l-76.894-76.894c59.718-21.462 123.95-33.146 190.856-33.146 223.31 0 416.876 130.042 512 320-45.022 89.916-112.118 166.396-193.974 222.026z" />
|
|
80
83
|
</font></defs></svg>
|
package/src/font/icomoon.ttf
CHANGED
|
Binary file
|
package/src/font/icomoon.woff
CHANGED
|
Binary file
|