fix(ui): apply corner style to remaining controls
This commit is contained in:
80 files changed
+487
-305
No files matched your search
@@ -0,0 +1,15 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { normalizeAppCornerStyle } from "@/lib/app/appTheme";
|
||||
|
||||
describe("app corner style", () => {
|
||||
it.each([
|
||||
[null, "small"],
|
||||
["", "small"],
|
||||
["invalid", "small"],
|
||||
["none", "none"],
|
||||
["small", "small"],
|
||||
["large", "large"],
|
||||
])("normalizes %s to %s", (value, expected) => {
|
||||
expect(normalizeAppCornerStyle(value)).toBe(expected);
|
||||
});
|
||||
});
|
||||
+18
-5
@@ -9,17 +9,18 @@ if (!startupScript) throw new Error("Startup theme script not found");
|
||||
|
||||
type StartupThemeOptions = {
|
||||
mode?: string | null;
|
||||
cornerStyle?: string | null;
|
||||
prefersDark?: boolean;
|
||||
storageError?: boolean;
|
||||
};
|
||||
|
||||
function runStartupTheme({ mode = null, prefersDark = false, storageError = false }: StartupThemeOptions = {}) {
|
||||
function runStartupTheme({ mode = null, cornerStyle = null, prefersDark = false, storageError = false }: StartupThemeOptions = {}) {
|
||||
const toggle = vi.fn();
|
||||
const root = { classList: { toggle }, style: { colorScheme: "" } };
|
||||
const root = { classList: { toggle }, dataset: { cornerStyle: "" }, style: { colorScheme: "" } };
|
||||
const localStorage = {
|
||||
getItem: vi.fn(() => {
|
||||
getItem: vi.fn((key: string) => {
|
||||
if (storageError) throw new DOMException("Storage unavailable", "SecurityError");
|
||||
return mode;
|
||||
return key === "dbx-corner-style" ? cornerStyle : mode;
|
||||
}),
|
||||
};
|
||||
const matchMedia = vi.fn(() => ({ matches: prefersDark }));
|
||||
@@ -64,6 +65,18 @@ describe("startup theme", () => {
|
||||
expect(root.style.colorScheme).toBe("light");
|
||||
});
|
||||
|
||||
it.each([
|
||||
[null, "small"],
|
||||
["invalid", "small"],
|
||||
["none", "none"],
|
||||
["small", "small"],
|
||||
["large", "large"],
|
||||
])("normalizes the startup corner style %s to %s", (cornerStyle, expected) => {
|
||||
const { root } = runStartupTheme({ cornerStyle });
|
||||
|
||||
expect(root.dataset.cornerStyle).toBe(expected);
|
||||
});
|
||||
|
||||
it("falls back to light when localStorage is unavailable", () => {
|
||||
const { root, toggle } = runStartupTheme({ storageError: true, prefersDark: true });
|
||||
|
||||
@@ -80,7 +93,7 @@ describe("startup theme", () => {
|
||||
|
||||
it("falls back to light when system appearance detection is unavailable", () => {
|
||||
const toggle = vi.fn();
|
||||
const root = { classList: { toggle }, style: { colorScheme: "" } };
|
||||
const root = { classList: { toggle }, dataset: { cornerStyle: "" }, style: { colorScheme: "" } };
|
||||
|
||||
Function("document", "localStorage", "window", startupScript)({ documentElement: root }, { getItem: () => "system" }, {});
|
||||
|
||||
|
||||
+9
-1
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveEditorTheme } from "@/lib/editor/editorThemes";
|
||||
import { buildSqlCompletionThemeRules, resolveEditorTheme } from "@/lib/editor/editorThemes";
|
||||
import type { AppThemePalette } from "@/lib/app/appTheme";
|
||||
import type { EditorTheme } from "@/stores/settingsStore";
|
||||
|
||||
@@ -43,3 +43,11 @@ describe("resolveEditorTheme", () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("SQL completion theme", () => {
|
||||
it("uses the configurable large radius for the popup container", () => {
|
||||
const rules = buildSqlCompletionThemeRules();
|
||||
|
||||
expect(rules[".cm-tooltip.cm-tooltip-autocomplete"]).toMatchObject({ borderRadius: "var(--dbx-radius-lg)" });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user