Skip to content

Commit 453b097

Browse files
committed
fix(studio): a searched group's chevron and tap target follow the app menu; the accent pair is rebound too
Claude-Session: https://claude.ai/code/session_01Utp6CbL6Nn3scsU8yvLyU4 Co-authored-by: Claude <noreply@anthropic.com>
1 parent b1dc4ad commit 453b097

6 files changed

Lines changed: 88 additions & 21 deletions

File tree

‎.changeset/37452-studio-menu-front-end-style.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
feat(studio): the Studio left menu is drawn as the app's menu, in Studio's own graphite
77

8-
Clause-②: no
8+
Clause-②: yes (widening)
99
Metadata-protocol: none
1010

11-
- **Groups collapse the way the app menu's do.** Each of the menu's groups is the app menu's collapsible group: its label is a disclosure button with a chevron, open by default, and a search opens every group it lists. A group still carries no count: a number in the Studio menu is an entry's items.
11+
- **Groups collapse the way the app menu's do.** Each of the menu's groups is the app menu's collapsible group: its label is a disclosure button with a chevron, open by default; a search opens every group it lists, chevron included, and holds it open; in the phone drawer the label is the app menu's 44 px tap target. A group still carries no count: a number in the Studio menu is an entry's items.
1212
- **An entry is the app menu's row.** It draws a bare line icon (no tile) before its name, at the app menu's row size; the open page's entry is the app menu's inset pill with a bar on its left edge.
13-
- **Studio's own accent.** The pill and the bar are graphite, light and dark, whatever the app's theme colour is (`STUDIO_ACCENT` in the Studio tokens); only the app's logo keeps the app's colour.
14-
- **New export: `NavigationGroupSection`** (`@object-ui/layout`), the collapsible sidebar group the app menu draws every `group` entry with. The app menu renders exactly as before.
13+
- **Studio's own accent.** The pill and the bar are graphite, light and dark, whatever the app's theme colour is (`STUDIO_ACCENT` in the Studio tokens); the app's `accentColor` no longer reaches anything under that class either: its hover tint is a faint graphite. Only the app's logo keeps the app's colour.
14+
- **New exports: `NavigationGroupSection` and its props type `NavigationGroupSectionProps`** (`@object-ui/layout`), the collapsible sidebar group the app menu draws every `group` entry with. The app menu renders exactly as before.

‎ui/packages/app-shell/src/views/studio-design/StudioMenu.test.tsx‎

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@
3131
* objectstack#37452 — drawn as the app's menu:
3232
* 11. A group is the app menu's collapsible group: its label is a disclosure
3333
* button, open by default; closing it hides its entries; a search opens
34-
* every group it lists.
34+
* every group it lists, chevron included, and holds it open; in the phone
35+
* drawer the label is the app menu's 44 px tap target.
3536
* 12. An entry draws a bare line icon before its name; the current entry is
3637
* the primitive's active row (the pill and left bar).
3738
* 13. The selected entry is tinted by Studio's graphite accent whatever the
38-
* app's theme colour is.
39+
* app's theme colours are: every theme token the app's branding writes
40+
* (primary and accent) is rebound over it.
3941
*
4042
* The provider, the sidebar primitive and the router are real; only the
4143
* metadata reads are doubled.
@@ -535,9 +537,31 @@ describe('drawn as the app\'s menu (objectstack#37452)', () => {
535537
fireEvent.change(screen.getByTestId('studio-menu-search'), { target: { value: 'position' } });
536538
expect(entry('type:position')).toBeVisible();
537539
expect(groupLabel('studio-menu-group-security')).toHaveAttribute('aria-expanded', 'true');
540+
// Drawn open, chevron included: the chevron is turned down as on any open group.
541+
const chevron = () => groupLabel('studio-menu-group-security').querySelector('svg')!;
542+
expect(chevron()).toHaveClass('rotate-90');
543+
// A click while the search holds it open changes nothing.
544+
fireEvent.click(groupLabel('studio-menu-group-security'));
545+
expect(groupLabel('studio-menu-group-security')).toHaveAttribute('aria-expanded', 'true');
546+
expect(chevron()).toHaveClass('rotate-90');
547+
expect(entry('type:position')).toBeVisible();
538548
// The author's choice is kept: clearing the search closes it again.
539549
fireEvent.change(screen.getByTestId('studio-menu-search'), { target: { value: '' } });
540550
expect(screen.queryByTestId('studio-menu-entry-type:position')).toBeNull();
551+
expect(chevron()).not.toHaveClass('rotate-90');
552+
});
553+
554+
it('in the phone drawer a group\'s label is the app menu\'s 44 px tap target; CONTROL: docked it is not', async () => {
555+
setWidth(390);
556+
renderAt(`/studio/${PKG}/data`);
557+
fireEvent.click(toggle());
558+
const drawer = await screen.findByRole('dialog');
559+
const label = within(drawer).getByTestId('studio-menu-group-data').querySelector('[data-sidebar="group-label"]')!;
560+
expect(label).toHaveClass('min-h-[44px]');
561+
cleanup();
562+
setWidth(1280);
563+
renderAt(`/studio/${PKG}/data`);
564+
expect(groupLabel('studio-menu-group-data')).not.toHaveClass('min-h-[44px]');
541565
});
542566

