refactor(status-page): convert refined theme to MUI sx + theme tokens
The reviewer's feedback on this PR is that the themes ship hardcoded class names against per-theme CSS files instead of following the project's MUI sx + theme.spacing()/palette pattern. This commit handles the refined theme as a proof of concept; the other three follow.
What changed
- New src/Pages/StatusPage/Status/themes/refined/styles.ts: a single function (tokens, isDark) -> sx recipes that mirror every rule in the deleted refined.css. All values are derived from the tokens already declared in tokens.ts so the colour/spacing source of truth doesn't change.
- RefinedStatusPage.tsx: drops the className= attributes and the import "./refined.css" in favour of sx={styles.x} drawn from the recipe map. Hardcoded class strings gone.
- refined.css: deleted (was 420 lines).
- Shared themed components (ThemedHeatmap, ThemedHistogram, ThemedInfrastructure): grew an opt-in sx-based API alongside the existing classPrefix one. The new API is what refined uses; bold / modern / editorial keep working unchanged on the legacy classPrefix path until they are migrated, after which the legacy code path is removed.
Verified
- tsc --noEmit clean
- prettier clean
- Pre-existing vite build error on this branch (flag-icons resolve, unrelated) is untouched
Next
- Convert the bold, modern and editorial themes the same way and remove the legacy classPrefix branch from the shared components.
This commit is contained in:
1 parent
944ee74a1d
commit
163f5ec1ec
6 files changed
+553
-493
No files matched your search
@@ -14,7 +14,8 @@ import {
|
||||
resolveOverallStatus,
|
||||
statusBadgeKey,
|
||||
} from "../shared/overallStatus";
|
||||
import "./refined.css";
|
||||
import { useStatusPageTheme } from "../StatusPageThemeProvider";
|
||||
import { refinedStyles } from "./styles";
|
||||
|
||||
type StatusPageMonitor = Monitor & { checks?: Monitor["recentChecks"] };
|
||||
|
||||
@@ -23,10 +24,10 @@ interface Props {
|
||||
monitors: StatusPageMonitor[];
|
||||
}
|
||||
|
||||
const PREFIX = "rf";
|
||||
|
||||
export const RefinedStatusPage = ({ statusPage, monitors }: Props) => {
|
||||
const { t } = useTranslation();
|
||||
const { tokens, mode } = useStatusPageTheme();
|
||||
const styles = refinedStyles(tokens, mode === "dark");
|
||||
const [chartMode, setChartMode] = useState<"heatmap" | "histogram">("heatmap");
|
||||
|
||||
const overall = resolveOverallStatus(monitors, t);
|
||||
@@ -35,72 +36,85 @@ export const RefinedStatusPage = ({ statusPage, monitors }: Props) => {
|
||||
: null;
|
||||
|
||||
return (
|
||||
<Box className={`${PREFIX}-page`}>
|
||||
<Box sx={styles.page}>
|
||||
<Box
|
||||
component="header"
|
||||
className={`${PREFIX}-top`}
|
||||
sx={styles.top}
|
||||
>
|
||||
<Box className={`${PREFIX}-brand`}>
|
||||
<Box sx={styles.brand}>
|
||||
{logoSrc ? (
|
||||
<Box
|
||||
component="img"
|
||||
src={logoSrc}
|
||||
alt={statusPage.companyName}
|
||||
className={`${PREFIX}-logo-img`}
|
||||
sx={styles.logoImg}
|
||||
/>
|
||||
) : (
|
||||
<Box className={`${PREFIX}-logo-mono`}>
|
||||
{monoFirstChar(statusPage.companyName)}
|
||||
</Box>
|
||||
<Box sx={styles.logoMono}>{monoFirstChar(statusPage.companyName)}</Box>
|
||||
)}
|
||||
<span className={`${PREFIX}-company`}>{statusPage.companyName}</span>
|
||||
<Box
|
||||
component="span"
|
||||
sx={styles.company}
|
||||
>
|
||||
{statusPage.companyName}
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
<Box className={`${PREFIX}-hero ${PREFIX}-tone-${overall.tone}`}>
|
||||
<Box className={`${PREFIX}-status-dot`} />
|
||||
<Box className={`${PREFIX}-status-copy`}>
|
||||
<h1 className={`${PREFIX}-hero-title`}>{overall.message}</h1>
|
||||
<p className={`${PREFIX}-hero-sub`}>
|
||||
<Box sx={styles.hero}>
|
||||
<Box sx={(styles.statusDot as Function)(overall.tone)} />
|
||||
<Box sx={styles.statusCopy}>
|
||||
<Box
|
||||
component="h1"
|
||||
sx={styles.heroTitle}
|
||||
>
|
||||
{overall.message}
|
||||
</Box>
|
||||
<Box
|
||||
component="p"
|
||||
sx={styles.heroSub}
|
||||
>
|
||||
{t("pages.statusPages.statusBar.monitoringSummary", {
|
||||
count: monitors.length,
|
||||
})}
|
||||
</p>
|
||||
</Box>
|
||||
</Box>
|
||||
<Box className={`${PREFIX}-hero-icon`}>{overall.icon}</Box>
|
||||
<Box sx={(styles.heroIcon as Function)(overall.tone)}>{overall.icon}</Box>
|
||||
</Box>
|
||||
|
||||
{statusPage.showCharts && (
|
||||
<Box className={`${PREFIX}-chart-switch-wrap`}>
|
||||
<Box sx={styles.chartSwitchWrap}>
|
||||
<Box
|
||||
className={`${PREFIX}-chart-switch`}
|
||||
sx={styles.chartSwitch}
|
||||
role="radiogroup"
|
||||
>
|
||||
<button
|
||||
<Box
|
||||
component="button"
|
||||
type="button"
|
||||
role="radio"
|
||||
aria-checked={chartMode === "heatmap"}
|
||||
className={chartMode === "heatmap" ? `${PREFIX}-active` : ""}
|
||||
onClick={() => setChartMode("heatmap")}
|
||||
sx={(styles.chartSwitchButton as Function)(chartMode === "heatmap")}
|
||||
>
|
||||
{t("pages.statusPages.monitorsList.chartTypeHeatmap")}
|
||||
</button>
|
||||
<button
|
||||
</Box>
|
||||
<Box
|
||||
component="button"
|
||||
type="button"
|
||||
role="radio"
|
||||
aria-checked={chartMode === "histogram"}
|
||||
className={chartMode === "histogram" ? `${PREFIX}-active` : ""}
|
||||
onClick={() => setChartMode("histogram")}
|
||||
sx={(styles.chartSwitchButton as Function)(chartMode === "histogram")}
|
||||
>
|
||||
{t("pages.statusPages.monitorsList.chartTypeHistogram")}
|
||||
</button>
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
<Stack
|
||||
component="ul"
|
||||
className={`${PREFIX}-monitor-list`}
|
||||
sx={styles.monitorList}
|
||||
>
|
||||
{monitors.map((monitor) => {
|
||||
const isHardware = monitor.type === "hardware";
|
||||
@@ -112,48 +126,68 @@ export const RefinedStatusPage = ({ statusPage, monitors }: Props) => {
|
||||
<Box
|
||||
component="li"
|
||||
key={monitor.id}
|
||||
className={`${PREFIX}-card ${PREFIX}-card-${monitor.status}`}
|
||||
sx={styles.card}
|
||||
>
|
||||
<Box className={`${PREFIX}-card-row`}>
|
||||
<Box className={`${PREFIX}-card-left`}>
|
||||
<Box className={`${PREFIX}-monitor-name`}>{monitor.name}</Box>
|
||||
<Box className={`${PREFIX}-monitor-meta`}>
|
||||
<span
|
||||
className={`${PREFIX}-pill ${PREFIX}-pill-${isHardware ? "hardware" : "default"}`}
|
||||
<Box sx={styles.cardRow}>
|
||||
<Box sx={styles.cardLeft}>
|
||||
<Box sx={styles.monitorName}>{monitor.name}</Box>
|
||||
<Box sx={styles.monitorMeta}>
|
||||
<Box
|
||||
component="span"
|
||||
sx={isHardware ? styles.pillHardware : styles.pill}
|
||||
>
|
||||
{getMonitorTypeLabel(monitor.type, t)}
|
||||
</span>
|
||||
</Box>
|
||||
{monitor.url && (
|
||||
<span
|
||||
className={`${PREFIX}-monitor-url`}
|
||||
<Box
|
||||
component="span"
|
||||
sx={styles.monitorUrl}
|
||||
title={monitor.url}
|
||||
>
|
||||
{monitor.url}
|
||||
</span>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
<span className={`${PREFIX}-badge ${PREFIX}-badge-${badgeTone}`}>
|
||||
<Box
|
||||
component="span"
|
||||
sx={(styles.badge as Function)(badgeTone)}
|
||||
>
|
||||
{t(statusBadgeKey[monitor.status])}
|
||||
</span>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
{showInfra && (
|
||||
<ThemedInfrastructure
|
||||
monitor={monitor}
|
||||
classPrefix={PREFIX}
|
||||
sxApi={{
|
||||
containerSx: styles.infra,
|
||||
emptySx: styles.infraEmpty,
|
||||
gaugeSx: styles.gauge,
|
||||
gaugeLabelSx: styles.gaugeLabel,
|
||||
gaugeValueSx: styles.gaugeValue,
|
||||
gaugeBarSx: styles.gaugeBar,
|
||||
gaugeFillSx: styles.gaugeFill as (
|
||||
level: "ok" | "warm" | "hot",
|
||||
width: number
|
||||
) => any,
|
||||
gaugeSubSx: styles.gaugeSub,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{showChart &&
|
||||
(chartMode === "heatmap" ? (
|
||||
<ThemedHeatmap
|
||||
checks={monitor.recentChecks ?? []}
|
||||
classPrefix={PREFIX}
|
||||
containerSx={styles.heatmap}
|
||||
cellSx={styles.heatmapCell as (kind: any) => any}
|
||||
/>
|
||||
) : (
|
||||
<ThemedHistogram
|
||||
checks={monitor.recentChecks ?? []}
|
||||
classPrefix={PREFIX}
|
||||
containerSx={styles.histogram}
|
||||
barSx={styles.bar as (kind: any, h: number) => any}
|
||||
statsSx={styles.chartStats}
|
||||
/>
|
||||
))}
|
||||
</Box>
|
||||
@@ -163,7 +197,7 @@ export const RefinedStatusPage = ({ statusPage, monitors }: Props) => {
|
||||
|
||||
<Box
|
||||
component="footer"
|
||||
className={`${PREFIX}-footer`}
|
||||
sx={styles.footer}
|
||||
>
|
||||
{t("pages.statusPages.footer.poweredBy")}{" "}
|
||||
<a
|
||||
|
||||
@@ -1,420 +0,0 @@
|
||||
/*
|
||||
* Refined theme — scoped to [data-status-theme="refined"].
|
||||
* Port of /Users/gorkemcetin/Desktop/checkmate-status-mockups/01-refined.html.
|
||||
* Colour tokens come from the provider's inline CSS vars (see tokens.ts).
|
||||
*/
|
||||
|
||||
[data-status-theme="refined"]:not([data-status-transparent]) {
|
||||
/* On the public route the wrapper paints its own bg and fills the
|
||||
viewport. Inside a BrowserFrame (admin preview) it stays transparent
|
||||
so the frame's rounded corners don't bleed the wrapper's square
|
||||
corners past the clip. */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
[data-status-theme="refined"] .rf-page {
|
||||
flex: 1 0 auto;
|
||||
max-width: 960px;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
padding: 48px 20px 80px;
|
||||
font:
|
||||
14px/1.5 -apple-system,
|
||||
BlinkMacSystemFont,
|
||||
"Inter",
|
||||
"Segoe UI",
|
||||
Roboto,
|
||||
sans-serif;
|
||||
color: var(--sp-text);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
/* --- header --- */
|
||||
[data-status-theme="refined"] .rf-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 28px;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.01em;
|
||||
color: var(--sp-text);
|
||||
}
|
||||
[data-status-theme="refined"] .rf-logo-mono {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: 8px;
|
||||
background: var(--sp-up);
|
||||
display: grid;
|
||||
place-items: center;
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
font-size: 13px;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-logo-img {
|
||||
max-height: 32px;
|
||||
max-width: 120px;
|
||||
object-fit: contain;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-company {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
/* --- hero status bar --- */
|
||||
[data-status-theme="refined"] .rf-hero {
|
||||
background: var(--sp-surface);
|
||||
border: 1px solid var(--sp-border);
|
||||
border-radius: var(--sp-radius);
|
||||
padding: 22px 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
box-shadow: var(
|
||||
--sp-shadow,
|
||||
0 1px 2px rgba(10, 16, 32, 0.06),
|
||||
0 6px 18px rgba(10, 16, 32, 0.08)
|
||||
);
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-status-dot {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
background: var(--sp-up);
|
||||
box-shadow: 0 0 0 4px var(--sp-up-soft);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-hero.rf-tone-warn .rf-status-dot {
|
||||
background: var(--sp-warn);
|
||||
box-shadow: 0 0 0 4px var(--sp-warn-soft);
|
||||
}
|
||||
[data-status-theme="refined"] .rf-hero.rf-tone-down .rf-status-dot {
|
||||
background: var(--sp-down);
|
||||
box-shadow: 0 0 0 4px var(--sp-down-soft);
|
||||
}
|
||||
[data-status-theme="refined"] .rf-status-copy {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-hero-title {
|
||||
margin: 0 0 2px;
|
||||
font-size: 17px;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.01em;
|
||||
color: var(--sp-text);
|
||||
}
|
||||
[data-status-theme="refined"] .rf-hero-sub {
|
||||
margin: 0;
|
||||
color: var(--sp-text-muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-hero-icon {
|
||||
color: var(--sp-text-muted);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-hero.rf-tone-up .rf-hero-icon {
|
||||
color: var(--sp-up);
|
||||
}
|
||||
[data-status-theme="refined"] .rf-hero.rf-tone-warn .rf-hero-icon {
|
||||
color: var(--sp-warn);
|
||||
}
|
||||
[data-status-theme="refined"] .rf-hero.rf-tone-down .rf-hero-icon {
|
||||
color: var(--sp-down);
|
||||
}
|
||||
|
||||
/* --- chart switch (segmented control) --- */
|
||||
[data-status-theme="refined"] .rf-chart-switch-wrap {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-chart-switch {
|
||||
display: inline-flex;
|
||||
border: 1px solid var(--sp-border);
|
||||
border-radius: 8px;
|
||||
background: var(--sp-surface);
|
||||
padding: 3px;
|
||||
gap: 2px;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-chart-switch > button {
|
||||
border: 0;
|
||||
background: transparent;
|
||||
font:
|
||||
inherit,
|
||||
-apple-system,
|
||||
sans-serif;
|
||||
font-size: 11px;
|
||||
padding: 5px 14px;
|
||||
cursor: pointer;
|
||||
color: var(--sp-text-muted);
|
||||
border-radius: 5px;
|
||||
transition:
|
||||
background 0.15s ease,
|
||||
color 0.15s ease;
|
||||
font-weight: 500;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-chart-switch > button:hover {
|
||||
color: var(--sp-text);
|
||||
}
|
||||
[data-status-theme="refined"] .rf-chart-switch > button.rf-active {
|
||||
color: var(--sp-up);
|
||||
background: var(--sp-up-soft);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* --- monitor card list --- */
|
||||
[data-status-theme="refined"] .rf-monitor-list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-card {
|
||||
background: var(--sp-surface);
|
||||
border: 1px solid var(--sp-border);
|
||||
border-radius: var(--sp-radius);
|
||||
box-shadow: var(
|
||||
--sp-shadow,
|
||||
0 1px 2px rgba(10, 16, 32, 0.06),
|
||||
0 6px 18px rgba(10, 16, 32, 0.08)
|
||||
);
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
transition:
|
||||
transform 0.15s,
|
||||
box-shadow 0.15s;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-card:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow:
|
||||
0 2px 4px rgba(16, 24, 40, 0.06),
|
||||
0 10px 24px rgba(16, 24, 40, 0.06);
|
||||
}
|
||||
|
||||
[data-status-theme="refined"] .rf-card-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
padding: 16px 20px;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-card-left {
|
||||
min-width: 0;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-monitor-name {
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
letter-spacing: -0.005em;
|
||||
color: var(--sp-text);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-monitor-meta {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
margin-top: 4px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-pill {
|
||||
font-size: 10px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
color: var(--sp-text-muted);
|
||||
border: 1px solid var(--sp-border);
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
font-weight: 600;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-pill-hardware {
|
||||
color: #1d4ed8;
|
||||
border-color: rgba(29, 78, 216, 0.3);
|
||||
background: rgba(29, 78, 216, 0.06);
|
||||
}
|
||||
[data-status-theme="refined"][data-status-mode="dark"] .rf-pill-hardware {
|
||||
color: #60a5fa;
|
||||
border-color: rgba(96, 165, 250, 0.3);
|
||||
background: rgba(96, 165, 250, 0.1);
|
||||
}
|
||||
[data-status-theme="refined"] .rf-monitor-url {
|
||||
font-size: 12px;
|
||||
color: var(--sp-text-muted);
|
||||
font-family: ui-monospace, Menlo, monospace;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
max-width: 280px;
|
||||
}
|
||||
|
||||
[data-status-theme="refined"] .rf-badge {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
padding: 4px 10px;
|
||||
border-radius: 999px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-badge-up {
|
||||
background: var(--sp-up-soft);
|
||||
color: var(--sp-up);
|
||||
}
|
||||
[data-status-theme="refined"] .rf-badge-warn {
|
||||
background: var(--sp-warn-soft);
|
||||
color: var(--sp-warn);
|
||||
}
|
||||
[data-status-theme="refined"] .rf-badge-down {
|
||||
background: var(--sp-down-soft);
|
||||
color: var(--sp-down);
|
||||
}
|
||||
|
||||
/* --- heatmap --- */
|
||||
[data-status-theme="refined"] .rf-heatmap {
|
||||
padding: 0 20px 16px;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(25, 1fr);
|
||||
gap: 3px;
|
||||
height: 42px;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-heatmap-cell {
|
||||
border-radius: 2px;
|
||||
background: var(--sp-up);
|
||||
transition: transform 0.15s;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-heatmap-cell:hover {
|
||||
transform: scaleY(1.15);
|
||||
}
|
||||
[data-status-theme="refined"] .rf-heatmap-cell.rf-fast {
|
||||
background: var(--sp-up);
|
||||
}
|
||||
[data-status-theme="refined"] .rf-heatmap-cell.rf-med {
|
||||
background: color-mix(in srgb, var(--sp-up) 60%, #ffffff 40%);
|
||||
}
|
||||
[data-status-theme="refined"] .rf-heatmap-cell.rf-slow {
|
||||
background: var(--sp-warn);
|
||||
}
|
||||
[data-status-theme="refined"] .rf-heatmap-cell.rf-down {
|
||||
background: var(--sp-down);
|
||||
}
|
||||
[data-status-theme="refined"] .rf-heatmap-cell.rf-empty {
|
||||
background: var(--sp-border);
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
/* --- histogram --- */
|
||||
[data-status-theme="refined"] .rf-histogram {
|
||||
padding: 0 20px;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(25, 1fr);
|
||||
gap: 3px;
|
||||
align-items: flex-end;
|
||||
height: 42px;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-bar {
|
||||
background: var(--sp-up);
|
||||
border-radius: 2px;
|
||||
min-height: 3px;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-bar.rf-down {
|
||||
background: var(--sp-down);
|
||||
}
|
||||
[data-status-theme="refined"] .rf-bar.rf-empty {
|
||||
background: var(--sp-border);
|
||||
opacity: 0.4;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-chart-stats {
|
||||
padding: 0 20px 16px;
|
||||
font-size: 11px;
|
||||
color: var(--sp-text-muted);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* --- infrastructure gauges --- */
|
||||
[data-status-theme="refined"] .rf-infra {
|
||||
padding: 14px 20px 18px;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 12px;
|
||||
}
|
||||
@media (max-width: 720px) {
|
||||
[data-status-theme="refined"] .rf-infra {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
[data-status-theme="refined"] .rf-infra-empty {
|
||||
padding: 14px 20px 18px;
|
||||
color: var(--sp-text-muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-gauge {
|
||||
border: 1px solid var(--sp-border);
|
||||
border-radius: 10px;
|
||||
padding: 12px 14px;
|
||||
background: var(--sp-bg);
|
||||
}
|
||||
[data-status-theme="refined"] .rf-gauge-label {
|
||||
font-size: 11px;
|
||||
color: var(--sp-text-muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
font-weight: 600;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-gauge-value {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.01em;
|
||||
margin-top: 2px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
color: var(--sp-text);
|
||||
}
|
||||
[data-status-theme="refined"] .rf-gauge-bar {
|
||||
height: 4px;
|
||||
background: var(--sp-border);
|
||||
border-radius: 2px;
|
||||
overflow: hidden;
|
||||
margin-top: 8px;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-gauge-fill {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background: var(--sp-up);
|
||||
border-radius: 2px;
|
||||
transition: width 0.6s;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-gauge-fill.rf-warm {
|
||||
background: var(--sp-warn);
|
||||
}
|
||||
[data-status-theme="refined"] .rf-gauge-fill.rf-hot {
|
||||
background: var(--sp-down);
|
||||
}
|
||||
[data-status-theme="refined"] .rf-gauge-sub {
|
||||
font-size: 11px;
|
||||
color: var(--sp-text-muted);
|
||||
margin-top: 6px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* --- footer --- */
|
||||
[data-status-theme="refined"] .rf-footer {
|
||||
text-align: center;
|
||||
color: var(--sp-text-muted);
|
||||
font-size: 12px;
|
||||
margin-top: 40px;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-footer a {
|
||||
color: var(--sp-up);
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 3px;
|
||||
font-weight: 600;
|
||||
}
|
||||
[data-status-theme="refined"] .rf-footer a:hover {
|
||||
color: var(--sp-up-strong, var(--sp-up));
|
||||
}
|
||||
@@ -0,0 +1,352 @@
|
||||
import type { StatusPageThemeTokens } from "../tokens";
|
||||
|
||||
export type RefinedTone = "up" | "warn" | "down";
|
||||
export type RefinedHeatCell = "fast" | "med" | "slow" | "down" | "empty";
|
||||
export type RefinedBarKind = "up" | "down" | "empty";
|
||||
export type RefinedGaugeFill = "ok" | "warm" | "hot";
|
||||
|
||||
const sansFontStack =
|
||||
'-apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif';
|
||||
|
||||
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 toneColor = (tone: RefinedTone, t: StatusPageThemeTokens) =>
|
||||
tone === "down" ? t.down : tone === "warn" ? t.warn : t.up;
|
||||
|
||||
const toneSoft = (tone: RefinedTone, t: StatusPageThemeTokens) =>
|
||||
tone === "down" ? t.downSoft : tone === "warn" ? t.warnSoft : t.upSoft;
|
||||
|
||||
export const refinedStyles = (tokens: StatusPageThemeTokens, isDark: boolean) => {
|
||||
const heatCellBg: Record<RefinedHeatCell, string> = {
|
||||
fast: tokens.up,
|
||||
med: `color-mix(in srgb, ${tokens.up} 60%, #ffffff 40%)`,
|
||||
slow: tokens.warn,
|
||||
down: tokens.down,
|
||||
empty: tokens.border,
|
||||
};
|
||||
|
||||
const barBg: Record<RefinedBarKind, string> = {
|
||||
up: tokens.up,
|
||||
down: tokens.down,
|
||||
empty: tokens.border,
|
||||
};
|
||||
|
||||
const gaugeFillBg: Record<RefinedGaugeFill, string> = {
|
||||
ok: tokens.up,
|
||||
warm: tokens.warn,
|
||||
hot: tokens.down,
|
||||
};
|
||||
|
||||
const sx: Record<string, any> = {
|
||||
page: {
|
||||
flex: "1 0 auto",
|
||||
maxWidth: 960,
|
||||
width: "100%",
|
||||
mx: "auto",
|
||||
p: "48px 20px 80px",
|
||||
fontFamily: sansFontStack,
|
||||
fontSize: 14,
|
||||
lineHeight: 1.5,
|
||||
color: tokens.text,
|
||||
WebkitFontSmoothing: "antialiased",
|
||||
},
|
||||
|
||||
top: {
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
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.up,
|
||||
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: "22px 24px",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
gap: "16px",
|
||||
boxShadow: cardShadow,
|
||||
mb: "20px",
|
||||
},
|
||||
statusDot: (tone: RefinedTone) => ({
|
||||
width: 10,
|
||||
height: 10,
|
||||
borderRadius: "50%",
|
||||
background: toneColor(tone, tokens),
|
||||
boxShadow: `0 0 0 4px ${toneSoft(tone, tokens)}`,
|
||||
flexShrink: 0,
|
||||
}),
|
||||
statusCopy: { flex: 1, minWidth: 0 },
|
||||
heroTitle: {
|
||||
m: 0,
|
||||
mb: "2px",
|
||||
fontSize: 17,
|
||||
fontWeight: 600,
|
||||
letterSpacing: "-0.01em",
|
||||
color: tokens.text,
|
||||
},
|
||||
heroSub: { m: 0, color: tokens.textMuted, fontSize: 13 },
|
||||
heroIcon: (tone: RefinedTone) => ({
|
||||
color: toneColor(tone, tokens),
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
}),
|
||||
|
||||
chartSwitchWrap: {
|
||||
display: "flex",
|
||||
justifyContent: "flex-end",
|
||||
mb: "12px",
|
||||
},
|
||||
chartSwitch: {
|
||||
display: "inline-flex",
|
||||
border: `1px solid ${tokens.border}`,
|
||||
borderRadius: "8px",
|
||||
background: tokens.surface,
|
||||
p: "3px",
|
||||
gap: "2px",
|
||||
},
|
||||
chartSwitchButton: (active: boolean) => ({
|
||||
border: 0,
|
||||
background: active ? tokens.upSoft : "transparent",
|
||||
fontFamily: "inherit",
|
||||
fontSize: 11,
|
||||
padding: "5px 14px",
|
||||
cursor: "pointer",
|
||||
color: active ? tokens.up : tokens.textMuted,
|
||||
borderRadius: "5px",
|
||||
transition: "background 0.15s ease, color 0.15s ease",
|
||||
fontWeight: active ? 600 : 500,
|
||||
"&:hover": { color: active ? tokens.up : 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",
|
||||
gridTemplateColumns: "1fr auto",
|
||||
alignItems: "center",
|
||||
gap: "16px",
|
||||
p: "16px 20px",
|
||||
},
|
||||
cardLeft: { minWidth: 0 },
|
||||
monitorName: {
|
||||
fontWeight: 600,
|
||||
fontSize: 14,
|
||||
letterSpacing: "-0.005em",
|
||||
color: tokens.text,
|
||||
overflow: "hidden",
|
||||
textOverflow: "ellipsis",
|
||||
whiteSpace: "nowrap",
|
||||
},
|
||||
monitorMeta: {
|
||||
display: "flex",
|
||||
gap: "10px",
|
||||
alignItems: "center",
|
||||
mt: "4px",
|
||||
flexWrap: "wrap",
|
||||
},
|
||||
pill: {
|
||||
fontSize: 10,
|
||||
textTransform: "uppercase",
|
||||
letterSpacing: "0.08em",
|
||||
color: tokens.textMuted,
|
||||
border: `1px solid ${tokens.border}`,
|
||||
padding: "2px 8px",
|
||||
borderRadius: "999px",
|
||||
fontWeight: 600,
|
||||
},
|
||||
pillHardware: isDark
|
||||
? {
|
||||
fontSize: 10,
|
||||
textTransform: "uppercase",
|
||||
letterSpacing: "0.08em",
|
||||
padding: "2px 8px",
|
||||
borderRadius: "999px",
|
||||
fontWeight: 600,
|
||||
color: "#60a5fa",
|
||||
border: "1px solid rgba(96, 165, 250, 0.3)",
|
||||
background: "rgba(96, 165, 250, 0.1)",
|
||||
}
|
||||
: {
|
||||
fontSize: 10,
|
||||
textTransform: "uppercase",
|
||||
letterSpacing: "0.08em",
|
||||
padding: "2px 8px",
|
||||
borderRadius: "999px",
|
||||
fontWeight: 600,
|
||||
color: "#1d4ed8",
|
||||
border: "1px solid rgba(29, 78, 216, 0.3)",
|
||||
background: "rgba(29, 78, 216, 0.06)",
|
||||
},
|
||||
monitorUrl: {
|
||||
fontSize: 12,
|
||||
color: tokens.textMuted,
|
||||
fontFamily: "ui-monospace, Menlo, monospace",
|
||||
overflow: "hidden",
|
||||
textOverflow: "ellipsis",
|
||||
whiteSpace: "nowrap",
|
||||
maxWidth: 280,
|
||||
},
|
||||
|
||||
badge: (tone: RefinedTone) => ({
|
||||
fontSize: 11,
|
||||
fontWeight: 600,
|
||||
padding: "4px 10px",
|
||||
borderRadius: "999px",
|
||||
whiteSpace: "nowrap",
|
||||
background: toneSoft(tone, tokens),
|
||||
color: toneColor(tone, tokens),
|
||||
}),
|
||||
|
||||
heatmap: {
|
||||
padding: "0 20px 16px",
|
||||
display: "grid",
|
||||
gridTemplateColumns: "repeat(25, 1fr)",
|
||||
gap: "3px",
|
||||
height: 42,
|
||||
},
|
||||
heatmapCell: (kind: RefinedHeatCell) => ({
|
||||
borderRadius: "2px",
|
||||
background: heatCellBg[kind],
|
||||
opacity: kind === "empty" ? 0.4 : 1,
|
||||
transition: "transform 0.15s",
|
||||
"&:hover": { transform: "scaleY(1.15)" },
|
||||
}),
|
||||
|
||||
histogram: {
|
||||
padding: "0 20px",
|
||||
display: "grid",
|
||||
gridTemplateColumns: "repeat(25, 1fr)",
|
||||
gap: "3px",
|
||||
alignItems: "flex-end",
|
||||
height: 42,
|
||||
},
|
||||
bar: (kind: RefinedBarKind, heightPct: number) => ({
|
||||
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: RefinedGaugeFill, widthPct: number) => ({
|
||||
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.up,
|
||||
textDecoration: "underline",
|
||||
textUnderlineOffset: "3px",
|
||||
fontWeight: 600,
|
||||
"&:hover": { color: tokens.upStrong || tokens.up },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
return sx;
|
||||
};
|
||||
@@ -2,18 +2,25 @@ import Tooltip from "@mui/material/Tooltip";
|
||||
import Box from "@mui/material/Box";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import type { SxProps, Theme } from "@mui/material/styles";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { CheckSnapshot } from "@/Types/Check";
|
||||
import { formatCheckTimestamp } from "./timeFormat";
|
||||
|
||||
const CELLS = 25;
|
||||
|
||||
export type HeatCellKind = "fast" | "med" | "slow" | "down" | "empty";
|
||||
|
||||
interface Props {
|
||||
checks: CheckSnapshot[];
|
||||
classPrefix: string;
|
||||
/** sx-based API — preferred. Themes pass their own container + cell recipes. */
|
||||
containerSx?: SxProps<Theme>;
|
||||
cellSx?: (kind: HeatCellKind) => SxProps<Theme>;
|
||||
/** Legacy className-based API — kept for unmigrated themes. Will be removed once all themes move to sx. */
|
||||
classPrefix?: string;
|
||||
}
|
||||
|
||||
const classify = (check: CheckSnapshot): "fast" | "med" | "slow" | "down" => {
|
||||
const classify = (check: CheckSnapshot): Exclude<HeatCellKind, "empty"> => {
|
||||
if (!check.status) return "down";
|
||||
const rt = check.responseTime ?? 0;
|
||||
if (rt > 500) return "slow";
|
||||
@@ -21,8 +28,9 @@ const classify = (check: CheckSnapshot): "fast" | "med" | "slow" | "down" => {
|
||||
return "fast";
|
||||
};
|
||||
|
||||
export const ThemedHeatmap = ({ checks, classPrefix }: Props) => {
|
||||
export const ThemedHeatmap = ({ checks, containerSx, cellSx, classPrefix }: Props) => {
|
||||
const { t } = useTranslation();
|
||||
const useSxApi = Boolean(cellSx);
|
||||
|
||||
const source = checks.slice(0, CELLS).reverse();
|
||||
const padded: (CheckSnapshot | null)[] = [
|
||||
@@ -30,9 +38,18 @@ export const ThemedHeatmap = ({ checks, classPrefix }: Props) => {
|
||||
...source,
|
||||
];
|
||||
|
||||
const containerProps = useSxApi
|
||||
? { sx: containerSx }
|
||||
: { className: `${classPrefix}-heatmap` };
|
||||
|
||||
const cellProps = (kind: HeatCellKind) =>
|
||||
useSxApi
|
||||
? { sx: cellSx!(kind) }
|
||||
: { className: `${classPrefix}-heatmap-cell ${classPrefix}-${kind}` };
|
||||
|
||||
return (
|
||||
<Box
|
||||
className={`${classPrefix}-heatmap`}
|
||||
{...containerProps}
|
||||
role="img"
|
||||
aria-label={t("pages.statusPages.monitorsList.chart.heatmapAria")}
|
||||
>
|
||||
@@ -41,11 +58,11 @@ export const ThemedHeatmap = ({ checks, classPrefix }: Props) => {
|
||||
return (
|
||||
<Box
|
||||
key={`empty-${i}`}
|
||||
className={`${classPrefix}-heatmap-cell ${classPrefix}-empty`}
|
||||
{...cellProps("empty")}
|
||||
/>
|
||||
);
|
||||
}
|
||||
const cls = classify(check);
|
||||
const kind = classify(check);
|
||||
const tooltipContent = (
|
||||
<Stack gap={0.25}>
|
||||
<Typography
|
||||
@@ -72,7 +89,7 @@ export const ThemedHeatmap = ({ checks, classPrefix }: Props) => {
|
||||
placement="top"
|
||||
>
|
||||
<Box
|
||||
className={`${classPrefix}-heatmap-cell ${classPrefix}-${cls}`}
|
||||
{...cellProps(kind)}
|
||||
aria-label={`${check.responseTime} ms, ${check.status ? "up" : "down"}`}
|
||||
/>
|
||||
</Tooltip>
|
||||
|
||||
@@ -3,6 +3,7 @@ import Tooltip from "@mui/material/Tooltip";
|
||||
import Box from "@mui/material/Box";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import type { SxProps, Theme } from "@mui/material/styles";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { CheckSnapshot } from "@/Types/Check";
|
||||
import { formatCheckTimestamp } from "./timeFormat";
|
||||
@@ -10,16 +11,32 @@ import { formatCheckTimestamp } from "./timeFormat";
|
||||
const CELLS = 25;
|
||||
const MIN_HEIGHT_PCT = 6;
|
||||
|
||||
export type BarKind = "up" | "down" | "empty";
|
||||
|
||||
interface Props {
|
||||
checks: CheckSnapshot[];
|
||||
classPrefix: string;
|
||||
/** sx-based API — preferred. */
|
||||
containerSx?: SxProps<Theme>;
|
||||
barSx?: (kind: BarKind, heightPct: number) => SxProps<Theme>;
|
||||
statsSx?: SxProps<Theme>;
|
||||
/** Legacy className-based API. Will be removed once all themes move to sx. */
|
||||
classPrefix?: string;
|
||||
statsGap?: number;
|
||||
}
|
||||
|
||||
const tone = (check: CheckSnapshot): "up" | "down" => (check.status ? "up" : "down");
|
||||
const tone = (check: CheckSnapshot): Exclude<BarKind, "empty"> =>
|
||||
check.status ? "up" : "down";
|
||||
|
||||
export const ThemedHistogram = ({ checks, classPrefix, statsGap = 1 }: Props) => {
|
||||
export const ThemedHistogram = ({
|
||||
checks,
|
||||
containerSx,
|
||||
barSx,
|
||||
statsSx,
|
||||
classPrefix,
|
||||
statsGap = 1,
|
||||
}: Props) => {
|
||||
const { t } = useTranslation();
|
||||
const useSxApi = Boolean(barSx);
|
||||
|
||||
const { padded, max, avg, peak } = useMemo(() => {
|
||||
const source = checks.slice(0, CELLS).reverse();
|
||||
@@ -35,12 +52,25 @@ export const ThemedHistogram = ({ checks, classPrefix, statsGap = 1 }: Props) =>
|
||||
return { padded: out, max: maxRt, avg: avgRt, peak: valid.length ? maxRt : 0 };
|
||||
}, [checks]);
|
||||
|
||||
const containerProps = useSxApi
|
||||
? { sx: containerSx }
|
||||
: { className: `${classPrefix}-histogram` };
|
||||
|
||||
const statsProps = useSxApi
|
||||
? { sx: statsSx }
|
||||
: { className: `${classPrefix}-chart-stats` };
|
||||
|
||||
return (
|
||||
<Stack gap={statsGap}>
|
||||
<Box className={`${classPrefix}-histogram`}>
|
||||
<Box {...containerProps}>
|
||||
{padded.map((check, i) => {
|
||||
if (!check) {
|
||||
return (
|
||||
return useSxApi ? (
|
||||
<Box
|
||||
key={`empty-${i}`}
|
||||
sx={barSx!("empty", MIN_HEIGHT_PCT)}
|
||||
/>
|
||||
) : (
|
||||
<Box
|
||||
key={`empty-${i}`}
|
||||
className={`${classPrefix}-bar ${classPrefix}-empty`}
|
||||
@@ -77,11 +107,18 @@ export const ThemedHistogram = ({ checks, classPrefix, statsGap = 1 }: Props) =>
|
||||
arrow
|
||||
placement="top"
|
||||
>
|
||||
<Box
|
||||
className={`${classPrefix}-bar ${classPrefix}-${tone(check)}`}
|
||||
style={{ height: `${height}%` }}
|
||||
aria-label={`${check.responseTime} ms`}
|
||||
/>
|
||||
{useSxApi ? (
|
||||
<Box
|
||||
sx={barSx!(tone(check), height)}
|
||||
aria-label={`${check.responseTime} ms`}
|
||||
/>
|
||||
) : (
|
||||
<Box
|
||||
className={`${classPrefix}-bar ${classPrefix}-${tone(check)}`}
|
||||
style={{ height: `${height}%` }}
|
||||
aria-label={`${check.responseTime} ms`}
|
||||
/>
|
||||
)}
|
||||
</Tooltip>
|
||||
);
|
||||
})}
|
||||
@@ -89,7 +126,7 @@ export const ThemedHistogram = ({ checks, classPrefix, statsGap = 1 }: Props) =>
|
||||
<Stack
|
||||
direction="row"
|
||||
justifyContent="space-between"
|
||||
className={`${classPrefix}-chart-stats`}
|
||||
{...statsProps}
|
||||
>
|
||||
<span>{t("pages.statusPages.monitorsList.chart.avg", { value: avg })}</span>
|
||||
<span>{t("pages.statusPages.monitorsList.chart.max", { value: peak })}</span>
|
||||
|
||||
@@ -1,11 +1,28 @@
|
||||
import Box from "@mui/material/Box";
|
||||
import prettyBytes from "pretty-bytes";
|
||||
import type { SxProps, Theme } from "@mui/material/styles";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { Monitor } from "@/Types/Monitor";
|
||||
|
||||
export type GaugeFillLevel = "ok" | "warm" | "hot";
|
||||
|
||||
interface InfraSx {
|
||||
containerSx: SxProps<Theme>;
|
||||
emptySx: SxProps<Theme>;
|
||||
gaugeSx: SxProps<Theme>;
|
||||
gaugeLabelSx: SxProps<Theme>;
|
||||
gaugeValueSx: SxProps<Theme>;
|
||||
gaugeBarSx: SxProps<Theme>;
|
||||
gaugeFillSx: (level: GaugeFillLevel, widthPct: number) => SxProps<Theme>;
|
||||
gaugeSubSx: SxProps<Theme>;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
monitor: Monitor & { checks?: Monitor["recentChecks"] };
|
||||
classPrefix: string;
|
||||
/** sx-based API — preferred. */
|
||||
sxApi?: InfraSx;
|
||||
/** Legacy className-based API. Will be removed once all themes move to sx. */
|
||||
classPrefix?: string;
|
||||
}
|
||||
|
||||
interface Gauge {
|
||||
@@ -17,16 +34,24 @@ interface Gauge {
|
||||
|
||||
const PCT = 100;
|
||||
|
||||
export const ThemedInfrastructure = ({ monitor, classPrefix }: Props) => {
|
||||
const heatLevel = (value: number): GaugeFillLevel =>
|
||||
value > 85 ? "hot" : value > 70 ? "warm" : "ok";
|
||||
|
||||
export const ThemedInfrastructure = ({ monitor, sxApi, classPrefix }: Props) => {
|
||||
const { t } = useTranslation();
|
||||
const useSxApi = Boolean(sxApi);
|
||||
const latest = monitor.recentChecks?.[0] ?? monitor.checks?.[0];
|
||||
if (!latest) {
|
||||
return (
|
||||
<Box className={`${classPrefix}-infra-empty`}>
|
||||
{t("pages.statusPages.monitorsList.noData")}
|
||||
</Box>
|
||||
|
||||
const renderEmpty = () => {
|
||||
const message = t("pages.statusPages.monitorsList.noData");
|
||||
return useSxApi ? (
|
||||
<Box sx={sxApi!.emptySx}>{message}</Box>
|
||||
) : (
|
||||
<Box className={`${classPrefix}-infra-empty`}>{message}</Box>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
if (!latest) return renderEmpty();
|
||||
|
||||
const gauges: Gauge[] = [];
|
||||
|
||||
@@ -67,10 +92,25 @@ export const ThemedInfrastructure = ({ monitor, classPrefix }: Props) => {
|
||||
});
|
||||
}
|
||||
|
||||
if (gauges.length === 0) {
|
||||
if (gauges.length === 0) return renderEmpty();
|
||||
|
||||
if (useSxApi) {
|
||||
const s = sxApi!;
|
||||
return (
|
||||
<Box className={`${classPrefix}-infra-empty`}>
|
||||
{t("pages.statusPages.monitorsList.noData")}
|
||||
<Box sx={s.containerSx}>
|
||||
{gauges.map((g) => (
|
||||
<Box
|
||||
key={g.key}
|
||||
sx={s.gaugeSx}
|
||||
>
|
||||
<Box sx={s.gaugeLabelSx}>{g.label}</Box>
|
||||
<Box sx={s.gaugeValueSx}>{g.value.toFixed(0)}%</Box>
|
||||
<Box sx={s.gaugeBarSx}>
|
||||
<Box sx={s.gaugeFillSx(heatLevel(g.value), Math.min(100, g.value))} />
|
||||
</Box>
|
||||
<Box sx={s.gaugeSubSx}>{g.sub}</Box>
|
||||
</Box>
|
||||
))}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user