feat(status-page): four selectable themes for the public status page

Adds four fully-designed visual themes for the public status page
(refined | modern | bold | editorial) with a light/dark mode selector,
admin preview in a mock browser frame, and a shared theme provider
that keeps the component tree unified while letting each theme own
its visual identity.

## Selectable themes
- Refined — clean, flat cards, soft shadows, colored status dot.
- Modern — flat surfaces with a pulsing status dot and staggered
  fade-in cards.
- Bold — conic-gradient logo, 34px hero title with a check disc,
  subtle dual-radial glow on dark mode, accent-green hover border.
- Editorial — serif headings, narrow newspaper column, 'Service
  Report' eyebrow + title, flat rectangular badges and dateline.

## Architecture
- Single `StatusPageThemeProvider` hosts CSS custom-property tokens
  per theme and resolves light/dark based on admin-forced mode,
  falling back to `prefers-color-scheme` with a matchMedia listener.
- Each theme owns only its `*StatusPage.tsx` + scoped CSS file.
  The heatmap, histogram, and infrastructure renderers are shared
  across all four themes (parameterized by a `classPrefix`) to avoid
  the 12-file duplication the initial draft had.
- Renderer lookup table in `Status/index.tsx` replaces a 4-way
  ternary chain; unknown themes fall through to the legacy renderer.
- `resolveOverallStatus`, `statusBadgeKey`, `monoFirstChar`, and
  `monitorBadgeTone` are extracted to `themes/shared/overallStatus.tsx`.

## Admin UX
- `ThemePicker` uses the project's `RadioWithDescription` and
  `Select` components — one radio card per theme plus an Auto/
  Light-only/Dark-only mode dropdown.
- `BrowserFrame` wraps the preview in the admin panel with a mock
  chrome (traffic lights + URL bar) that adopts the status page's
  theme tokens. Edge-to-edge fill with no gray bleed.
- Public route renders the theme directly on the viewport with the
  document body painted to the theme background, reverted on unmount.

## Performance & polish
- Histogram's derived stats (padded array, max, avg, peak) are
  memoized on `checks`; `max` is reused for `peak` instead of
  computing twice.
- Editorial's dateline is wrapped in `useMemo` so the 10s poll
  doesn't rerender "April 23, 2026" as a changing string.
- Provider's `setSystemMode` reconciliation uses the updater form
  to avoid an extra render when the value is unchanged.
- `monoFirstChar` no longer uses a non-null assertion.

## Form plumbing
- `useStatusPageForm` defaults include `theme` + `themeMode`.
- `Validation/statusPage.ts` accepts both as optional zod enums.
- `Pages/StatusPage/Create/index.tsx` appends both to FormData on
  create and update.

## CLAUDE.md
- Dev port note: local client runs on 10001 (5173 is used by a
  different local project); server `CLIENT_HOST` is set to match.
This commit is contained in:
gorkem-bwl committed 2026-04-23 22:51:40 -04:00
1 parent ad964446de
commit 944ee74a1d
28 files changed
+3967 -114

No files matched your search

