diff --git a/src/client/api.ts b/src/client/api.ts index 02aac03..3e4a52a 100644 --- a/src/client/api.ts +++ b/src/client/api.ts @@ -96,7 +96,10 @@ export const DEFAULT_THEME_CONFIG: ThemeConfig = { uiEffects: true, motionEffects: true, dynamicAccent: true, - gradient: { ...DEFAULT_GRADIENT_CONFIG, stops: [...DEFAULT_GRADIENT_CONFIG.stops] }, + gradient: { + ...DEFAULT_GRADIENT_CONFIG, + stops: [...DEFAULT_GRADIENT_CONFIG.stops], + }, custom: { ...DEFAULT_CUSTOM_TOKENS }, }; @@ -154,7 +157,10 @@ export function normalizeThemeConfig( ? rawGrad.stops .slice(0, 3) .map((s, idx) => - normalizeStoredHex(s, DEFAULT_GRADIENT_CONFIG.stops[idx] ?? "#0f172a"), + normalizeStoredHex( + s, + DEFAULT_GRADIENT_CONFIG.stops[idx] ?? "#0f172a", + ), ) : [...DEFAULT_GRADIENT_CONFIG.stops]; while (rawStops.length < 2) { @@ -185,7 +191,10 @@ export function normalizeThemeConfig( applyToPanels: rawGrad?.applyToPanels ?? true, }, custom: { - bgDeep: normalizeStoredHex(rawCustom?.bgDeep, DEFAULT_CUSTOM_TOKENS.bgDeep), + bgDeep: normalizeStoredHex( + rawCustom?.bgDeep, + DEFAULT_CUSTOM_TOKENS.bgDeep, + ), bgPanelSolid: normalizeStoredHex( rawCustom?.bgPanelSolid, DEFAULT_CUSTOM_TOKENS.bgPanelSolid, @@ -194,18 +203,27 @@ export function normalizeThemeConfig( rawCustom?.bgElevated, DEFAULT_CUSTOM_TOKENS.bgElevated, ), - border: normalizeStoredHex(rawCustom?.border, DEFAULT_CUSTOM_TOKENS.border), + border: normalizeStoredHex( + rawCustom?.border, + DEFAULT_CUSTOM_TOKENS.border, + ), text: normalizeStoredHex(rawCustom?.text, DEFAULT_CUSTOM_TOKENS.text), textDim: normalizeStoredHex( rawCustom?.textDim, DEFAULT_CUSTOM_TOKENS.textDim, ), - accent: normalizeStoredHex(rawCustom?.accent, DEFAULT_CUSTOM_TOKENS.accent), + accent: normalizeStoredHex( + rawCustom?.accent, + DEFAULT_CUSTOM_TOKENS.accent, + ), glow: normalizeStoredHex(rawCustom?.glow, DEFAULT_CUSTOM_TOKENS.glow), green: normalizeStoredHex(rawCustom?.green, DEFAULT_CUSTOM_TOKENS.green), amber: normalizeStoredHex(rawCustom?.amber, DEFAULT_CUSTOM_TOKENS.amber), red: normalizeStoredHex(rawCustom?.red, DEFAULT_CUSTOM_TOKENS.red), - violet: normalizeStoredHex(rawCustom?.violet, DEFAULT_CUSTOM_TOKENS.violet), + violet: normalizeStoredHex( + rawCustom?.violet, + DEFAULT_CUSTOM_TOKENS.violet, + ), panelOpacity: Number.isFinite(opacityNum) ? Math.max(0.65, Math.min(1, opacityNum)) : DEFAULT_CUSTOM_TOKENS.panelOpacity, @@ -245,7 +263,9 @@ export function getSettings(): ClientSettings { ) as LegacyClientSettings; cachedSettings = { quality: - raw.quality === "low" || raw.quality === "medium" ? raw.quality : "high", + raw.quality === "low" || raw.quality === "medium" + ? raw.quality + : "high", sound: raw.sound ?? true, notifications: raw.notifications ?? true, theme: normalizeThemeConfig(raw.theme, raw), diff --git a/src/client/app.ts b/src/client/app.ts index 00769b3..65c4b4f 100644 --- a/src/client/app.ts +++ b/src/client/app.ts @@ -16,11 +16,7 @@ import { type WikiScreenParams, } from "./state.js"; import { applyVisualPreferences } from "./theme.js"; -import { - initNotificationDrawer, - initTooltipController, - toast, -} from "./ui.js"; +import { initNotificationDrawer, initTooltipController, toast } from "./ui.js"; import { renderAuth } from "./screens/auth.js"; import { renderContracts } from "./screens/contracts.js"; import { renderDashboard } from "./screens/dashboard.js"; diff --git a/src/client/theme.ts b/src/client/theme.ts index 4e86437..20dcaea 100644 --- a/src/client/theme.ts +++ b/src/client/theme.ts @@ -309,11 +309,7 @@ export function mixHex(hexA: string, hexB: string, weightB: number): string { const w = Math.max(0, Math.min(1, weightB)); const [r1, g1, b1] = hexToRgb(hexA); const [r2, g2, b2] = hexToRgb(hexB); - return rgbToHex( - r1 + (r2 - r1) * w, - g1 + (g2 - g1) * w, - b1 + (b2 - b1) * w, - ); + return rgbToHex(r1 + (r2 - r1) * w, g1 + (g2 - g1) * w, b1 + (b2 - b1) * w); } export function isLightHex(hex: string): boolean { @@ -398,7 +394,11 @@ function applyDerivedTokens( const bgHover = mixHex(tokens.bgElevated, tokens.text, light ? 0.1 : 0.08); const borderBright = mixHex(tokens.border, tokens.text, 0.18); const textFaint = mixHex(tokens.textDim, tokens.bgDeep, 0.35); - const brandStrong = mixHex(tokens.accent, light ? "#000000" : "#0b0e14", 0.22); + const brandStrong = mixHex( + tokens.accent, + light ? "#000000" : "#0b0e14", + 0.22, + ); set("--bg-deep", tokens.bgDeep); set("--bg-panel", hexToRgba(tokens.bgPanelSolid, tokens.panelOpacity)); @@ -423,11 +423,23 @@ function applyDerivedTokens( set("--amber", tokens.amber); set("--red", tokens.red); set("--violet", tokens.violet); - set("--bg-glass", hexToRgba(tokens.bgPanelSolid, Math.min(0.95, tokens.panelOpacity))); + set( + "--bg-glass", + hexToRgba(tokens.bgPanelSolid, Math.min(0.95, tokens.panelOpacity)), + ); set("--bg-inset", hexToRgba(tokens.bgDeep, light ? 0.72 : 0.6)); - set("--bg-header-fade", light ? "transparent" : hexToRgba(tokens.bgDeep, 0.92)); - set("--overlay-scrim", light ? "rgba(15, 23, 42, 0.42)" : "rgba(7, 10, 15, 0.84)"); - set("--badge-bg", light ? tokens.bgPanelSolid : hexToRgba(tokens.bgDeep, 0.72)); + set( + "--bg-header-fade", + light ? "transparent" : hexToRgba(tokens.bgDeep, 0.92), + ); + set( + "--overlay-scrim", + light ? "rgba(15, 23, 42, 0.42)" : "rgba(7, 10, 15, 0.84)", + ); + set( + "--badge-bg", + light ? tokens.bgPanelSolid : hexToRgba(tokens.bgDeep, 0.72), + ); const accentIsLight = isLightHex(tokens.accent); set( @@ -440,26 +452,34 @@ function applyDerivedTokens( ); set( "--btn-primary-text", - light ? (accentIsLight ? "#0f172a" : "#ffffff") : mixHex(tokens.accent, "#ffffff", 0.75), - ); - set( - "--btn-warn-bg", - hexToRgba(tokens.amber, 0.15), + light + ? accentIsLight + ? "#0f172a" + : "#ffffff" + : mixHex(tokens.accent, "#ffffff", 0.75), ); + set("--btn-warn-bg", hexToRgba(tokens.amber, 0.15)); set( "--btn-warn-text", - light ? mixHex(tokens.amber, "#000000", 0.35) : mixHex(tokens.amber, "#ffffff", 0.65), + light + ? mixHex(tokens.amber, "#000000", 0.35) + : mixHex(tokens.amber, "#ffffff", 0.65), ); set("--btn-danger-bg", hexToRgba(tokens.red, 0.13)); set( "--btn-danger-text", - light ? mixHex(tokens.red, "#000000", 0.35) : mixHex(tokens.red, "#ffffff", 0.65), + light + ? mixHex(tokens.red, "#000000", 0.35) + : mixHex(tokens.red, "#ffffff", 0.65), ); set( "--btn-ghost-bg", light ? tokens.bgPanelSolid : hexToRgba(tokens.bgPanelSolid, 0.68), ); - set("--title-color", light ? tokens.text : mixHex(tokens.text, "#ffffff", 0.55)); + set( + "--title-color", + light ? tokens.text : mixHex(tokens.text, "#ffffff", 0.55), + ); set("--bg-gradient", extras.bgGradient ?? "none"); set("--panel-gradient", extras.panelGradient ?? "none"); } @@ -475,7 +495,9 @@ function buildGradientTokens(theme: ThemeConfig): { const sLast = normalizeHex(g.stops[g.stops.length - 1] ?? s1, s1); const light = g.surfaceBase === "light"; - const bgDeep = light ? mixHex("#f1f5f9", s0, 0.16) : mixHex("#0b0e14", s0, 0.45); + const bgDeep = light + ? mixHex("#f1f5f9", s0, 0.16) + : mixHex("#0b0e14", s0, 0.45); const bgPanelSolid = light ? mixHex("#ffffff", s0, 0.08) : mixHex("#111622", s0, 0.42); @@ -489,8 +511,12 @@ function buildGradientTokens(theme: ThemeConfig): { // Choose an accent that stays legible against the surface base const rawAccent = isLightHex(s1) === light ? sLast : s1; const accent = light - ? (isLightHex(rawAccent) ? "#0284c7" : rawAccent) - : (isLightHex(rawAccent) ? rawAccent : mixHex(rawAccent, "#60a5fa", 0.62)); + ? isLightHex(rawAccent) + ? "#0284c7" + : rawAccent + : isLightHex(rawAccent) + ? rawAccent + : mixHex(rawAccent, "#60a5fa", 0.62); const tokens: CustomThemeTokens = { bgDeep, @@ -622,10 +648,7 @@ export function getThemePalette(): ResolvedThemePalette { "--bg-panel-solid", isLight ? "#ffffff" : "#12161f", ); - const bgElevated = readVar( - "--bg-elevated", - isLight ? "#e2e8f0" : "#19202e", - ); + const bgElevated = readVar("--bg-elevated", isLight ? "#e2e8f0" : "#19202e"); const border = readVar("--border", isLight ? "#cbd5e1" : "#2a3449"); const text = readVar("--text", isLight ? "#0f172a" : "#e2e8f0"); const textDim = readVar("--text-dim", isLight ? "#475569" : "#94a3b8"); diff --git a/src/client/ui/themeModal.ts b/src/client/ui/themeModal.ts index 325ff3f..d519afc 100644 --- a/src/client/ui/themeModal.ts +++ b/src/client/ui/themeModal.ts @@ -91,7 +91,10 @@ function createPreviewCard(draft: ThemeConfig): HTMLElement { { class: "spread" }, h( "span", - { class: "mono accent", style: { fontSize: "11px", fontWeight: "700" } }, + { + class: "mono accent", + style: { fontSize: "11px", fontWeight: "700" }, + }, "LIVE TELEMETRY PREVIEW", ), h("span", { class: "badge info" }, `${shapeLabel} ยท ${colorLabel}`), @@ -315,7 +318,11 @@ export function openThemeSettingsModal(): void { h( "div", { class: "row", style: { gap: "6px" } }, - h("span", { class: "mono dim", style: { fontSize: "10px" } }, "Starters:"), + h( + "span", + { class: "mono dim", style: { fontSize: "10px" } }, + "Starters:", + ), ...GRADIENT_STARTERS.map((starter) => h( "button", @@ -438,7 +445,10 @@ export function openThemeSettingsModal(): void { ]; const seedSelect = h( "select", - { class: "input", style: { width: "auto", padding: "4px 8px", fontSize: "11px" } }, + { + class: "input", + style: { width: "auto", padding: "4px 8px", fontSize: "11px" }, + }, ...seedOptions.map((o) => h("option", { value: o.id }, o.label)), ) as HTMLSelectElement; @@ -658,21 +668,13 @@ export function openThemeSettingsModal(): void { "label", { class: "row", style: { cursor: "pointer", fontSize: "12px" } }, uiFxChk, - h( - "span", - {}, - "UI Glows, Backdrop Blur, Shadows & Background Grid", - ), + h("span", {}, "UI Glows, Backdrop Blur, Shadows & Background Grid"), ), h( "label", { class: "row", style: { cursor: "pointer", fontSize: "12px" } }, motionFxChk, - h( - "span", - {}, - "Animations, 3D Bloom, Camera Shake & Plume Shimmer", - ), + h("span", {}, "Animations, 3D Bloom, Camera Shake & Plume Shimmer"), ), h( "label", diff --git a/src/client/wiki/wikiModal.ts b/src/client/wiki/wikiModal.ts index 3ea77e6..2916c1c 100644 --- a/src/client/wiki/wikiModal.ts +++ b/src/client/wiki/wikiModal.ts @@ -12,11 +12,13 @@ export function closeWikiDrawer(): void { activeCleanup = null; } -export function openWikiDrawer(opts: { - articleId?: WikiArticleId; - glossaryKey?: GlossaryKey | string; - query?: string; -} = {}): void { +export function openWikiDrawer( + opts: { + articleId?: WikiArticleId; + glossaryKey?: GlossaryKey | string; + query?: string; + } = {}, +): void { closeWikiDrawer(); const modalRoot = document.getElementById("modal-root") ?? document.body; const overlay = h("div", { class: "modal-overlay wiki-drawer-overlay" }); diff --git a/src/client/wiki/wikiWorkspace.ts b/src/client/wiki/wikiWorkspace.ts index 68f1d09..be56ee8 100644 --- a/src/client/wiki/wikiWorkspace.ts +++ b/src/client/wiki/wikiWorkspace.ts @@ -90,8 +90,7 @@ export function renderWikiWorkspace( const needle = q.trim().toLowerCase(); if (!needle) return []; const hits: SearchHit[] = []; - const clip = (s: string) => - s.length > 88 ? `${s.slice(0, 88)}...` : s; + const clip = (s: string) => (s.length > 88 ? `${s.slice(0, 88)}...` : s); for (const art of WIKI_ARTICLES) { const hay =