From fcdc203017af20a69dc2118f1d9145c9f637b154 Mon Sep 17 00:00:00 2001 From: lyc8503 Date: Sun, 21 Sep 2025 01:17:00 +0800 Subject: [PATCH] feat: improve styles for alert, support mobile devices --- components/MaintenanceAlert.tsx | 43 +++++++++++++++++++++------------ components/NoIncidents.tsx | 23 ++++++++---------- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/components/MaintenanceAlert.tsx b/components/MaintenanceAlert.tsx index f8a9307..da7b2e3 100644 --- a/components/MaintenanceAlert.tsx +++ b/components/MaintenanceAlert.tsx @@ -1,4 +1,5 @@ -import { Alert, List, Text } from '@mantine/core' +import { Alert, List, Text, useMantineTheme } from '@mantine/core' +import { useMediaQuery } from '@mantine/hooks' import { IconAlertTriangle } from '@tabler/icons-react' import { MaintenanceConfig, MonitorTarget } from '@/types/config' @@ -9,32 +10,42 @@ export default function MaintenanceAlert({ maintenance: Omit & { monitors?: MonitorTarget[] } style?: React.CSSProperties }) { - const titleStyle: React.CSSProperties = {} + const theme = useMantineTheme() + const isDesktop = useMediaQuery(`(min-width: ${theme.breakpoints.sm})`) return ( } title={ - ( - - {maintenance.title || 'Scheduled Maintenance'} - - ) + + {maintenance.title || 'Scheduled Maintenance'} + } color={maintenance.color || 'yellow'} withCloseButton={false} style={{ position: 'relative', margin: '16px auto 0 auto', ...style }} > - {/* Date range in top right */} + {/* Date range in top right (desktop) or inline (mobile) */}
From: {new Date(maintenance.start).toLocaleString()} @@ -43,7 +54,7 @@ export default function MaintenanceAlert({ {maintenance.end ? new Date(maintenance.end).toLocaleString() : 'Until further notice'}
- {maintenance.body} + {maintenance.body} {maintenance.monitors && maintenance.monitors.length > 0 && ( <> diff --git a/components/NoIncidents.tsx b/components/NoIncidents.tsx index 22e9a2d..f3b8066 100644 --- a/components/NoIncidents.tsx +++ b/components/NoIncidents.tsx @@ -5,7 +5,16 @@ export default function NoIncidentsAlert({ style }: { style?: React.CSSPropertie return ( } - title="No Incidents in this month" + title={ + + {'No incidents in this month'} + + } color="gray" withCloseButton={false} style={{ @@ -14,18 +23,6 @@ export default function NoIncidentsAlert({ style }: { style?: React.CSSPropertie ...style, }} > -
There are no incidents for this month.
)