@shellui/core 0.5.0-beta.2 → 0.5.0

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 (70) hide show
  1. package/README.md +5 -5
  2. package/package.json +3 -2
  3. package/schemas/shellui.config.schema.json +10 -2
  4. package/src/app.tsx +8 -4
  5. package/src/components/ContentView.tsx +12 -5
  6. package/src/components/ui/alert-dialog.tsx +1 -1
  7. package/src/components/ui/dialog.tsx +5 -1
  8. package/src/components/ui/dropdown-menu.tsx +39 -4
  9. package/src/components/ui/sheet.tsx +1 -1
  10. package/src/components/ui/sidebar.tsx +60 -20
  11. package/src/components/ui/tabs.tsx +52 -0
  12. package/src/constants/urls.ts +1 -0
  13. package/src/features/auth/AuthProvider.tsx +17 -6
  14. package/src/features/chromeActions/ChromeActionIcons.tsx +261 -0
  15. package/src/features/chromeActions/ChromeActionsDemoView.tsx +149 -0
  16. package/src/features/chromeActions/ChromeActionsHost.tsx +1511 -0
  17. package/src/features/chromeActions/ChromeActionsProvider.tsx +141 -0
  18. package/src/features/chromeActions/chromeActionsStore.spec.ts +61 -0
  19. package/src/features/chromeActions/chromeActionsStore.ts +77 -0
  20. package/src/features/chromeActions/computeActionInsets.spec.ts +360 -0
  21. package/src/features/chromeActions/computeActionInsets.ts +326 -0
  22. package/src/features/chromeActions/index.ts +26 -0
  23. package/src/features/chromeActions/resolveUuidForRemoveIframe.spec.ts +49 -0
  24. package/src/features/config/types.ts +16 -2
  25. package/src/features/layouts/AppLayout.tsx +30 -3
  26. package/src/features/layouts/OverlayShell.tsx +63 -13
  27. package/src/features/layouts/app-bar-inset/AppBarInsetLayout.tsx +22 -0
  28. package/src/features/layouts/appbar/AppBarLayout.tsx +230 -86
  29. package/src/features/layouts/chrome/DesktopChrome.tsx +17 -3
  30. package/src/features/layouts/chrome/InsetMobileRadiusOverlay.tsx +18 -0
  31. package/src/features/layouts/chrome/index.ts +8 -0
  32. package/src/features/layouts/chrome/runtime.ts +73 -0
  33. package/src/features/layouts/chrome/useScrollHideChrome.ts +210 -0
  34. package/src/features/layouts/floating/FloatingBottomDock.tsx +410 -0
  35. package/src/features/layouts/floating/FloatingLayout.tsx +152 -0
  36. package/src/features/layouts/floating/FloatingSidebar.tsx +327 -0
  37. package/src/features/layouts/floating/FloatingStatusScrim.tsx +36 -0
  38. package/src/features/layouts/floating/computeFloatingInsets.spec.ts +83 -0
  39. package/src/features/layouts/floating/computeFloatingInsets.ts +155 -0
  40. package/src/features/layouts/floating/isShellOwnedPath.spec.ts +25 -0
  41. package/src/features/layouts/floating/isShellOwnedPath.ts +17 -0
  42. package/src/features/layouts/floating/layoutChromeStore.spec.ts +138 -0
  43. package/src/features/layouts/floating/layoutChromeStore.ts +209 -0
  44. package/src/features/layouts/floating/scrollChrome.spec.ts +49 -0
  45. package/src/features/layouts/floating/useFloatingChrome.ts +206 -0
  46. package/src/features/layouts/sidebar/SidebarLayout.tsx +119 -37
  47. package/src/features/layouts/sidebar/types.ts +4 -0
  48. package/src/features/layouts/sidebar-inset/SidebarInsetLayout.tsx +15 -0
  49. package/src/features/layouts/windows/WindowsLayout.tsx +240 -110
  50. package/src/features/overlays/ResponsiveModal.tsx +201 -21
  51. package/src/features/overlays/overlaySize.spec.ts +18 -0
  52. package/src/features/overlays/overlaySize.ts +89 -0
  53. package/src/features/settings/SettingsProvider.tsx +36 -9
  54. package/src/features/settings/SettingsView.tsx +6 -6
  55. package/src/features/settings/components/Develop.tsx +33 -13
  56. package/src/features/settings/components/develop/ChromeActionsTestButtons.tsx +63 -0
  57. package/src/features/settings/utils/buildSettingsForPropagation.ts +16 -0
  58. package/src/features/storage/StoragePickerContext.tsx +1 -0
  59. package/src/features/storage/uploads/uploadQueue.spec.ts +56 -1
  60. package/src/features/storage/uploads/uploadQueue.ts +42 -1
  61. package/src/features/theme/applyTheme.ts +23 -5
  62. package/src/hooks/use-mobile.tsx +21 -7
  63. package/src/hooks/use-viewport.ts +40 -0
  64. package/src/i18n/translations/en/settings.json +17 -2
  65. package/src/i18n/translations/fr/settings.json +17 -2
  66. package/src/index.css +473 -12
  67. package/src/index.html +6 -4
  68. package/src/index.ts +8 -0
  69. package/src/routes/components/RouteFallback.tsx +21 -2
  70. package/src/routes/routes.tsx +14 -0