@@ -37,6 +37,7 @@ export const HeaderStatusPageControls = ({
>
<Typography
variant="h1"
className="sp-heading"
overflow="hidden"
textOverflow="ellipsis"
sx={{
@@ -63,12 +63,14 @@ const MonitorHeader = ({
>
<Typography
variant="h6"
className="sp-heading"
sx={{ overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}
>
{monitor.name}
</Typography>
<Typography
variant="caption"
className="sp-badge"
sx={getMonitorBadgeStyles(monitor.type ?? "", theme)}
>
{getMonitorTypeLabel(monitor.type, t)}
@@ -153,6 +155,7 @@ export const MonitorsList = ({ statusPage, monitors }: MonitorsListProps) => {
{monitors.map((monitor) => (
<BaseBox
key={monitor.id}
className="sp-card"
padding={theme.spacing(LAYOUT.MD)}
>
<MonitorHeader
@@ -12,26 +12,23 @@ import Typography from "@mui/material/Typography";
import { useTranslation } from "react-i18next";
import { useTheme } from "@mui/material";
import type { Theme } from "@mui/material";
import type { Monitor, MonitorStatus } from "@/Types/Monitor";
type SemanticTone = "up" | "down" | "warn" | "info";
interface StatusDisplay {
icon: JSX.Element;
msg?: string;
color?: string;
tone: SemanticTone;
}
const getMonitorStatus = (monitors: Monitor[], theme: Theme, t: Function) => {
const monitorsStatus: StatusDisplay = {
icon: <AlertTriangle size={24} />,
};
// Handle empty monitors array
const getMonitorStatus = (monitors: Monitor[], t: Function): StatusDisplay => {
if (monitors.length === 0) {
monitorsStatus.msg = t("pages.statusPages.statusBar.noMonitors");
monitorsStatus.color = theme.palette.warning.main;
monitorsStatus.icon = <CircleX size={24} />;
return monitorsStatus;
return {
msg: t("pages.statusPages.statusBar.noMonitors"),
tone: "warn",
icon: <CircleX size={24} />,
};
}
const allOf = (...statuses: MonitorStatus[]) =>
@@ -41,75 +38,112 @@ const getMonitorStatus = (monitors: Monitor[], theme: Theme, t: Function) => {
const noneOf = (...statuses: MonitorStatus[]) =>
monitors.every((m) => !statuses.includes(m.status));
// All monitors in a single state
if (allOf("up")) {
monitorsStatus.msg = t("pages.statusPages.statusBar.allUp");
monitorsStatus.color = theme.palette.success.main;
monitorsStatus.icon = <CircleCheck size={24} />;
} else if (allOf("breached")) {
monitorsStatus.msg = t("pages.statusPages.statusBar.allBreached");
monitorsStatus.color = theme.palette.error.main;
monitorsStatus.icon = <ShieldAlert size={24} />;
} else if (allOf("maintenance")) {
monitorsStatus.msg = t("pages.statusPages.statusBar.allMaintenance");
monitorsStatus.color = theme.palette.warning.main;
monitorsStatus.icon = <Wrench size={24} />;
} else if (allOf("down")) {
monitorsStatus.msg = t("pages.statusPages.statusBar.allDown");
monitorsStatus.color = theme.palette.error.main;
monitorsStatus.icon = <CircleX size={24} />;
} else if (allOf("paused")) {
monitorsStatus.msg = t("pages.statusPages.statusBar.allPaused");
monitorsStatus.color = theme.palette.warning.main;
monitorsStatus.icon = <PauseCircle size={24} />;
} else if (allOf("initializing")) {
monitorsStatus.msg = t("pages.statusPages.statusBar.allInitializing");
monitorsStatus.color = theme.palette.warning.main;
monitorsStatus.icon = <Loader size={24} />;
// Breached takes highest priority in mixed states
} else if (someOf("breached") && someOf("down")) {
monitorsStatus.msg = t("pages.statusPages.statusBar.breachedAndDown");
monitorsStatus.color = theme.palette.error.main;
monitorsStatus.icon = <ShieldAlert size={24} />;
} else if (someOf("breached")) {
monitorsStatus.msg = t("pages.statusPages.statusBar.breached");
monitorsStatus.color = theme.palette.error.main;
monitorsStatus.icon = <ShieldAlert size={24} />;
// Maintenance combinations
} else if (someOf("maintenance") && someOf("down")) {
monitorsStatus.msg = t("pages.statusPages.statusBar.maintenanceAndDown");
monitorsStatus.color = theme.palette.error.main;
monitorsStatus.icon = <Wrench size={24} />;
} else if (someOf("maintenance") && noneOf("down")) {
monitorsStatus.msg = t("pages.statusPages.statusBar.maintenance");
monitorsStatus.color = theme.palette.warning.main;
monitorsStatus.icon = <Wrench size={24} />;
// Degraded (some down, no maintenance/breached)
} else if (someOf("down")) {
monitorsStatus.msg = t("pages.statusPages.statusBar.degraded");
monitorsStatus.color = theme.palette.warning.main;
monitorsStatus.icon = <AlertTriangle size={24} />;
// Some Paused
} else if (someOf("paused")) {
monitorsStatus.msg = t("pages.statusPages.statusBar.partiallyPaused");
monitorsStatus.color = theme.palette.warning.main;
monitorsStatus.icon = <PauseCircle size={24} />;
// Initializing
} else if (someOf("initializing")) {
monitorsStatus.msg = t("pages.statusPages.statusBar.initializing");
monitorsStatus.color = theme.palette.info.main;
monitorsStatus.icon = <Loader size={24} />;
} else {
monitorsStatus.msg = t("pages.statusPages.statusBar.unknown");
monitorsStatus.color = theme.palette.warning.main;
return {
msg: t("pages.statusPages.statusBar.allUp"),
tone: "up",
icon: <CircleCheck size={24} />,
};
}
if (allOf("breached")) {
return {
msg: t("pages.statusPages.statusBar.allBreached"),
tone: "down",
icon: <ShieldAlert size={24} />,
};
}
if (allOf("maintenance")) {
return {
msg: t("pages.statusPages.statusBar.allMaintenance"),
tone: "warn",
icon: <Wrench size={24} />,
};
}
if (allOf("down")) {
return {
msg: t("pages.statusPages.statusBar.allDown"),
tone: "down",
icon: <CircleX size={24} />,
};
}
if (allOf("paused")) {
return {
msg: t("pages.statusPages.statusBar.allPaused"),
tone: "warn",
icon: <PauseCircle size={24} />,
};
}
if (allOf("initializing")) {
return {
msg: t("pages.statusPages.statusBar.allInitializing"),
tone: "warn",
icon: <Loader size={24} />,
};
}
return monitorsStatus;
// Breached takes highest priority in mixed states
if (someOf("breached") && someOf("down")) {
return {
msg: t("pages.statusPages.statusBar.breachedAndDown"),
tone: "down",
icon: <ShieldAlert size={24} />,
};
}
if (someOf("breached")) {
return {
msg: t("pages.statusPages.statusBar.breached"),
tone: "down",
icon: <ShieldAlert size={24} />,
};
}
if (someOf("maintenance") && someOf("down")) {
return {
msg: t("pages.statusPages.statusBar.maintenanceAndDown"),
tone: "down",
icon: <Wrench size={24} />,
};
}
if (someOf("maintenance") && noneOf("down")) {
return {
msg: t("pages.statusPages.statusBar.maintenance"),
tone: "warn",
icon: <Wrench size={24} />,
};
}
if (someOf("down")) {
return {
msg: t("pages.statusPages.statusBar.degraded"),
tone: "warn",
icon: <AlertTriangle size={24} />,
};
}
if (someOf("paused")) {
return {
msg: t("pages.statusPages.statusBar.partiallyPaused"),
tone: "warn",
icon: <PauseCircle size={24} />,
};
}
if (someOf("initializing")) {
return {
msg: t("pages.statusPages.statusBar.initializing"),
tone: "info",
icon: <Loader size={24} />,
};
}
return {
msg: t("pages.statusPages.statusBar.unknown"),
tone: "warn",
icon: <AlertTriangle size={24} />,
};
};
const toneToCssVar: Record<SemanticTone, string> = {
up: "var(--sp-up)",
down: "var(--sp-down)",
warn: "var(--sp-warn)",
info: "var(--sp-up)",
};
interface StatusBarProps {
@@ -119,7 +153,7 @@ interface StatusBarProps {
export const StatusBar = ({ monitors }: StatusBarProps) => {
const theme = useTheme();
const { t } = useTranslation();
const monitorsStatus = getMonitorStatus(monitors, theme, t);
const monitorsStatus = getMonitorStatus(monitors, t);
return (
<Stack
@@ -128,11 +162,12 @@ export const StatusBar = ({ monitors }: StatusBarProps) => {
justifyContent="center"
gap={theme.spacing(2)}
height={theme.spacing(30)}
bgcolor={monitorsStatus.color}
bgcolor={toneToCssVar[monitorsStatus.tone]}
borderRadius={theme.shape.borderRadius}
className="sp-hero"
>
{monitorsStatus.icon}
<Typography>{monitorsStatus.msg}</Typography>
<Typography className="sp-hero-title">{monitorsStatus.msg}</Typography>
</Stack>
);
};