Skip to content

Commit 3504829

Browse files
committed
feat: add isToastActive, dismissToast and fix close btn styling
1 parent e0a6615 commit 3504829

File tree

5 files changed

+36
-12
lines changed

5 files changed

+36
-12
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "0.2.32-beta-3",
3+
"version": "0.2.32-beta-4",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Shared/Services/ToastManager/constants.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ export const TOAST_BASE_CONFIG: ToastContainerProps = {
2020
toastClassName: 'custom-toast',
2121
bodyClassName: 'custom-toast__body',
2222
closeButton: ({ closeToast }) => (
23-
<Button
24-
icon={<ICClose className="fcn-0" />}
25-
onClick={closeToast}
26-
dataTestId="close-toast"
27-
ariaLabel="Close toast"
28-
size={ComponentSizeType.xs}
29-
variant={ButtonVariantType.text}
30-
style={ButtonStyleType.neutral}
31-
/>
23+
<div className="custom-toast__close-btn">
24+
<Button
25+
icon={<ICClose className="fcn-0" />}
26+
onClick={closeToast}
27+
dataTestId="close-toast"
28+
ariaLabel="Close toast"
29+
size={ComponentSizeType.xs}
30+
variant={ButtonVariantType.text}
31+
style={ButtonStyleType.neutral}
32+
/>
33+
</div>
3234
),
3335
}
3436

src/Shared/Services/ToastManager/toastManager.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,13 @@
6060
}
6161
}
6262
}
63+
64+
// Custom styling for close btn
65+
&__close-btn {
66+
svg {
67+
use {
68+
fill: var(--N0) !important;
69+
}
70+
}
71+
}
6372
}

src/Shared/Services/ToastManager/toastManager.service.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ class ToastManager {
7676
return ToastManager.#instance
7777
}
7878

79+
/**
80+
* Handler for showing the toast
81+
*/
7982
// eslint-disable-next-line class-methods-use-this
8083
showToast = (
8184
{
@@ -110,6 +113,16 @@ class ToastManager {
110113
},
111114
)
112115
}
116+
117+
/**
118+
* Handler for dismissing an existing toast
119+
*/
120+
dismissToast = toast.dismiss
121+
122+
/**
123+
* Handler for checking if the toast is active
124+
*/
125+
isToastActive = toast.isActive
113126
}
114127

115128
export const ToastManagerContainer = () => <ToastContainer {...TOAST_BASE_CONFIG} />

0 commit comments

Comments
 (0)