|
31 | 31 | * objectstack#37452 — drawn as the app's menu: |
32 | 32 | * 11. A group is the app menu's collapsible group: its label is a disclosure |
33 | 33 | * 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. |
35 | 36 | * 12. An entry draws a bare line icon before its name; the current entry is |
36 | 37 | * the primitive's active row (the pill and left bar). |
37 | 38 | * 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. |
39 | 41 | * |
40 | 42 | * The provider, the sidebar primitive and the router are real; only the |
41 | 43 | * metadata reads are doubled. |
@@ -535,9 +537,31 @@ describe('drawn as the app\'s menu (objectstack#37452)', () => { |
535 | 537 | fireEvent.change(screen.getByTestId('studio-menu-search'), { target: { value: 'position' } }); |
536 | 538 | expect(entry('type:position')).toBeVisible(); |
537 | 539 | 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(); |
538 | 548 | // The author's choice is kept: clearing the search closes it again. |
539 | 549 | fireEvent.change(screen.getByTestId('studio-menu-search'), { target: { value: '' } }); |
540 | 550 | 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]'); |
541 | 565 | }); |
542 | 566 |
|
543 | 567 | 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)', () => { |
569 | 593 | const ROOT_TOKENS = ['--primary', '--primary-foreground', '--ring', '--sidebar-primary', '--sidebar-ring', '--accent', '--accent-foreground']; |
570 | 594 |
|
571 | 595 | 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' }); |
574 | 598 | return <>{children}</>; |
575 | 599 | } |
576 | 600 |
|
577 | 601 | afterEach(() => { |
578 | 602 | 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); |
580 | 604 | }); |
581 | 605 |
|
582 | 606 | /** 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)', () => { |
606 | 630 | (token) => token.startsWith('--') && !token.startsWith('--brand-'), |
607 | 631 | ); |
608 | 632 | expect(written).toContain('--primary'); |
| 633 | + expect(written).toContain('--accent'); |
609 | 634 | expect(root.getPropertyValue('--primary').trim()).not.toBe(STUDIO_ACCENT_HSL.light); |
610 | 635 |
|
611 | 636 | // The selected entry is the active row, and it sits inside Studio's accent scope. |
|
0 commit comments