import type { SxProps, Theme } from "@mui/material/styles"; import type { StatusPageThemeTokens } from "../tokens"; import { type OverallTone, toneColor, toneSoft } from "../shared/overallStatus"; import { MONO_STACK, SANS_STACK } from "../shared/fontStacks"; import type { BarKind, HeatCellKind } from "../shared/ChartCells"; export type RefinedHeatCell = HeatCellKind; export type RefinedBarKind = BarKind; export type RefinedGaugeFill = "ok" | "warm" | "hot"; import { MAX_RECENT_CHECKS } from "@/Types/Monitor"; export interface RefinedStyles { page: SxProps; top: SxProps; brand: SxProps; logoMono: SxProps; logoImg: SxProps; company: SxProps; hero: SxProps; statusDot: (tone: OverallTone) => SxProps; heroRow: SxProps; heroTitle: SxProps; heroSub: SxProps; heroIcon: (tone: OverallTone) => SxProps; chartSwitchWrap: SxProps; chartSwitch: SxProps; chartSwitchButton: (active: boolean) => SxProps; monitorList: SxProps; card: SxProps; cardRow: SxProps; cardLeft: SxProps; monitorName: SxProps; monitorMeta: SxProps; pill: SxProps; pillHardware: SxProps; monitorUrl: SxProps; badge: (tone: OverallTone) => SxProps; heatmap: SxProps; heatmapCell: (kind: RefinedHeatCell) => SxProps; histogram: SxProps; bar: (kind: RefinedBarKind, heightPct: number) => SxProps; chartStats: SxProps; infra: SxProps; infraEmpty: SxProps; gauge: SxProps; gaugeLabel: SxProps; gaugeValue: SxProps; gaugeBar: SxProps; gaugeFill: (level: RefinedGaugeFill, widthPct: number) => SxProps; gaugeSub: SxProps; footer: SxProps; } const cardShadow = "0 1px 2px rgba(10, 16, 32, 0.06), 0 6px 18px rgba(10, 16, 32, 0.08)"; const cardShadowHover = "0 2px 4px rgba(16, 24, 40, 0.06), 0 10px 24px rgba(16, 24, 40, 0.06)"; const pillBase = { fontSize: 10, textTransform: "uppercase" as const, letterSpacing: "0.08em", padding: "2px 8px", borderRadius: "999px", fontWeight: 600, }; export const refinedStyles = ( tokens: StatusPageThemeTokens, _isDark: boolean ): RefinedStyles => { const heatCellBg: Record = { fast: tokens.up, med: `color-mix(in srgb, ${tokens.up} 60%, #ffffff 40%)`, slow: tokens.warn, degraded: tokens.degraded, down: tokens.down, empty: tokens.border, }; const barBg: Record = { up: tokens.up, degraded: tokens.degraded, down: tokens.down, empty: tokens.border, }; const gaugeFillBg: Record = { ok: tokens.up, warm: tokens.warn, hot: tokens.down, }; return { page: { flex: "1 0 auto", maxWidth: 960, width: "100%", mx: "auto", p: "48px 20px 80px", fontFamily: SANS_STACK, fontSize: 14, lineHeight: 1.5, color: tokens.text, WebkitFontSmoothing: "antialiased", }, top: { alignItems: { xs: "flex-start", md: "center" }, justifyContent: "space-between", gap: "12px", mb: "28px", }, brand: { display: "flex", alignItems: "center", gap: "10px", fontWeight: 600, letterSpacing: "-0.01em", color: tokens.text, }, logoMono: { width: 28, height: 28, borderRadius: "8px", background: tokens.brand, display: "grid", placeItems: "center", color: "#fff", fontWeight: 700, fontSize: 13, }, logoImg: { maxHeight: 32, maxWidth: 120, objectFit: "contain" }, company: { fontSize: 14 }, hero: { background: tokens.surface, border: `1px solid ${tokens.border}`, borderRadius: tokens.radius, padding: { xs: "18px 20px", md: "22px 24px" }, display: "flex", flexDirection: "column", gap: "4px", boxShadow: cardShadow, mb: "20px", }, statusDot: (tone) => ({ width: 10, height: 10, borderRadius: "50%", background: toneColor(tone, tokens), boxShadow: `0 0 0 4px ${toneSoft(tone, tokens)}`, flexShrink: 0, }), heroRow: { display: "flex", alignItems: "center", gap: { xs: "12px", md: "16px" }, }, heroTitle: { m: 0, flex: 1, minWidth: 0, fontSize: 17, fontWeight: 600, letterSpacing: "-0.01em", color: tokens.text, }, heroSub: { m: 0, color: tokens.textMuted, fontSize: 13 }, heroIcon: (tone) => ({ display: { xs: "none", md: "flex" }, color: toneColor(tone, tokens), alignItems: "center", flexShrink: 0, }), chartSwitchWrap: { display: "flex", justifyContent: { xs: "center", md: "flex-end" }, mb: "12px", }, chartSwitch: { display: "inline-flex", width: { xs: "100%", md: "auto" }, maxWidth: "100%", border: `1px solid ${tokens.border}`, borderRadius: "8px", background: tokens.surface, p: "3px", gap: "2px", }, chartSwitchButton: (active) => ({ flex: 1, minWidth: 0, whiteSpace: "nowrap", textAlign: "center", border: 0, background: active ? tokens.brandSoft : "transparent", fontFamily: "inherit", fontSize: 11, padding: { xs: "5px 6px", md: "5px 14px" }, cursor: "pointer", color: active ? tokens.brand : tokens.textMuted, borderRadius: "5px", transition: "background 0.15s ease, color 0.15s ease", fontWeight: active ? 600 : 500, "&:hover": { color: active ? tokens.brand : tokens.text }, }), monitorList: { listStyle: "none", m: 0, p: 0, display: "flex", flexDirection: "column", gap: "12px", }, card: { background: tokens.surface, border: `1px solid ${tokens.border}`, borderRadius: tokens.radius, boxShadow: cardShadow, overflow: "hidden", position: "relative", transition: "transform 0.15s, box-shadow 0.15s", "&:hover": { transform: "translateY(-1px)", boxShadow: cardShadowHover }, }, cardRow: { display: "grid", alignItems: { xs: "start", md: "center" }, gridTemplateColumns: { xs: "minmax(0, 1fr)", md: "1fr auto" }, gridTemplateAreas: { xs: `"name" "status" "meta"`, md: `"name name" "meta status"`, }, columnGap: { md: "16px" }, rowGap: { xs: "10px", md: "4px" }, p: "16px 20px", }, cardLeft: { minWidth: 0, flex: 1, width: { xs: "100%", md: "auto" } }, monitorName: { gridArea: "name", minWidth: 0, width: { xs: "100%", md: "auto" }, fontWeight: 600, fontSize: 14, letterSpacing: "-0.005em", color: tokens.text, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", }, monitorMeta: { gridArea: "meta", gap: "10px", alignItems: { xs: "flex-start", md: "center" }, flexWrap: "wrap", }, pill: { ...pillBase, color: tokens.textMuted, border: `1px solid ${tokens.border}`, }, pillHardware: { ...pillBase, color: tokens.brand, border: `1px solid ${tokens.border}`, background: tokens.brandSoft, }, monitorUrl: { fontSize: 12, color: tokens.textMuted, fontFamily: MONO_STACK, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", maxWidth: 280, }, badge: (tone) => ({ gridArea: "status", justifySelf: "start", fontSize: 11, fontWeight: 600, padding: "4px 10px", borderRadius: "999px", whiteSpace: "nowrap", background: toneSoft(tone, tokens), color: toneColor(tone, tokens), }), heatmap: { padding: { xs: "0 10px 14px", md: "0 20px 16px" }, display: "grid", gridTemplateColumns: `repeat(${MAX_RECENT_CHECKS}, 1fr)`, gap: { xs: "1px", md: "3px" }, height: 42, }, heatmapCell: (kind) => ({ borderRadius: "2px", background: heatCellBg[kind], opacity: kind === "empty" ? 0.4 : 1, transition: "transform 0.15s", "&:hover": { transform: "scaleY(1.15)" }, }), histogram: { padding: { xs: "0 10px", md: "0 20px" }, display: "grid", gridTemplateColumns: `repeat(${MAX_RECENT_CHECKS}, 1fr)`, gap: { xs: "1px", md: "3px" }, alignItems: "flex-end", height: 42, }, bar: (kind, heightPct) => ({ background: barBg[kind], borderRadius: "2px", minHeight: 3, opacity: kind === "empty" ? 0.4 : 1, height: `${heightPct}%`, }), chartStats: { padding: "0 20px 16px", fontSize: 11, color: tokens.textMuted, fontVariantNumeric: "tabular-nums", }, infra: { padding: "14px 20px 18px", display: "grid", gridTemplateColumns: { xs: "1fr", md: "repeat(3, 1fr)" }, gap: "12px", }, infraEmpty: { padding: "14px 20px 18px", color: tokens.textMuted, fontSize: 13, }, gauge: { border: `1px solid ${tokens.border}`, borderRadius: "10px", p: "12px 14px", background: tokens.bg, }, gaugeLabel: { fontSize: 11, color: tokens.textMuted, textTransform: "uppercase", letterSpacing: "0.08em", fontWeight: 600, }, gaugeValue: { fontSize: 20, fontWeight: 600, letterSpacing: "-0.01em", mt: "2px", fontVariantNumeric: "tabular-nums", color: tokens.text, }, gaugeBar: { height: 4, background: tokens.border, borderRadius: "2px", overflow: "hidden", mt: "8px", }, gaugeFill: (level, widthPct) => ({ display: "block", height: "100%", background: gaugeFillBg[level], borderRadius: "2px", transition: "width 0.6s", width: `${Math.max(0, Math.min(100, widthPct))}%`, }), gaugeSub: { fontSize: 11, color: tokens.textMuted, mt: "6px", fontVariantNumeric: "tabular-nums", }, footer: { textAlign: "center", color: tokens.textMuted, fontSize: 12, mt: "40px", "& a": { color: tokens.brand, textDecoration: "underline", textUnderlineOffset: "3px", fontWeight: 600, "&:hover": { color: tokens.brandStrong }, }, }, }; };