Repository navigation
Commit 691a0bc
feat(studio): the left menu is drawn as the app's menu, in Studio's own graphite (#37478)
repo:objectstack#5 · os-bill · session_01Utp6CbL6Nn3scsU8yvLyU4
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgTC1DCWJ4MisoLdbUU1V1sb)_
Fixes #37452
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:Studio
左侧菜单改成和前端应用菜单一样——分组标题可以点开收起,每一项前面是不带底色的线条图标,当前页是浅灰胶囊加左侧竖条,选中色用 Studio
自己的石墨色,不再跟着应用的主题色变;前端应用菜单本身看起来不变。
- 为什么做:App Studio 改版第一阶段的第一张卡,让 Studio 的导航和前端长得一样,并给后续几张卡准备好 Studio
专用的石墨色。
- 出错会怎样:做 Studio
的人可能看到菜单分组收起后找不到某一项(点分组标题就能展开,搜索时分组会自动展开),或选中色不对;只是样式与折叠,撤回这个改动就恢复原样,不涉及数据。
- 要你做什么:无。
## What changes
- **Groups collapse the way the app menu's do.** The collapsible group
the app menu draws for every `group` entry is now an exported component,
`NavigationGroupSection` with its props type
`NavigationGroupSectionProps` (`@object-ui/layout`, a published package,
hence `Clause-②: yes (widening)`; listed in the package README), and the
app menu renders through it with the same output as before. Studio's
menu draws each of its groups with it: the label is the disclosure
button with the chevron, open by default. While a search lists matches,
every listed group is drawn open, chevron turned down, and a click on
its label is not taken; the author's choice comes back when the search
is cleared. In the phone drawer the label is the app menu's 44 px tap
target. A Studio group still carries no count (ADR-0084, amended: a
number in this menu is an entry's items), so the closed-group count is
optional and Studio passes none.
- **An entry is the app menu's row.** Default `SidebarMenuButton` size
(was `sm`), a bare line icon before the name with no tile (the
maintainer's 「可以不要背景」), the muted item count at the right; the selected
entry's count is not muted. Each listed type has its own icon (a
module-local map in `StudioMenu.tsx`; an unmapped type draws its group's
icon); entries that are not a type draw one per kind. The group label no
longer draws a group icon, matching mockup 1.
- **Studio's own accent.** `studio-tokens.ts` gains `STUDIO_ACCENT_HSL`
/ `STUDIO_ACCENT_FOREGROUND_HSL` (graphite, light and dark) and
`STUDIO_ACCENT`, a class string that rebinds every theme token the app's
branding writes on the page root: `--primary`, `--primary-foreground`,
`--ring`, `--sidebar-primary`, `--sidebar-ring` to graphite, and
`--accent` / `--accent-foreground` (written from the app's
`accentColor`) to a faint graphite tint (`STUDIO_ACCENT_TINT_HSL`),
since in this theme `--accent` is the hover tint, not a strong colour.
It re-derives Tailwind's `--color-*` from them on the same element. The
menu wraps its header and body in it, so the front end's existing
selected-row rule (the pill and its 2 px left bar, which read the
theme's primary) draws graphite in Studio, docked or in the phone
drawer, whatever the app's theme colour is. Mounting the accent on the
whole Studio root is left to the later card that owns the surface.
- Untouched, as ruled: the sidebar primitive, `StudioDesignSurface.tsx`,
the top bar.
## Tests
- `StudioMenu.test.tsx`, a new top-level describe: the group label is a
disclosure button, open by default, closing it hides only its entries
and draws no count; a search lists matches in a group the author closed
with its chevron turned down, a click during the search is not taken (on
a closed group and on an open one), and clearing it restores the
author's choice; in the phone drawer the label is 44 px
(`min-h-[44px]`), docked it is not; each entry draws a bare line icon as
the row's first child; the current entry is the primitive's active row
and only it; with a non-default app theme applied through the app
shell's own branding hook (a rose primary and an amber accent on the
page root, the control), every theme token the hook wrote is rebound to
graphite, light and dark, on an ancestor of the selected entry, with
nothing in between writing one back.
- `studio-tokens.test.ts` (new): the literal class string's values equal
the constants in both themes (the accent pair included), graphite is a
neutral, the hover tint is faint, and the `--color-*` tokens are
re-derived.
- Existing pins updated where this card made them false: the two
StudioMenu group-label assertions (a label was "a muted heading, not
focusable"), and the Access-segment pin's glyph check in
`StudioDesignSurface.accessSegment-12452.test.tsx` (the shield moved
from the group label to the permission-set entry).
## Acceptance notes
- **Read first** (by risk):
`ui/packages/layout/src/NavigationRenderer.tsx` (the extracted
`NavigationGroupSection`; the app menu's `group` arm now renders through
it and must draw the same DOM),
`ui/packages/app-shell/src/views/studio-design/studio-tokens.ts`
(`STUDIO_ACCENT`),
`ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx` (the
accent wrapper and the group sections).
- **File-surface note:** the claim's surface did not name
`StudioDesignSurface.accessSegment-12452.test.tsx`; its glyph assertion
pinned the group-label icon this card removes, so it is updated here
(test only; the component file is untouched). The seat ratified it (L1
7186198980) and extended the surface to `ui/packages/layout/README.md`.
- The command palette's Studio groups still draw each type item with its
group's icon, so the menu and the palette now draw different icons for a
type, and the `studioMenuData.ts` header's "the two draw the same types,
icons and names" is no longer true for icons. Neither file was in this
card's surface. Carrier: #37424.
- On a package, a search draws the groups flat (outside the 高级 fold), so
clearing the search remounts the tiered groups open: a group the author
closed before searching comes back open. On `~org` / `~all` the closed
state survives a search (pinned).
- Real-browser check (Chromium, 1440x900 at 2x, light and dark, head
803afb6): readings and screenshots are in the final-head comment on
this PR.
## Verification
Two-minute check: open any Studio page under an app with a non-default
theme colour (for example a rose `primaryColor`). Expected: the left
menu's group headers have a chevron and collapse on click, every entry
has a line icon with no tile, and the open page's entry is a grey pill
with a dark graphite bar on its left (light grey in dark mode), not the
app's colour.
<details><summary>Local runs (head 803afb6)</summary>
- `pnpm --dir ui exec vitest run --maxWorkers=2
packages/app-shell/src/views/studio-design/StudioMenu.test.tsx
packages/app-shell/src/views/studio-design/studio-tokens.test.ts
packages/app-shell/src/views/studio-design/StudioDesignSurface.accessSegment-12452.test.tsx
packages/layout/` under the verify lock (head 453b097): `Test Files 53
passed (53)`, `Tests 448 passed (448)`; StudioMenu and studio-tokens on
803afb6: `Tests 40 passed (40)`.
- `pnpm --dir ui exec vitest run --maxWorkers=2
packages/app-shell/src/views/studio-design/
packages/app-shell/src/layout/ packages/app-shell/src/views/__tests__/`
(head 41fc38d): `Tests 1 failed / 4659 passed`; the one failure was the
Access-segment glyph pin, updated in bca58d4 and green since (4 of 4).
- `pnpm --filter @object-ui/layout type-check`, `pnpm --filter
@object-ui/layout build`, `pnpm --filter @object-ui/app-shell build` (on
b1dc4ad), `pnpm --filter @object-ui/app-shell type-check` (includes the
test project; re-run on 803afb6): exit 0.
- `pnpm exec eslint` on the six changed UI files: 0 errors; no new
warning in the Studio files.
- `dispatch-gates --commands` derived 38 commands for this diff; all 38
exit 0 on 803afb6; `--ran` reconciliation with exit codes: 38 derived,
38 run, 0 NOT-MEASURED (a derived zero).
- `pnpm check:new-line-citations`: 0 new citations.
</details>
<details><summary>Ablations (each mutation landed and restored by
`scripts/ablation-replace.mjs`, blob back to HEAD, `git diff HEAD`
empty)</summary>
- On b1dc4ad, the accent wrapper without `STUDIO_ACCENT`: the
graphite-under-a-non-default-theme test goes red (1 failed / 32 passed).
- On 803afb6: `open={open || searching}` to `open={open}`: the search
test red (1 failed / 39 passed); back to the old shape `open={open}
forceOpen={searching}`: red on the chevron's `rotate-90`; `onOpenChange`
always `setOpen`: "a click on an open group's label during a search is
not taken" red; `isMobile={false}`: the 44 px tap-target test red; the
accent pair dropped from `STUDIO_ACCENT`: the light-theme tokens test
and the every-theme-token test red.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CbL6Nn3scsU8yvLyU4)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent e0b0471 commit 691a0bc
8 files changed
Lines changed: 656 additions & 148 deletions
File tree
- .changeset
- ui/packages
- app-shell/src/views/studio-design
- layout
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | | - | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
208 | 209 | | |
209 | 210 | | |
210 | 211 | | |
211 | | - | |
| 212 | + | |
212 | 213 | | |
213 | | - | |
| 214 | + | |
214 | 215 | | |
215 | 216 | | |
216 | 217 | | |
| |||
230 | 231 | | |
231 | 232 | | |
232 | 233 | | |
233 | | - | |
234 | | - | |
| 234 | + | |
| 235 | + | |
235 | 236 | | |
236 | 237 | | |
237 | 238 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
31 | 42 | | |
32 | 43 | | |
33 | 44 | | |
34 | 45 | | |
35 | 46 | | |
| 47 | + | |
36 | 48 | | |
37 | 49 | | |
38 | 50 | | |
| |||
63 | 75 | | |
64 | 76 | | |
65 | 77 | | |
| 78 | + | |
66 | 79 | | |
67 | 80 | | |
| 81 | + | |
68 | 82 | | |
69 | 83 | | |
70 | 84 | | |
| |||
234 | 248 | | |
235 | 249 | | |
236 | 250 | | |
237 | | - | |
| 251 | + | |
238 | 252 | | |
239 | 253 | | |
240 | 254 | | |
241 | 255 | | |
242 | | - | |
243 | | - | |
| 256 | + | |
244 | 257 | | |
245 | 258 | | |
246 | 259 | | |
| |||
407 | 420 | | |
408 | 421 | | |
409 | 422 | | |
410 | | - | |
| 423 | + | |
411 | 424 | | |
412 | 425 | | |
413 | 426 | | |
| |||
418 | 431 | | |
419 | 432 | | |
420 | 433 | | |
421 | | - | |
| 434 | + | |
422 | 435 | | |
423 | 436 | | |
424 | 437 | | |
| |||
486 | 499 | | |
487 | 500 | | |
488 | 501 | | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
0 commit comments