@shellui/core 0.7.0-alpha.8 → 0.7.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +1 -1
  2. package/package.json +23 -6
  3. package/src/components/ui/drawer.tsx +47 -30
  4. package/src/components/ui/sheet.tsx +18 -12
  5. package/src/components/ui/shell-divider.spec.tsx +63 -0
  6. package/src/components/ui/shell-divider.tsx +20 -0
  7. package/src/components/ui/sidebar.tsx +26 -12
  8. package/src/components/ui/tooltip.tsx +4 -2
  9. package/src/features/admin/AdminView.tsx +9 -6
  10. package/src/features/auth/AuthProvider.tsx +10 -1
  11. package/src/features/auth/components/LoginButton.spec.tsx +203 -0
  12. package/src/features/auth/components/LoginButton.tsx +77 -28
  13. package/src/features/auth/components/LoginButtonIcons.tsx +4 -8
  14. package/src/features/auth/utils/index.ts +1 -0
  15. package/src/features/auth/utils/resolveSdkLoginRedirectPath.spec.ts +41 -0
  16. package/src/features/auth/utils/resolveSdkLoginRedirectPath.ts +31 -0
  17. package/src/features/chromeActions/ChromeActionsHost.tsx +5 -1
  18. package/src/features/chromeActions/computeActionInsets.ts +7 -4
  19. package/src/features/layouts/OverlayShell.tsx +58 -40
  20. package/src/features/layouts/appbar/AppBarItemIcon.spec.tsx +45 -0
  21. package/src/features/layouts/appbar/AppBarItemIcon.tsx +19 -0
  22. package/src/features/layouts/appbar/AppBarLayout.tsx +115 -110
  23. package/src/features/layouts/appbar/appBarOverflow.spec.ts +27 -0
  24. package/src/features/layouts/appbar/appBarOverflow.ts +42 -0
  25. package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +13 -24
  26. package/src/features/layouts/chrome/ContentDragOverlay.tsx +5 -6
  27. package/src/features/layouts/chrome/DesktopChrome.tsx +37 -0
  28. package/src/features/layouts/chrome/DesktopHistoryButtons.tsx +15 -4
  29. package/src/features/layouts/chrome/MacStrip.tsx +33 -0
  30. package/src/features/layouts/chrome/constants.ts +36 -8
  31. package/src/features/layouts/chrome/index.ts +8 -0
  32. package/src/features/layouts/chrome/stripDragMap.ts +35 -0
  33. package/src/features/layouts/chrome/stripNoDrag.spec.tsx +103 -0
  34. package/src/features/layouts/chrome/useScrollHideChrome.ts +3 -8
  35. package/src/features/layouts/chrome/viewport.ts +11 -4
  36. package/src/features/layouts/filterNavigationForAuthState.spec.ts +5 -3
  37. package/src/features/layouts/floating/FloatingBottomDock.tsx +263 -43
  38. package/src/features/layouts/floating/FloatingLayout.tsx +14 -8
  39. package/src/features/layouts/floating/FloatingSidebar.tsx +178 -81
  40. package/src/features/layouts/floating/computeFloatingInsets.ts +22 -4
  41. package/src/features/layouts/floating/moreSections.spec.ts +28 -0
  42. package/src/features/layouts/floating/moreSections.ts +31 -0
  43. package/src/features/layouts/floating/useFloatingChrome.ts +3 -1
  44. package/src/features/layouts/floating/useSoftKeyboard.spec.ts +39 -0
  45. package/src/features/layouts/floating/useSoftKeyboard.ts +82 -0
  46. package/src/features/layouts/fullscreen/FullscreenLayout.spec.tsx +68 -0
  47. package/src/features/layouts/fullscreen/FullscreenLayout.tsx +47 -10
  48. package/src/features/layouts/sidebar/NavigationContent.tsx +17 -9
  49. package/src/features/layouts/sidebar/SidebarIcons.tsx +70 -9
  50. package/src/features/layouts/sidebar/SidebarInner.spec.tsx +149 -0
  51. package/src/features/layouts/sidebar/SidebarInner.tsx +103 -43
  52. package/src/features/layouts/sidebar/SidebarLayout.tsx +24 -17
  53. package/src/features/layouts/utils.ts +4 -3
  54. package/src/features/layouts/windows/DesktopDots.tsx +76 -0
  55. package/src/features/layouts/windows/WindowsLayout.tsx +265 -160
  56. package/src/features/layouts/windows/deskDots.spec.ts +54 -0
  57. package/src/features/layouts/windows/deskDots.ts +314 -0
  58. package/src/features/overlays/ResponsiveModal.tsx +5 -3
  59. package/src/features/overlays/overlaySize.spec.ts +56 -16
  60. package/src/features/overlays/overlaySize.ts +114 -31
  61. package/src/features/overlays/phoneDrawerAnchoring.spec.ts +187 -0
  62. package/src/features/overlays/useOverlayReportedSize.ts +8 -3
  63. package/src/features/theme/applyTheme.ts +8 -0
  64. package/src/features/theme/navContrast.spec.ts +49 -0
  65. package/src/features/theme/navContrast.ts +108 -0
  66. package/src/i18n/translations/en/common.json +26 -0
  67. package/src/i18n/translations/fr/common.json +26 -0
  68. package/src/index.css +1156 -77
  69. package/src/service-worker/devCaches.spec.ts +32 -0
  70. package/src/service-worker/devCaches.ts +27 -0
  71. package/src/service-worker/sw-dev.ts +23 -23
