Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .claude/skills/ui/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ description: 写或改网页界面时使用:web/src 下的页面和组件、
3. **用留白和细线分区,不用边框和底色。** 列表的行与行之间一条细线;区块之间靠间距(页面左右 40px、区块之间 44px,窄屏 16px 和 32px)。
4. **标题不抢内容。** 区块标题是小号的灰字(13px、`text-ink-2`);卡片的标题才是大字(`CardTitle`)。
5. **主操作是黑色**(暗色主题下是白色)。一组按钮里只有一个主操作,其余用 `outline` 或 `ghost`。
6. **状态用形状表达,颜色只做补充。** 选中的选项是墨色边框加实心的勾;进度是五小段。
7. **动效短,而且有含义。** 悬停只变颜色(150ms);做完一件事,卡片淡出、下一张补上。系统设置了减少动态效果时全部关掉(组件已带 `motion-reduce:`)。
6. **状态用形状表达,颜色只做补充。** 选中的选项是墨色边框加实心的勾;进度是一小段一小段(工作流有几个节点就几段)。
7. **动效短,而且有含义。** 悬停只变颜色或透明度(150ms,主按钮淡到 0.86),不移动、不缩放;做完一件事,卡片淡出、下一张补上。系统设置了减少动态效果时全部关掉(组件已带 `motion-reduce:`)。

### 组件对照

