fix(web): reconcile visual consistency after master rebase

This commit is contained in:
imccyu committed 2026-09-24 14:58:55 +08:00
1 parent 63c7e370ce
commit 6000dcdda5
30 files changed
+148 -61

No files matched your search

+2 -2
View File
@@ -12,8 +12,8 @@
en: a5edee063916cd27
zh: 7a5286350ff09e58
/desktop-local-update-verification/native-overlay-visibility:
en: b81edb5b5540247f
zh: d824b176de12865e
en: cff2c259a195bb57
zh: fa03ff3fdc32a346
/desktop-local-update-verification/manual-walkthrough:
en: c4b4ee8763d8464a
zh: ee2159bc08966592
+1 -1
View File
@@ -26,7 +26,7 @@ pnpm exec tsc -b apps/desktop/tsconfig.host.json
apps/desktop/.desktop-build/targets/mac-arm64/electron/Electron.app/Contents/MacOS/Electron apps/desktop/tests/fixtures/update-overlay-visibility.mjs
```
The fixture owns a unique profile and writes `result.json` under `.desktop-build/qualification/update-overlay-*`. It compares native visibility, background blur, and listener cleanup with the owner-local expected output for parent hide/show and document readiness while the parent is hidden. It uses no network, product login, or dsh Host. This qualifies native window restoration rather than the full first-login flow.
The fixture owns a unique profile and writes `result.json` under `.desktop-build/qualification/update-overlay-*`. It compares native visibility, unfiltered parent content, and listener cleanup with the owner-local expected output for parent hide/show and document readiness while the parent is hidden. It uses no network, product login, or dsh Host. This qualifies native window restoration rather than the full first-login flow.
<a id="verification-interactive"></a>
+1 -1
View File
@@ -26,7 +26,7 @@ pnpm exec tsc -b apps/desktop/tsconfig.host.json
apps/desktop/.desktop-build/targets/mac-arm64/electron/Electron.app/Contents/MacOS/Electron apps/desktop/tests/fixtures/update-overlay-visibility.mjs
```
夹具使用独立 profile,在 `.desktop-build/qualification/update-overlay-*` 下写入 `result.json`。它对照所属测试目录中的预期输出,检查父窗口隐藏/显示、父窗口隐藏期间文档就绪两种顺序中的原生可见性、背景模糊和监听清理。它不使用网络、产品登录或 dsh Host。这项验证覆盖原生窗口恢复,不覆盖完整的首次登录流程。
夹具使用独立 profile,在 `.desktop-build/qualification/update-overlay-*` 下写入 `result.json`。它对照所属测试目录中的预期输出,检查父窗口隐藏/显示、父窗口隐藏期间文档就绪两种顺序中的原生可见性、父页面不受模糊影响及监听清理。它不使用网络、产品登录或 dsh Host。这项验证覆盖原生窗口恢复,不覆盖完整的首次登录流程。
<a id="verification-interactive"></a>
@@ -1,14 +1,14 @@
[
{
"initiallyVisible": true,
"loaded": { "parent": true, "overlay": true, "filter": "blur(2px)" },
"restored": { "parent": true, "overlay": true, "filter": "blur(2px)" },
"loaded": { "parent": true, "overlay": true, "filter": "none" },
"restored": { "parent": true, "overlay": true, "filter": "none" },
"released": { "filter": "none", "showListenersRestored": true, "keyboardListeners": 0 }
},
{
"initiallyVisible": false,
"loaded": { "parent": false, "overlay": false, "filter": "blur(2px)" },
"restored": { "parent": true, "overlay": true, "filter": "blur(2px)" },
"loaded": { "parent": false, "overlay": false, "filter": "none" },
"restored": { "parent": true, "overlay": true, "filter": "none" },
"released": { "filter": "none", "showListenersRestored": true, "keyboardListeners": 0 }
},
{ "parentDestroyed": true, "overlayDestroyed": true }
@@ -43,7 +43,6 @@ async function main() {
phase = `overlay ready (${initiallyVisible})`
await ready
await initiallyShown
// A renderer round trip observes the CSS request already queued by the overlay.
const filter = () => parent.webContents.executeJavaScript('getComputedStyle(document.body).filter')
const loaded = { parent: parent.isVisible(), overlay: overlay.isVisible(), filter: await filter() }
if (initiallyVisible) {
+5 -3
View File
@@ -43,7 +43,8 @@ it('restores a ready overlay each time its parent is shown and releases visibili
window.destroyed = true
window.emit('closed')
expect(parent.listenerCount('show')).toBe(0)
expect(parent.webContents.removeInsertedCSS).toHaveBeenCalledWith('blur')
expect(parent.webContents.insertCSS).not.toHaveBeenCalled()
expect(parent.webContents.removeInsertedCSS).not.toHaveBeenCalled()
parent.emit('show')
expect(window.show).toHaveBeenCalledTimes(3)
})
@@ -63,7 +64,7 @@ it('waits for both a visible parent and a ready document, in either order', asyn
}
})
it('does not show or retain blur when closed before its document and CSS insertion settle', async () => {
it('does not show or change parent styles when closed before its document is ready', async () => {
const { parent, window, visibility } = visibilityFixture(false)
window.destroyed = true
window.emit('closed')
@@ -73,7 +74,8 @@ it('does not show or retain blur when closed before its document and CSS inserti
await Promise.resolve()
expect(window.show).not.toHaveBeenCalled()
expect(parent.listenerCount('show')).toBe(0)
expect(parent.webContents.removeInsertedCSS).toHaveBeenCalledWith('blur')
expect(parent.webContents.insertCSS).not.toHaveBeenCalled()
expect(parent.webContents.removeInsertedCSS).not.toHaveBeenCalled()
})
it('releases a macOS overlay after its parent has already been destroyed', async () => {
+5 -1
View File
@@ -26,6 +26,10 @@ function appearance(element: Locator) {
it('shares settings card materials and control sizes in both palettes', async () => {
const scaffold = await launchWebScaffold({})
onTestFinished(() => scaffold.close())
await scaffold.ctx.settings.mutate('ui-settings-account', [
{ op: 'set', path: ['step'], value: 'done' },
{ op: 'set', path: ['completion'], value: 'completed' },
])
const account = scaffold.ctx.deepseekAccount
const state: AccountView = {
status: 'credential-stored', attempt: null,
@@ -66,7 +70,7 @@ it('shares settings card materials and control sizes in both palettes', async ()
await dialog.getByRole('button', { name: '账号与余额', exact: true }).click()
const section = dialog.getByRole('region', { name: '账号与余额', exact: true })
await section.getByText('¥128.50', { exact: true }).waitFor()
await expect.poll(() => section.innerText()).toContain('¥128.50')
const cards = section.locator(':scope > div')
expect(await cards.count()).toBe(2)
const profile = await appearance(cards.nth(0))
+2 -2
View File
@@ -18,8 +18,8 @@
en: 51cd57ec0fe8bb03
zh: 53784eee8aa8be6e
/dsh-unified-corner-radius-standard/reuse-tokens-and-preserve-deliberate-shapes:
en: 512d676cc06ad2a7
zh: 841d8cdc64f5831c
en: fb6d50f3139ad186
zh: 668cb0c02bd22167
/dsh-unified-corner-radius-standard/nested-geometry-and-hover:
en: 3920921700d8ad1c
zh: fc99da8a5e905a27
+1 -1
View File
@@ -47,7 +47,7 @@ Code blocks, diffs, and file previews share R16: changed-file entry cards, deliv
Reuse `ui-primitives` controls before adding feature-owned geometry. Use `box-sizing: border-box` for fixed outer dimensions. Filled, outline, ghost, loading, and disabled variants keep the same size and radius; hover, pressed, selected, and focus states do not change the radius.
Consume the named tokens instead of introducing local values such as 10px, 14px, 18px, or 24px for ordinary controls and cards. A family-specific property may refer to a shared token, as `--dsl-guide-entry-radius` does. Geometry derived from a real inset may use `calc()`; it is not an additional scale tier.
Consume the named tokens instead of introducing local values such as 10px, 14px, 18px, or 24px for ordinary controls and cards. Schedule controls, Desktop onboarding, account notices, and shortcut controls retain their package-owned geometry; the [radius exception record](../packages/client/ui-theme/tests/expected/radius-exceptions.expected.json) pins each permitted file, selector, and declaration rather than exempting whole packages. A family-specific property may refer to a shared token, as `--dsl-guide-entry-radius` does. Geometry derived from a real inset may use `calc()`; it is not an additional scale tier.
Ordinary rounded surfaces use the theme's `superellipse(1.5)` curve where supported. `corner-shape` is not inherited: the theme applies it to elements and their `::before`/`::after`. Unsupported engines retain ordinary circular corners. Do not introduce component-specific smoothing that makes a fill and its outline curve differently.
+1 -1
View File
@@ -47,7 +47,7 @@ H 表示以 CSS 像素计、包含边框的设计外部高度。R 表示浏览
添加功能自有的几何规则前,优先复用 `ui-primitives` 控件。固定外部尺寸使用 `box-sizing: border-box`。填充、描边、ghost、加载中和禁用变体保持相同尺寸与圆角;hover、按下、选中和焦点状态不改变圆角。
普通控件和卡片使用具名 token,不新增 10px、14px、18px、24px 等局部数值。组件族专用属性可引用共享 token,例如 `--dsl-guide-entry-radius`。由真实内缩距离派生的几何可使用 `calc()`;它不构成新的尺度档位。
普通控件和卡片使用具名 token,不新增 10px、14px、18px、24px 等局部数值。计划任务控件、Desktop 引导、账号通知和快捷键控件保留所属包的几何规则;[圆角例外记录](../packages/client/ui-theme/tests/expected/radius-exceptions.expected.json)逐项固定允许的文件、选择器及声明,不豁免整个包。组件族专用属性可引用共享 token,例如 `--dsl-guide-entry-radius`。由真实内缩距离派生的几何可使用 `calc()`;它不构成新的尺度档位。
普通圆角表面在支持时使用主题的 `superellipse(1.5)` 曲线。`corner-shape` 不会继承:主题将它应用于元素及其 `::before`/`::after`。不支持的引擎保留普通圆弧。不要添加组件专用的平滑规则,导致底色与外框使用不同曲线。
+2 -2
View File
@@ -9,8 +9,8 @@
en: dc8c41fbf9869179
zh: e45976a585cb9c86
/web-ui-style-reference/component-rules:
en: 7d606db7386bbf73
zh: 3f8753d6bbc1c274
en: e6072b2fcbf69de6
zh: bc9ed31961812451
/web-ui-style-reference/corner-radii-and-settings-cards:
en: 118972f6c2bd6ce4
zh: 85f8416b03e4dd8b
+1 -1
View File
@@ -23,7 +23,7 @@ Global style sheets belong in `ui-theme/src/styles/`. Component styles live besi
- Preserve keyboard focus visibility and reduced-motion behavior when adding transitions or hover-only controls.
- Rounded corners inherit the global superellipse smoothing from ui-theme's `corner-shape.css` on supporting engines. Pair `corner-shape: round` with every full-round `border-radius` (`50%`, `100%`, or a pill radius) so circles and capsules keep circular arcs; the ui-theme corner-shape spec enforces the pairing.
- Elevated surfaces (menus, popovers, modals, panels, floating buttons, the composer) set `border: 0` and take `box-shadow: var(--dsw-elevation-panel)`, `var(--dsw-elevation-prominent)`, or the composer's `var(--dsw-elevation-soft)` (larger blur at lower alpha): the 0.5px hairline stroke is the first shadow layer, and `--dsw-elevation-stroke-color` rebinds or suppresses it per surface or state. Never pair a `--dsw-alias-border-*` border with an lv/elevation shadow — the ui-theme elevation spec rejects the pairing; state-colored borders (warn panels) stay real borders.
- Existing and new dropdown, context, submenu, and selection menus use `Menu` or wrap custom content in `MenuSurface`. The material is the theme-owned `--dsw-menu-surface-fill` plus `--dsw-menu-backdrop-filter`; feature and platform CSS must not override either. The ui-theme menu spec rejects unwrapped menu/listbox renderers, material overrides, and token redefinitions.
- Existing and new dropdown, context, submenu, and selection menus use `Menu` or wrap custom content in `MenuSurface`. The material is the theme-owned `--dsw-menu-surface-fill` plus `--dsw-menu-backdrop-filter`; feature and platform CSS must not override either. The ui-theme menu spec rejects unwrapped menu/listbox renderers, material overrides, and token redefinitions. The schedule-owned `TaskMenu` and `ClockPicker` retain their existing containers and material as explicit exceptions ([owner](../packages/client/ui-schedule/README.md)).
- Modal backdrops, including settings and confirmation dialogs, retain their translucent dark mask without blur. The theme sets `--dsw-mask-blur` to `none`; Desktop-owned modal overlays also leave the parent page unfiltered.
- Menu background filtering stays on an isolated layer so nested menus and fixed overlays retain their positioning and backdrop. On macOS, `MenuSurface` adds an opaque backing behind page content only within each menu’s bounds, allowing Chromium to blur content over native vibrancy; CSS anchors follow placement and size, and unmounting removes the backing. Overlays without this backing use `--dsw-specific-menu`, whose theme-owned macOS fill is 94% opaque to keep underlying text from bleeding through. Other elevated surfaces using that fill pair it with the same filter on their own isolated background when they contain fixed overlays ([decision](../.agents/notes/implemented/feature/2026-09-17-compact-translucent-menu-surfaces.md)).
- Flat borders and separators that use a neutral `--dsw-alias-border-*` token draw at `0.5px` — buttons, inputs, cards, row dividers, and separators drawn as filled boxes (menu separators, the conversation header seam, markdown `hr`, vertical rails) share the hairline weight, which Chromium paints as one device pixel. Dashed affordances and state-colored borders keep 1px; spinner ring tracks keep their width through the spec's explicit allowlist. The ui-theme elevation spec rejects wider neutral solid borders.
+1 -1
View File
@@ -23,7 +23,7 @@
- 添加过渡动画或仅悬停可见的控件时,保留清晰可见的键盘焦点和减少动态效果行为。
- 支持的引擎上,圆角继承 ui-theme `corner-shape.css` 的全局超级椭圆平滑。每个正圆 `border-radius`(`50%`、`100%` 或胶囊半径)必须配对 `corner-shape: round`,使圆形与胶囊保持圆弧;ui-theme 的 corner-shape spec 强制这一配对。
- 高层级表面(菜单、浮层、对话框、面板、悬浮按钮、输入框)设 `border: 0` 并使用 `box-shadow: var(--dsw-elevation-panel)`、`var(--dsw-elevation-prominent)` 或输入框专用的 `var(--dsw-elevation-soft)`(更大模糊、更低透明度):0.5px 发丝描边是第一层投影,`--dsw-elevation-stroke-color` 可按表面或状态重绑或抑制描边。不得将 `--dsw-alias-border-*` border 与 lv/elevation 投影配对——ui-theme 的 elevation spec 会拒绝;状态色 border(warn 面板)保持真 border。
- 存量和新增的下拉菜单、上下文菜单、子菜单及选择菜单使用 `Menu`,自定义内容用 `MenuSurface` 包裹。材质由主题的 `--dsw-menu-surface-fill` 和 `--dsw-menu-backdrop-filter` 组成;功能及平台 CSS 不得覆盖两者。ui-theme 菜单检查拒绝未使用共享容器的 menu/listbox 渲染、材质覆盖和 token 重定义。
- 存量和新增的下拉菜单、上下文菜单、子菜单及选择菜单使用 `Menu`,自定义内容用 `MenuSurface` 包裹。材质由主题的 `--dsw-menu-surface-fill` 和 `--dsw-menu-backdrop-filter` 组成;功能及平台 CSS 不得覆盖两者。ui-theme 菜单检查拒绝未使用共享容器的 menu/listbox 渲染、材质覆盖和 token 重定义。计划任务自有的 `TaskMenu` 与 `ClockPicker` 是明确例外,保留现有容器和材质([所属包](../packages/client/ui-schedule/README.zh.md))。
- 设置、确认框等模态弹窗保留黑色半透明遮罩,不模糊背景。主题将 `--dsw-mask-blur` 设为 `none`;Desktop 自有模态浮层也不对父页面施加模糊。
- 菜单背景模糊绘制在独立图层上,保证嵌套菜单和 fixed 浮层的定位及背景采样。macOS 上,`MenuSurface` 仅在各菜单范围内、页面内容后方添加实色底层,使 Chromium 能在原生透明材质上模糊页面内容;CSS 锚点跟随位置及尺寸,卸载时移除底层。没有该底层的浮层使用 `--dsw-specific-menu`,主题在 macOS 上将其设为 94% 不透明度,防止下方文字透出。其他使用该填充的浮起表面也须配套同一模糊;包含 fixed 浮层时,将两者绘制在独立背景层上([决策](../.agents/notes/implemented/feature/2026-09-17-compact-translucent-menu-surfaces.zh.md))。
- 使用中性 `--dsw-alias-border-*` token 的平面边框与分割线一律 `0.5px`——按钮、输入框、卡片、行分割线,以及以填充盒绘制的分隔线(菜单分隔、对话标题栏接缝、markdown `hr`、竖向轨道线)共用发丝线粗细,Chromium 将其绘制为一个设备像素。dashed 记号与状态色 border 保持 1px;spinner 圆环经 spec 的显式豁免保留原宽度。更宽的中性 solid border 会被 ui-theme elevation spec 拒绝。
+1 -1
View File
@@ -112,7 +112,7 @@ One UI feature = one plugin package (`src/client/` browser half). A multi-domain
[docs/web-styling.md](../../docs/web-styling.md) is authoritative. Shared `--dsw-*` tokens and global sheets live in `ui-theme/src/styles/`; feature components consume semantic aliases through CSS Modules and `clsx`, with no literal colors, component library, or Tailwind. Code comments are English. Design judgment beyond those rules — feedback surfaces, loading states, overlay safety, platform window adaptation — follows [dsh-client-ui-ux](../../.agents/skills/dsh-client-ui-ux/SKILL.md).
Menus use `Menu` or `MenuSurface`, including custom listboxes. Preserve the shared transparency and blur ([rules](../../docs/web-styling.md#component-rules)).
Menus use `Menu` or `MenuSurface`, including custom listboxes, except the explicitly listed schedule containers. Preserve the shared transparency and blur ([rules](../../docs/web-styling.md#component-rules)).
Every product-visible string—including text, accessibility names, tooltips, placeholders, status/unit formatters, and primitive chrome—lives in a typed locale dictionary and reaches components through the standard `t` seat or an already-localized prop. Cordis-free primitives require complete label props and own no fallback copy. Keep user/model/wire data and code tokens verbatim; internal matching uses discriminants or stable ids, never localized text. `pnpm run verify-client-ui-i18n` enforces source ownership ([decision](../../.agents/notes/implemented/architecture/2026-08-23-locale-owned-client-ui-copy.md)).
@@ -18,7 +18,7 @@
en: 8451ab527ba71867
zh: 933fac58cfa592b9
/deepseek-ai-dsh-client-ui-model-selection/use-this-package/model-and-effort:
en: 4ee7be9a9b7af3b1
en: e38d0195677a7b69
zh: 4eea8a9b1664afd9
/deepseek-ai-dsh-client-ui-model-selection/use-this-package/unroutable-sessions:
en: 7f20428c747ff052
+1 -1
View File
@@ -35,7 +35,7 @@ Mouse selection uses native browser clicks, including their cancellation behavio
### Model and effort
Models stay grouped by provider. The composer menu shows model and effort names only, with DeepSeek Account first and DeepSeek second; third-party providers retain their catalog order. Navigation chevrons use the `--dsw-alias-menu-icon` color. The `/model` popup shows provider names and catalog descriptions; it localizes the two built-in DeepSeek descriptions and leaves external provider descriptions verbatim. The popup applies the selected model's default effort; the composer can then choose any advertised effort. An adapter without reasoning metadata leaves the Effort row absent; there is no arbitrary effort input.
Models stay grouped by provider. The composer menu shows model and effort names only, with DeepSeek Account first and DeepSeek second; third-party providers retain their catalog order. Navigation chevrons use `--dsw-alias-menu-icon`. The `/model` popup shows provider names and catalog descriptions; it localizes the two built-in DeepSeek descriptions and leaves external provider descriptions verbatim. The popup applies the selected model's default effort; the composer can then choose any advertised effort. An adapter without reasoning metadata leaves the Effort row absent; there is no arbitrary effort input.
The composer replaces the model and effort text with the Models icon when the expanded controls cannot share one line, and restores the text when space permits. The full selection remains available in the trigger's accessible name, tooltip, and menu.
@@ -18,8 +18,8 @@
en: 91ac7c457248a593
zh: 744c9cea337bb20f
/deepseek-ai-dsh-client-ui-primitives/use-this-package/component-catalog:
en: a4bfdb1295875e92
zh: 23c332ede9e3f605
en: 33299e518ff2cad1
zh: 880c7da903bc20d4
/deepseek-ai-dsh-client-ui-primitives/use-this-package/controls-and-icons:
en: 83052e14c3fb34cf
zh: 0adb09885723296a
+1 -1
View File
@@ -40,7 +40,7 @@ Check this table before writing a control in a feature package. A plugin cannot
| Export | What it is |
|---|---|
| `Button` | Clickable action; `variant` selects `primary`, `ghost`, `outline`, or `toolbar`. |
| `Button` | Clickable action; `variant` selects `primary`, `ghost`, `outline`, or `toolbar`. Its ref targets the native button for focus and overlay anchoring. |
| `Switch` | Two-state toggle, 36×20. `label` is required, so the control cannot ship unnamed. |
| `SegmentedControl` | Tablist of two or more equal-width segments with one sliding indicator, for switching a card or panel between a few modes; the owner holds the selection and `label` names the list. `id` seeds each tab's id (`<id>-<value>`) and the panel it controls (`<id>-<value>-panel`), which the owner renders and points back at the tab with `aria-labelledby`; a segment may be `disabled` with a `title`, and `disabled` on the control locks every segment while the shown panel has work in flight. |
| `Checkbox` | Labeled native checkbox with controlled state, keyboard interaction, and disabled styling; the caller supplies localized `label` text. |
+1 -1
View File
@@ -40,7 +40,7 @@ kind: "package-library"
| 导出 | 是什么 |
|---|---|
| `Button` | 可点击操作;`variant` 选择 `primary`、`ghost`、`outline` 或 `toolbar`。 |
| `Button` | 可点击操作;`variant` 选择 `primary`、`ghost`、`outline` 或 `toolbar`。ref 指向原生按钮,供焦点控制与浮层锚定使用。 |
| `Switch` | 36×20 的双态开关。`label` 必填,控件不可能在没有名称的情况下发布。 |
| `SegmentedControl` | 两段或更多等宽分段加一个滑动指示块的 tablist,用于在几种模式间切换一张卡片或面板;选中项由调用方持有,`label` 为列表命名。`id` 派生每个 tab 的 id(`<id>-<value>`)及其控制的面板 id(`<id>-<value>-panel`),面板由调用方渲染并用 `aria-labelledby` 指回 tab;分段可 `disabled` 并带 `title`,控件级 `disabled` 在当前面板有进行中的操作时锁住全部分段。 |
| `Checkbox` | 带标签的原生复选框,支持受控状态、键盘交互和禁用样式;调用方提供本地化的 `label` 文本。 |
+17 -12
View File
@@ -1,31 +1,36 @@
// Button: token-styled button atom. Variants map to the --dsw-alias-button-*
// fill families; no framework imports, all behavior via props.
import type { ButtonHTMLAttributes, ReactNode } from 'react'
import { forwardRef, type ButtonHTMLAttributes, type ReactNode } from 'react'
import clsx from 'clsx'
import css from './Button.module.css'
/** Visual variant, each backed by its --dsw-alias-button-* token family. */
export type ButtonVariant = 'primary' | 'ghost' | 'outline' | 'toolbar'
/**
* Render a button.
* @param props.variant - visual family (default 'ghost').
* @param props.size - 'md' 36px control with 12px corners or 'sm' 28px control with 8px corners.
* @param props.icon - optional leading 16px icon node.
* @returns the button element; native button attributes pass through.
*/
export function Button({ variant = 'ghost', size = 'md', icon, className, children, ...rest }: {
type ButtonProps = {
variant?: ButtonVariant
size?: 'md' | 'sm'
icon?: ReactNode
className?: string | undefined
children?: ReactNode
} & ButtonHTMLAttributes<HTMLButtonElement>) {
} & ButtonHTMLAttributes<HTMLButtonElement>
/**
* Render a button.
* @param props.variant - visual family (default 'ghost').
* @param props.size - 'md' 36px control with 12px corners or 'sm' 28px control with 8px corners.
* @param props.icon - optional leading 16px icon node.
* @param ref - native button for focus management and overlay anchors.
* @returns the button element; native button attributes pass through.
*/
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button({
variant = 'ghost', size = 'md', icon, className, children, ...rest
}, ref) {
return (
<button type="button" className={clsx(css.button, css[variant], css[size], className)} {...rest}>
<button ref={ref} type="button" className={clsx(css.button, css[variant], css[size], className)} {...rest}>
{icon != null && <span className={css.icon}>{icon}</span>}
{children}
</button>
)
}
})
@@ -5,7 +5,7 @@
width: 100%;
height: 180px;
overflow: hidden;
border-radius: 8px;
border-radius: var(--dsw-radius-sm);
background: var(--dsw-alias-bg-base);
}
.image { width: 100%; height: 100%; min-height: 0; object-fit: contain; opacity: 0; }
@@ -448,7 +448,7 @@
max-width: 100%;
padding: 0;
border: 0;
border-radius: 8px;
border-radius: var(--dsw-radius-sm);
background: transparent;
vertical-align: middle;
cursor: zoom-in;
@@ -1,5 +1,5 @@
// @vitest-environment jsdom
import { useState } from 'react'
import { createRef, useState } from 'react'
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { Button, ConnectionIndicator, Input, Menu, MenuItemButton, Modal, Pill } from '@deepseek-ai/dsh-client-ui-primitives'
@@ -8,6 +8,16 @@ import { POINTER_GRACE_MS } from '../src/pointer-grace.ts'
afterEach(cleanup)
describe('Button', () => {
it('exposes its native button for focus and releases the ref on unmount', () => {
const ref = createRef<HTMLButtonElement>()
const { unmount } = render(<Button ref={ref}>Focus</Button>)
expect(ref.current).toBe(screen.getByRole('button', { name: 'Focus' }))
ref.current?.focus()
expect(document.activeElement).toBe(ref.current)
unmount()
expect(ref.current).toBeNull()
})
it('renders children, icon, and forwards clicks', () => {
const onClick = vi.fn()
render(<Button variant="primary" icon={<svg data-testid="ic" />} onClick={onClick}>Go</Button>)
@@ -14,15 +14,13 @@
min-width: 124px;
max-width: 280px;
padding: 4px;
border-radius: 12px;
--dsw-elevation-stroke-color: var(--dsw-alias-border-inverted);
}
.signedOutMenu [role='menuitem'] {
min-height: 40px;
gap: 8px;
padding: 8px 10px;
border-radius: 10px;
border-radius: var(--dsw-radius-md);
font-size: 14px;
line-height: 22px;
}
@@ -30,7 +28,7 @@
.signedOutMenu [role='menuitem'] > span:first-child:not(:last-child) {
width: 16px;
height: 16px;
color: var(--dsw-alias-label-primary);
color: var(--dsw-alias-menu-icon);
}
.signedOutMenu [role='menuitem'] > span:first-child:not(:last-child) svg { width: 16px; height: 16px; }
+2 -2
View File
@@ -27,8 +27,8 @@
en: 54296471349d9f77
zh: 8ca162b7b57b822e
/deepseek-ai-dsh-client-ui-theme/understand-the-implementation:
en: 946f34aebe974b69
zh: 1842315f53f39b6d
en: 8fbfdb050e880f9b
zh: dd201f049036c5c4
/deepseek-ai-dsh-client-ui-theme/understand-the-implementation/stylesheets:
en: 1d398bcc78b09ef2
zh: cc657eeb80b55a62
+1 -1
View File
@@ -44,7 +44,7 @@ When the host composition includes an HTTP server, the host half embeds the regi
<a id="understand-the-implementation"></a>
## Understand the implementation
All menus share `--dsw-menu-surface-fill` and blur through `MenuSurface`; platform code must preserve those token values. Other overlays consume `--dsw-specific-menu`, which keeps a nearly opaque macOS fill without a menu backing. The enforced source rules are defined in the [styling reference](../../../docs/web-styling.md#component-rules). Modal masks retain their dark translucent fill without background blur.
Shared menus use `--dsw-menu-surface-fill` and blur through `MenuSurface`; platform code must preserve those token values. Other overlays consume `--dsw-specific-menu`, which keeps a nearly opaque macOS fill without a menu backing. The enforced source rules are defined in the [styling reference](../../../docs/web-styling.md#component-rules). Modal masks retain their dark translucent fill without background blur.
<details>
<summary>Implementation internals — click to expand</summary>
+1 -1
View File
@@ -44,7 +44,7 @@ kind: "package-reference"
<a id="understand-the-implementation"></a>
## 理解实现
所有菜单通过 `MenuSurface` 共享 `--dsw-menu-surface-fill` 和模糊,平台代码须保留这些 token 值。其他浮层使用 `--dsw-specific-menu`,在没有菜单底层时保留 macOS 上接近不透明的填充。源码约束见[样式参考](../../../docs/web-styling.zh.md#component-rules)。 模态遮罩保留黑色半透明填充,不模糊背景。
公共菜单通过 `MenuSurface` 共享 `--dsw-menu-surface-fill` 和模糊,平台代码须保留这些 token 值。其他浮层使用 `--dsw-specific-menu`,在没有菜单底层时保留 macOS 上接近不透明的填充。源码约束见[样式参考](../../../docs/web-styling.zh.md#component-rules)。 模态遮罩保留黑色半透明填充,不模糊背景。
<details>
<summary>实现细节——点击展开</summary>
@@ -0,0 +1,65 @@
{
"ui-primitives/src/ShortcutKeys.module.css": [
".keys: border-radius: 10px"
],
"ui-schedule/src/client/ClockPicker.module.css": [
".option: border-radius: 10px"
],
"ui-schedule/src/client/DatePicker.module.css": [
".nav: border-radius: 8px",
".cell: border-radius: 8px"
],
"ui-schedule/src/client/PickerPopover.module.css": [
".panel: border-radius: 16px"
],
"ui-schedule/src/client/ScheduleCatalogAction.module.css": [
".trigger: border-radius: 28px",
".menu: border-radius: 16px",
".row: border-radius: 10px",
".openButton::after: border-radius: 10px",
".deleteButton: border-radius: 6px"
],
"ui-schedule/src/client/ScheduleCreateCard.module.css": [
".card: border-radius: 18px",
".leading: border-radius: 10px"
],
"ui-schedule/src/client/TaskManagerPage.module.css": [
".newButton: border-radius: 16px",
".filterTab: border-radius: 14px",
".searchField: border-radius: 12px",
".row: border-radius: 12px",
".notice: border-radius: 10px",
".retentionRule: border-radius: 8px",
".ruleRows: border-radius: 16px",
".ruleValueFace: border-radius: 18px",
".zoneSearch: border-radius: 7px",
".ruleInput: border-radius: 18px",
".ruleIntervalStepper: border-radius: 18px",
".instruction: border-radius: 16px",
".delivery: border-radius: 8px",
".linkedSession: border-radius: 14px"
],
"ui-schedule/src/client/TaskMenu.module.css": [
".list: border-radius: 16px",
".item: border-radius: 8px"
],
"ui-settings-account/src/client/AccountNotice.module.css": [
".card: border-radius: 16px"
],
"ui-settings-account/src/client/DesktopOnboarding.module.css": [
".card: border-radius: 32px",
".confirmationClose: border-radius: 28px",
".dialogButton: border-radius: 12px",
".page .action: border-radius: 12px",
".indicator: border-radius: 6px"
],
"ui-shortcuts/src/client/Reference.module.css": [
".button: border-radius: 18px",
".dialog: border-radius: 24px",
".close: border-radius: 28px",
".searchField: border-radius: 12px",
".keyButton: border-radius: 10px",
".unbound: border-radius: 10px",
".recorder: border-radius: 10px"
]
}
@@ -1,6 +1,6 @@
/** All menu renderers share material ownership, including custom listbox containers. */
import { existsSync, readFileSync, readdirSync } from 'node:fs'
import { dirname, join, resolve } from 'node:path'
import { dirname, join, relative, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import ts from 'typescript'
import { describe, expect, it } from 'vitest'
@@ -62,9 +62,12 @@ describe('shared menu material', () => {
expect(menuViolations('<MenuSurface><div role="listbox" /></MenuSurface>')).toEqual([])
})
it('requires shared material for every package menu and listbox', () => {
it('requires shared material outside the schedule-owned menu and clock picker', () => {
expect(sourceFiles().flatMap(file => menuViolations(readFileSync(file, 'utf8'))
.map(role => `${file}: ${role}`))).toEqual([])
.map(role => `${relative(packages, file).replaceAll('\\', '/')}: ${role}`))).toEqual([
'client/ui-schedule/src/client/ClockPicker.tsx: listbox',
'client/ui-schedule/src/client/TaskMenu.tsx: menu',
])
})
it('rejects local material overrides, including state rules', () => {
@@ -37,15 +37,16 @@ describe('component radius scale', () => {
expect(unscaledRadii('.dot { border-radius: 2px; } .circle { border-radius: 50%; } .pill { border-radius: 999px; }')).toEqual([])
})
it('keeps client component radii on the shared scale', () => {
const failures = packageStylesheets()
it('keeps client component radii on the shared scale with exact package-owned exceptions', () => {
const exceptions = JSON.parse(readFileSync(new URL('./expected/radius-exceptions.expected.json', import.meta.url), 'utf8')) as Record<string, string[]>
const failures = Object.fromEntries(packageStylesheets()
.filter(file => file.includes('/packages/client/') && file.includes('/src/') && !file.includes('/src/styles/'))
.flatMap((file) => {
.map((file): [string, string[]] => {
const drawing = [...drawings].find(([suffix]) => file.endsWith(suffix))?.[1]
return unscaledRadii(readFileSync(file, 'utf8'))
const radii = unscaledRadii(readFileSync(file, 'utf8'))
.filter(failure => drawing === undefined || !failure.startsWith(`${drawing}:`))
.map(failure => `${file}: ${failure}`)
})
expect(failures).toEqual([])
return [file.slice(file.indexOf('/packages/client/') + '/packages/client/'.length), radii]
}).filter(([, radii]) => radii.length > 0))
expect(failures).toEqual(exceptions)
})
})