From 484bbfc7043e33dd224adda9a6ed826e86e0d889 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Mon, 16 Nov 2026 11:16:55 +0800 Subject: [PATCH] fix(ui): paint tree row tints as full-width bands (#3652) File colours, excluded folders and data source colours were painted as the row's own background: inset from the tree's edges, rounded per row, or dropped under hover and selection, so a run of tinted rows read as a ragged stack. The tint is now a full-width band under the row; hover and selection stay rounded on top. Excluded folders and data source colours share the rowTint path. Fixes #3616 --- src/features/database/Database.module.css | 25 ++----------------- src/features/database/DatabaseView.test.tsx | 10 ++++---- src/features/database/DatabaseView.tsx | 15 +++-------- .../project-tree/ProjectView.module.css | 3 --- src/features/project-tree/ProjectView.tsx | 9 +++---- src/ui/Tree.module.css | 21 ++++++++-------- 6 files changed, 25 insertions(+), 58 deletions(-) diff --git a/src/features/database/Database.module.css b/src/features/database/Database.module.css index 3705c454e..1fd9c9179 100644 --- a/src/features/database/Database.module.css +++ b/src/features/database/Database.module.css @@ -251,6 +251,8 @@ min-height: 0; display: flex; flex-direction: column; + /* Data source colours are stronger than file colours. */ + --row-tint-strength: var(--tint-strength); } .treeHost > * { flex: 1; @@ -262,29 +264,6 @@ gap: var(--space-1-5); min-width: 0; } -/* The whole tree row, indent included, so a coloured source and its children form one band. */ -.tintedRow:not([aria-selected="true"]):not(:hover) { - border-radius: 0; - background: color-mix(in srgb, var(--db-tint) var(--tint-strength), transparent); -} -.tintRed { - --db-tint: var(--db-color-red); -} -.tintOrange { - --db-tint: var(--db-color-orange); -} -.tintYellow { - --db-tint: var(--db-color-yellow); -} -.tintGreen { - --db-tint: var(--db-color-green); -} -.tintBlue { - --db-tint: var(--db-color-blue); -} -.tintViolet { - --db-tint: var(--db-color-violet); -} .nodeLabel { overflow: hidden; text-overflow: ellipsis; diff --git a/src/features/database/DatabaseView.test.tsx b/src/features/database/DatabaseView.test.tsx index 768978c40..ff04eceb2 100644 --- a/src/features/database/DatabaseView.test.tsx +++ b/src/features/database/DatabaseView.test.tsx @@ -8,7 +8,6 @@ import { tablesKey, useDatabase } from "./store"; import { tableInput } from "./tableInput"; import { useEditorRegistry } from "@/editor/api"; import { provideEditorService, provideToolWindowService, type EditorInput } from "@/workbench/contributions"; -import styles from "./Database.module.css"; vi.mock("@tanstack/react-virtual", () => ({ useVirtualizer: ({ count }: { count: number }) => ({ @@ -195,9 +194,10 @@ describe("data source colour", () => { }); render(); const tree = within(screen.getByRole("tree", { name: "Data sources" })); - for (const name of ["PostgreSQL", "public", "routines", "refresh_data"]) { - expect(tree.getByText(name).closest('[role="treeitem"]')).toHaveClass(styles.tintedRow!, styles.tintRed!); - } - expect(tree.getByText("SQLite").closest('[role="treeitem"]')).not.toHaveClass(styles.tintedRow!); + const tint = (name: string) => + tree.getByText(name).closest('[role="treeitem"]')!.style.getPropertyValue("--row-tint"); + for (const name of ["PostgreSQL", "public", "routines", "refresh_data"]) + expect(tint(name)).toBe("var(--db-color-red)"); + expect(tint("SQLite")).toBe(""); }); }); diff --git a/src/features/database/DatabaseView.tsx b/src/features/database/DatabaseView.tsx index 1c585cde4..1a4323689 100644 --- a/src/features/database/DatabaseView.tsx +++ b/src/features/database/DatabaseView.tsx @@ -6,7 +6,7 @@ * source to open its query console. */ import { useEffect, useMemo, useRef } from "react"; -import type { DbColor, DbDatabases, DbTableDetails } from "@/platform/ipc"; +import type { DbDatabases, DbTableDetails } from "@/platform/ipc"; import { executeAction } from "@/platform/actions"; import { shortcutLabel } from "@/platform/keymap"; import { @@ -55,15 +55,6 @@ import styles from "./Database.module.css"; import { tx } from "@/platform/i18n"; import { databaseRequest } from "./requests"; -const ROW_TINTS: Record = { - red: styles.tintRed, - orange: styles.tintOrange, - yellow: styles.tintYellow, - green: styles.tintGreen, - blue: styles.tintBlue, - violet: styles.tintViolet, -}; - const GROUP_LABELS: Record = { columns: "columns", keys: "keys", @@ -525,11 +516,11 @@ export function DatabaseView() { getIcon={(n) => icon(n)} getDetail={detail} getColor={(n) => (n.kind === "message" && n.error ? "var(--danger)" : undefined)} - rowClassName={(n) => { + rowTint={(n) => { // IDEA tints every row of a coloured data source across its full width and height. const target = nodeTarget(n); const color = target ? sourceOf(target)?.color : null; - return color ? `${styles.tintedRow} ${ROW_TINTS[color]}` : undefined; + return color ? `var(--db-color-${color})` : undefined; }} speedSearchField renderNode={(n: Node, state) => { diff --git a/src/features/project-tree/ProjectView.module.css b/src/features/project-tree/ProjectView.module.css index 589e73c99..d9a9b1f7d 100644 --- a/src/features/project-tree/ProjectView.module.css +++ b/src/features/project-tree/ProjectView.module.css @@ -56,9 +56,6 @@ .excluded { color: var(--vcs-ignored); } -.excludedRow { - background: color-mix(in srgb, var(--vcs-ignored) 14%, transparent); -} .error { text-decoration-line: underline; text-decoration-style: wavy; diff --git a/src/features/project-tree/ProjectView.tsx b/src/features/project-tree/ProjectView.tsx index 072251fd1..4a034af3d 100644 --- a/src/features/project-tree/ProjectView.tsx +++ b/src/features/project-tree/ProjectView.tsx @@ -436,6 +436,8 @@ interface DragState { } const DRAG_THRESHOLD = 4; +/** IDEA's "excluded" look: excluded folders and what is under them get a muted band. */ +const EXCLUDED_TINT = "var(--vcs-ignored)"; /** Folder under a viewport point inside `container` (a file row resolves to its folder). */ function folderAt(container: HTMLElement | null, x: number, y: number): { key: string; path: string } | null { @@ -873,11 +875,8 @@ export function ProjectView() { isExpandable={isExpandable} loadChildren={loadChildren} renderNode={renderNode} - rowClassName={(n) => (n.excluded ? styles.excludedRow : undefined)} - rowTint={ - fileColors - ? (n) => (n.excluded || n.group || n.placeholder ? undefined : fileColors(n.path, n.dir)) - : undefined + rowTint={(n) => + n.excluded ? EXCLUDED_TINT : n.group || n.placeholder ? undefined : fileColors?.(n.path, n.dir) } expanded={expanded} onExpandedChange={onExpandedChange} diff --git a/src/ui/Tree.module.css b/src/ui/Tree.module.css index df7acd17d..d6da1156b 100644 --- a/src/ui/Tree.module.css +++ b/src/ui/Tree.module.css @@ -39,6 +39,8 @@ .sizer { position: relative; width: 100%; + /* Keeps the tint bands of rows above the tree's background. */ + isolation: isolate; } .row { position: absolute; @@ -68,16 +70,15 @@ .row:hover { background: var(--bg-tree-hover, color-mix(in srgb, var(--fg-strong) 4%, transparent)); } -/* File Colors: the row's background takes its scope's colour. */ -.tinted { - background: color-mix(in srgb, var(--row-tint) var(--file-tint-strength, 14%), transparent); -} -.tinted:hover { - background: color-mix( - in srgb, - var(--row-tint) var(--file-tint-strength, 14%), - var(--bg-tree-hover, color-mix(in srgb, var(--fg-strong) 4%, transparent)) - ); +/* File Colors: a full-width band under the row, so runs of tinted rows read as one block; + hover and selection stay rounded on top of it. */ +.tinted::before { + content: ""; + position: absolute; + inset: 0 calc(-1 * var(--tree-inset, 6px)); + z-index: -1; + background: color-mix(in srgb, var(--row-tint) var(--row-tint-strength, var(--file-tint-strength, 14%)), transparent); + pointer-events: none; } /* Tree.selectionInactiveBackground when unfocused, selectionBackground when focused. */ .selected,