Expand Down
Binary file added docs/e2e/ui-fixes/gallery/dialog-1440.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/e2e/ui-fixes/gallery/dialog-390.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/e2e/ui-fixes/gallery/gallery-dark-1440.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/e2e/ui-fixes/gallery/gallery-dark-390.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/e2e/ui-fixes/gallery/gallery-light-1440.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/e2e/ui-fixes/gallery/gallery-light-390.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 100 additions & 0 deletions docs/e2e/ui-fixes/gallery/gallery-report.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"commit": "5fc95e691fc5492ee91aa4b1d3313c65f6027e8d",
"uncommitted": [
" D docs/e2e/ui-fixes/gallery/dialog-1440.png",
" D docs/e2e/ui-fixes/gallery/dialog-390.png",
" D docs/e2e/ui-fixes/gallery/gallery-dark-1440.png",
" D docs/e2e/ui-fixes/gallery/gallery-dark-390.png",
" D docs/e2e/ui-fixes/gallery/gallery-light-1440.png",
" D docs/e2e/ui-fixes/gallery/gallery-light-390.png",
" D docs/e2e/ui-fixes/gallery/gallery-report.json"
],
"checks": {
"light 1440:主按钮的底色是令牌 --ink": true,
"light 1440:主按钮高 36px(组件样式盖过了现有页面的 button 规则)": true,
"light 1440:输入框的边框是令牌 --line": true,
"light 1440:卡片底色是令牌 --surface、没有边框、有阴影": true,
"light 1440:输入框、多行输入框、下拉、按钮用页面字体(不是浏览器默认的表单字体)": true,
"light 1440:键盘聚焦的按钮有 2px 墨色外框、离元素 2px": true,
"light 1440:页面底色上的 bare-ghost 按钮没有底色(现有 button 规则的底色没漏进来)": true,
"light 1440:页面底色上的 bare-link 按钮没有底色(现有 button 规则的底色没漏进来)": true,
"light 1440:输入框字号:窄屏 16px(iOS 不放大),宽屏 14px": true,
"light 1440:不横向滚动": true,
"light 1440:任务行高 44px": true,
"light 1440:任务行的进度显示": true,
"light 1440:任务行的分隔线和清单同宽,行的悬停底色左右各宽 12px": true,
"light 1440:悬停的那一行上下的分隔线隐去": true,
"light 1440:鼠标移到不能点的行上,分隔线不变": true,
"light 1440:点选项能选中": true,
"light 1440:选中的选项是墨色边框、勾是墨色实心": true,
"light 1440:键盘下键选中下一个选项": true,
"light 1440:在「其他」里输入后,已选的选项取消": true,
"light 1440:再选一个选项,「其他」清空": true,
"light 1440:下拉菜单打开,有 4 项": true,
"light 1440:Esc 关闭下拉菜单,焦点回到触发按钮": true,
"light 1440:点「改动」切换过去": true,
"light 1440:键盘左键切回「过程」": true,
"light 1440:对话框打开后焦点在对话框里": true,
"light 1440:对话框两边至少留 16px": true,
"light 1440:右上角关闭按钮 28×28、没有内边距(现有 button 规则的内边距没漏进来)": true,
"light 1440:Esc 关闭对话框,焦点回到触发按钮": true,
"light 1440:点「删除」执行并关闭": true,
"light 390:主按钮的底色是令牌 --ink": true,
"light 390:主按钮高 36px(组件样式盖过了现有页面的 button 规则)": true,
"light 390:输入框的边框是令牌 --line": true,
"light 390:卡片底色是令牌 --surface、没有边框、有阴影": true,
"light 390:输入框、多行输入框、下拉、按钮用页面字体(不是浏览器默认的表单字体)": true,
"light 390:键盘聚焦的按钮有 2px 墨色外框、离元素 2px": true,
"light 390:页面底色上的 bare-ghost 按钮没有底色(现有 button 规则的底色没漏进来)": true,
"light 390:页面底色上的 bare-link 按钮没有底色(现有 button 规则的底色没漏进来)": true,
"light 390:输入框字号:窄屏 16px(iOS 不放大),宽屏 14px": true,
"light 390:不横向滚动": true,
"light 390:任务行高 44px": true,
"light 390:任务行的进度在窄屏下隐藏": true,
"light 390:任务行的分隔线和清单同宽,行的悬停底色左右各宽 12px": true,
"light 390:点选项能选中": true,
"light 390:选中的选项是墨色边框、勾是墨色实心": true,
"light 390:键盘下键选中下一个选项": true,
"light 390:在「其他」里输入后,已选的选项取消": true,
"light 390:再选一个选项,「其他」清空": true,
"light 390:下拉菜单打开,有 4 项": true,
"light 390:Esc 关闭下拉菜单,焦点回到触发按钮": true,
"light 390:点「改动」切换过去": true,
"light 390:键盘左键切回「过程」": true,
"light 390:对话框打开后焦点在对话框里": true,
"light 390:对话框两边至少留 16px": true,
"light 390:右上角关闭按钮 28×28、没有内边距(现有 button 规则的内边距没漏进来)": true,
"light 390:Esc 关闭对话框,焦点回到触发按钮": true,
"light 390:点「删除」执行并关闭": true,
"dark 1440:主按钮的底色是令牌 --ink": true,
"dark 1440:主按钮高 36px(组件样式盖过了现有页面的 button 规则)": true,
"dark 1440:输入框的边框是令牌 --line": true,
"dark 1440:卡片底色是令牌 --surface、没有边框、有阴影": true,
"dark 1440:输入框、多行输入框、下拉、按钮用页面字体(不是浏览器默认的表单字体)": true,
"dark 1440:键盘聚焦的按钮有 2px 墨色外框、离元素 2px": true,
"dark 1440:页面底色上的 bare-ghost 按钮没有底色(现有 button 规则的底色没漏进来)": true,
"dark 1440:页面底色上的 bare-link 按钮没有底色(现有 button 规则的底色没漏进来)": true,
"dark 1440:输入框字号:窄屏 16px(iOS 不放大),宽屏 14px": true,
"dark 1440:不横向滚动": true,
"dark 1440:任务行高 44px": true,
"dark 1440:任务行的进度显示": true,
"dark 1440:任务行的分隔线和清单同宽,行的悬停底色左右各宽 12px": true,
"dark 1440:悬停的那一行上下的分隔线隐去": true,
"dark 1440:鼠标移到不能点的行上,分隔线不变": true,
"dark 390:主按钮的底色是令牌 --ink": true,
"dark 390:主按钮高 36px(组件样式盖过了现有页面的 button 规则)": true,
"dark 390:输入框的边框是令牌 --line": true,
"dark 390:卡片底色是令牌 --surface、没有边框、有阴影": true,
"dark 390:输入框、多行输入框、下拉、按钮用页面字体(不是浏览器默认的表单字体)": true,
"dark 390:键盘聚焦的按钮有 2px 墨色外框、离元素 2px": true,
"dark 390:页面底色上的 bare-ghost 按钮没有底色(现有 button 规则的底色没漏进来)": true,
"dark 390:页面底色上的 bare-link 按钮没有底色(现有 button 规则的底色没漏进来)": true,
"dark 390:输入框字号:窄屏 16px(iOS 不放大),宽屏 14px": true,
"dark 390:不横向滚动": true,
"dark 390:任务行高 44px": true,
"dark 390:任务行的进度在窄屏下隐藏": true,
"dark 390:任务行的分隔线和清单同宽,行的悬停底色左右各宽 12px": true,
"页面没有脚本错误": true
},
"errors": []
}
1 change: 1 addition & 0 deletions docs/e2e/ui-fixes/pages-compare-commits.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"main":"0174f329ed3fbd15dbb5dca28c1396c6dce66c1c","branch":"d3a2f16bfde44db616f400148bb3f47058aad2c1"}
4 changes: 4 additions & 0 deletions docs/e2e/ui-fixes/pages-compare.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"compared": 40,
"different": []
}
Binary file added docs/e2e/ui-fixes/vs-design/gallery-dark-390.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/e2e/ui-fixes/vs-design/vs-design-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/e2e/ui-fixes/vs-design/vs-design-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 10 additions & 10 deletions scripts/ui-gallery/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ function Gallery() {
{ key: 'sum', label: '汇总', state: 'todo' },
]}
/>
<OptionGroup legend="导出时要不要包含已中止的任务?">
<Option name="scope" value="all" defaultChecked title="包含,并加一列「状态」" badge={<Badge>推荐</Badge>} description="和列表页看到的一致;要排除时在表格里按状态筛掉" />
<Option name="scope" value="none" title="不包含" description="导出的行数会和列表页不一样" />
<Option name="scope" value="ask" title="导出时让人选" description="多一个选项,范围变大" />
<OptionOther placeholder="其他…" aria-label="其他" />
<OptionGroup name="scope" legend="导出时要不要包含已中止的任务?" defaultValue={{ kind: 'option', value: 'all' }}>
<Option value="all" title="包含,并加一列「状态」" badge={<Badge>推荐</Badge>} description="和列表页看到的一致;要排除时在表格里按状态筛掉" />
<Option value="none" title="不包含" description="导出的行数会和列表页不一样" />
<Option value="ask" title="导出时让人选" description="多一个选项,范围变大" />
<OptionOther placeholder="其他…" />
</OptionGroup>
</CardContent>
<CardFooter>
<Button>
继续
<ChevronRightIcon />
<ChevronRightIcon width={14} height={14} />
</Button>
</CardFooter>
</Card>
Expand Down Expand Up @@ -161,10 +161,10 @@ function Gallery() {

<Section title="进行中的任务">
<TaskList>
<TaskRow name="导出任务列表为 CSV" done={0} waiting state="规格 · 等你回答" onSelect={() => {}} />
<TaskRow name="任务列表支持按状态筛选" done={4} waiting state="评审通过 · 等你验收" />
<TaskRow name="统计页增加按仓库筛选" done={2} state="测试 · 第 2 轮" onSelect={() => {}} />
<TaskRow name="升级 vite 到最新的小版本" done={4} state="交付 · 正在推送" />
<TaskRow name="导出任务列表为 CSV" total={5} done={0} waiting state="规格 · 等你回答" onSelect={() => {}} />
<TaskRow name="任务列表支持按状态筛选" total={5} done={4} waiting state="评审通过 · 等你验收" />
<TaskRow name="统计页增加按仓库筛选" total={5} done={2} state="测试 · 第 2 轮" onSelect={() => {}} />
<TaskRow name="升级 vite 到最新的小版本" total={5} done={4} state="交付 · 正在推送" />
</TaskList>
</Section>

Expand Down
30 changes: 24 additions & 6 deletions scripts/web-ui-gallery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,41 @@ for (const scheme of ['light', 'dark'] as const) {
check(`${tag}:不横向滚动`, await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth))
await page.screenshot({ path: join(out, `gallery-${scheme}-${width}.png`), fullPage: true })

const taskRow = page.locator('[data-slot=task-row] > *').first()
const taskRow = page.locator('[data-slot=task-row] > div > *').first()
check(`${tag}:任务行高 44px`, (await style(taskRow, 'height')) === '44px')
const progressShown = (await style(page.locator('[data-slot=task-row] > * > span[aria-hidden]').first(), 'display')) !== 'none'
check(`${tag}:任务行的五段进度${width < 640 ? '在窄屏下隐藏' : '显示'}`, progressShown === width >= 640)
const progressShown = (await style(page.locator('[data-slot=task-row] > div > * > span[aria-hidden]').first(), 'display')) !== 'none'
check(`${tag}:任务行的进度${width < 640 ? '在窄屏下隐藏' : '显示'}`, progressShown === width >= 640)
// 分隔线和清单同宽,悬停的那一行比清单左右各宽 12px;鼠标移上去时这一行上下的线隐去
const list = await page.locator('[data-slot=task-list]').first().boundingBox()
const second = page.locator('[data-slot=task-row]').nth(1)
const li = await second.boundingBox()
const inner = await second.locator('> div > *').boundingBox()
check(`${tag}:任务行的分隔线和清单同宽,行的悬停底色左右各宽 12px`, li.x === list.x && li.width === list.width && inner.x === list.x - 12 && inner.width === list.width + 24)
if (width >= 640) {
await page.locator('[data-slot=task-row]').nth(2).hover()
await page.waitForTimeout(300)
const third = await style(page.locator('[data-slot=task-row]').nth(2), 'border-top-color')
const fourth = await style(page.locator('[data-slot=task-row]').nth(3), 'border-top-color')
check(`${tag}:悬停的那一行上下的分隔线隐去`, third === 'rgba(0, 0, 0, 0)' && fourth === 'rgba(0, 0, 0, 0)')
// 不能点的行没有悬停底色,分隔线也不隐去
await page.locator('[data-slot=task-row]').nth(1).hover()
await page.waitForTimeout(300)
check(`${tag}:鼠标移到不能点的行上,分隔线不变`, (await style(page.locator('[data-slot=task-row]').nth(1), 'border-top-color')) !== 'rgba(0, 0, 0, 0)')
await page.mouse.move(0, 0)
}

if (scheme === 'light') {
// 选项:点击选中,选中的是墨色边框和实心的勾;键盘下键选下一个
const options = page.locator('[data-slot=option]')
await options.nth(1).click()
await page.waitForTimeout(300) // 边框颜色有 150ms 的过渡
const second = page.locator('input[name=scope]').nth(1)
check(`${tag}:点选项能选中`, await second.isChecked())
const secondOption = page.locator('input[name=scope]').nth(1)
check(`${tag}:点选项能选中`, await secondOption.isChecked())
check(
`${tag}:选中的选项是墨色边框、勾是墨色实心`,
(await style(options.nth(1), 'border-top-color')) === toRgb(vars.ink) && (await style(options.nth(1).locator('span[aria-hidden]'), 'background-color')) === toRgb(vars.ink),
)
await second.focus()
await secondOption.focus()
await page.keyboard.press('ArrowDown')
check(`${tag}:键盘下键选中下一个选项`, await page.locator('input[name=scope]').nth(2).isChecked())

Expand Down
Loading
Loading