- Two half-width entry bars (76px, 72px stacked on phones): icon square, title, one ellipsized line, right-side button. 生成报告 is the pale accent (action-soft fill, action text, 600), 40px visual / 44px hit; 打开年运 is a bordered link. Phones show 生成 / 打开. - 过往的报告: 共 N 份 only when every page is loaded; 刷新 removed, the failed-read alert keeps 重试. - 64px rows with hairlines; the whole row links to the report (generating opens its progress); type icon (FileText / Sun / Heart), title, meta (date · depth · themes, annual date only, failed rows show the failure summary), plain status text by colour. ⋯ delete menu is a sibling of the link. Phones drop the icon and the year. - Signed-out / empty / failed states follow the same language; no large icon. - Entry CSS moved from annual-report.css (off-allowlist 720px cut) to the global 767 cut. Depth labels: DB only allows the four labelled values; the raw "full" came from the screenshot mock, not a product bug. - Tests: new reports-page-option-a-20261103; updated assertions carry 原值/新值/原因. DESIGN.md and CHANGELOG updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoyeZrYn6ryNcSe5Y2Y
89 lines
5.3 KiB
TypeScript
89 lines
5.3 KiB
TypeScript
import assert from "node:assert/strict";
|
||
import { readFileSync } from "node:fs";
|
||
import test from "node:test";
|
||
|
||
import { cssDeclarations } from "./css-contract-test-support.ts";
|
||
|
||
const globalStyles = readFileSync(new URL("../src/app/globals.css", import.meta.url), "utf8");
|
||
|
||
function minHeightPx(selector: string) {
|
||
const matches = [...cssDeclarations(selector, globalStyles).matchAll(/min-height:\s*(\d+)px/g)]
|
||
.map((hit) => Number(hit[1]));
|
||
assert.ok(matches.length > 0, `${selector} must declare min-height`);
|
||
return Math.max(...matches);
|
||
}
|
||
|
||
function hasHitExpandPseudo(selector: string) {
|
||
const after = cssDeclarations(`${selector}::after`, globalStyles);
|
||
assert.match(after, /position:\s*absolute/);
|
||
assert.match(after, /content:\s*""/);
|
||
return after;
|
||
}
|
||
|
||
test("40px controls grow to a 44px box when that does not pack a scrolling list badly", () => {
|
||
assert.ok(minHeightPx(".select-item") >= 44);
|
||
assert.ok(minHeightPx(".birth-time-window-details .birth-time-skip-button") >= 44);
|
||
// 原值:minHeightPx(".report-center-section-heading button") >= 44(「刷新」按钮)
|
||
// 新值:读取失败提示里的「重试」`.report-center-retry` >= 44
|
||
// 原因:2026-11-03 方案 A 去掉「刷新」,手动重读只留在读取失败的提示里;44px 要求不变
|
||
assert.ok(minHeightPx(".report-center-retry") >= 44);
|
||
});
|
||
|
||
test("icon and chip controls keep their visual size and expand the hit with a pseudo-element", () => {
|
||
const actions = cssDeclarations(".message-actions button", globalStyles);
|
||
assert.match(actions, /width:\s*26px/);
|
||
assert.match(actions, /height:\s*26px/);
|
||
assert.match(cssDeclarations(".message-actions", globalStyles), /gap:\s*1px/);
|
||
const actionHit = hasHitExpandPseudo(".message-actions button");
|
||
// 原值: 热区锁 27×34(44×44 会与相邻按钮和 follow-up 重叠)。
|
||
// 新值: 细指针仍是 27×34;粗指针见下一条,gap 20px + 底边 20px 后才放大到 44×44。
|
||
// 原因: BUG-695,触屏点赞容易点成点踩。
|
||
assert.match(actionHit, /width:\s*27px/);
|
||
assert.match(actionHit, /height:\s*34px/);
|
||
|
||
// 原值:`.chart-nav-chip`(侧栏星盘列表的名字 chip)
|
||
// 新值:`.starter-entry`(空态的两枚入口 pill)
|
||
// 原因:星盘列表 chip 已随入口收敛删除(D6)。空态的入口 pill 是这一类「视觉小于
|
||
// 44px、靠伪元素扩热区」控件的新成员,36px 视觉 + -4px 外扩,正好归这条合同管。
|
||
// 原值(2):`.starter-entry` 36px + ::after inset -4px
|
||
// 新值(2):顶栏的两行人物胶囊 `.chat-profile-picker-trigger.is-chip` 40px + ::before inset -2px(44px)
|
||
// 原因(2):2026-11-02 首页界面整理:今日星语胶囊删除;顶栏人物胶囊是这一类控件的新成员
|
||
// 原值(3):`minHeightPx(".chat-profile-picker-trigger.is-chip") >= 40`(胶囊写死 40px)
|
||
// 新值(3):胶囊取 `--chat-header-pill`;桌面 40px、手机 44px
|
||
// 原因(3):2026-11-02 人物胶囊和点数胶囊共用一个顶栏高度
|
||
// 原值(4):胶囊桌面 40px + ::before inset -2px
|
||
// 新值(4):胶囊任何宽度都是 44px(`--chat-header-pill`),不再需要伪元素;这一类的新成员是
|
||
// 选择星盘每行的 ⋯:32px 视觉 + ::before 上下各扩 6px(44px 高),宽度留在自己那一列
|
||
// 原因(4):2026-11-02 选择星盘原型:人物胶囊 44px,⋯ 在桌面是 32px
|
||
assert.match(cssDeclarations(".chat-profile-picker-trigger.is-chip", globalStyles), /min-height:\s*var\(--chat-header-pill\)/);
|
||
// 原值(5):胶囊 44px、没有 ::before
|
||
// 新值(5):胶囊画出来 34px,::before 上下各扩 5px(44px 高),左右不扩,不压邻居
|
||
// 原因(5):2026-11-02 产品:顶栏胶囊太高、边框贴到顶栏上下边
|
||
assert.match(cssDeclarations(".chat-header", globalStyles), /--chat-header-pill:\s*34px/);
|
||
const chipHit = cssDeclarations(".chat-profile-picker-trigger.is-chip::before", globalStyles);
|
||
assert.match(chipHit, /position:\s*absolute/);
|
||
assert.match(chipHit, /inset:\s*-5px 0/);
|
||
assert.match(chipHit, /content:\s*""/);
|
||
const moreHit = cssDeclarations(".chat-profile-picker-more::before", globalStyles);
|
||
assert.match(moreHit, /position:\s*absolute/);
|
||
assert.match(moreHit, /inset:\s*-6px 0/);
|
||
assert.match(moreHit, /content:\s*""/);
|
||
|
||
const auth = cssDeclarations(".auth-links button", globalStyles);
|
||
assert.match(auth, /min-height:\s*32px/);
|
||
assert.match(hasHitExpandPseudo(".auth-links button"), /inset:\s*-4px/);
|
||
});
|
||
|
||
test("coarse pointers get a 44×44 message-action hit that does not overlap neighbours", () => {
|
||
const coarseStart = globalStyles.indexOf("@media (pointer: coarse)");
|
||
assert.notEqual(coarseStart, -1);
|
||
const coarse = globalStyles.slice(coarseStart, globalStyles.indexOf("}", globalStyles.indexOf(".markdown-code-copy", coarseStart)) + 1);
|
||
assert.match(coarse, /\.message-actions \{[\s\S]*gap:\s*var\(--space-5\)/);
|
||
assert.match(coarse, /margin-bottom:\s*var\(--space-5\)/);
|
||
assert.match(coarse, /\.message-actions button::after \{[\s\S]*width:\s*44px;[\s\S]*height:\s*44px;/);
|
||
assert.match(coarse, /\.markdown-code-copy \{[\s\S]*min-height:\s*44px;/);
|
||
const base = globalStyles.slice(0, coarseStart);
|
||
assert.match(base, /\.message-actions \{[\s\S]*gap:\s*1px;/);
|
||
assert.match(base, /\.message-actions button::after \{[\s\S]*width:\s*27px;[\s\S]*height:\s*34px;/);
|
||
});
|