refactor(status-page): convert bold, modern and editorial themes to MUI sx
Finishes the migration started for refined. Each theme now consumes the same pattern: - A typed *Styles interface that names every entry the page consumes (no `as Function` casts at the call site) - A *Styles factory that takes (tokens, isDark) and returns sx recipes derived from existing tokens.ts plus the shared toneColor/toneSoft helpers in shared/overallStatus - A useMemo around the factory call so MUI's sx processor sees referential equality across renders that don't change tokens - modern.css's keyframes (pulse + staggered fade-in + reduced-motion guard) ported via @mui/system keyframes inside the modern styles factory - bold.css's hero glow + conic logo + pseudo-elements ported as inline sx via "&::before" / "& > *" selectors - editorial.css's serif typography + hairline dividers + flat rectangular badges ported as plain sx with the serif/sans family stacks named at module scope Drop the four .css files (~1789 lines) along with the className= attributes and the import "./*.css" lines in each StatusPage component. The shared themed components (ThemedHeatmap, ThemedHistogram, ThemedInfrastructure) lose their legacy classPrefix branch entirely now that no theme uses it. The dual-API gate is gone; there is one path. Verified: tsc --noEmit clean, prettier clean. Note: theme-overrides.css remains for the legacy non-themed status page components (StatusBar, MonitorsList, HeaderStatusPageControls). That's separate scope from the four-theme work the reviewer flagged; can be migrated in a follow-up.
This commit is contained in:
1 parent
b95d8886b9
commit
c6c50063d8
12 files changed
+1442
-1616
No files matched your search
@@ -13,11 +13,8 @@ export type HeatCellKind = "fast" | "med" | "slow" | "down" | "empty";
|
||||
|
||||
interface Props {
|
||||
checks: CheckSnapshot[];
|
||||
/** 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;
|
||||
containerSx: SxProps<Theme>;
|
||||
cellSx: (kind: HeatCellKind) => SxProps<Theme>;
|
||||
}
|
||||
|
||||
const classify = (check: CheckSnapshot): Exclude<HeatCellKind, "empty"> => {
|
||||
@@ -28,9 +25,8 @@ const classify = (check: CheckSnapshot): Exclude<HeatCellKind, "empty"> => {
|
||||
return "fast";
|
||||
};
|
||||
|
||||
export const ThemedHeatmap = ({ checks, containerSx, cellSx, classPrefix }: Props) => {
|
||||
export const ThemedHeatmap = ({ checks, containerSx, cellSx }: Props) => {
|
||||
const { t } = useTranslation();
|
||||
const useSxApi = Boolean(containerSx && cellSx);
|
||||
|
||||
const source = checks.slice(0, CELLS).reverse();
|
||||
const padded: (CheckSnapshot | null)[] = [
|
||||
@@ -38,18 +34,9 @@ export const ThemedHeatmap = ({ checks, containerSx, cellSx, classPrefix }: Prop
|
||||
...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
|
||||
{...containerProps}
|
||||
sx={containerSx}
|
||||
role="img"
|
||||
aria-label={t("pages.statusPages.monitorsList.chart.heatmapAria")}
|
||||
>
|
||||
@@ -58,7 +45,7 @@ export const ThemedHeatmap = ({ checks, containerSx, cellSx, classPrefix }: Prop
|
||||
return (
|
||||
<Box
|
||||
key={`empty-${i}`}
|
||||
{...cellProps("empty")}
|
||||
sx={cellSx("empty")}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -89,7 +76,7 @@ export const ThemedHeatmap = ({ checks, containerSx, cellSx, classPrefix }: Prop
|
||||
placement="top"
|
||||
>
|
||||
<Box
|
||||
{...cellProps(kind)}
|
||||
sx={cellSx(kind)}
|
||||
aria-label={`${check.responseTime} ms, ${check.status ? "up" : "down"}`}
|
||||
/>
|
||||
</Tooltip>
|
||||
|
||||
Reference in new issue
Block a user