543567
it('an entry draws a bare line icon before its name, on the app menu\'s row', () => {
@@ -569,14 +593,14 @@ describe('drawn as the app\'s menu (objectstack#37452)', () => {
569593
const ROOT_TOKENS = ['--primary', '--primary-foreground', '--ring', '--sidebar-primary', '--sidebar-ring', '--accent', '--accent-foreground'];
570594

571595
function Branded({ children }: { children: ReactNode }) {
572-
// A non-default app theme: a rose primary, written on the page root by the app shell's own hook.
573-
useAppShellBranding({ primaryColor: '#e11d48' });
596+
// A non-default app theme: a rose primary and an amber accent, written on the page root by the app shell's own hook.
597+
useAppShellBranding({ primaryColor: '#e11d48', accentColor: '#f59e0b' });
574598
return <>{children}</>;
575599
}
576600

577601
afterEach(() => {
578602
for (const token of ROOT_TOKENS) document.documentElement.style.removeProperty(token);
579-
for (const token of ['--brand-primary', '--brand-primary-hsl']) document.documentElement.style.removeProperty(token);
603+
for (const token of ['--brand-primary', '--brand-primary-hsl', '--brand-accent', '--brand-accent-hsl']) document.documentElement.style.removeProperty(token);
580604
});
581605

582606
/** The declarations a class string makes: `[--x:a_b]` and `dark:[--x:a_b]`, underscores read as spaces. */
@@ -606,6 +630,7 @@ describe('drawn as the app\'s menu (objectstack#37452)', () => {
606630
(token) => token.startsWith('--') && !token.startsWith('--brand-'),
607631
);
608632
expect(written).toContain('--primary');
633+
expect(written).toContain('--accent');
609634
expect(root.getPropertyValue('--primary').trim()).not.toBe(STUDIO_ACCENT_HSL.light);
610635

611636
// The selected entry is the active row, and it sits inside Studio's accent scope.

‎ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,18 +196,25 @@ function studioMenuEntryIcon(entry: StudioMenuEntry, group: StudioMenuGroup | nu
196196

197197
/**
198198
* One group of the menu: the app menu's collapsible group, open until the
199-
* author closes it, and open whatever its state while a search lists matches.
199+
* author closes it. While a search lists matches the group is drawn open,
200+
* chevron included, and a click on its label changes nothing: the author's
201+
* own choice comes back when the search is cleared. In the phone drawer its
202+
* label is the app menu's 44 px tap target.
200203
*/
204+
function ignoreOpenChange(): void {}
205+
201206
function StudioMenuGroupSection({
202207
label,
203208
labelId,
204209
searching,
210+
isMobile,
205211
testId,
206212
children,
207213
}: {
208214
label: string;
209215
labelId: string;
210216
searching: boolean;
217+
isMobile: boolean;
211218
testId: string;
212219
children: React.ReactNode;
213220
}): React.ReactElement {
@@ -216,9 +223,9 @@ function StudioMenuGroupSection({
216223
<NavigationGroupSection
217224
label={label}
218225
labelId={labelId}
219-
open={open}
220-
onOpenChange={setOpen}
221-
forceOpen={searching}
226+
open={open || searching}
227+
onOpenChange={searching ? ignoreOpenChange : setOpen}
228+
isMobile={isMobile}
222229
data-testid={testId}
223230
>
224231
{children}
@@ -402,6 +409,7 @@ function StudioMenuBody({
402409
label={studioMenuGroupLabel(group, locale)}
403410
labelId={`${searchId}-${tier}-${group}`}
404411
searching={searching}
412+
isMobile={isMobile}
405413
testId={tier === 'advanced' ? `studio-menu-advanced-group-${group}` : `studio-menu-group-${group}`}
406414
>
407415
{entries.map((entry) => renderEntry(entry, group))}

‎ui/packages/app-shell/src/views/studio-design/studio-tokens.test.ts‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
*/
99

1010
import { describe, expect, it } from 'vitest';
11-
import { STUDIO_ACCENT, STUDIO_ACCENT_FOREGROUND_HSL, STUDIO_ACCENT_HSL } from './studio-tokens';
11+
import {
12+
STUDIO_ACCENT,
13+
STUDIO_ACCENT_FOREGROUND_HSL,
14+
STUDIO_ACCENT_HSL,
15+
STUDIO_ACCENT_TINT_FOREGROUND_HSL,
16+
STUDIO_ACCENT_TINT_HSL,
17+
} from './studio-tokens';
1218

1319
/** The declarations the class string makes in one theme: `[--x:a_b]` / `dark:[--x:a_b]`, underscores read as spaces. */
1420
function declarations(dark: boolean): Map<string, string> {
@@ -30,6 +36,15 @@ describe('STUDIO_ACCENT (objectstack#37452)', () => {
3036
expect(decl.get(token), token).toBe(STUDIO_ACCENT_HSL[theme]);
3137
}
3238
expect(decl.get('--primary-foreground')).toBe(STUDIO_ACCENT_FOREGROUND_HSL[theme]);
39+
// The hover tint: a faint graphite, never graphite itself.
40+
expect(decl.get('--accent')).toBe(STUDIO_ACCENT_TINT_HSL[theme]);
41+
expect(decl.get('--accent-foreground')).toBe(STUDIO_ACCENT_TINT_FOREGROUND_HSL[theme]);
42+
});
43+
44+
it('the hover tint is a faint neutral: near white in the light theme, near black in the dark one', () => {
45+
const lightness = (hsl: string) => Number.parseFloat(hsl.split(' ')[2]);
46+
expect(lightness(STUDIO_ACCENT_TINT_HSL.light)).toBeGreaterThan(90);
47+
expect(lightness(STUDIO_ACCENT_TINT_HSL.dark)).toBeLessThan(25);
3348
});
3449

3550
it('graphite is a neutral: low saturation in both themes, dark in the light theme and light in the dark one', () => {
@@ -50,6 +65,8 @@ describe('STUDIO_ACCENT (objectstack#37452)', () => {
5065
['--color-ring', '--ring'],
5166
['--color-sidebar-primary', '--sidebar-primary'],
5267
['--color-sidebar-ring', '--sidebar-ring'],
68+
['--color-accent', '--accent'],
69+
['--color-accent-foreground', '--accent-foreground'],
5370
]) {
5471
expect(decl.get(color), color).toBe(`hsl(var(${token}))`);
5572
}

‎ui/packages/app-shell/src/views/studio-design/studio-tokens.ts‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,27 @@
2323
export const STUDIO_ACCENT_HSL = { light: '220 9% 23%', dark: '220 9% 83%' } as const;
2424
/** Text drawn on the accent, light and dark. */
2525
export const STUDIO_ACCENT_FOREGROUND_HSL = { light: '0 0% 100%', dark: '220 13% 9%' } as const;
26+
/**
27+
* The theme's `--accent` is its hover and highlight tint (a ghost button's or
28+
* a menu item's hover), not a strong colour, so Studio rebinds it to a faint
29+
* graphite tint, not to graphite itself; the app's branding writes it from
30+
* the app's `accentColor`.
31+
*/
32+
export const STUDIO_ACCENT_TINT_HSL = { light: '220 9% 94%', dark: '220 9% 18%' } as const;
33+
/** Text drawn on the tint, light and dark. */
34+
export const STUDIO_ACCENT_TINT_FOREGROUND_HSL = { light: '220 13% 9%', dark: '220 9% 96%' } as const;
2635

2736
/**
2837
* The class that makes Studio's accent the theme's primary inside an
2938
* element: everything under it that the app's theme colour would tint (the
3039
* selected menu entry's pill and left bar, focus rings, `bg-primary` /
3140
* `text-primary`) draws graphite instead, whatever colour the app's branding
32-
* wrote on the page root. It rebinds the theme's tokens (`--primary`,
33-
* `--ring`, `--sidebar-primary`, `--sidebar-ring`, the foreground) to
34-
* {@link STUDIO_ACCENT_HSL} and {@link STUDIO_ACCENT_FOREGROUND_HSL}, light
35-
* and dark, and re-derives Tailwind's `--color-*` from them on the same
41+
* wrote on the page root. It rebinds every theme token that branding
42+
* writes: `--primary`, `--ring`, `--sidebar-primary`, `--sidebar-ring` and
43+
* the foreground to {@link STUDIO_ACCENT_HSL} and
44+
* {@link STUDIO_ACCENT_FOREGROUND_HSL}, and `--accent` with its foreground to
45+
* {@link STUDIO_ACCENT_TINT_HSL} and {@link STUDIO_ACCENT_TINT_FOREGROUND_HSL},
46+
* light and dark. It re-derives Tailwind's `--color-*` from them on the same
3647
* element, because those are computed once on the page root and inherited
3748
* with the app's colour already in them.
3849
*
@@ -42,13 +53,16 @@ export const STUDIO_ACCENT_FOREGROUND_HSL = { light: '0 0% 100%', dark: '220 13%
4253
*
4354
* A literal class string: Tailwind finds a class by scanning source, so the
4455
* values are spelled here again; `studio-tokens.test.ts` holds them equal to
45-
* the two constants above.
56+
* the four constants above.
4657
*/
4758
export const STUDIO_ACCENT =
4859
'[--primary:220_9%_23%] [--primary-foreground:0_0%_100%] [--ring:220_9%_23%] [--sidebar-primary:220_9%_23%] [--sidebar-ring:220_9%_23%] ' +
60+
'[--accent:220_9%_94%] [--accent-foreground:220_13%_9%] ' +
4961
'dark:[--primary:220_9%_83%] dark:[--primary-foreground:220_13%_9%] dark:[--ring:220_9%_83%] dark:[--sidebar-primary:220_9%_83%] dark:[--sidebar-ring:220_9%_83%] ' +
62+
'dark:[--accent:220_9%_18%] dark:[--accent-foreground:220_9%_96%] ' +
5063
'[--color-primary:hsl(var(--primary))] [--color-primary-foreground:hsl(var(--primary-foreground))] [--color-ring:hsl(var(--ring))] ' +
51-
'[--color-sidebar-primary:hsl(var(--sidebar-primary))] [--color-sidebar-ring:hsl(var(--sidebar-ring))]';
64+
'[--color-sidebar-primary:hsl(var(--sidebar-primary))] [--color-sidebar-ring:hsl(var(--sidebar-ring))] ' +
65+
'[--color-accent:hsl(var(--accent))] [--color-accent-foreground:hsl(var(--accent-foreground))]';
5266

5367
/**
5468
* Shell header (objectui#12509). One 48 px row at every width, two columns:

‎ui/packages/layout/README.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ The `responsive-grid` and `navigation-renderer` keys are retired too (objectui#1
4646
A breakpoint grid is the `grid` node with a breakpoint `columns` object
4747
(`{ "type": "grid", "columns": { "xs": 1, "md": 2 }, "gap": 4 }`), and navigation is
4848
application metadata: the app's `navigation` items, drawn by the shell.
49-
`ResponsiveGrid` and `NavigationRenderer` stay exports for JSX composition.
49+
`ResponsiveGrid` and `NavigationRenderer` stay exports for JSX composition, and so does
50+
`NavigationGroupSection` (props `NavigationGroupSectionProps`): the collapsible sidebar group
51+
`NavigationRenderer` draws every `group` entry with, for a host that draws its own menu and wants
52+
the same group header (Studio's left menu is one).
5053

5154
## Components
5255

0 commit comments

Comments
 (0)