@agilant/toga-blox 1.0.14 → 1.0.16
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.
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
|
|
3
3
|
const Toaster = ({ message, additionalClasses, clearMessage, hasClearButton, statusProps = {
|
|
4
|
-
colorClass: "bg-gray-100 border border-gray-500 text-
|
|
4
|
+
colorClass: "bg-gray-100 border border-gray-500 text-gray-800",
|
|
5
5
|
icon: { icon: "circleCheck", type: "solid" },
|
|
6
6
|
}, }) => {
|
|
7
7
|
const handleClearMessage = () => {
|
|
8
8
|
if (clearMessage) {
|
|
9
|
-
alert("Message Cleared!");
|
|
10
9
|
clearMessage(true);
|
|
11
10
|
}
|
|
12
11
|
};
|
|
13
|
-
// Pull out colorClass and icon from statusProps
|
|
14
12
|
const { colorClass, icon: maybeIcon } = statusProps;
|
|
15
|
-
// We'll combine colorClass with other container styles
|
|
16
13
|
const containerClasses = colorClass ?? "";
|
|
17
|
-
// Your existing custom classes
|
|
18
14
|
const shadowClasses = `shadow-lg shadow-boxShadow rounded-lg`;
|
|
19
|
-
const closeButtonClasses = `cursor-pointer text-xs
|
|
20
|
-
|
|
15
|
+
const closeButtonClasses = `cursor-pointer text-xs`;
|
|
16
|
+
const messageClasses = `grid grid-cols-[24px_1fr_24px] items-center gap-x-2`;
|
|
17
|
+
return (_jsx("div", { "data-testid": "toaster-test-id", role: "alert", "aria-live": "polite", className: `${shadowClasses} ${containerClasses} ${additionalClasses}`, children: message.map((msg, index) => (_jsxs("div", { className: messageClasses, children: [_jsx("div", { children: index === 0 && maybeIcon
|
|
18
|
+
? getFontAwesomeIcon(maybeIcon.icon, maybeIcon.type)
|
|
19
|
+
: null }), _jsx("p", { className: index === 0 && "font-semibold", children: msg }), _jsx("div", { children: index === 0 && hasClearButton && (_jsx("div", { "data-testid": "clear-button", className: closeButtonClasses, onClick: handleClearMessage, children: getFontAwesomeIcon("x", "solid") })) })] }, index))) }));
|
|
21
20
|
};
|
|
22
21
|
export default Toaster;
|
|
@@ -98,5 +98,19 @@ HasClearMessage.args = {
|
|
|
98
98
|
colorClass: "bg-orange-100 border border-orange-500 text-orange-800",
|
|
99
99
|
icon: { icon: "circleCheck", type: "solid" },
|
|
100
100
|
},
|
|
101
|
-
additionalClasses: "py-2 px-5",
|
|
101
|
+
additionalClasses: "py-2 px-5 min-w-96",
|
|
102
|
+
};
|
|
103
|
+
export const hasMultipleMessages = Template.bind({});
|
|
104
|
+
hasMultipleMessages.args = {
|
|
105
|
+
message: ["Message One", "Message Two", "Message Three"],
|
|
106
|
+
hasClearButton: true,
|
|
107
|
+
clearMessage: () => {
|
|
108
|
+
alert("Message Cleared!");
|
|
109
|
+
},
|
|
110
|
+
statusProps: {
|
|
111
|
+
// Orange variant
|
|
112
|
+
colorClass: "bg-orange-100 border border-orange-500 text-orange-800",
|
|
113
|
+
icon: { icon: "circleCheck", type: "solid" },
|
|
114
|
+
},
|
|
115
|
+
additionalClasses: "py-2 px-5 min-w-96",
|
|
102
116
|
};
|