@@ -0,0 +1,152 @@
1
+ import { Outlet } from 'react-router';
2
+ import { useEffect, useMemo } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { shellui } from '@shellui/sdk';
5
+ import type { NavigationItem, NavigationGroup, ThemeAsset } from '../../config/types';
6
+ import {
7
+ filterNavigationForAuthState,
8
+ filterNavigationByViewport,
9
+ flattenNavigationItems,
10
+ hasLoginNavigationItem,
11
+ resolveLocalizedString,
12
+ splitNavigationByPosition,
13
+ } from '../utils';
14
+ import { useNavigationItems } from '../../../routes/hooks/useNavigationItems';
15
+ import { useAuth } from '../../auth/hooks/useAuth';
16
+ import { useSettings } from '../../settings/hooks/useSettings';
17
+ import { useViewport } from '../../../hooks/use-viewport';
18
+ import { DesktopHistoryButtons } from '../chrome/DesktopHistoryButtons';
19
+ import { useIsTauriClient, useMacTrafficLights } from '../chrome/runtime';
20
+ import {
21
+ DESKTOP_TITLEBAR_HEIGHT_PX,
22
+ DESKTOP_TITLEBAR_PAD_TOP_PX,
23
+ MAC_TRAFFIC_LIGHTS_WIDTH_PX,
24
+ } from '../chrome/constants';
25
+ import { FloatingBottomDock } from './FloatingBottomDock';
26
+ import { FloatingSidebar } from './FloatingSidebar';
27
+ import { FloatingStatusScrim } from './FloatingStatusScrim';
28
+ import { useFloatingChrome } from './useFloatingChrome';
29
+ import { SafeAreaTopbarOffset, isShellUiRootWindow } from '../chrome/SafeAreaTopbar';
30
+ import { useChromeActionsSnapshot } from '../../chromeActions/ChromeActionsProvider';
31
+ import { actionChromeFlags } from '../../chromeActions/computeActionInsets';
32
+ import { SHELL_DEVELOP_CHROME_ACTIONS_FRAME } from '../../chromeActions/chromeActionsStore';
33
+
34
+ export interface FloatingLayoutProps {
35
+ title?: string;
36
+ appIcon?: ThemeAsset;
37
+ logo?: ThemeAsset;
38
+ navigation?: (NavigationItem | NavigationGroup)[];
39
+ }
40
+
41
+ /** Adaptive layout: floating glass chrome over full-bleed content (tabs/dock + sidebar). */
42
+ export function FloatingLayout({ title, appIcon, navigation = [] }: FloatingLayoutProps) {
43
+ const { i18n } = useTranslation();
44
+ const { isAuthenticated } = useAuth();
45
+ const { settings } = useSettings();
46
+ const { navigationItem } = useNavigationItems();
47
+ const viewport = useViewport();
48
+ const { chromeVisible, sidebarCollapsed, toggleSidebarCollapsed } = useFloatingChrome(viewport);
49
+ const isTauriEnv = useIsTauriClient();
50
+ const trafficLights = useMacTrafficLights();
51
+ const currentLanguage = i18n.language || 'en';
52
+
53
+ const hasCustomLoginNav = useMemo(() => hasLoginNavigationItem(navigation), [navigation]);
54
+ // Same rule as sidebar / app-bar: show account menu when logged in (login nav item is filtered out).
55
+ const showAuthButton = !hasCustomLoginNav || isAuthenticated;
56
+
57
+ const authAwareNavigation = useMemo(
58
+ () =>
59
+ filterNavigationForAuthState(navigation, isAuthenticated, settings.developerFeatures.enabled),
60
+ [navigation, isAuthenticated, settings.developerFeatures.enabled],
61
+ );
62
+
63
+ const { startNav, endItems } = useMemo(() => {
64
+ const navViewport = viewport === 'mobile' ? 'mobile' : 'desktop';
65
+ const viewportNav = filterNavigationByViewport(authAwareNavigation, navViewport);
66
+ const { start, end } = splitNavigationByPosition(viewportNav);
67
+ return { startNav: start, endItems: end };
68
+ }, [authAwareNavigation, viewport]);
69
+
70
+ const tabItems = useMemo(() => flattenNavigationItems(startNav), [startNav]);
71
+
72
+ const chromeActions = useChromeActionsSnapshot();
73
+ const hasMainTopActions = useMemo(() => {
74
+ for (const actions of chromeActions) {
75
+ if (!actionChromeFlags(actions).hasTop) continue;
76
+ if (actions.frameUuid === SHELL_DEVELOP_CHROME_ACTIONS_FRAME) continue;
77
+ for (const [uuid, iframe] of shellui.frameRegistry.getAllIframes()) {
78
+ if (uuid !== actions.frameUuid || !iframe.isConnected) continue;
79
+ if (iframe.dataset.shelluiFrame === 'overlay') continue;
80
+ if (iframe.closest('[data-shellui-windows-layout]')) continue;
81
+ return true;
82
+ }
83
+ }
84
+ return false;
85
+ }, [chromeActions]);
86
+
87
+ useEffect(() => {
88
+ if (!title) return;
89
+ if (navigationItem) {
90
+ const label = resolveLocalizedString(navigationItem.label, currentLanguage);
91
+ document.title = `${label} | ${title}`;
92
+ } else {
93
+ document.title = title;
94
+ }
95
+ }, [navigationItem, title, currentLanguage]);
96
+
97
+ const showTabBar = viewport === 'mobile' || viewport === 'tablet';
98
+ const showSidebar = viewport === 'desktop';
99
+ const showSafeAreaTopbar = showTabBar && isShellUiRootWindow();
100
+ // Status scrim only when there’s no top action chrome (that bar paints its own fade).
101
+ const showStatusScrim = showSafeAreaTopbar && !hasMainTopActions;
102
+
103
+ return (
104
+ <div
105
+ data-shellui-floating-layout=""
106
+ data-viewport={viewport}
107
+ className="relative flex h-full max-h-full w-full flex-col overflow-hidden bg-background"
108
+ >
109
+ <SafeAreaTopbarOffset enabled={showSafeAreaTopbar} />
110
+ <FloatingStatusScrim enabled={showStatusScrim} />
111
+
112
+ {isTauriEnv ? (
113
+ <div
114
+ className="pointer-events-auto absolute top-0 left-0 z-[46] flex items-center"
115
+ style={{
116
+ height: DESKTOP_TITLEBAR_HEIGHT_PX,
117
+ paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
118
+ paddingLeft: trafficLights ? MAC_TRAFFIC_LIGHTS_WIDTH_PX : 8,
119
+ }}
120
+ >
121
+ <DesktopHistoryButtons />
122
+ </div>
123
+ ) : null}
124
+
125
+ <main className="relative min-h-0 min-w-0 flex-1 overflow-hidden">
126
+ <Outlet />
127
+ </main>
128
+
129
+ {showTabBar ? (
130
+ <FloatingBottomDock
131
+ items={tabItems}
132
+ endItems={endItems}
133
+ showAuthButton={showAuthButton}
134
+ chromeVisible={chromeVisible}
135
+ viewport={viewport}
136
+ />
137
+ ) : null}
138
+
139
+ {showSidebar ? (
140
+ <FloatingSidebar
141
+ title={title}
142
+ appIcon={appIcon}
143
+ navigation={startNav}
144
+ endItems={endItems}
145
+ showAuthButton={showAuthButton}
146
+ collapsed={sidebarCollapsed}
147
+ onToggleCollapsed={toggleSidebarCollapsed}
148
+ />
149
+ ) : null}
150
+ </div>
151
+ );
152
+ }
@@ -0,0 +1,327 @@
1
+ import { Link, useLocation } from 'react-router';
2
+ import { useMemo } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { shellui } from '@shellui/sdk';
5
+ import type { NavigationItem, NavigationGroup, ThemeAsset } from '../../config/types';
6
+ import {
7
+ flattenNavigationItems,
8
+ getActivePathPrefix,
9
+ getNavPathPrefix,
10
+ resolveLocalizedString,
11
+ filterNavigationForSidebar,
12
+ } from '../utils';
13
+ import { getExternalFaviconUrl } from '../sidebar/sidebarUtils';
14
+ import { NavIcon, ExternalLinkIcon } from '../sidebar/SidebarIcons';
15
+ import { AppBrandIcon } from '../branding/AppBrandIcon';
16
+ import { LoginButton } from '../../auth/components/LoginButton';
17
+ import { cn } from '../../../lib/utils';
18
+ import { useIsTauriClient, useMacTrafficLights } from '../chrome/runtime';
19
+ import { MAC_TRAFFIC_LIGHTS_WIDTH_PX } from '../chrome/constants';
20
+ import {
21
+ FLOATING_CHROME_MARGIN,
22
+ FLOATING_SIDEBAR_TOGGLE_SIZE,
23
+ FLOATING_SIDEBAR_WIDTH,
24
+ } from './computeFloatingInsets';
25
+
26
+ const isGroup = (item: NavigationItem | NavigationGroup): item is NavigationGroup => {
27
+ return 'title' in item && 'items' in item;
28
+ };
29
+
30
+ type NavSection =
31
+ | { type: 'group'; group: NavigationGroup }
32
+ | { type: 'items'; items: NavigationItem[] };
33
+
34
+ function buildSections(navigation: (NavigationItem | NavigationGroup)[]): NavSection[] {
35
+ const result: NavSection[] = [];
36
+ for (const item of navigation) {
37
+ if (isGroup(item)) {
38
+ result.push({ type: 'group', group: item });
39
+ continue;
40
+ }
41
+ const last = result[result.length - 1];
42
+ if (last?.type === 'items') {
43
+ last.items.push(item);
44
+ } else {
45
+ result.push({ type: 'items', items: [item] });
46
+ }
47
+ }
48
+ return result;
49
+ }
50
+
51
+ function SidebarPanelIcon({ className }: { className?: string }) {
52
+ return (
53
+ <svg
54
+ xmlns="http://www.w3.org/2000/svg"
55
+ width="24"
56
+ height="24"
57
+ viewBox="0 0 24 24"
58
+ fill="none"
59
+ stroke="currentColor"
60
+ strokeWidth="2"
61
+ strokeLinecap="round"
62
+ strokeLinejoin="round"
63
+ className={className}
64
+ aria-hidden
65
+ >
66
+ <rect
67
+ width="18"
68
+ height="18"
69
+ x="3"
70
+ y="3"
71
+ rx="2"
72
+ />
73
+ <path d="M9 3v18" />
74
+ </svg>
75
+ );
76
+ }
77
+
78
+ /** Floating glass sidebar for desktop floating layout (collapsible). */
79
+ export function FloatingSidebar({
80
+ title,
81
+ appIcon,
82
+ navigation,
83
+ endItems = [],
84
+ showAuthButton = false,
85
+ collapsed,
86
+ onToggleCollapsed,
87
+ }: {
88
+ title?: string;
89
+ appIcon?: ThemeAsset;
90
+ navigation: (NavigationItem | NavigationGroup)[];
91
+ /** Footer links (settings, login, …) — `position: 'end'`. */
92
+ endItems?: NavigationItem[];
93
+ /** Account / login control (same semantics as sidebar layout). */
94
+ showAuthButton?: boolean;
95
+ collapsed: boolean;
96
+ onToggleCollapsed: () => void;
97
+ }) {
98
+ const location = useLocation();
99
+ const { i18n, t } = useTranslation('settings');
100
+ const lang = i18n.language || 'en';
101
+ const trafficLights = useMacTrafficLights();
102
+ const isTauriEnv = useIsTauriClient();
103
+ const trafficPadPx = trafficLights ? MAC_TRAFFIC_LIGHTS_WIDTH_PX : 0;
104
+ /** History cluster only for the collapsed chip (shares the top-left corner on Tauri). */
105
+ const chipLeadingPx = trafficPadPx + (isTauriEnv ? 72 : 0);
106
+
107
+ const sidebarNav = useMemo(() => filterNavigationForSidebar(navigation), [navigation]);
108
+ const sections = useMemo(() => buildSections(sidebarNav), [sidebarNav]);
109
+ const flat = useMemo(() => flattenNavigationItems(sidebarNav), [sidebarNav]);
110
+ const activePathPrefix = useMemo(
111
+ () => getActivePathPrefix(location.pathname, [...flat, ...endItems]),
112
+ [location.pathname, flat, endItems],
113
+ );
114
+
115
+ const sidebarEdgePad = {
116
+ paddingTop: `calc(${FLOATING_CHROME_MARGIN}px + var(--shellui-safe-area-top, 0px))`,
117
+ paddingLeft: `calc(${FLOATING_CHROME_MARGIN}px + var(--shellui-safe-area-left, 0px) + ${trafficPadPx}px)`,
118
+ paddingBottom: `calc(${FLOATING_CHROME_MARGIN}px + var(--shellui-safe-area-bottom, 0px))`,
119
+ };
120
+
121
+ const chipEdgePad = {
122
+ paddingTop: `calc(${FLOATING_CHROME_MARGIN}px + var(--shellui-safe-area-top, 0px))`,
123
+ paddingLeft: `calc(${FLOATING_CHROME_MARGIN}px + var(--shellui-safe-area-left, 0px) + ${chipLeadingPx}px)`,
124
+ };
125
+
126
+ const toggleLabel = collapsed
127
+ ? t('develop.layout.showSidebar', { defaultValue: 'Show sidebar' })
128
+ : t('develop.layout.hideSidebar', { defaultValue: 'Hide sidebar' });
129
+
130
+ const renderItem = (navItem: NavigationItem) => {
131
+ const pathPrefix = getNavPathPrefix(navItem);
132
+ const label = resolveLocalizedString(navItem.label, lang);
133
+ const isOverlay = navItem.openIn === 'modal' || navItem.openIn === 'drawer';
134
+ const isExternal = navItem.openIn === 'external';
135
+ const isActive = !isOverlay && !isExternal && pathPrefix === activePathPrefix;
136
+ const faviconUrl = isExternal && !navItem.icon ? getExternalFaviconUrl(navItem.url) : null;
137
+ const iconSrc = navItem.icon ?? faviconUrl ?? null;
138
+
139
+ const className = cn(
140
+ 'shellui-floating-nav-item flex w-full items-center gap-2.5 px-2.5 py-2 text-sm transition-colors',
141
+ isActive
142
+ ? 'bg-sidebar-primary font-medium text-sidebar-primary-foreground'
143
+ : 'text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
144
+ );
145
+
146
+ const content = (
147
+ <>
148
+ <NavIcon
149
+ src={iconSrc}
150
+ className="size-4 shrink-0"
151
+ />
152
+ <span className="truncate">{label}</span>
153
+ {isExternal ? <ExternalLinkIcon className="ml-auto size-3.5 opacity-70" /> : null}
154
+ </>
155
+ );
156
+
157
+ if (navItem.openIn === 'modal') {
158
+ return (
159
+ <button
160
+ key={`${navItem.path}-${navItem.url}`}
161
+ type="button"
162
+ className={className}
163
+ onClick={() => shellui.openModal(navItem.url)}
164
+ >
165
+ {content}
166
+ </button>
167
+ );
168
+ }
169
+ if (navItem.openIn === 'drawer') {
170
+ return (
171
+ <button
172
+ key={`${navItem.path}-${navItem.url}`}
173
+ type="button"
174
+ className={className}
175
+ onClick={() => shellui.openDrawer({ url: navItem.url, position: navItem.drawerPosition })}
176
+ >
177
+ {content}
178
+ </button>
179
+ );
180
+ }
181
+ if (isExternal) {
182
+ return (
183
+ <a
184
+ key={`${navItem.path}-${navItem.url}`}
185
+ href={navItem.url}
186
+ target="_blank"
187
+ rel="noopener noreferrer"
188
+ className={className}
189
+ >
190
+ {content}
191
+ </a>
192
+ );
193
+ }
194
+
195
+ return (
196
+ <Link
197
+ key={`${navItem.path}-${navItem.url}`}
198
+ to={pathPrefix}
199
+ className={className}
200
+ aria-current={isActive ? 'page' : undefined}
201
+ >
202
+ {content}
203
+ </Link>
204
+ );
205
+ };
206
+
207
+ return (
208
+ <>
209
+ {/* Collapsed expand chip — fades/scales in after the panel slides away. */}
210
+ <div
211
+ data-shellui-floating-sidebar="collapsed"
212
+ className={cn(
213
+ 'shellui-floating-sidebar-chip pointer-events-none absolute top-0 left-0 z-[46] flex',
214
+ collapsed ? 'pointer-events-none opacity-100' : 'pointer-events-none opacity-0',
215
+ )}
216
+ style={chipEdgePad}
217
+ aria-hidden={!collapsed}
218
+ >
219
+ <button
220
+ type="button"
221
+ tabIndex={collapsed ? 0 : -1}
222
+ className={cn(
223
+ 'shellui-floating-glass flex items-center justify-center text-sidebar-foreground',
224
+ 'transition-[transform,opacity] duration-150 ease-out',
225
+ 'hover:opacity-95 active:scale-[0.98]',
226
+ collapsed
227
+ ? 'pointer-events-auto scale-100 opacity-100 delay-75'
228
+ : 'pointer-events-none scale-90 opacity-0 delay-0',
229
+ )}
230
+ style={{ width: FLOATING_SIDEBAR_TOGGLE_SIZE, height: FLOATING_SIDEBAR_TOGGLE_SIZE }}
231
+ aria-label={toggleLabel}
232
+ aria-expanded={false}
233
+ onClick={onToggleCollapsed}
234
+ >
235
+ <SidebarPanelIcon className="size-4" />
236
+ </button>
237
+ </div>
238
+
239
+ {/* Expanded panel — GPU slide + fade (transform/opacity only). */}
240
+ <aside
241
+ data-shellui-floating-sidebar="expanded"
242
+ className={cn(
243
+ 'shellui-floating-sidebar-panel pointer-events-none absolute inset-y-0 left-0 z-[45] flex',
244
+ collapsed && 'pointer-events-none',
245
+ )}
246
+ style={sidebarEdgePad}
247
+ aria-hidden={collapsed}
248
+ >
249
+ <nav
250
+ className={cn(
251
+ 'shellui-floating-glass pointer-events-auto flex h-full flex-col overflow-hidden',
252
+ 'origin-left will-change-transform',
253
+ 'transition-[transform,opacity] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]',
254
+ collapsed
255
+ ? 'pointer-events-none -translate-x-[calc(100%+1.25rem)] scale-[0.98] opacity-0'
256
+ : 'translate-x-0 scale-100 opacity-100',
257
+ )}
258
+ style={{ width: FLOATING_SIDEBAR_WIDTH }}
259
+ aria-label={title || 'Navigation'}
260
+ >
261
+ <div className="flex shrink-0 items-center gap-2 border-b border-sidebar-border/80 px-2.5 py-2.5">
262
+ {appIcon ? (
263
+ <AppBrandIcon
264
+ appIcon={appIcon}
265
+ title={title}
266
+ className="size-7 shrink-0"
267
+ />
268
+ ) : null}
269
+ <span className="min-w-0 flex-1" />
270
+ <button
271
+ type="button"
272
+ tabIndex={collapsed ? -1 : 0}
273
+ className="shellui-floating-nav-control flex size-8 shrink-0 items-center justify-center text-sidebar-foreground transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"
274
+ aria-label={toggleLabel}
275
+ aria-expanded={!collapsed}
276
+ onClick={onToggleCollapsed}
277
+ >
278
+ <SidebarPanelIcon className="size-4" />
279
+ </button>
280
+ </div>
281
+
282
+ <div className="flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto p-2">
283
+ {sections.map((section, sectionIndex) => {
284
+ if (section.type === 'group') {
285
+ const groupTitle = resolveLocalizedString(section.group.title, lang);
286
+ return (
287
+ <div
288
+ key={`group-${groupTitle}-${sectionIndex}`}
289
+ className="flex flex-col gap-0.5"
290
+ >
291
+ <div
292
+ className="px-2.5 pb-1 text-[11px] font-medium tracking-wide text-sidebar-foreground/60 uppercase"
293
+ style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
294
+ >
295
+ {groupTitle}
296
+ </div>
297
+ {section.group.items.map(renderItem)}
298
+ </div>
299
+ );
300
+ }
301
+
302
+ return (
303
+ <div
304
+ key={`items-${section.items.map((i) => i.path).join('-')}-${sectionIndex}`}
305
+ className="flex flex-col gap-0.5"
306
+ >
307
+ {section.items.map(renderItem)}
308
+ </div>
309
+ );
310
+ })}
311
+ </div>
312
+
313
+ {endItems.length > 0 || showAuthButton ? (
314
+ <div className="flex shrink-0 flex-col gap-0.5 border-t border-sidebar-border/80 p-2">
315
+ {endItems.map(renderItem)}
316
+ {showAuthButton ? (
317
+ <div className="px-0.5 pt-0.5">
318
+ <LoginButton variant="sidebar" />
319
+ </div>
320
+ ) : null}
321
+ </div>
322
+ ) : null}
323
+ </nav>
324
+ </aside>
325
+ </>
326
+ );
327
+ }
@@ -0,0 +1,36 @@
1
+ import { isShellUiRootWindow } from '../chrome/SafeAreaTopbar';
2
+ import { useIsHomeScreenPwa } from '../chrome/runtime';
3
+
4
+ /** Fade length below the status-bar band into content. */
5
+ const STATUS_SCRIM_FADE_PX = 28;
6
+
7
+ /**
8
+ * iPhone / notch: tint over the safe-area top when there is no top action chrome
9
+ * (action bar owns its own scrim). No backdrop-blur — it fights animations.
10
+ * Only on the outermost shell window (host already clears nested iframes).
11
+ *
12
+ * Skipped on Safari Home Screen PWAs: iOS 26/27 already paints an invasive
13
+ * system status gradient there; stacking ours is catastrophic. Tauri WKWebView
14
+ * and browser tabs keep this controlled fade.
15
+ */
16
+ export function FloatingStatusScrim({ enabled }: { enabled: boolean }) {
17
+ const homeScreenPwa = useIsHomeScreenPwa();
18
+ if (!enabled || !isShellUiRootWindow() || homeScreenPwa) return null;
19
+
20
+ return (
21
+ <div
22
+ aria-hidden
23
+ data-shellui-floating-status-scrim=""
24
+ className="pointer-events-none absolute inset-x-0 top-0 z-[44]"
25
+ >
26
+ <div
27
+ className="bg-background/80"
28
+ style={{ height: 'var(--shellui-safe-area-top, 0px)' }}
29
+ />
30
+ <div
31
+ className="bg-gradient-to-b from-background/80 to-transparent"
32
+ style={{ height: STATUS_SCRIM_FADE_PX }}
33
+ />
34
+ </div>
35
+ );
36
+ }
@@ -0,0 +1,83 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import {
3
+ computeFloatingInsets,
4
+ FLOATING_CHROME_MARGIN,
5
+ FLOATING_CONTENT_CLEARANCE,
6
+ FLOATING_SIDEBAR_WIDTH,
7
+ FLOATING_TAB_BAR_HEIGHT,
8
+ FLOATING_TAB_BAR_HEIGHT_TABLET,
9
+ } from './computeFloatingInsets';
10
+
11
+ describe('computeFloatingInsets', () => {
12
+ const safe = { top: 10, right: 2, bottom: 20, left: 3 };
13
+
14
+ it('returns safe area only when chrome is hidden', () => {
15
+ expect(
16
+ computeFloatingInsets({ viewport: 'mobile', chromeVisible: false, safeArea: safe }),
17
+ ).toEqual(safe);
18
+ expect(
19
+ computeFloatingInsets({ viewport: 'tablet', chromeVisible: false, safeArea: safe }),
20
+ ).toEqual(safe);
21
+ expect(
22
+ computeFloatingInsets({ viewport: 'desktop', chromeVisible: false, safeArea: safe }),
23
+ ).toEqual(safe);
24
+ });
25
+
26
+ it('adds bottom tab bar on mobile when visible (half bottom pad)', () => {
27
+ expect(
28
+ computeFloatingInsets({ viewport: 'mobile', chromeVisible: true, safeArea: safe }),
29
+ ).toEqual({
30
+ top: 10,
31
+ right: 2,
32
+ bottom:
33
+ (20 + FLOATING_CHROME_MARGIN) / 2 +
34
+ FLOATING_TAB_BAR_HEIGHT +
35
+ FLOATING_CHROME_MARGIN +
36
+ FLOATING_CONTENT_CLEARANCE,
37
+ left: 3,
38
+ });
39
+ });
40
+
41
+ it('adds bottom tab bar on tablet when visible (full bottom pad, taller dock)', () => {
42
+ expect(
43
+ computeFloatingInsets({ viewport: 'tablet', chromeVisible: true, safeArea: safe }),
44
+ ).toEqual({
45
+ top: 10,
46
+ right: 2,
47
+ bottom:
48
+ 20 +
49
+ FLOATING_CHROME_MARGIN +
50
+ FLOATING_TAB_BAR_HEIGHT_TABLET +
51
+ FLOATING_CHROME_MARGIN +
52
+ FLOATING_CONTENT_CLEARANCE,
53
+ left: 3,
54
+ });
55
+ });
56
+
57
+ it('adds left sidebar on desktop when visible', () => {
58
+ expect(
59
+ computeFloatingInsets({ viewport: 'desktop', chromeVisible: true, safeArea: safe }),
60
+ ).toEqual({
61
+ top: 10,
62
+ right: 2,
63
+ bottom: 20,
64
+ left: 3 + FLOATING_SIDEBAR_WIDTH + FLOATING_CHROME_MARGIN * 2 + FLOATING_CONTENT_CLEARANCE,
65
+ });
66
+ });
67
+
68
+ it('keeps content full-bleed when desktop sidebar is collapsed', () => {
69
+ expect(
70
+ computeFloatingInsets({
71
+ viewport: 'desktop',
72
+ chromeVisible: true,
73
+ sidebarCollapsed: true,
74
+ safeArea: safe,
75
+ }),
76
+ ).toEqual({
77
+ top: 10,
78
+ right: 2,
79
+ bottom: 20,
80
+ left: 3,
81
+ });
82
+ });
83
+ });