forked from Creditra/Creditra-Frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBannerAlert.tsx
More file actions
52 lines (49 loc) · 1.49 KB
/
Copy pathBannerAlert.tsx
File metadata and controls
52 lines (49 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { useNotifications } from "../../context/NotificationContext";
import { TYPE_COLOR, TYPE_ICON } from "./notificationIcons";
import "./BannerAlert.css";
export function BannerAlerts() {
const { banners, dismissBanner } = useNotifications();
if (banners.length === 0) return null;
return (
<div className="banner-stack">
{banners.map((banner) => {
const colors = TYPE_COLOR[banner.type];
return (
<div
key={banner.id}
className="banner-alert"
style={{ background: colors.bg, borderColor: colors.border }}
role="alert"
>
<span
className="banner-icon"
style={{ color: colors.icon }}
aria-hidden="true"
>
{TYPE_ICON[banner.type]}
</span>
<span className="banner-message">{banner.message}</span>
{banner.action && (
<button
className="banner-action"
style={{ color: colors.text }}
onClick={banner.action.onClick}
>
{banner.action.label}
</button>
)}
{banner.dismissible !== false && (
<button
className="banner-close"
onClick={() => dismissBanner(banner.id)}
aria-label="Dismiss alert"
>
×
</button>
)}
</div>
);
})}
</div>
);
}