ui: fix review follow-ups for dashboard tabs
This commit is contained in:
parent
37a914bb88
commit
20100a0982
@ -36,7 +36,7 @@ import {
|
|||||||
} from "./navigation.ts";
|
} from "./navigation.ts";
|
||||||
import { saveSettings, type UiSettings } from "./storage.ts";
|
import { saveSettings, type UiSettings } from "./storage.ts";
|
||||||
import { startThemeTransition, type ThemeTransitionContext } from "./theme-transition.ts";
|
import { startThemeTransition, type ThemeTransitionContext } from "./theme-transition.ts";
|
||||||
import { resolveTheme, type ResolvedTheme, type ThemeMode } from "./theme.ts";
|
import { colorSchemeForTheme, resolveTheme, type ResolvedTheme, type ThemeMode } from "./theme.ts";
|
||||||
import type { AgentsListResult } from "./types.ts";
|
import type { AgentsListResult } from "./types.ts";
|
||||||
|
|
||||||
type SettingsHost = {
|
type SettingsHost = {
|
||||||
@ -273,7 +273,7 @@ export function applyResolvedTheme(host: SettingsHost, resolved: ResolvedTheme)
|
|||||||
}
|
}
|
||||||
const root = document.documentElement;
|
const root = document.documentElement;
|
||||||
root.dataset.theme = resolved;
|
root.dataset.theme = resolved;
|
||||||
root.style.colorScheme = resolved;
|
root.style.colorScheme = colorSchemeForTheme(resolved);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function attachThemeListener(host: SettingsHost) {
|
export function attachThemeListener(host: SettingsHost) {
|
||||||
|
|||||||
9
ui/src/ui/navigation-groups.test.ts
Normal file
9
ui/src/ui/navigation-groups.test.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { TAB_GROUPS } from "./navigation.ts";
|
||||||
|
|
||||||
|
describe("TAB_GROUPS", () => {
|
||||||
|
it("does not expose unfinished settings slices in the sidebar", () => {
|
||||||
|
const settings = TAB_GROUPS.find((group) => group.label === "settings");
|
||||||
|
expect(settings?.tabs).toEqual(["config", "debug", "logs"]);
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -10,16 +10,7 @@ export const TAB_GROUPS = [
|
|||||||
{ label: "agent", tabs: ["agents", "skills", "nodes"] },
|
{ label: "agent", tabs: ["agents", "skills", "nodes"] },
|
||||||
{
|
{
|
||||||
label: "settings",
|
label: "settings",
|
||||||
tabs: [
|
tabs: ["config", "debug", "logs"],
|
||||||
"config",
|
|
||||||
"communications",
|
|
||||||
"appearance",
|
|
||||||
"automation",
|
|
||||||
"infrastructure",
|
|
||||||
"aiAgents",
|
|
||||||
"debug",
|
|
||||||
"logs",
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it, vi } from "vitest";
|
||||||
import { parseThemeSelection, resolveTheme } from "./theme.ts";
|
import { colorSchemeForTheme, parseThemeSelection, resolveTheme } from "./theme.ts";
|
||||||
|
|
||||||
describe("resolveTheme", () => {
|
describe("resolveTheme", () => {
|
||||||
it("keeps the legacy mode-only signature working for existing callers", () => {
|
it("keeps the legacy mode-only signature working for existing callers", () => {
|
||||||
@ -17,6 +17,11 @@ describe("resolveTheme", () => {
|
|||||||
expect(resolveTheme("knot")).toBe("openknot-light");
|
expect(resolveTheme("knot")).toBe("openknot-light");
|
||||||
vi.unstubAllGlobals();
|
vi.unstubAllGlobals();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("maps resolved theme families back to valid CSS color-scheme values", () => {
|
||||||
|
expect(colorSchemeForTheme("openknot")).toBe("dark");
|
||||||
|
expect(colorSchemeForTheme("dash-light")).toBe("light");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("parseThemeSelection", () => {
|
describe("parseThemeSelection", () => {
|
||||||
|
|||||||
@ -91,3 +91,9 @@ export function resolveTheme(themeOrMode: ThemeName | ThemeMode, mode?: ThemeMod
|
|||||||
}
|
}
|
||||||
return resolvedMode === "light" ? "dash-light" : "dash";
|
return resolvedMode === "light" ? "dash-light" : "dash";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function colorSchemeForTheme(theme: ResolvedTheme): "light" | "dark" {
|
||||||
|
return theme === "light" || theme === "openknot-light" || theme === "dash-light"
|
||||||
|
? "light"
|
||||||
|
: "dark";
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user