From 08617f87c02158da3b82569991245efc2cc20842 Mon Sep 17 00:00:00 2001 From: ngqile Date: Tue, 1 Dec 2026 22:49:09 +0800 Subject: [PATCH] feat: stronger scroll cue on wide tables Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM --- .../components/ui/table.scrollcue.test.tsx | 32 +++++++++++++++++++ solvway-admin-portal/app/globals.css | 12 ++++--- 2 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 solvway-admin-portal/app/components/ui/table.scrollcue.test.tsx diff --git a/solvway-admin-portal/app/components/ui/table.scrollcue.test.tsx b/solvway-admin-portal/app/components/ui/table.scrollcue.test.tsx new file mode 100644 index 0000000..63508e8 --- /dev/null +++ b/solvway-admin-portal/app/components/ui/table.scrollcue.test.tsx @@ -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)); + }); +}); diff --git a/solvway-admin-portal/app/globals.css b/solvway-admin-portal/app/globals.css index d15d87a..5edc5b3 100644 --- a/solvway-admin-portal/app/globals.css +++ b/solvway-admin-portal/app/globals.css @@ -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; } /*