Sidebar polish round. Menus. `dropdown-menu` and `context-menu` were two copies of one engine that differed only in how the trigger fires — identical from `computePosition` down — and neither could nest. Both are now thin wrappers over `components/ui/menu/`, which owns anchoring, a pure page-stack navigation model, and one presentation fork: flyout on pointer, pushed pages in a sheet on compact. All 31 call sites are unchanged. Items got a rounded inset fill, a visible separator, and `selected` (a check) split from `active` (a fill). Sidebar display preferences. The flat wall of four sections becomes one row per decision with its value, and per-feature toggles over what a workspace row shows: host, pull request, checks, scripts. Each is independent — a ticked toggle that draws nothing is a lie. `display-preferences/` hides that grouping lives in zustand while title source and row items are app settings. Timestamps. "Last activity" now ticks itself. The label rounds to the minute and never shows seconds; past a week it becomes a date. The timer lives in the leaf `<Text>`, at most one per resolution tier shared by every row, and a tick only re-renders when the string actually changed — so a memoized row that legitimately never re-renders still stays current. Colour. Full status tier regenerated at 90% of gamut max (was 85), same rule as the muted tier, lightness and hue untouched. File icons are pulled toward neutral in OKLab behind `getFileIconSvg` — material-icon-theme picks its palette for a tree where the icon is the only colour on the row, and ours is not. New/deleted files use the forge square-plus/square-minus glyphs at muted weight instead of tinted pills. Project icons round a little more; uploaded icons never do. The project status badge is a knockout again: it fills with the colour of the row behind it, so the ring reads as a gap in the icon rather than a white halo. File rows. The always-visible kebab is gone from the file explorer and diff tree in favour of right-click, which also reclaims the reserved action slot.
47 lines
1.7 KiB
TypeScript
47 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { getFileIconSvg } from "./file-icon-svg";
|
|
import { getRawFileIconSvg } from "./material-file-icons";
|
|
|
|
function hexColors(svg: string): string[] {
|
|
return svg.match(/#[0-9a-fA-F]{6}/g) ?? [];
|
|
}
|
|
|
|
/** How far a colour is from grey, measured crudely enough not to re-derive the implementation. */
|
|
function channelSpread(hex: string): number {
|
|
const [r, g, b] = [1, 3, 5].map((index) => Number.parseInt(hex.slice(index, index + 2), 16));
|
|
return Math.max(r, g, b) - Math.min(r, g, b);
|
|
}
|
|
|
|
describe("getFileIconSvg", () => {
|
|
it("keeps the vendor geometry and only rewrites colours", () => {
|
|
const raw = getRawFileIconSvg("index.ts");
|
|
const toned = getFileIconSvg("index.ts");
|
|
expect(toned).not.toBe(raw);
|
|
expect(toned.replace(/#[0-9a-fA-F]{6}/g, "#")).toBe(raw.replace(/#[0-9a-fA-F]{6}/g, "#"));
|
|
});
|
|
|
|
it("pulls every colour toward neutral", () => {
|
|
const spread = (svg: string) => hexColors(svg).map(channelSpread);
|
|
|
|
for (const file of ["main.ts", "app.jsx", "style.css", "data.json", "notes.md"]) {
|
|
const before = spread(getRawFileIconSvg(file));
|
|
const after = spread(getFileIconSvg(file));
|
|
expect(after).toHaveLength(before.length);
|
|
after.forEach((value, index) => expect(value).toBeLessThan(before[index]));
|
|
}
|
|
});
|
|
|
|
it("leaves non-colour attributes alone", () => {
|
|
const toned = getFileIconSvg("Main.kt");
|
|
expect(toned).toContain('fill="url(#a)"');
|
|
});
|
|
|
|
it("returns the same string for repeated lookups", () => {
|
|
expect(getFileIconSvg("a.ts")).toBe(getFileIconSvg("b.ts"));
|
|
});
|
|
|
|
it("falls back to the default icon for unknown extensions", () => {
|
|
expect(getFileIconSvg("thing.qqq")).toBe(getFileIconSvg("thing"));
|
|
});
|
|
});
|