feat: stronger scroll cue on wide tables

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-12-01 22:49:09 +08:00
1 parent 5ac248cee7
commit 08617f87c0
2 files changed
+39 -5

No files matched your search

@@ -0,0 +1,32 @@
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
// refine-visitor-pages-and-shell: wide tables show a visible fade on an edge that can still scroll.
// The old 10px shadow at 12% was too faint to notice at 360px.
describe("table scroll cue", () => {
const css = readFileSync(join(__dirname, "../../globals.css"), "utf8");
const rule = css.match(/\[data-slot="table-container"\]\s*\{([\s\S]*?)\n\}/)?.[1] ?? "";
it("uses local covers over scroll shadows", () => {
expect(rule.match(/ local/g)).toHaveLength(2);
expect(rule.match(/ scroll/g)).toHaveLength(2);
});
it("draws a shadow wide and strong enough to see, from theme tokens only", () => {
const shadow = [...rule.matchAll(/var\(--foreground\) (\d+)%[^/]*\/ (\d+)px/g)];
expect(shadow).toHaveLength(2);
for (const [, pct, px] of shadow) {
expect(Number(pct)).toBeGreaterThanOrEqual(18);
expect(Number(px)).toBeGreaterThanOrEqual(16);
}
expect(rule).not.toMatch(/#[0-9a-f]{3,8}\b|rgb\(|hsl\(/i);
});
it("makes each cover wider than its shadow, so the fade is gone at that end", () => {
const covers = [...rule.matchAll(/var\(--card\)[^/]*\/ (\d+)px/g)].map((m) => Number(m[1]));
const shadows = [...rule.matchAll(/var\(--foreground\)[^/]*\/ (\d+)px/g)].map((m) => Number(m[1]));
expect(covers).toHaveLength(2);
expect(Math.min(...covers)).toBeGreaterThan(Math.max(...shadows));
});
});
+7 -5
View File
@@ -248,13 +248,15 @@ h4 {
}
}
/* Scroll-edge cue: a soft shadow on a side only while more content is scrollable there. */
/* Scroll-edge cue: a shadow on a side only while more content is scrollable there. The covers
(local) scroll with the content and hide the shadows (scroll) at each end. Covers assume a card
backdrop; on the page ground they read as a faint lighter strip. */
[data-slot="table-container"] {
background:
linear-gradient(to right, var(--card) 30%, transparent) left center / 24px 100% no-repeat local,
linear-gradient(to left, var(--card) 30%, transparent) right center / 24px 100% no-repeat local,
linear-gradient(to right, color-mix(in srgb, var(--foreground) 12%, transparent), transparent) left center / 10px 100% no-repeat scroll,
linear-gradient(to left, color-mix(in srgb, var(--foreground) 12%, transparent), transparent) right center / 10px 100% no-repeat scroll;
linear-gradient(to right, var(--card) 40%, transparent) left center / 40px 100% no-repeat local,
linear-gradient(to left, var(--card) 40%, transparent) right center / 40px 100% no-repeat local,
linear-gradient(to right, color-mix(in srgb, var(--foreground) 18%, transparent), transparent) left center / 20px 100% no-repeat scroll,
linear-gradient(to left, color-mix(in srgb, var(--foreground) 18%, transparent), transparent) right center / 20px 100% no-repeat scroll;
}
/*