@@ -0,0 +1,68 @@
1
+ // @vitest-environment happy-dom
2
+ import { act } from 'react';
3
+ import { createRoot, type Root } from 'react-dom/client';
4
+ import { MemoryRouter } from 'react-router';
5
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
6
+ import { FullscreenLayout } from './FullscreenLayout';
7
+
8
+ const env = { mac: false, root: true };
9
+
10
+ vi.mock('react-i18next', () => ({ useTranslation: () => ({ i18n: { language: 'en' } }) }));
11
+ vi.mock('../chrome/runtime', () => ({
12
+ useIsTauriClient: () => env.mac,
13
+ useMacOverlayChrome: () => env.mac,
14
+ useMacTrafficLights: () => env.mac,
15
+ }));
16
+ vi.mock('../chrome/DesktopHistoryButtons', () => ({ DesktopHistoryButtons: () => null }));
17
+ vi.mock('../chrome/SafeAreaTopbar', () => ({ isShellUiRootWindow: () => env.root }));
18
+
19
+ (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
20
+
21
+ let container: HTMLDivElement;
22
+ let root: Root;
23
+
24
+ beforeEach(() => {
25
+ env.mac = false;
26
+ env.root = true;
27
+ container = document.createElement('div');
28
+ document.body.appendChild(container);
29
+ root = createRoot(container);
30
+ });
31
+
32
+ afterEach(() => {
33
+ act(() => root.unmount());
34
+ container.remove();
35
+ });
36
+
37
+ function main(): HTMLElement {
38
+ act(() =>
39
+ root.render(
40
+ <MemoryRouter>
41
+ <FullscreenLayout navigation={[]}>
42
+ <p>content</p>
43
+ </FullscreenLayout>
44
+ </MemoryRouter>,
45
+ ),
46
+ );
47
+ const el = container.querySelector<HTMLElement>('[data-shellui-fullscreen]');
48
+ if (!el) throw new Error('missing main');
49
+ return el;
50
+ }
51
+
52
+ describe('FullscreenLayout safe areas', () => {
53
+ it('pads the root window for the notch and home indicator', () => {
54
+ expect(main().className).toContain('shellui-fullscreen-safe');
55
+ });
56
+
57
+ it('does not pad again inside a nested shell iframe', () => {
58
+ env.root = false;
59
+ expect(main().className).not.toContain('shellui-fullscreen-safe');
60
+ });
61
+
62
+ it('keeps the macOS strip padding instead', () => {
63
+ env.mac = true;
64
+ const el = main();
65
+ expect(el.className).not.toContain('shellui-fullscreen-safe');
66
+ expect(el.style.paddingTop).toBe('48px');
67
+ });
68
+ });
@@ -4,12 +4,20 @@ import { useTranslation } from 'react-i18next';
4
4
  import type { NavigationItem, NavigationGroup } from '../../config/types';
5
5
  import { flattenNavigationItems } from '../utils';
6
6
  import { DesktopHistoryButtons } from '../chrome/DesktopHistoryButtons';
7
- import { useIsTauriClient, useMacTrafficLights } from '../chrome/runtime';
7
+ import { useIsTauriClient, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
8
8
  import {
9
9
  DESKTOP_TITLEBAR_HEIGHT_PX,
10
10
  DESKTOP_TITLEBAR_PAD_TOP_PX,
11
- MAC_TRAFFIC_LIGHTS_WIDTH_PX,
11
+ MAC_LIGHTS_SAFE_PX,
12
+ SHELL_HEADER_HEIGHT_PX,
13
+ SHELL_HEADER_PAD_TOP_PX,
12
14
  } from '../chrome/constants';
15
+ import { MAC_DRAG_REGION_PROPS, MacLightsSafeArea, MacStripSpacer } from '../chrome/MacStrip';
16
+ import { isShellUiRootWindow } from '../chrome/SafeAreaTopbar';
17
+ import { cn } from '../../../lib/utils';
18
+
19
+ /** macOS: content starts under the 32px strip plus 16px. */
20
+ const MAC_CONTENT_PAD_TOP_PX = 48;
13
21
 
14
22
  interface FullscreenLayoutProps {
15
23
  title?: string;
@@ -31,7 +39,10 @@ export function FullscreenLayout({ title, navigation, children }: FullscreenLayo
31
39
  const { i18n } = useTranslation();
32
40
  const isTauriEnv = useIsTauriClient();
33
41
  const trafficLights = useMacTrafficLights();
42
+ const macStrip = useMacOverlayChrome();
34
43
  const currentLanguage = i18n.language || 'en';
44
+ // Nested shell-in-iframe: the root window already cleared the safe areas.
45
+ const safeAreaPad = isShellUiRootWindow();
35
46
  const navigationItems = useMemo(() => flattenNavigationItems(navigation), [navigation]);
36
47
 
37
48
  useEffect(() => {
@@ -52,20 +63,46 @@ export function FullscreenLayout({ title, navigation, children }: FullscreenLayo
52
63
  }, [location.pathname, title, navigationItems, currentLanguage]);
53
64
 
54
65
  return (
55
- <main className="relative flex h-full max-h-full w-full flex-col overflow-hidden bg-background">
56
- {isTauriEnv ? (
66
+ <main
67
+ data-shellui-fullscreen=""
68
+ className={cn(
69
+ 'relative flex h-full max-h-full w-full flex-col overflow-hidden bg-background',
70
+ // Phones: clear the notch and home indicator (nothing higher up pads them).
71
+ !macStrip && safeAreaPad && 'shellui-fullscreen-safe',
72
+ )}
73
+ style={macStrip ? { paddingTop: MAC_CONTENT_PAD_TOP_PX } : undefined}
74
+ >
75
+ {macStrip ? (
76
+ /* Transparent 32px drag strip: safe area 80, history glass group, drag spacer. */
57
77
  <div
58
- className="pointer-events-auto absolute top-0 left-0 z-[46] flex items-center"
78
+ data-shellui-mac-strip=""
79
+ {...MAC_DRAG_REGION_PROPS}
80
+ className="absolute inset-x-0 top-0 z-[46] flex items-center select-none"
59
81
  style={{
60
82
  height: DESKTOP_TITLEBAR_HEIGHT_PX,
61
83
  paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
62
- paddingLeft: trafficLights ? MAC_TRAFFIC_LIGHTS_WIDTH_PX : 8,
63
84
  }}
64
- {...(trafficLights
65
- ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
66
- : {})}
67
85
  >
68
- <DesktopHistoryButtons />
86
+ <MacLightsSafeArea />
87
+ {isTauriEnv ? (
88
+ <DesktopHistoryButtons
89
+ strip
90
+ className="shellui-history-glass"
91
+ />
92
+ ) : null}
93
+ <MacStripSpacer />
94
+ </div>
95
+ ) : isTauriEnv ? (
96
+ <div
97
+ className="pointer-events-auto absolute top-0 left-0 z-[46] flex items-center"
98
+ style={{
99
+ height: SHELL_HEADER_HEIGHT_PX,
100
+ paddingTop: SHELL_HEADER_PAD_TOP_PX,
101
+ paddingLeft: trafficLights ? MAC_LIGHTS_SAFE_PX : 8,
102
+ }}
103
+ {...(trafficLights ? MAC_DRAG_REGION_PROPS : {})}
104
+ >
105
+ <DesktopHistoryButtons className="shellui-history-glass" />
69
106
  </div>
70
107
  ) : null}
71
108
  {children || <Outlet />}
@@ -11,7 +11,6 @@ import {
11
11
  SidebarMenuItem,
12
12
  SidebarMenuButton,
13
13
  } from '../../../components/ui/sidebar';
14
- import { cn } from '../../../lib/utils';
15
14
  import { getActivePathPrefix, getNavPathPrefix, flattenNavigationItems } from '../utils';
16
15
  import { getExternalFaviconUrl } from './sidebarUtils';
17
16
  import { ExternalLinkIcon, NavIcon } from './SidebarIcons';
@@ -29,7 +28,7 @@ export function NavigationContent({
29
28
  trailing?: ReactNode;
30
29
  }) {
31
30
  const location = useLocation();
32
- const { i18n } = useTranslation();
31
+ const { t, i18n } = useTranslation();
33
32
  const currentLanguage = i18n.language || 'en';
34
33
 
35
34
  const resolveLocalizedString = (
@@ -77,9 +76,17 @@ export function NavigationContent({
77
76
  const itemLabel = resolveLocalizedString(navItem.label, currentLanguage);
78
77
  const faviconUrl = isExternal && !navItem.icon ? getExternalFaviconUrl(navItem.url) : null;
79
78
  const iconSrc = navItem.icon ?? faviconUrl ?? null;
80
- const iconEl = <NavIcon src={iconSrc} />;
79
+ const iconEl = (
80
+ <NavIcon
81
+ src={iconSrc}
82
+ className="shellui-nav-icon"
83
+ />
84
+ );
81
85
  const externalIcon = isExternal ? (
82
- <ExternalLinkIcon className="ml-auto size-4 shrink-0 opacity-70" />
86
+ <>
87
+ <ExternalLinkIcon className="shellui-nav-external ml-auto size-3.5 shrink-0 opacity-70" />
88
+ <span className="sr-only">{t('shellChrome.externalLink')}</span>
89
+ </>
83
90
  ) : null;
84
91
  const content = (
85
92
  <>
@@ -126,8 +133,9 @@ export function NavigationContent({
126
133
  <SidebarMenuButton
127
134
  asChild
128
135
  isActive={isActive}
136
+ aria-current={isActive ? 'page' : undefined}
129
137
  tooltip={itemLabel}
130
- className={cn('w-full', isActive && 'bg-sidebar-accent text-sidebar-accent-foreground')}
138
+ className="shellui-nav-row w-full"
131
139
  >
132
140
  {linkOrTrigger}
133
141
  </SidebarMenuButton>
@@ -140,7 +148,7 @@ export function NavigationContent({
140
148
 
141
149
  if (sections.length === 0 && trailingItem) {
142
150
  return (
143
- <SidebarGroup className="mt-0">
151
+ <SidebarGroup className="mt-0 px-2 py-0">
144
152
  <SidebarGroupContent>
145
153
  <SidebarMenu className="gap-0.5">{trailingItem}</SidebarMenu>
146
154
  </SidebarGroupContent>
@@ -159,9 +167,9 @@ export function NavigationContent({
159
167
  return (
160
168
  <SidebarGroup
161
169
  key={`group-${groupTitle}-${sectionIndex}`}
162
- className="mt-0"
170
+ className="mt-0 px-2 py-0"
163
171
  >
164
- <SidebarGroupLabel className="mb-1">{groupTitle}</SidebarGroupLabel>
172
+ <SidebarGroupLabel className="shellui-nav-label">{groupTitle}</SidebarGroupLabel>
165
173
  <SidebarGroupContent>
166
174
  <SidebarMenu className="gap-0.5">
167
175
  {section.group.items.map((navItem) => (
@@ -177,7 +185,7 @@ export function NavigationContent({
177
185
  return (
178
186
  <SidebarGroup
179
187
  key={`items-${section.items.map((i) => i.path).join('-')}-${sectionIndex}`}
180
- className="mt-0"
188
+ className="mt-0 px-2 py-0"
181
189
  >
182
190
  <SidebarGroupContent>
183
191
  <SidebarMenu className="gap-0.5">
@@ -1,7 +1,7 @@
1
1
  import { cn } from '../../../lib/utils';
2
2
  import { isAppIcon } from './sidebarUtils';
3
3
 
4
- /** Inline SVG: external-link icon. Bundled so consumers don't need to serve static SVGs. */
4
+ /** Inline SVG: external link (arrow up right). Bundled so consumers don't need to serve static SVGs. */
5
5
  export function ExternalLinkIcon({ className }: { className?: string }) {
6
6
  return (
7
7
  <svg
@@ -17,18 +17,79 @@ export function ExternalLinkIcon({ className }: { className?: string }) {
17
17
  className={cn('shrink-0', className)}
18
18
  aria-hidden
19
19
  >
20
- <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" />
21
- <polyline points="15 3 21 3 21 9" />
22
- <line
23
- x1="10"
24
- y1="14"
25
- x2="21"
26
- y2="3"
27
- />
20
+ <path d="M7 7h10v10" />
21
+ <path d="M7 17 17 7" />
28
22
  </svg>
29
23
  );
30
24
  }
31
25
 
26
+ function LucideSvg({ className, children }: { className?: string; children: React.ReactNode }) {
27
+ return (
28
+ <svg
29
+ xmlns="http://www.w3.org/2000/svg"
30
+ width="24"
31
+ height="24"
32
+ viewBox="0 0 24 24"
33
+ fill="none"
34
+ stroke="currentColor"
35
+ strokeWidth="2"
36
+ strokeLinecap="round"
37
+ strokeLinejoin="round"
38
+ className={cn('shrink-0', className)}
39
+ aria-hidden
40
+ >
41
+ {children}
42
+ </svg>
43
+ );
44
+ }
45
+
46
+ /** lucide x */
47
+ export function CloseIcon({ className }: { className?: string }) {
48
+ return (
49
+ <LucideSvg className={className}>
50
+ <path d="M18 6 6 18" />
51
+ <path d="m6 6 12 12" />
52
+ </LucideSvg>
53
+ );
54
+ }
55
+
56
+ /** lucide ellipsis */
57
+ export function EllipsisIcon({ className }: { className?: string }) {
58
+ return (
59
+ <LucideSvg className={className}>
60
+ <circle
61
+ cx="12"
62
+ cy="12"
63
+ r="1"
64
+ />
65
+ <circle
66
+ cx="19"
67
+ cy="12"
68
+ r="1"
69
+ />
70
+ <circle
71
+ cx="5"
72
+ cy="12"
73
+ r="1"
74
+ />
75
+ </LucideSvg>
76
+ );
77
+ }
78
+
79
+ /** Settings gear (same glyph as the account menu). */
80
+ export function SettingsIcon({ className }: { className?: string }) {
81
+ return (
82
+ <LucideSvg className={className}>
83
+ <circle
84
+ cx="12"
85
+ cy="12"
86
+ r="3"
87
+ />
88
+ <path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z" />
89
+ </LucideSvg>
90
+ );
91
+ }
92
+
32
93
  /** Default nav icon when a navigation item has no custom icon. */
33
94
  export function DefaultNavIcon({ className }: { className?: string }) {
34
95
  return (
@@ -0,0 +1,149 @@
1
+ // @vitest-environment happy-dom
2
+ import { act, type ReactNode } from 'react';
3
+ import { createRoot, type Root } from 'react-dom/client';
4
+ import { MemoryRouter } from 'react-router';
5
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
6
+ import en from '../../../i18n/translations/en/common.json';
7
+ import fr from '../../../i18n/translations/fr/common.json';
8
+ import { SIDEBAR_PANEL_ID, SidebarProvider, SidebarTrigger } from '../../../components/ui/sidebar';
9
+ import { SidebarInner } from './SidebarInner';
10
+
11
+ const mobile = { value: false };
12
+
13
+ vi.mock('../../../hooks/use-mobile', () => ({ useIsMobile: () => mobile.value }));
14
+ vi.mock('../chrome/runtime', () => ({
15
+ useIsTauriClient: () => false,
16
+ useMacOverlayChrome: () => false,
17
+ useMacTrafficLights: () => false,
18
+ }));
19
+ vi.mock('./NavigationContent', () => ({
20
+ NavigationContent: ({ trailing }: { trailing?: ReactNode }) => trailing ?? null,
21
+ }));
22
+ vi.mock('../../config/useConfig', () => ({ useConfig: () => ({ config: {} }) }));
23
+ vi.mock('../../auth/components/LoginButton', () => ({
24
+ LoginButton: ({ dividerAbove }: { dividerAbove?: boolean }) => (
25
+ <span
26
+ data-login=""
27
+ data-divider={String(Boolean(dividerAbove))}
28
+ />
29
+ ),
30
+ }));
31
+ vi.mock('react-i18next', () => ({
32
+ useTranslation: () => ({
33
+ t: (key: string) => {
34
+ const [group, leaf] = key.split('.') as [keyof typeof en, string];
35
+ return (en[group] as Record<string, string>)[leaf] ?? key;
36
+ },
37
+ }),
38
+ }));
39
+
40
+ (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
41
+
42
+ let container: HTMLDivElement;
43
+ let root: Root;
44
+
45
+ beforeEach(() => {
46
+ mobile.value = false;
47
+ container = document.createElement('div');
48
+ document.body.appendChild(container);
49
+ root = createRoot(container);
50
+ });
51
+
52
+ afterEach(() => {
53
+ act(() => root.unmount());
54
+ container.remove();
55
+ });
56
+
57
+ function render(node: React.ReactNode, open = true) {
58
+ act(() => {
59
+ root.render(
60
+ <MemoryRouter>
61
+ <SidebarProvider defaultOpen={open}>{node}</SidebarProvider>
62
+ </MemoryRouter>,
63
+ );
64
+ });
65
+ }
66
+
67
+ function q<T extends Element = HTMLElement>(scope: ParentNode, sel: string): T {
68
+ const el = scope.querySelector<T>(sel);
69
+ if (!el) throw new Error(`missing ${sel}`);
70
+ return el;
71
+ }
72
+
73
+ const inner = (
74
+ <SidebarInner
75
+ startNav={[]}
76
+ endItems={[]}
77
+ showAuthButton={false}
78
+ title="Acme"
79
+ appIcon="/icon.svg"
80
+ />
81
+ );
82
+
83
+ describe('SidebarTrigger', () => {
84
+ it('reports aria-expanded and aria-controls', () => {
85
+ render(<SidebarTrigger />);
86
+ const btn = q<HTMLButtonElement>(container, 'button');
87
+ expect(btn.getAttribute('aria-controls')).toBe(SIDEBAR_PANEL_ID);
88
+ expect(btn.getAttribute('aria-expanded')).toBe('true');
89
+ act(() => btn.click());
90
+ expect(btn.getAttribute('aria-expanded')).toBe('false');
91
+ });
92
+ });
93
+
94
+ describe('SidebarInner header', () => {
95
+ it('shows the app name next to the logo, with no border under the header', () => {
96
+ render(inner);
97
+ const header = q(container, '[data-sidebar="header"]');
98
+ expect(header.textContent).toContain('Acme');
99
+ expect(header.className).not.toContain('border-b');
100
+ expect(q(header, 'span.truncate').className).toContain(
101
+ 'group-data-[collapsible=icon]:opacity-0',
102
+ );
103
+ });
104
+
105
+ it('mobile sheet header is 52px with a labelled close button', () => {
106
+ mobile.value = true;
107
+ render(inner);
108
+ const header = q(container, '[data-sidebar="header"]');
109
+ expect(header.style.height).toBe('52px');
110
+ const close = q(header, 'button');
111
+ expect(close.getAttribute('aria-label')).toBe('Close menu');
112
+ expect(header.textContent).toContain('Acme');
113
+ });
114
+
115
+ it('has the close label in French', () => {
116
+ expect(fr.shellChrome.closeMenu).toBe('Fermer le menu');
117
+ });
118
+ });
119
+
120
+ describe('SidebarInner footer account divider', () => {
121
+ const footer = (endItems: { label: string; path: string; url: string }[]) => (
122
+ <SidebarInner
123
+ startNav={[]}
124
+ endItems={endItems}
125
+ showAuthButton
126
+ title="Acme"
127
+ />
128
+ );
129
+
130
+ it('asks for a divider when footer items sit above the account block', () => {
131
+ render(footer([{ label: 'Settings', path: 'settings', url: '/settings' }]));
132
+ expect(q(container, '[data-login]').getAttribute('data-divider')).toBe('true');
133
+ });
134
+
135
+ it('opens the footer with the shared full-width divider instead of a border', () => {
136
+ render(footer([]));
137
+ const foot = q(container, '[data-shellui-nav-footer]');
138
+ expect(foot.className).not.toContain('border-t');
139
+ const first = foot.firstElementChild;
140
+ expect(first?.getAttribute('data-shellui-divider')).toBe('');
141
+ expect(first?.className).toContain('shellui-divider');
142
+ expect(first?.hasAttribute('data-shellui-footer-divider')).toBe(true);
143
+ });
144
+
145
+ it('skips the account divider when the account block is the only footer item', () => {
146
+ render(footer([]));
147
+ expect(q(container, '[data-login]').getAttribute('data-divider')).toBe('false');
148
+ });
149
+ });