Skip to content

Commit 31b0537

Browse files
os-zhuangclaude
andauthored
docs(protocol): widget-contract 的 Theme 段停止教 #3494 已删除的 density,token 词表按 #5021 重写 (#5291) (#5454)
`content/docs/protocol/objectui/widget-contract.mdx` 的 Theme 段散文与 YAML 示例 都在教 `density`(「`density` is one of `compact`, `regular`, or `spacious`」+ 示例里的 `density: regular`)。该键在 #3494 就被删了,而 `ThemeSchema` 自 #4001 批 15 起是 `.strict()` —— 照抄本页示例必然 parse 失败。拒绝本身是响亮且带处方的 (`THEME_RETIRED_KEY_GUIDANCE` 的 `density` 墓碑),问题在于平台自己的权威文档把 作者送进了那次拒绝;对从这一页取样写主题的 AI 作者尤其贵。 原示例其实有两处解析失败——除 `density` 外,`colors:` 下只有一行注释,YAML 解析成 `null`,而 `colors` 必填且其 `primary` 必填。现在的示例是一份真能通过 `ThemeSchema` 解析的完整主题。 同时把整段 token 词表刷新到 #5021 之后: - 逐一列出 `ThemeSchema` 的十个可写键,并给出每个键实际落到 document 上的 CSS 变量 ——`colors` 出门时的改名(`surface` → `--card`、`text` → `--foreground`、 `error` → `--destructive` …)、`borderRadius.base` / `shadows.base` 发裸 `--radius` / `--shadow`、`typography` 自 #5021 起只剩 `fontFamily.base` (发 `--font-sans`)、`customVars` 逐字发出。 - 新增 Callout 点名两批退役键:#3494 的八个,以及 #5021(`@objectstack/spec` 17.0.0, ADR-0049)的 `animation` / `zIndex`、`typography` 四条排版标尺、 `fontFamily.heading` / `mono`;处方统一是 `customVars`(逐字节等价替代),并给出 `os migrate meta --from 16`。 每条断言都对着 `packages/spec/src/ui/theme.zod.ts` 与 objectui `ThemeEngine.ts` 逐键核过:16 个退役键全部被拒、10 个活键全部被接受。 不碰 `content/docs/references/**` 与 `content/docs/releases/`。Docs-only。 Claude-Session: https://claude.ai/code/session_01GX3sL71LFq8m2usg6VqTSE Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3681d2a commit 31b0537

2 files changed

Lines changed: 73 additions & 4 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
---
3+
4+
docs(protocol): `protocol/objectui/widget-contract` 的 Theme 段停止教 #3494 已删除的 `density`,整段 token 词表按 #5021 的退役结果重写 (#5291)
5+
6+
该页 Theme 段的散文与 YAML 示例都在教 `density`(「`density` is one of `compact`,
7+
`regular`, or `spacious`」+ 示例里的 `density: regular`)。这个键在 #3494 就被删了,
8+
`ThemeSchema`#4001 批 15 起是 `.strict()` —— 两件事叠加的结果是**照抄本页示例
9+
必然 parse 失败**:`defineStack({ themes })` / `defineTheme()` 都会拒。拒绝本身是响亮
10+
且带处方的(`THEME_RETIRED_KEY_GUIDANCE``density` 的墓碑),问题在于平台自己的权威
11+
文档把作者送进了那次拒绝——对从这一页取样写主题的 AI 作者尤其贵。
12+
13+
原示例其实有**两处**解析失败:除 `density` 外,`colors:` 下只有一行注释,YAML 解析成
14+
`null`,而 `colors` 是必填且 `primary` 必填。现在的示例是一份真能通过 `ThemeSchema`
15+
解析的完整主题。
16+
17+
同时把整段的 token 词表口径刷新到 #5021 之后:
18+
19+
- 逐一列出 `ThemeSchema`**十个**可写键(`name` / `label` / `description` / `mode` /
20+
`extends` 五个身份与继承键,加 `colors` / `borderRadius` / `shadows` / `typography` /
21+
`customVars` 五个 token 键),并给出每个键实际落到 document 上的 CSS 变量——包括
22+
`colors` 出门时的改名(`surface``--card``text``--foreground`
23+
`error``--destructive` …)、`borderRadius.base` / `shadows.base` 发的是裸
24+
`--radius` / `--shadow``typography`#5021 起只剩 `fontFamily.base`(发
25+
`--font-sans`)。
26+
- 新增一段 Callout 点名两批退役键:#3494`spacing` / `breakpoints` / `logo` /
27+
`density` / `wcagContrast` / `rtl` / `touchTarget` / `keyboardNavigation`,以及 #5021
28+
(`@objectstack/spec` 17.0.0, ADR-0049)的 `animation` / `zIndex``typography` 四条
29+
排版标尺、`fontFamily.heading` / `mono`;两批的处方都是 `customVars`,且是逐字节等价
30+
的替代(`customVars` 里写 `font-size-lg` 发的就是同一个 `--font-size-lg`),并给出
31+
`os migrate meta --from 16`
32+
33+
页面的每条断言都对着 `packages/spec/src/ui/theme.zod.ts` 与 objectui `ThemeEngine.ts`
34+
逐键核过:16 个退役键全部被拒、10 个活键全部被接受。
35+
36+
Docs-only;releases nothing.

