Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/frontend/packages/swarm-ui/src/theme-boot.js
iris 3d88108c4f frontend: light-theme terminal contrast, theme before first paint, color-scheme, motion and focus defaults
Light theme: the terminal and code blocks sat on --crust, a mid grey there, so text was 2:1 to 3:1. They now use --code-bg, which keeps 95% of a light palette's background (58% of the dark one's, as before); scrims and shadows keep --crust. Dark --muted goes from 4.44:1 to 4.72:1 on --bg. The stored theme and motion overrides are set by a blocking boot script in the head (the page allows no inline script), so a light OS no longer paints light before the dark default; a test keeps its keys in step with the shell. color-scheme follows the palette, so native controls and scrollbars match a forced theme. Five infinite animations (dashboard banner, container icon, pending badge, warn banner, spinner) now honour reduced motion and the in-app motion setting, ConnectionDot uses the same three-rule shape as the others, and the hive-warn element honours the system preference. Keyboard focus gets a default ring, and the cancel button and pane divider keep a visible one.
2026-11-19 20:45:18 +01:00

22 lines
1 KiB
JavaScript

// Sets the stored theme and motion overrides on <html> before the first paint.
// The app applies them again once it mounts (`useApplyThemeOverride`,
// `useApplyMotionOverride`), but that is after the page has painted, so a light
// OS showed a light flash before the dark default took over. This runs from a
// blocking script in the head, as the page's policy allows no inline script. The
// keys and the fallbacks ("dark" for the theme, "system" for motion) are those of
// `shell/Shell.tsx`; `test/theme-boot.test.mjs` keeps them in step.
(function () {
function read(key, fallback) {
try {
var raw = localStorage.getItem(key);
return raw === null ? fallback : JSON.parse(raw);
} catch (e) {
return fallback;
}
}
var root = document.documentElement;
var theme = read("swarm-ui:theme-override", "dark");
if (theme === "light" || theme === "dark") root.dataset.theme = theme;
var motion = read("swarm-ui:motion-override", "system");
if (motion === "reduce" || motion === "allow") root.dataset.motion = motion;
})();