Skip to content

Commit 808c0cb

Browse files
committed
refactor(ui): streamline SystemNotificationBanner component
1 parent 5e40035 commit 808c0cb

File tree

3 files changed

+30
-43
lines changed

3 files changed

+30
-43
lines changed

app/layout.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function ThemeProvider({ children }: { children: React.ReactNode }) {
5454
config.appearance.compact,
5555
]);
5656

57-
// Update CSS custom properties when theme changes
57+
// Update CSS custom properties when the theme changes
5858
useEffect(() => {
5959
const root = document.documentElement;
6060

@@ -121,7 +121,8 @@ export default function RootLayout({
121121
children: React.ReactNode;
122122
}) {
123123
return (
124-
<html lang="en">{/* className={openSans.className} */}
124+
<html lang="en">
125+
{/* className={openSans.className} */}
125126
<head>
126127
<title>DesignSparx - Nextjs Mantine Admin Dashboard Template</title>
127128
<link

components/system-notification-banner/SystemNotificationBanner.tsx

Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
'use client';
22

3-
import {
4-
Alert,
5-
Anchor,
6-
Box,
7-
Button,
8-
CloseButton,
9-
Group,
10-
Stack,
11-
StackProps,
12-
Text,
13-
} from '@mantine/core';
3+
import { Alert, Anchor, Group, Stack, StackProps } from '@mantine/core';
144
import {
155
IconAlertTriangle,
166
IconCircleCheck,
@@ -25,7 +15,7 @@ import {
2515
} from '@/contexts/system-notifications/types';
2616

2717
interface SystemNotificationBannerProps
28-
extends Pick<StackProps, 'm' | 'mb' | 'mt' | 'my' | 'mx'> {
18+
extends Pick<StackProps, 'm' | 'mb' | 'mt' | 'my' | 'mx' | 'p'> {
2919
layout?: 'main' | 'guest' | 'auth';
3020
}
3121

@@ -69,44 +59,32 @@ const SystemNotificationBanner = ({
6959
const config = notificationConfig[notification.type];
7060

7161
return (
72-
<Box
62+
<Alert
7363
key={notification.id}
7464
bg={`var(--mantine-color-${config.color}-filled)`}
7565
c="white"
7666
py="xs"
7767
px="md"
68+
icon={config.icon}
69+
withCloseButton={notification.dismissible !== false}
70+
onClose={() => dismissNotification(notification.id)}
7871
>
79-
<Group justify="space-between" align="center" wrap="nowrap" gap="md">
80-
<Group gap="xs" wrap="nowrap" style={{ flex: 1, minWidth: 0 }}>
81-
{config.icon}
82-
<Text size="sm" truncate>
83-
{notification.message}
84-
</Text>
85-
{notification.action?.href && (
86-
<Anchor
87-
href={notification.action.href}
88-
target="_blank"
89-
rel="noopener noreferrer"
90-
c="white"
91-
fw={600}
92-
size="sm"
93-
underline="always"
94-
style={{ flexShrink: 0 }}
95-
>
96-
{notification.action.label}
97-
</Anchor>
98-
)}
99-
</Group>
100-
{notification.dismissible !== false && (
101-
<CloseButton
102-
size="sm"
72+
<Group gap="xs" wrap="nowrap">
73+
{notification.message}
74+
{notification.action?.href && (
75+
<Anchor
76+
href={notification.action.href}
77+
target="_blank"
78+
rel="noopener noreferrer"
10379
c="white"
104-
onClick={() => dismissNotification(notification.id)}
105-
aria-label="Dismiss notification"
106-
/>
80+
underline="always"
81+
style={{ flexShrink: 0 }}
82+
>
83+
{notification.action.label}
84+
</Anchor>
10785
)}
10886
</Group>
109-
</Box>
87+
</Alert>
11088
);
11189
})}
11290
</Stack>

theme/theme.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,14 @@ export const createDynamicTheme = (config: {
293293
},
294294
},
295295
},
296+
297+
Anchor: {
298+
styles: {
299+
root: {
300+
fontSize: config.compact ? rem(12) : rem(14),
301+
},
302+
},
303+
},
296304
},
297305

298306
// Custom CSS variables that can be used throughout the app

0 commit comments

Comments
 (0)