Skip to content

feat(web): support a dark scheme and capture light and dark Gate 3 pairs - #8

Merged
TN019 merged 9 commits into
mainfrom
feat/dark-scheme-and-gate3-pairs
Dec 1, 2026
Merged

TN019 merged 9 commits into
mainfrom
feat/dark-scheme-and-gate3-pairs

Conversation

@TN019

@TN019 TN019 commented Dec 1, 2026

Copy link
Copy Markdown

Why

Operators use the page in both light and dark system themes, so the page needs a dark scheme that still passes accessibility checks, and the documentation screenshots need a matching pair for each scene.

What changed

  • web/src/style.css: move every colour into variables on :root, set color-scheme: light dark, and override them under prefers-color-scheme: dark. A later commit also moves the green, red and network light colours into --green-light, --red-light and --net-light; they are the same in both schemes.
  • web/src/main.tsx: the turnstile arm is aria-hidden and the Locked/Walk through text sits in its own turnstile-label strip, so it stays readable over the arm. A disabled turnstile keeps full opacity.
  • e2e/entrance.spec.ts runs the scan-and-axe check once for light and once for dark. playwright.config.ts sets deviceScaleFactor: 2.
  • e2e/screenshot-pair.ts: screenshotPair(page, name) scrolls to the top and writes <name>.png and <name>.dark.png with animations disabled. real-gate3-stopped.spec.ts uses it.
  • scripts/screenshots.sh: given GATEPOST_DIR, GATE3_WORKING_REF and GATE3_CRASH_REF, it prints both revisions, builds the crash revision in a temporary worktree, starts the entrance with --gate3-crash, runs the Gate 3 spec, shuts everything down, and fails if any gatepost-sim-devices container remains. A trap cleans up on failure.
  • Replace docs/screenshots/gate3-stopped.png with the 2× light capture, add gate3-stopped.dark.png, and document the pairs and the script in both READMEs and both screenshot READMEs.

How to verify

pnpm test
pnpm build
PORT=28080 DEVICE_PORT=7600 node bridge/dist/server.js &
node scripts/fake-gates.mjs &
pnpm test:e2e

Both fake gates scan and meet axe checks in light and ... in dark should run. To retake the pair, with Docker and a Gatepost checkout:

GATEPOST_DIR=../gatepost GATE3_WORKING_REF=<fixed-rev> GATE3_CRASH_REF=<crash-rev> scripts/screenshots.sh

背景

运维人员的系统主题有浅色也有深色,所以页面需要一套同样能通过无障碍检查的深色配色;文档截图也要为每个场景各准备一对浅色和深色图。

改动

  • web/src/style.css:所有颜色都改为 :root 上的变量,设置 color-scheme: light dark,并在 prefers-color-scheme: dark 下覆盖这些变量。随后的一个提交又把绿灯、红灯和网络灯的颜色移到 --green-light、--red-light 和 --net-light,这三个颜色在两种主题下相同。
  • web/src/main.tsx:转闸横杆设为 aria-hidden,Locked/Walk through 文字放进单独的 turnstile-label 条,不会被横杆挡住;禁用状态的转闸保持不透明。
  • e2e/entrance.spec.ts 分别以 light 和 dark 各跑一次扫码加 axe 检查。playwright.config.ts 设置 deviceScaleFactor: 2。
  • e2e/screenshot-pair.ts:screenshotPair(page, name) 先滚动到顶部,再在关闭动画的情况下写出 <name>.png 和 <name>.dark.png。real-gate3-stopped.spec.ts 改用它截图。
  • scripts/screenshots.sh:给定 GATEPOST_DIR、GATE3_WORKING_REF 和 GATE3_CRASH_REF 后,先打印两个版本,在临时 worktree 中构建崩溃版本,以 --gate3-crash 启动入口,运行 Gate 3 用例,然后全部关闭;如果还有 gatepost-sim-devices 的容器残留就报错。出错时由 trap 负责清理。
  • 用 2 倍缩放的浅色截图替换 docs/screenshots/gate3-stopped.png,新增 gate3-stopped.dark.png,并在两份 README 和两份截图说明中写明截图对和脚本用法。

怎么验证

pnpm test
pnpm build
PORT=28080 DEVICE_PORT=7600 node bridge/dist/server.js &
node scripts/fake-gates.mjs &
pnpm test:e2e

应同时运行 fake gates scan and meet axe checks in light 和 ... in dark 两个用例。要重拍这对截图,需要 Docker 和 Gatepost 检出:

GATEPOST_DIR=../gatepost GATE3_WORKING_REF=<fixed-rev> GATE3_CRASH_REF=<crash-rev> scripts/screenshots.sh

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Ingrid Larsen · reviewer

screenshots.sh creates worktrees and a Compose project. What is left behind if Playwright fails halfway?


screenshots.sh 会创建 worktree 和 Compose 项目。如果 Playwright 中途失败,会留下什么?

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Noah Williams · author

Nothing, as far as the script can tell: the EXIT trap runs scripts/venue.sh down while .venue-state exists and removes the crash worktree. On success the script also checks that no gatepost-sim-devices container remains.


就脚本所能判断的范围而言,什么都不会留下:只要 .venue-state 存在,EXIT trap 就会运行 scripts/venue.sh down,并删除崩溃版本的 worktree。成功结束时,脚本还会检查没有残留的 gatepost-sim-devices 容器。

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Ingrid Larsen · reviewer

Why make the light colours variables if dark mode doesn't override them?


既然深色模式并不覆盖指示灯颜色,为什么还要把它们改成变量?

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Mateo Rossi · author

So every colour in the stylesheet comes from the theme block. The bulbs look the same in both schemes today; if one needs to change, it is a single variable.


这样样式表里的每个颜色都来自主题定义。目前两种主题下灯的颜色一样,以后要改也只需改一个变量。

@TN019
TN019 merged commit 129473a into main Dec 1, 2026
1 check failed
@TN019
TN019 deleted the feat/dark-scheme-and-gate3-pairs branch December 1, 2026 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant