Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/frontend/packages/shared/src/settings/solid-backgrounds.tsx
iris 099118d31e swarm ui: a solid backgrounds setting turns the frosted surfaces opaque
A gear-menu toggle, off by default: the header bar, badges and terminal
panes lose their see-through fill and blur.
2026-11-01 13:43:14 +01:00

39 lines
1.4 KiB
TypeScript

// "Solid backgrounds" — a gear-menu toggle that turns the frosted, see-through
// surfaces opaque (mara: "add setting to disable transparency", e.g. the top
// bar and badge backgrounds). Off by default, so the look is unchanged until
// someone turns it on.
//
// The setting sets `data-solid="true"` on `<html>`, and `./solid-backgrounds.css`
// answers it. The caller owns the storage key, as with the theme and motion
// overrides, and mounts `useApplySolidBackgrounds` once so the choice applies
// before the menu is ever opened; `SolidBackgroundsSetting` is the menu's row.
import { useEffect } from "preact/hooks";
import { useLocalSetting } from "./settings-storage.js";
import "./solid-backgrounds.css";
export function useApplySolidBackgrounds(key: string): void {
const [solid] = useLocalSetting<boolean>(key, false);
useEffect(() => {
const root = document.documentElement;
if (solid) root.dataset.solid = "true";
else delete root.dataset.solid;
}, [solid]);
}
export function SolidBackgroundsSetting({
storageKey,
}: {
storageKey: string;
}) {
const [solid, setSolid] = useLocalSetting<boolean>(storageKey, false);
return (
<label class="settings-menu-row">
<span>solid backgrounds</span>
<input
type="checkbox"
checked={solid}
onChange={(e) => setSolid((e.target as HTMLInputElement).checked)}
/>
</label>
);
}