@luscii-healthtech/web-ui 2.3.1 → 2.4.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/components/Icons/WarningIcon.d.ts +3 -0
- package/dist/components/Icons/types/IconProps.type.d.ts +1 -0
- package/dist/components/Toaster/Toaster.d.ts +17 -0
- package/dist/components/Toaster/toast-elements-getter.d.ts +22 -0
- package/dist/components/Toaster/toast-progress-animator.d.ts +12 -0
- package/dist/components/Toaster/toast.d.ts +12 -0
- package/dist/index.d.ts +2 -1
- package/dist/web-ui-tailwind.css +29 -0
- package/dist/web-ui.cjs.development.js +315 -122
- package/dist/web-ui.cjs.development.js.map +1 -1
- package/dist/web-ui.cjs.production.min.js +1 -1
- package/dist/web-ui.cjs.production.min.js.map +1 -1
- package/dist/web-ui.esm.js +313 -121
- package/dist/web-ui.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Icons/CheckIcon.tsx +1 -0
- package/src/components/Icons/CrossIcon.tsx +1 -0
- package/src/components/Icons/WarningIcon.tsx +24 -0
- package/src/components/Icons/types/IconProps.type.ts +1 -0
- package/src/components/Toaster/Toaster.scss +53 -0
- package/src/components/Toaster/Toaster.tsx +100 -0
- package/src/components/Toaster/toast-elements-getter.ts +72 -0
- package/src/components/Toaster/toast-progress-animator.ts +53 -0
- package/src/components/Toaster/toast.ts +112 -0
- package/src/index.tsx +6 -4
- package/dist/components/Acknowledgement/Acknowledgement.d.ts +0 -22
- package/src/components/Acknowledgement/Acknowledgement.js +0 -61
- package/src/components/Acknowledgement/Acknowledgement.scss +0 -49
package/package.json
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { IconProps } from "./types/IconProps.type";
|
|
4
|
+
|
|
5
|
+
export const WarningIcon: React.VoidFunctionComponent<IconProps> = (props) => {
|
|
6
|
+
return (
|
|
7
|
+
<svg
|
|
8
|
+
className={props.className}
|
|
9
|
+
onClick={props.onClick}
|
|
10
|
+
role={props.onClick ? "button" : undefined}
|
|
11
|
+
data-test-id={props["data-test-id"]}
|
|
12
|
+
width="20"
|
|
13
|
+
height="20"
|
|
14
|
+
viewBox="0 0 20 20"
|
|
15
|
+
fill="none"
|
|
16
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
17
|
+
>
|
|
18
|
+
<path
|
|
19
|
+
d="M10 0C4.48 0 0 4.48 0 10C0 15.52 4.48 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM10 11C9.45 11 9 10.55 9 10V6C9 5.45 9.45 5 10 5C10.55 5 11 5.45 11 6V10C11 10.55 10.55 11 10 11ZM11 15H9V13H11V15Z"
|
|
20
|
+
fill="currentColor"
|
|
21
|
+
/>
|
|
22
|
+
</svg>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#application-toaster {
|
|
2
|
+
position: fixed;
|
|
3
|
+
left: 50%;
|
|
4
|
+
transform: translate(-50%, 150%);
|
|
5
|
+
bottom: 15px;
|
|
6
|
+
|
|
7
|
+
// https://easings.net/#easeInOutBack
|
|
8
|
+
transition: transform 0.3s cubic-bezier(0.68, -0.6, 0.32, 1.6);
|
|
9
|
+
|
|
10
|
+
&.shelved {
|
|
11
|
+
transform: translate(-50%, 150%);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&.expanded {
|
|
15
|
+
transform: translate(-50%, 0);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&.type-success {
|
|
19
|
+
[data-test-id="toaster-title"] {
|
|
20
|
+
@apply text-green-700;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.failure-icon {
|
|
24
|
+
@apply hidden;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
[data-test-id="toaster-progress-bar-container"] {
|
|
28
|
+
@apply bg-green-50;
|
|
29
|
+
|
|
30
|
+
[data-test-id="toaster-progress-bar"] {
|
|
31
|
+
@apply bg-green-400;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&.type-failure {
|
|
37
|
+
[data-test-id="toaster-title"] {
|
|
38
|
+
@apply text-red-700;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.success-icon {
|
|
42
|
+
@apply hidden;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[data-test-id="toaster-progress-bar-container"] {
|
|
46
|
+
@apply bg-red-50;
|
|
47
|
+
|
|
48
|
+
[data-test-id="toaster-progress-bar"] {
|
|
49
|
+
@apply bg-red-400;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
|
|
4
|
+
import { Text } from "../Text/Text";
|
|
5
|
+
import { CheckIcon } from "../Icons/CheckIcon";
|
|
6
|
+
import { CrossIcon } from "../Icons/CrossIcon";
|
|
7
|
+
import { WarningIcon } from "../Icons/WarningIcon";
|
|
8
|
+
|
|
9
|
+
import "./Toaster.scss";
|
|
10
|
+
|
|
11
|
+
export interface ToasterProps {
|
|
12
|
+
type: "success" | "failure";
|
|
13
|
+
message: string;
|
|
14
|
+
title: string;
|
|
15
|
+
isVisible?: boolean;
|
|
16
|
+
/** if you need to reposition the toaster for whatever reason you can use these props */
|
|
17
|
+
styleOverwrite?: Pick<
|
|
18
|
+
React.CSSProperties,
|
|
19
|
+
"top" | "bottom" | "left" | "right"
|
|
20
|
+
>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const TOASTER_TYPE_OPTIONS = {
|
|
24
|
+
SUCCESS: "success",
|
|
25
|
+
FAILURE: "failure",
|
|
26
|
+
} as const;
|
|
27
|
+
export type ToasterType =
|
|
28
|
+
typeof TOASTER_TYPE_OPTIONS[keyof typeof TOASTER_TYPE_OPTIONS];
|
|
29
|
+
|
|
30
|
+
const Toaster: React.VoidFunctionComponent<ToasterProps> = ({
|
|
31
|
+
message = "",
|
|
32
|
+
title = "",
|
|
33
|
+
type = TOASTER_TYPE_OPTIONS.SUCCESS,
|
|
34
|
+
isVisible,
|
|
35
|
+
styleOverwrite,
|
|
36
|
+
}) => {
|
|
37
|
+
const isSuccess = type === TOASTER_TYPE_OPTIONS.SUCCESS;
|
|
38
|
+
const isFailure = type === TOASTER_TYPE_OPTIONS.FAILURE;
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div
|
|
42
|
+
style={styleOverwrite}
|
|
43
|
+
id="application-toaster"
|
|
44
|
+
data-test-id={`toaster-panel-${type}`}
|
|
45
|
+
className={classNames(
|
|
46
|
+
"bg-white cursor-pointer",
|
|
47
|
+
"rounded-md shadow-md",
|
|
48
|
+
"min-h-13 max-h-19 w-104 transition-transform",
|
|
49
|
+
|
|
50
|
+
{
|
|
51
|
+
shelved: !isVisible,
|
|
52
|
+
expanded: isVisible,
|
|
53
|
+
"type-success": isSuccess,
|
|
54
|
+
"type-failure": isFailure,
|
|
55
|
+
}
|
|
56
|
+
)}
|
|
57
|
+
>
|
|
58
|
+
<div className="relative p-4">
|
|
59
|
+
<div className="flex flex-row">
|
|
60
|
+
<div
|
|
61
|
+
data-test-id="success-toaster-icon"
|
|
62
|
+
className={classNames("success-icon text-green-700", {
|
|
63
|
+
hidden: isFailure,
|
|
64
|
+
})}
|
|
65
|
+
>
|
|
66
|
+
<CheckIcon />
|
|
67
|
+
</div>
|
|
68
|
+
<div
|
|
69
|
+
data-test-id="failure-toaster-icon"
|
|
70
|
+
className={classNames("failure-icon text-red-700", {
|
|
71
|
+
hidden: isSuccess,
|
|
72
|
+
})}
|
|
73
|
+
>
|
|
74
|
+
<WarningIcon />
|
|
75
|
+
</div>
|
|
76
|
+
<div className="ml-3">
|
|
77
|
+
<Text type="strong" data-test-id="toaster-title" text={title} />
|
|
78
|
+
<Text data-test-id="toaster-message" text={message} />
|
|
79
|
+
</div>
|
|
80
|
+
<CrossIcon
|
|
81
|
+
data-test-id="toaster-close-button"
|
|
82
|
+
className="ml-auto cursor-pointer text-slate-500"
|
|
83
|
+
/>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<div
|
|
88
|
+
data-test-id="toaster-progress-bar-container"
|
|
89
|
+
className={classNames("h-1 absolute bottom-0 w-full rounded-b-md")}
|
|
90
|
+
>
|
|
91
|
+
<div
|
|
92
|
+
data-test-id="toaster-progress-bar"
|
|
93
|
+
className={classNames("h-full")}
|
|
94
|
+
/>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export default Toaster;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
interface GetToasterElementsParams {
|
|
2
|
+
timeoutId: NodeJS.Timeout;
|
|
3
|
+
progressBarAnimationFrameHandler: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
interface GetToasterElementsReturn {
|
|
7
|
+
toasterElementMessage: HTMLElement;
|
|
8
|
+
toasterProgressBar: HTMLElement;
|
|
9
|
+
toasterElementTitle: HTMLElement;
|
|
10
|
+
toasterElementSuccessIcon: HTMLElement;
|
|
11
|
+
toasterElementFailureIcon: HTMLElement;
|
|
12
|
+
toasterElementContainer: HTMLElement;
|
|
13
|
+
toasterCloseButton: HTMLElement;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param params.timeoutId - the timeoutId (that makes the toaster vanish), in case of a shortcut
|
|
19
|
+
* @param params.progressBarAnimationFrameHandler - animation frame id to be canceled in case of a shortcut
|
|
20
|
+
* @returns a collection of html elements to be manipulated by the animation
|
|
21
|
+
*/
|
|
22
|
+
export const getToasterElements = (
|
|
23
|
+
params: GetToasterElementsParams
|
|
24
|
+
): GetToasterElementsReturn => {
|
|
25
|
+
const { timeoutId, progressBarAnimationFrameHandler } = params;
|
|
26
|
+
const toasterElementContainer = document.querySelector<HTMLElement>(
|
|
27
|
+
"#application-toaster"
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
if (!toasterElementContainer) {
|
|
31
|
+
clearTimeout(timeoutId);
|
|
32
|
+
clearTimeout(progressBarAnimationFrameHandler);
|
|
33
|
+
|
|
34
|
+
throw new Error(
|
|
35
|
+
"Make sure that the Toaster component element is rendered with an id [application-toaster]"
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const toasterElementMessage = toasterElementContainer?.querySelector(
|
|
40
|
+
'[data-test-id="toaster-message"]'
|
|
41
|
+
) as HTMLElement;
|
|
42
|
+
|
|
43
|
+
const toasterElementTitle = toasterElementContainer?.querySelector(
|
|
44
|
+
'[data-test-id="toaster-title"]'
|
|
45
|
+
) as HTMLElement;
|
|
46
|
+
|
|
47
|
+
const toasterElementSuccessIcon = toasterElementContainer?.querySelector(
|
|
48
|
+
'[data-test-id="success-toaster-icon"]'
|
|
49
|
+
) as HTMLElement;
|
|
50
|
+
|
|
51
|
+
const toasterElementFailureIcon = toasterElementContainer?.querySelector(
|
|
52
|
+
'[data-test-id="failure-toaster-icon"]'
|
|
53
|
+
) as HTMLElement;
|
|
54
|
+
|
|
55
|
+
const toasterCloseButton = toasterElementContainer?.querySelector(
|
|
56
|
+
'[data-test-id="toaster-close-button"]'
|
|
57
|
+
) as HTMLElement;
|
|
58
|
+
|
|
59
|
+
const toasterProgressBar = toasterElementContainer?.querySelector(
|
|
60
|
+
'[data-test-id="toaster-progress-bar"]'
|
|
61
|
+
) as HTMLElement;
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
toasterElementContainer,
|
|
65
|
+
toasterElementMessage,
|
|
66
|
+
toasterElementTitle,
|
|
67
|
+
toasterProgressBar,
|
|
68
|
+
toasterElementSuccessIcon,
|
|
69
|
+
toasterElementFailureIcon,
|
|
70
|
+
toasterCloseButton,
|
|
71
|
+
};
|
|
72
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
interface AnimateProgressParams {
|
|
2
|
+
animationDuration: number;
|
|
3
|
+
progressBarElement: HTMLElement;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
|
|
8
|
+
* @param params.animationDuration - the amount of seconds the duration will take
|
|
9
|
+
* @param params.progressBarElement - the html element for the progress bar
|
|
10
|
+
* @returns the animation frame id
|
|
11
|
+
*/
|
|
12
|
+
export const animateProgress = (params: AnimateProgressParams): number => {
|
|
13
|
+
const { animationDuration, progressBarElement } = params;
|
|
14
|
+
|
|
15
|
+
let progressBarAnimationFrameHandler: number;
|
|
16
|
+
|
|
17
|
+
let startingTimestamp = 0;
|
|
18
|
+
let previousTimestamp = 0;
|
|
19
|
+
let done = false;
|
|
20
|
+
const animationTick = 100 / animationDuration;
|
|
21
|
+
|
|
22
|
+
const animate = (animationTimestamp: number) => {
|
|
23
|
+
if (!startingTimestamp) {
|
|
24
|
+
startingTimestamp = animationTimestamp;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const elapsed = animationTimestamp - startingTimestamp;
|
|
28
|
+
|
|
29
|
+
if (previousTimestamp !== animationTimestamp) {
|
|
30
|
+
const count = 100 - animationTick * elapsed;
|
|
31
|
+
progressBarElement.style.width = `${count}%`;
|
|
32
|
+
if (count === 0) {
|
|
33
|
+
done = true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (elapsed < animationDuration) {
|
|
38
|
+
// Stop the animation after duration is finished
|
|
39
|
+
previousTimestamp = animationTimestamp;
|
|
40
|
+
|
|
41
|
+
if (!done) {
|
|
42
|
+
progressBarAnimationFrameHandler =
|
|
43
|
+
window.requestAnimationFrame(animate);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
progressBarElement.style.width = "100%";
|
|
49
|
+
|
|
50
|
+
progressBarAnimationFrameHandler = requestAnimationFrame(animate);
|
|
51
|
+
|
|
52
|
+
return progressBarAnimationFrameHandler;
|
|
53
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { getToasterElements } from "./toast-elements-getter";
|
|
2
|
+
import { animateProgress } from "./toast-progress-animator";
|
|
3
|
+
|
|
4
|
+
let timeoutId: NodeJS.Timeout;
|
|
5
|
+
let progressBarAnimationFrameHandler: number;
|
|
6
|
+
|
|
7
|
+
const defaultDurationInSeconds = 5;
|
|
8
|
+
|
|
9
|
+
type ToastParams =
|
|
10
|
+
| {
|
|
11
|
+
message: string;
|
|
12
|
+
title?: string;
|
|
13
|
+
showIcon?: boolean;
|
|
14
|
+
type: "success" | "failure";
|
|
15
|
+
}
|
|
16
|
+
| string;
|
|
17
|
+
|
|
18
|
+
const showToaster = (params: ToastParams) => {
|
|
19
|
+
clearTimeout(timeoutId);
|
|
20
|
+
clearTimeout(progressBarAnimationFrameHandler);
|
|
21
|
+
|
|
22
|
+
const {
|
|
23
|
+
toasterElementContainer,
|
|
24
|
+
toasterElementMessage,
|
|
25
|
+
toasterElementTitle,
|
|
26
|
+
toasterProgressBar,
|
|
27
|
+
toasterElementSuccessIcon,
|
|
28
|
+
toasterElementFailureIcon,
|
|
29
|
+
toasterCloseButton,
|
|
30
|
+
} = getToasterElements({
|
|
31
|
+
timeoutId,
|
|
32
|
+
progressBarAnimationFrameHandler,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const animationDuration = defaultDurationInSeconds * 1000;
|
|
36
|
+
|
|
37
|
+
progressBarAnimationFrameHandler = animateProgress({
|
|
38
|
+
animationDuration,
|
|
39
|
+
progressBarElement: toasterProgressBar,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
timeoutId = setTimeout(() => {
|
|
43
|
+
toasterElementContainer.classList.remove("expanded");
|
|
44
|
+
clearTimeout(timeoutId);
|
|
45
|
+
cancelAnimationFrame(progressBarAnimationFrameHandler);
|
|
46
|
+
}, animationDuration);
|
|
47
|
+
|
|
48
|
+
function shortcutAndClose() {
|
|
49
|
+
toasterElementContainer.classList.remove("expanded");
|
|
50
|
+
toasterElementContainer.classList.add("shelved");
|
|
51
|
+
|
|
52
|
+
clearTimeout(timeoutId);
|
|
53
|
+
cancelAnimationFrame(progressBarAnimationFrameHandler);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
toasterCloseButton.removeEventListener("click", shortcutAndClose, true);
|
|
57
|
+
toasterCloseButton.addEventListener("click", shortcutAndClose);
|
|
58
|
+
|
|
59
|
+
toasterElementContainer.removeEventListener("click", shortcutAndClose, true);
|
|
60
|
+
toasterElementContainer.addEventListener("click", shortcutAndClose);
|
|
61
|
+
|
|
62
|
+
// Basic usage, no need to manipulate any other element;
|
|
63
|
+
if (typeof params === "string") {
|
|
64
|
+
toasterElementMessage.textContent = params;
|
|
65
|
+
toasterElementTitle.classList.add("hidden");
|
|
66
|
+
|
|
67
|
+
toasterElementSuccessIcon.classList.remove("hidden");
|
|
68
|
+
toasterElementFailureIcon.classList.add("hidden");
|
|
69
|
+
|
|
70
|
+
toasterElementContainer.classList.remove("type-failure");
|
|
71
|
+
toasterElementContainer.classList.add("type-success");
|
|
72
|
+
toasterElementContainer.classList.add("expanded");
|
|
73
|
+
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const { title = "", showIcon = true, message, type } = params;
|
|
78
|
+
|
|
79
|
+
toasterElementTitle.classList.toggle("hidden", !title);
|
|
80
|
+
toasterElementTitle.textContent = title;
|
|
81
|
+
|
|
82
|
+
toasterElementSuccessIcon.classList.toggle("hidden", !showIcon);
|
|
83
|
+
toasterElementFailureIcon.classList.toggle("hidden", !showIcon);
|
|
84
|
+
|
|
85
|
+
toasterElementMessage.textContent = message;
|
|
86
|
+
toasterElementContainer.classList.remove("type-success");
|
|
87
|
+
toasterElementContainer.classList.remove("type-failure");
|
|
88
|
+
toasterElementContainer.classList.add("expanded");
|
|
89
|
+
toasterElementContainer.classList.add(`type-${type}`);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const toast = (params: ToastParams): void => {
|
|
93
|
+
showToaster(params);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
toast.error = (message: string): void => {
|
|
97
|
+
showToaster({
|
|
98
|
+
message: message,
|
|
99
|
+
type: "failure",
|
|
100
|
+
showIcon: true,
|
|
101
|
+
title: "",
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
toast.info = (message: string): void => {
|
|
106
|
+
showToaster({
|
|
107
|
+
message: message,
|
|
108
|
+
type: "success",
|
|
109
|
+
showIcon: true,
|
|
110
|
+
title: "",
|
|
111
|
+
});
|
|
112
|
+
};
|
package/src/index.tsx
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export {
|
|
2
|
-
default as
|
|
3
|
-
|
|
4
|
-
} from "./components/
|
|
2
|
+
default as Toaster,
|
|
3
|
+
TOASTER_TYPE_OPTIONS,
|
|
4
|
+
} from "./components/Toaster/Toaster";
|
|
5
|
+
export { toast } from "./components/Toaster/toast";
|
|
6
|
+
|
|
5
7
|
export { default as Avatar } from "./components/Avatar/Avatar";
|
|
6
8
|
export { default as Badge } from "./components/Badge/Badge";
|
|
7
9
|
export {
|
|
@@ -44,7 +46,7 @@ export {
|
|
|
44
46
|
} from "./components/List/List";
|
|
45
47
|
export {
|
|
46
48
|
CheckboxList,
|
|
47
|
-
|
|
49
|
+
CheckboxListProps,
|
|
48
50
|
} from "./components/CheckboxList/CheckboxList";
|
|
49
51
|
|
|
50
52
|
export { MultiSelect } from "./components/MultiSelect/MultiSelect";
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export namespace ACKNOWLEDGEMENT_TYPE_OPTIONS {
|
|
2
|
-
export const SUCCESS: string;
|
|
3
|
-
export const FAILURE: string;
|
|
4
|
-
}
|
|
5
|
-
export default Acknowledgement;
|
|
6
|
-
declare function Acknowledgement({ message, type, isVisible, hasIcon, className, }: {
|
|
7
|
-
message?: string | undefined;
|
|
8
|
-
type?: string | undefined;
|
|
9
|
-
isVisible?: boolean | undefined;
|
|
10
|
-
hasIcon?: boolean | undefined;
|
|
11
|
-
className?: string | undefined;
|
|
12
|
-
}): JSX.Element;
|
|
13
|
-
declare namespace Acknowledgement {
|
|
14
|
-
export const propTypes: {
|
|
15
|
-
message: PropTypes.Requireable<string>;
|
|
16
|
-
type: PropTypes.Requireable<string>;
|
|
17
|
-
hasIcon: PropTypes.Requireable<boolean>;
|
|
18
|
-
isVisible: PropTypes.Requireable<boolean>;
|
|
19
|
-
className: PropTypes.Requireable<string>;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
import PropTypes from "prop-types";
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import classNames from "classnames";
|
|
4
|
-
|
|
5
|
-
import { Text } from "../Text/Text";
|
|
6
|
-
import successIcon from "../../assets/success-icon.svg";
|
|
7
|
-
import failureIcon from "../../assets/error-icon.svg";
|
|
8
|
-
|
|
9
|
-
import "./Acknowledgement.scss";
|
|
10
|
-
|
|
11
|
-
export const ACKNOWLEDGEMENT_TYPE_OPTIONS = {
|
|
12
|
-
SUCCESS: "success",
|
|
13
|
-
FAILURE: "failure",
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
Acknowledgement.propTypes = {
|
|
17
|
-
message: PropTypes.string,
|
|
18
|
-
type: PropTypes.oneOf([ACKNOWLEDGEMENT_TYPE_OPTIONS.SUCCESS, ACKNOWLEDGEMENT_TYPE_OPTIONS.FAILURE]),
|
|
19
|
-
hasIcon: PropTypes.bool,
|
|
20
|
-
isVisible: PropTypes.bool,
|
|
21
|
-
className: PropTypes.string,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
function Acknowledgement({
|
|
25
|
-
message = "",
|
|
26
|
-
type = ACKNOWLEDGEMENT_TYPE_OPTIONS.SUCCESS,
|
|
27
|
-
isVisible = false,
|
|
28
|
-
hasIcon = false,
|
|
29
|
-
className = "",
|
|
30
|
-
}) {
|
|
31
|
-
const containerClassName = classNames("cweb-acknowledgement", className, {
|
|
32
|
-
"type-success": type === ACKNOWLEDGEMENT_TYPE_OPTIONS.SUCCESS,
|
|
33
|
-
"type-failure": type === ACKNOWLEDGEMENT_TYPE_OPTIONS.FAILURE,
|
|
34
|
-
"is-visible": isVisible,
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
const iconContainerClasses = classNames("acknowledgement-icon-container", {
|
|
38
|
-
hidden: !hasIcon,
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const successIconClasses = classNames("icon success-icon acknowledgement-icon", {
|
|
42
|
-
hidden: type !== ACKNOWLEDGEMENT_TYPE_OPTIONS.SUCCESS,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const failureIconClasses = classNames("icon failure-icon acknowledgement-icon", {
|
|
46
|
-
hidden: type !== ACKNOWLEDGEMENT_TYPE_OPTIONS.FAILURE,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<div id="application-acknowledgement" data-test-id={`acknowledgement-panel-${type}`} className={containerClassName}>
|
|
51
|
-
<div className={iconContainerClasses}>
|
|
52
|
-
<img src={successIcon} className={successIconClasses} alt="Success icon" />
|
|
53
|
-
<img src={failureIcon} className={failureIconClasses} alt="Failure icon" />
|
|
54
|
-
</div>
|
|
55
|
-
|
|
56
|
-
<Text data-test-id="acknowledgement-message" text={message} />
|
|
57
|
-
</div>
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export default Acknowledgement;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
@import "../../styles/layout";
|
|
2
|
-
@import "../../styles/colors";
|
|
3
|
-
|
|
4
|
-
.cweb-acknowledgement {
|
|
5
|
-
@include horizontal-static-position(fixed, 10000);
|
|
6
|
-
@include flexbox-vertical(center, center);
|
|
7
|
-
|
|
8
|
-
$horizontal-margin: 6px;
|
|
9
|
-
$max-width: 360px - $horizontal-margin;
|
|
10
|
-
|
|
11
|
-
top: 0;
|
|
12
|
-
margin: 0 auto;
|
|
13
|
-
opacity: 0;
|
|
14
|
-
width: $max-width;
|
|
15
|
-
max-width: calc(100% - #{$horizontal-margin});
|
|
16
|
-
box-shadow: 0 0 20px 0 rgba(106, 191, 165, 0.2);
|
|
17
|
-
padding: 16px;
|
|
18
|
-
border-radius: 8px;
|
|
19
|
-
|
|
20
|
-
transform: translateY(-100%);
|
|
21
|
-
transition: transform ease-out 400ms, opacity 1ms linear 500ms;
|
|
22
|
-
|
|
23
|
-
> .acknowledgement-icon-container {
|
|
24
|
-
width: 48px;
|
|
25
|
-
height: 48px;
|
|
26
|
-
|
|
27
|
-
margin-bottom: 12px;
|
|
28
|
-
|
|
29
|
-
> .acknowledgement-icon {
|
|
30
|
-
width: 100%;
|
|
31
|
-
height: 100%;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
&.type-success {
|
|
36
|
-
background: $color-positive-support;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
&.type-failure {
|
|
40
|
-
background: $color-negative-support;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
&.is-visible {
|
|
44
|
-
opacity: 1;
|
|
45
|
-
transform: translateY(32px);
|
|
46
|
-
transition: transform ease-in 150ms;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|