Skip to content

Commit 5023924

Browse files
committed
fix(theme): replace remaining hardcoded hex colors in primitives and fix failing tests
- CortexHeaderItem: #1C1C1D → var(--cortex-bg-secondary) - CortexDropdown: #1C1C1D/#2E2F31 → var(--cortex-bg-secondary)/var(--cortex-border-default) - CortexSeparator: #2E2F31 → var(--cortex-border-default) - CortexSmallButton: remove fallback #141415 - CortexOpenProjectDropdown: remove fallback #1C1C1D - CortexHeaderItem.test.tsx: update assertions to expect CSS variables - CortexSeparator.test.tsx: update assertion to expect CSS variable - cov-CortexDiffEditor.test.tsx: add missing getProjectPath mock
1 parent 39c8349 commit 5023924

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

src/components/cortex/editor/__tests__/cov-CortexDiffEditor.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { describe, it, expect, vi } from "vitest";
22
import { render } from "@solidjs/testing-library";
33

44
vi.mock("@/utils/tauri-api", () => ({ invoke: vi.fn().mockResolvedValue(undefined), listen: vi.fn().mockResolvedValue(vi.fn()), emit: vi.fn(), tauriInvoke: vi.fn().mockResolvedValue(undefined) }));
5-
vi.mock("@/utils/workspace", () => ({ getWorkspacePath: vi.fn(() => "/test"), isWorkspaceOpen: vi.fn(() => true), getRelativePath: vi.fn((p: string) => p), joinPath: vi.fn((...args: string[]) => args.join("/")), normalizePath: vi.fn((p: string) => p) }));
5+
vi.mock("@/utils/workspace", () => ({ getWorkspacePath: vi.fn(() => "/test"), isWorkspaceOpen: vi.fn(() => true), getRelativePath: vi.fn((p: string) => p), joinPath: vi.fn((...args: string[]) => args.join("/")), normalizePath: vi.fn((p: string) => p), getProjectPath: vi.fn(() => "/test"), setProjectPath: vi.fn(), clearProjectPath: vi.fn() }));
66
vi.mock("@/utils/logger", () => ({ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn(), trace: vi.fn() }, createLogger: vi.fn(() => ({ info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn(), trace: vi.fn() })), default: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn(), trace: vi.fn() } }));
77

88
import { CortexDiffEditor } from "../../../cortex/editor/CortexDiffEditor";

src/components/cortex/primitives/CortexDropdown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ export const CortexDropdown: Component<CortexDropdownProps> = (props) => {
267267
bottom: pos.showAbove ? `${window.innerHeight - pos.y + 4}px` : undefined,
268268
width: `${pos.width}px`,
269269
"min-width": "160px",
270-
background: "#1C1C1D",
271-
border: "1px solid #2E2F31",
270+
background: "var(--cortex-bg-secondary)",
271+
border: "1px solid var(--cortex-border-default)",
272272
padding: "4px",
273273
"box-shadow": "0 8px 16px rgba(0,0,0,0.3), 0 4px 8px rgba(0,0,0,0.4)",
274274
"z-index": "var(--cortex-z-dropdown, 600)",

src/components/cortex/primitives/CortexOpenProjectDropdown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const CortexOpenProjectDropdown: Component<CortexOpenProjectDropdownProps
4949
"font-size": "16px",
5050
"font-weight": "400",
5151
"line-height": "1em",
52-
color: local.isOpen ? "var(--cortex-open-project-open-text, #1C1C1D)" : "var(--cortex-text-secondary)",
52+
color: local.isOpen ? "var(--cortex-open-project-open-text)" : "var(--cortex-text-secondary)",
5353
"white-space": "nowrap",
5454
"user-select": "none",
5555
});
@@ -81,7 +81,7 @@ export const CortexOpenProjectDropdown: Component<CortexOpenProjectDropdownProps
8181
<CortexIcon
8282
name={local.isOpen ? "chevron-up" : "chevron-down"}
8383
size={16}
84-
color={local.isOpen ? "var(--cortex-open-project-open-text, #1C1C1D)" : "var(--cortex-text-primary)"}
84+
color={local.isOpen ? "var(--cortex-open-project-open-text)" : "var(--cortex-text-primary)"}
8585
/>
8686
</button>
8787
<Show when={local.isOpen && local.children}>

src/components/cortex/primitives/CortexSmallButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const CortexSmallButton: Component<CortexSmallButtonProps> = (props) => {
2929
const [active, setActive] = createSignal(false);
3030

3131
const getBackground = (): string => {
32-
if (active() && !local.disabled) return "var(--cortex-bg-primary, #141415)";
32+
if (active() && !local.disabled) return "var(--cortex-bg-primary)";
3333
if (hovered() && !local.disabled) return "var(--cortex-bg-hover, #252628)";
3434
return "var(--cortex-small-btn-bg, #1A1B1F)";
3535
};

src/components/cortex/primitives/__tests__/CortexHeaderItem.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe("CortexHeaderItem", () => {
6666
<CortexHeaderItem label="File" isActive={true} />
6767
));
6868
const button = getByRole("button") as HTMLElement;
69-
expect(button.style.background).toBe("rgb(28, 28, 29)");
69+
expect(button.style.background).toBe("var(--cortex-bg-secondary)");
7070
});
7171

7272
it("has primary text color when active", () => {
@@ -127,7 +127,7 @@ describe("CortexHeaderItem", () => {
127127
const button = getByRole("button") as HTMLElement;
128128
const mouseEnterEvent = new MouseEvent("mouseenter", { bubbles: true });
129129
button.dispatchEvent(mouseEnterEvent);
130-
expect(button.style.background).toBe("rgb(28, 28, 29)");
130+
expect(button.style.background).toBe("var(--cortex-bg-secondary)");
131131
});
132132

133133
it("applies primary text color on hover", () => {

src/components/cortex/primitives/__tests__/CortexSeparator.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ describe("CortexSeparator", () => {
7575
const { getByRole } = render(() => <CortexSeparator />);
7676
const separator = getByRole("separator");
7777
const line = separator.querySelector("div") as HTMLElement;
78-
expect(line.style.borderBottom).toBe("1px solid rgb(46, 47, 49)");
78+
expect(line.style.borderBottom).toBe("1px solid var(--cortex-border-default)");
7979
});
8080
});
8181

0 commit comments

Comments
 (0)