content/docs/protocol/objectui/widget-contract.mdx

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,21 +316,54 @@ The widget manifest carries **no** performance block. Virtualization for large d
316316

317317
## Theme
318318

319-
ObjectUI theming is defined by `ThemeSchema` in `packages/spec/src/ui/theme.zod.ts`. A theme requires a `name`, `label`, and `colors` palette. The `mode` is one of `light`, `dark`, or `auto`, and `density` is one of `compact`, `regular`, or `spacious`. `borderRadius` is a scale object (`none`/`sm`/`base`/`md`/`lg`/...), not a single token:
319+
ObjectUI theming is defined by `ThemeSchema` in `packages/spec/src/ui/theme.zod.ts`, and it declares **ten** authorable keys — that list is the whole vocabulary. Five of them are identity and inheritance: `name` (a snake_case identifier) and `label` are required, `description` is optional, `mode` is one of `light`, `dark`, or `auto` (default `light`), and `extends` names another theme to inherit from. The other five are the token surface:
320+
321+
| Key | Required | Shape | What it puts on the document |
322+
|-------|-------|-------|-------|
323+
| `colors` | ✅ | `ColorPalette`; only `primary` is mandatory inside it | The shadcn palette variables — **renamed on the way out**: `surface` emits `--card`, `text` emits `--foreground`, `textSecondary` emits `--muted-foreground`, `disabled` emits `--muted`, `error` emits `--destructive`. |
324+
| `borderRadius` | — | A scale object (`none`/`sm`/`base`/`md`/`lg`/`xl`/`2xl`/`full`), not a single token | `--radius-sm`, `--radius-md`, ... — and `base` emits the bare `--radius`. |
325+
| `shadows` | — | The same stops plus `inner` | `--shadow-sm`, `--shadow-md`, ... — and `base` emits the bare `--shadow`. |
326+
| `typography` | — | One live key since #5021: `fontFamily.base` | `--font-sans`. |
327+
| `customVars` | — | A flat string map | Every entry verbatim, `--` prefixed if you omit it: `z-modal: '1050'` emits `--z-modal: 1050`. This is the declared door for any other custom property. |
320328

321329
```yaml
322330
name: corporate
323331
label: Corporate
324332
mode: light
325-
density: regular
326333
colors:
327-
# ColorPalette configuration
334+
primary: '#2563eb'
335+
surface: '#ffffff'
336+
text: '#111827'
328337
borderRadius:
329338
base: 0.25rem
330339
md: 0.375rem
340+
shadows:
341+
base: '0 1px 3px rgb(0 0 0 / 0.1)'
342+
typography:
343+
fontFamily:
344+
base: 'Inter, system-ui, sans-serif'
345+
customVars:
346+
space-4: 1rem
331347
```
332348

333-
Widgets inherit the active theme automatically; they do not each carry a full set of color/typography props.
349+
`ThemeSchema` is `.strict()` (#4001), so a key outside that list is a **parse failure** at `defineStack({ themes })` / `defineTheme()`, carrying its own prescription — not a value silently dropped while the theme still reports valid.
350+
351+
<Callout type="warn">
352+
**Older theme samples no longer parse** — check yours before copying it forward.
353+
**#3494** removed `spacing`, `breakpoints`, `logo`, `density`, `wcagContrast`,
354+
`rtl`, `touchTarget` and `keyboardNavigation`: the theme engine never emitted a
355+
variable for any of them, so authoring one was a silent no-op. **#5021**
356+
(`@objectstack/spec` 17.0.0, ADR-0049) removed `animation`, `zIndex`, the
357+
`typography.fontSize` / `fontWeight` / `lineHeight` / `letterSpacing` scales and
358+
`typography.fontFamily.heading` / `mono`: those *were* emitted, faithfully and
359+
for years, but no first-party component or stylesheet has ever read one.
360+
The prescription in both waves is `customVars`, and it is a byte-for-byte
361+
replacement — `customVars` carrying `font-size-lg: 1.125rem` puts exactly the
362+
same `--font-size-lg` on the document the retired scale did. Run
363+
`os migrate meta --from 16` to rewrite stored metadata automatically.
364+
</Callout>
365+
366+
Widgets inherit the active theme automatically; they do not each carry their own copy of the palette or the font stack.
334367

335368
## What's Next?
336369

0 commit comments

Comments
 (0)