@shellui/core 0.4.0 → 0.5.0-alpha.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.
- package/README.md +2 -2
- package/package.json +15 -3
- package/schemas/curated-themes.json +4035 -0
- package/schemas/shellui.config.schema.json +961 -0
- package/schemas/shellui.theme.schema.json +187 -0
- package/src/app.tsx +4 -1
- package/src/components/ContentView.tsx +144 -9
- package/src/components/LoadingOverlay.tsx +1 -1
- package/src/components/ui/alert-dialog.tsx +1 -1
- package/src/components/ui/dialog.tsx +23 -5
- package/src/components/ui/drawer.tsx +282 -42
- package/src/components/ui/dropdown-menu.tsx +7 -2
- package/src/components/ui/input.tsx +21 -0
- package/src/components/ui/separator.tsx +23 -0
- package/src/components/ui/sheet.tsx +220 -0
- package/src/components/ui/sidebar.tsx +785 -221
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/constants/urls.ts +1 -0
- package/src/features/admin/utils.ts +2 -45
- package/src/features/alertDialog/DialogContext.tsx +1 -1
- package/src/features/auth/components/LoginButton.tsx +25 -18
- package/src/features/auth/components/LoginPreferencesControls.tsx +124 -0
- package/src/features/auth/components/LoginView.tsx +131 -49
- package/src/features/config/types.ts +64 -82
- package/src/features/drawer/DrawerContext.tsx +55 -19
- package/src/features/layouts/AppLayout.tsx +3 -3
- package/src/features/layouts/OverlayShell.tsx +376 -77
- package/src/features/layouts/appbar/AppBarLayout.tsx +501 -88
- package/src/features/layouts/branding/AppBrandIcon.tsx +95 -0
- package/src/features/layouts/branding/resolveThemeAsset.spec.ts +33 -0
- package/src/features/layouts/branding/resolveThemeAsset.ts +33 -0
- package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +49 -0
- package/src/features/layouts/chrome/ContentDragOverlay.tsx +19 -0
- package/src/features/layouts/chrome/DesktopBackButton.tsx +71 -0
- package/src/features/layouts/chrome/DesktopChrome.tsx +28 -0
- package/src/features/layouts/chrome/DesktopForwardButton.tsx +59 -0
- package/src/features/layouts/chrome/DesktopHistoryButtons.tsx +16 -0
- package/src/features/layouts/chrome/constants.ts +11 -0
- package/src/features/layouts/chrome/goDesktopBack.spec.ts +218 -0
- package/src/features/layouts/chrome/goDesktopBack.ts +106 -0
- package/src/features/layouts/chrome/index.ts +26 -0
- package/src/features/layouts/chrome/runtime.ts +45 -0
- package/src/features/layouts/findMatchingNavigationItem.spec.ts +55 -0
- package/src/features/layouts/fullscreen/FullscreenLayout.tsx +17 -1
- package/src/features/layouts/isFrameForAppUrl.spec.ts +33 -0
- package/src/features/layouts/sidebar/NavigationContent.tsx +70 -34
- package/src/features/layouts/sidebar/SidebarIcons.tsx +41 -42
- package/src/features/layouts/sidebar/SidebarInner.tsx +142 -24
- package/src/features/layouts/sidebar/SidebarLayout.tsx +100 -37
- package/src/features/layouts/sidebar/sidebarUtils.ts +0 -7
- package/src/features/layouts/sidebar/types.ts +3 -3
- package/src/features/layouts/utils.ts +73 -5
- package/src/features/layouts/windows/WindowsLayout.tsx +173 -61
- package/src/features/modal/ModalContext.spec.ts +77 -0
- package/src/features/modal/ModalContext.tsx +32 -57
- package/src/features/modal/validateAndNormalizeUrl.ts +96 -0
- package/src/features/overlays/OverlayDrawerPendingBar.tsx +26 -0
- package/src/features/overlays/OverlayDynamicDemoView.tsx +108 -0
- package/src/features/overlays/OverlayPendingSpinner.tsx +18 -0
- package/src/features/overlays/ResponsiveModal.tsx +483 -0
- package/src/features/overlays/overlaySize.spec.ts +71 -0
- package/src/features/overlays/overlaySize.ts +228 -0
- package/src/features/overlays/useOverlayReportedSize.ts +130 -0
- package/src/features/settings/SettingsProvider.tsx +66 -46
- package/src/features/settings/SettingsView.tsx +42 -47
- package/src/features/settings/components/Appearance.tsx +305 -55
- package/src/features/settings/components/develop/DrawerTestButtons.tsx +18 -0
- package/src/features/settings/components/develop/ModalTestButtons.tsx +23 -0
- package/src/features/settings/utils/getResolvedAppearanceForSettings.ts +11 -5
- package/src/features/storage/StoragePickerContext.tsx +3 -3
- package/src/features/theme/applyTheme.ts +143 -0
- package/src/features/theme/color.ts +83 -0
- package/src/features/theme/curated/amber-minimal.json +86 -0
- package/src/features/theme/curated/amethyst-haze.json +86 -0
- package/src/features/theme/curated/astro-vista.json +86 -0
- package/src/features/theme/curated/bold-tech.json +86 -0
- package/src/features/theme/curated/bubblegum.json +86 -0
- package/src/features/theme/curated/caffeine.json +83 -0
- package/src/features/theme/curated/candyland.json +86 -0
- package/src/features/theme/curated/catppuccin.json +86 -0
- package/src/features/theme/curated/claude.json +86 -0
- package/src/features/theme/curated/claymorphism.json +86 -0
- package/src/features/theme/curated/clean-slate.json +86 -0
- package/src/features/theme/curated/cosmic-night.json +86 -0
- package/src/features/theme/curated/cyberpunk.json +86 -0
- package/src/features/theme/curated/darkmatter.json +86 -0
- package/src/features/theme/curated/doom-64.json +86 -0
- package/src/features/theme/curated/elegant-luxury.json +86 -0
- package/src/features/theme/curated/graphite.json +86 -0
- package/src/features/theme/curated/index.ts +260 -0
- package/src/features/theme/curated/kodama-grove.json +86 -0
- package/src/features/theme/curated/light-green.json +87 -0
- package/src/features/theme/curated/midnight-bloom.json +86 -0
- package/src/features/theme/curated/mocha-mousse.json +86 -0
- package/src/features/theme/curated/modern-minimal.json +86 -0
- package/src/features/theme/curated/mono.json +84 -0
- package/src/features/theme/curated/nature.json +86 -0
- package/src/features/theme/curated/neo-brutalism.json +86 -0
- package/src/features/theme/curated/northern-lights.json +86 -0
- package/src/features/theme/curated/notebook.json +87 -0
- package/src/features/theme/curated/ocean-breeze.json +86 -0
- package/src/features/theme/curated/pastel-dreams.json +86 -0
- package/src/features/theme/curated/perpetuity.json +86 -0
- package/src/features/theme/curated/quantum-rose.json +86 -0
- package/src/features/theme/curated/retro-arcade.json +86 -0
- package/src/features/theme/curated/sage-garden.json +86 -0
- package/src/features/theme/curated/shadcn.json +83 -0
- package/src/features/theme/curated/shellui.json +82 -0
- package/src/features/theme/curated/soft-pop.json +86 -0
- package/src/features/theme/curated/solar-dusk.json +86 -0
- package/src/features/theme/curated/starry-night.json +86 -0
- package/src/features/theme/curated/sunset-horizon.json +86 -0
- package/src/features/theme/curated/supabase.json +85 -0
- package/src/features/theme/curated/t3-chat.json +83 -0
- package/src/features/theme/curated/tangerine.json +86 -0
- package/src/features/theme/curated/twitter.json +86 -0
- package/src/features/theme/curated/vercel.json +86 -0
- package/src/features/theme/curated/vintage-paper.json +86 -0
- package/src/features/theme/curated/violet-bloom.json +87 -0
- package/src/features/theme/curated/zen-inspired.json +87 -0
- package/src/features/theme/index.ts +76 -0
- package/src/features/theme/normalize.ts +159 -0
- package/src/features/theme/registry.ts +50 -0
- package/src/features/theme/resolveConfig.ts +182 -0
- package/src/features/theme/safeApplyTheme.ts +147 -0
- package/src/features/theme/themes.spec.ts +276 -0
- package/src/features/theme/themes.ts +82 -558
- package/src/features/theme/tokenKeys.ts +60 -0
- package/src/features/theme/types.ts +170 -0
- package/src/features/theme/useTheme.tsx +48 -50
- package/src/hooks/use-mobile.tsx +19 -0
- package/src/i18n/translations/en/common.json +41 -0
- package/src/i18n/translations/en/settings.json +10 -2
- package/src/i18n/translations/fr/common.json +41 -0
- package/src/i18n/translations/fr/settings.json +10 -2
- package/src/index.css +372 -128
- package/src/index.ts +71 -0
- package/src/lib/z-index.ts +4 -1
- package/src/routes/components/IndexRoute.tsx +12 -2
- package/src/routes/components/NavigationItemRoute.tsx +1 -10
- package/src/routes/hooks/useNavigationItems.ts +29 -44
- package/src/routes/routes.tsx +58 -27
- package/tailwind.config.js +27 -27
- package/src/features/layouts/sidebar/BottomNavItem.tsx +0 -88
- package/src/features/layouts/sidebar/MobileBottomNav.tsx +0 -168
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import { useMemo, useEffect, type ReactNode } from 'react';
|
|
2
|
-
import { Link, useLocation, Outlet
|
|
1
|
+
import { useMemo, useEffect, useState, Fragment, type ReactNode } from 'react';
|
|
2
|
+
import { Link, useLocation, Outlet } from 'react-router';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { shellui } from '@shellui/sdk';
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
NavigationItem,
|
|
7
|
+
NavigationGroup,
|
|
8
|
+
LocalizedString,
|
|
9
|
+
ThemeAsset,
|
|
10
|
+
} from '../../config/types';
|
|
11
|
+
import { AppBrandIcon } from '../branding/AppBrandIcon';
|
|
6
12
|
import {
|
|
7
13
|
filterNavigationForAuthState,
|
|
8
14
|
filterNavigationByViewport,
|
|
@@ -14,34 +20,39 @@ import {
|
|
|
14
20
|
splitNavigationByPosition,
|
|
15
21
|
withHomepageWhenNoRoot,
|
|
16
22
|
} from '../utils';
|
|
17
|
-
import {
|
|
23
|
+
import { Button } from '../../../components/ui/button';
|
|
24
|
+
import {
|
|
25
|
+
DropdownMenu,
|
|
26
|
+
DropdownMenuContent,
|
|
27
|
+
DropdownMenuItem,
|
|
28
|
+
DropdownMenuTrigger,
|
|
29
|
+
} from '../../../components/ui/dropdown-menu';
|
|
18
30
|
import { AppBarTooltip, TooltipProvider } from '../../../components/ui/tooltip';
|
|
19
31
|
import { cn } from '../../../lib/utils';
|
|
32
|
+
import { useIsMobile } from '../../../hooks/use-mobile';
|
|
20
33
|
import { LoginButton } from '../../auth/components/LoginButton';
|
|
21
34
|
import { useAuth } from '../../auth/hooks/useAuth';
|
|
22
35
|
import { useSettings } from '../../settings/hooks/useSettings';
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
import { NavIcon } from '../sidebar/SidebarIcons';
|
|
37
|
+
import { getExternalFaviconUrl } from '../sidebar/sidebarUtils';
|
|
38
|
+
import { DesktopHistoryButtons } from '../chrome/DesktopHistoryButtons';
|
|
39
|
+
import { useIsTauriClient, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
|
|
40
|
+
import {
|
|
41
|
+
DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
42
|
+
MAC_TRAFFIC_LIGHTS_GAP_PX,
|
|
43
|
+
MAC_TRAFFIC_LIGHTS_WIDTH_PX,
|
|
44
|
+
} from '../chrome/constants';
|
|
25
45
|
|
|
26
46
|
interface AppBarLayoutProps {
|
|
27
47
|
title?: string;
|
|
28
|
-
appIcon?:
|
|
29
|
-
logo?:
|
|
48
|
+
appIcon?: ThemeAsset;
|
|
49
|
+
logo?: ThemeAsset;
|
|
30
50
|
navigation: (NavigationItem | NavigationGroup)[];
|
|
31
51
|
}
|
|
32
52
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const hostname = parsed.hostname;
|
|
37
|
-
if (!hostname) return null;
|
|
38
|
-
return `https://icons.duckduckgo.com/ip3/${hostname}.ico`;
|
|
39
|
-
} catch {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const isAppIcon = (src: string) => src.startsWith('/icons/');
|
|
53
|
+
type NavSection =
|
|
54
|
+
| { type: 'group'; title: LocalizedString; items: NavigationItem[] }
|
|
55
|
+
| { type: 'items'; items: NavigationItem[] };
|
|
45
56
|
|
|
46
57
|
function resolveLocalizedLabel(
|
|
47
58
|
value: string | { en: string; fr: string; [key: string]: string },
|
|
@@ -51,6 +62,413 @@ function resolveLocalizedLabel(
|
|
|
51
62
|
return value[lang] || value.en || value.fr || Object.values(value)[0] || '';
|
|
52
63
|
}
|
|
53
64
|
|
|
65
|
+
function isNavigationGroup(item: NavigationItem | NavigationGroup): item is NavigationGroup {
|
|
66
|
+
return 'title' in item && 'items' in item;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function AppsGridIcon({ className }: { className?: string }) {
|
|
70
|
+
return (
|
|
71
|
+
<svg
|
|
72
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
73
|
+
width="24"
|
|
74
|
+
height="24"
|
|
75
|
+
viewBox="0 0 24 24"
|
|
76
|
+
fill="currentColor"
|
|
77
|
+
className={className}
|
|
78
|
+
aria-hidden
|
|
79
|
+
>
|
|
80
|
+
<rect
|
|
81
|
+
x="3"
|
|
82
|
+
y="3"
|
|
83
|
+
width="4.5"
|
|
84
|
+
height="4.5"
|
|
85
|
+
rx="0.75"
|
|
86
|
+
/>
|
|
87
|
+
<rect
|
|
88
|
+
x="9.75"
|
|
89
|
+
y="3"
|
|
90
|
+
width="4.5"
|
|
91
|
+
height="4.5"
|
|
92
|
+
rx="0.75"
|
|
93
|
+
/>
|
|
94
|
+
<rect
|
|
95
|
+
x="16.5"
|
|
96
|
+
y="3"
|
|
97
|
+
width="4.5"
|
|
98
|
+
height="4.5"
|
|
99
|
+
rx="0.75"
|
|
100
|
+
/>
|
|
101
|
+
<rect
|
|
102
|
+
x="3"
|
|
103
|
+
y="9.75"
|
|
104
|
+
width="4.5"
|
|
105
|
+
height="4.5"
|
|
106
|
+
rx="0.75"
|
|
107
|
+
/>
|
|
108
|
+
<rect
|
|
109
|
+
x="9.75"
|
|
110
|
+
y="9.75"
|
|
111
|
+
width="4.5"
|
|
112
|
+
height="4.5"
|
|
113
|
+
rx="0.75"
|
|
114
|
+
/>
|
|
115
|
+
<rect
|
|
116
|
+
x="16.5"
|
|
117
|
+
y="9.75"
|
|
118
|
+
width="4.5"
|
|
119
|
+
height="4.5"
|
|
120
|
+
rx="0.75"
|
|
121
|
+
/>
|
|
122
|
+
<rect
|
|
123
|
+
x="3"
|
|
124
|
+
y="16.5"
|
|
125
|
+
width="4.5"
|
|
126
|
+
height="4.5"
|
|
127
|
+
rx="0.75"
|
|
128
|
+
/>
|
|
129
|
+
<rect
|
|
130
|
+
x="9.75"
|
|
131
|
+
y="16.5"
|
|
132
|
+
width="4.5"
|
|
133
|
+
height="4.5"
|
|
134
|
+
rx="0.75"
|
|
135
|
+
/>
|
|
136
|
+
<rect
|
|
137
|
+
x="16.5"
|
|
138
|
+
y="16.5"
|
|
139
|
+
width="4.5"
|
|
140
|
+
height="4.5"
|
|
141
|
+
rx="0.75"
|
|
142
|
+
/>
|
|
143
|
+
</svg>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function navItemIsActive(item: NavigationItem, activePathPrefix: string | null): boolean {
|
|
148
|
+
const isOverlay = item.openIn === 'modal' || item.openIn === 'drawer';
|
|
149
|
+
const isExternal = item.openIn === 'external';
|
|
150
|
+
return !isOverlay && !isExternal && getNavPathPrefix(item) === activePathPrefix;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function itemIconSrc(item: NavigationItem): string | null {
|
|
154
|
+
if (item.icon) return item.icon;
|
|
155
|
+
if (item.openIn === 'external') return getExternalFaviconUrl(item.url);
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function NavItemGlyph({
|
|
160
|
+
item,
|
|
161
|
+
label,
|
|
162
|
+
className,
|
|
163
|
+
/** Rounded muted tile with a compact icon inside (app-bar launcher). */
|
|
164
|
+
tiled = false,
|
|
165
|
+
}: {
|
|
166
|
+
item: NavigationItem;
|
|
167
|
+
label: string;
|
|
168
|
+
className?: string;
|
|
169
|
+
tiled?: boolean;
|
|
170
|
+
}) {
|
|
171
|
+
const iconSrc = itemIconSrc(item);
|
|
172
|
+
const firstLetter = label ? label.charAt(0).toUpperCase() : '?';
|
|
173
|
+
|
|
174
|
+
if (tiled) {
|
|
175
|
+
return (
|
|
176
|
+
<span
|
|
177
|
+
className={cn(
|
|
178
|
+
'flex size-10 shrink-0 items-center justify-center rounded-lg bg-background text-muted-foreground shadow-sm ring-1 ring-border/60',
|
|
179
|
+
className,
|
|
180
|
+
)}
|
|
181
|
+
aria-hidden
|
|
182
|
+
>
|
|
183
|
+
{iconSrc ? (
|
|
184
|
+
<NavIcon
|
|
185
|
+
src={iconSrc}
|
|
186
|
+
className="size-5"
|
|
187
|
+
/>
|
|
188
|
+
) : (
|
|
189
|
+
<span className="text-xs font-semibold">{firstLetter}</span>
|
|
190
|
+
)}
|
|
191
|
+
</span>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (iconSrc) {
|
|
196
|
+
return (
|
|
197
|
+
<NavIcon
|
|
198
|
+
src={iconSrc}
|
|
199
|
+
className={cn('size-4', className)}
|
|
200
|
+
/>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
return (
|
|
204
|
+
<span
|
|
205
|
+
className={cn(
|
|
206
|
+
'flex size-5 shrink-0 items-center justify-center rounded-md bg-muted text-[10px] font-semibold text-muted-foreground',
|
|
207
|
+
className,
|
|
208
|
+
)}
|
|
209
|
+
aria-hidden
|
|
210
|
+
>
|
|
211
|
+
{firstLetter}
|
|
212
|
+
</span>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function navigateToItem(item: NavigationItem): void {
|
|
217
|
+
if (item.openIn === 'modal') {
|
|
218
|
+
shellui.openModal(item.url);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (item.openIn === 'drawer') {
|
|
222
|
+
shellui.openDrawer({ url: item.url, position: item.drawerPosition });
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (item.openIn === 'external') {
|
|
226
|
+
window.open(item.url, '_blank', 'noopener,noreferrer');
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
// Link navigation handled by callers that render <Link>
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function buildStartSections(start: (NavigationItem | NavigationGroup)[]): NavSection[] {
|
|
233
|
+
const filtered: (NavigationItem | NavigationGroup)[] = [];
|
|
234
|
+
for (const entry of start) {
|
|
235
|
+
if (isNavigationGroup(entry)) {
|
|
236
|
+
const items = entry.items.filter((i) => !i.hidden);
|
|
237
|
+
if (items.length > 0) {
|
|
238
|
+
filtered.push({ ...entry, items });
|
|
239
|
+
}
|
|
240
|
+
} else if (!entry.hidden) {
|
|
241
|
+
filtered.push(entry);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const flat = flattenNavigationItems(filtered);
|
|
246
|
+
const ensured = withHomepageWhenNoRoot(flat.filter((i) => !i.hidden));
|
|
247
|
+
const home = ensured.find((i) => i.path === '' || i.path === '/');
|
|
248
|
+
const needsHome = Boolean(home && !flat.some((i) => i.path === home.path));
|
|
249
|
+
const withHome: (NavigationItem | NavigationGroup)[] =
|
|
250
|
+
needsHome && home ? [home, ...filtered] : filtered;
|
|
251
|
+
|
|
252
|
+
const sections: NavSection[] = [];
|
|
253
|
+
for (const entry of withHome) {
|
|
254
|
+
if (isNavigationGroup(entry)) {
|
|
255
|
+
sections.push({
|
|
256
|
+
type: 'group',
|
|
257
|
+
title: entry.title,
|
|
258
|
+
items: entry.items.filter((i) => !i.hidden),
|
|
259
|
+
});
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
const last = sections[sections.length - 1];
|
|
263
|
+
if (last?.type === 'items') {
|
|
264
|
+
last.items.push(entry);
|
|
265
|
+
} else {
|
|
266
|
+
sections.push({ type: 'items', items: [entry] });
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return sections;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** Resolve selected item + localized category for the current path. */
|
|
273
|
+
function resolveSelectedDisplay(
|
|
274
|
+
sections: NavSection[],
|
|
275
|
+
activePathPrefix: string | null,
|
|
276
|
+
lang: string,
|
|
277
|
+
): { item: NavigationItem; label: string; category: string | null } | null {
|
|
278
|
+
for (const section of sections) {
|
|
279
|
+
const category = section.type === 'group' ? resolveLocalizedLabel(section.title, lang) : null;
|
|
280
|
+
for (const item of section.items) {
|
|
281
|
+
if (navItemIsActive(item, activePathPrefix)) {
|
|
282
|
+
return {
|
|
283
|
+
item,
|
|
284
|
+
label: resolveNavLabel(item.label, lang) || item.path || 'Home',
|
|
285
|
+
category,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
for (const section of sections) {
|
|
291
|
+
const category = section.type === 'group' ? resolveLocalizedLabel(section.title, lang) : null;
|
|
292
|
+
for (const item of section.items) {
|
|
293
|
+
if (item.openIn === 'modal' || item.openIn === 'drawer' || item.openIn === 'external') {
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
return {
|
|
297
|
+
item,
|
|
298
|
+
label: resolveNavLabel(item.label, lang) || item.path || 'Home',
|
|
299
|
+
category,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const firstSection = sections[0];
|
|
304
|
+
const first = firstSection?.items[0];
|
|
305
|
+
if (!first) return null;
|
|
306
|
+
return {
|
|
307
|
+
item: first,
|
|
308
|
+
label: resolveNavLabel(first.label, lang) || first.path || 'Home',
|
|
309
|
+
category:
|
|
310
|
+
firstSection.type === 'group' ? resolveLocalizedLabel(firstSection.title, lang) : null,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function AppBarLauncherTile({
|
|
315
|
+
item,
|
|
316
|
+
label,
|
|
317
|
+
activePathPrefix,
|
|
318
|
+
onActivate,
|
|
319
|
+
onNavigate,
|
|
320
|
+
}: {
|
|
321
|
+
item: NavigationItem;
|
|
322
|
+
label: string;
|
|
323
|
+
activePathPrefix: string | null;
|
|
324
|
+
onActivate: (item: NavigationItem) => void;
|
|
325
|
+
onNavigate: () => void;
|
|
326
|
+
}) {
|
|
327
|
+
const isActive = navItemIsActive(item, activePathPrefix);
|
|
328
|
+
const pathPrefix = getNavPathPrefix(item);
|
|
329
|
+
const tileClass =
|
|
330
|
+
'group flex w-[7rem] shrink-0 flex-col items-center justify-start rounded-md px-1 pt-4 pb-2 text-center focus:bg-transparent data-[highlighted]:bg-transparent';
|
|
331
|
+
const body = (
|
|
332
|
+
<span
|
|
333
|
+
className={cn(
|
|
334
|
+
'flex aspect-square w-full flex-col items-center justify-center gap-1.5 overflow-hidden rounded-md p-2 transition-colors',
|
|
335
|
+
'hover:bg-accent/80 hover:text-accent-foreground',
|
|
336
|
+
'group-data-[highlighted]:bg-accent/80 group-data-[highlighted]:text-accent-foreground',
|
|
337
|
+
isActive && 'bg-accent/80 text-accent-foreground',
|
|
338
|
+
)}
|
|
339
|
+
>
|
|
340
|
+
<NavItemGlyph
|
|
341
|
+
item={item}
|
|
342
|
+
label={label}
|
|
343
|
+
tiled
|
|
344
|
+
/>
|
|
345
|
+
<span className="line-clamp-2 w-full text-center text-[11px] leading-snug font-medium break-words">
|
|
346
|
+
{label}
|
|
347
|
+
</span>
|
|
348
|
+
</span>
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
if (item.openIn === 'modal' || item.openIn === 'drawer' || item.openIn === 'external') {
|
|
352
|
+
return (
|
|
353
|
+
<DropdownMenuItem
|
|
354
|
+
className={tileClass}
|
|
355
|
+
onSelect={() => onActivate(item)}
|
|
356
|
+
>
|
|
357
|
+
{body}
|
|
358
|
+
</DropdownMenuItem>
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return (
|
|
363
|
+
<DropdownMenuItem
|
|
364
|
+
className={tileClass}
|
|
365
|
+
asChild
|
|
366
|
+
>
|
|
367
|
+
<Link
|
|
368
|
+
to={pathPrefix}
|
|
369
|
+
onClick={onNavigate}
|
|
370
|
+
>
|
|
371
|
+
{body}
|
|
372
|
+
</Link>
|
|
373
|
+
</DropdownMenuItem>
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function AppBarLauncher({
|
|
378
|
+
sections,
|
|
379
|
+
activePathPrefix,
|
|
380
|
+
currentLanguage,
|
|
381
|
+
}: {
|
|
382
|
+
sections: NavSection[];
|
|
383
|
+
activePathPrefix: string | null;
|
|
384
|
+
currentLanguage: string;
|
|
385
|
+
}) {
|
|
386
|
+
const { t } = useTranslation();
|
|
387
|
+
const [open, setOpen] = useState(false);
|
|
388
|
+
const selected = useMemo(
|
|
389
|
+
() => resolveSelectedDisplay(sections, activePathPrefix, currentLanguage),
|
|
390
|
+
[sections, activePathPrefix, currentLanguage],
|
|
391
|
+
);
|
|
392
|
+
|
|
393
|
+
const activateItem = (item: NavigationItem) => {
|
|
394
|
+
if (item.openIn === 'modal' || item.openIn === 'drawer' || item.openIn === 'external') {
|
|
395
|
+
navigateToItem(item);
|
|
396
|
+
setOpen(false);
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
const renderTile = (item: NavigationItem, index: number) => {
|
|
401
|
+
const label = resolveNavLabel(item.label, currentLanguage) || item.path || 'Home';
|
|
402
|
+
return (
|
|
403
|
+
<AppBarLauncherTile
|
|
404
|
+
key={`${item.path}-${item.url}-${index}`}
|
|
405
|
+
item={item}
|
|
406
|
+
label={label}
|
|
407
|
+
activePathPrefix={activePathPrefix}
|
|
408
|
+
onActivate={activateItem}
|
|
409
|
+
onNavigate={() => setOpen(false)}
|
|
410
|
+
/>
|
|
411
|
+
);
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
return (
|
|
415
|
+
<div
|
|
416
|
+
data-shellui-no-drag=""
|
|
417
|
+
className="flex min-w-0 items-center"
|
|
418
|
+
>
|
|
419
|
+
<DropdownMenu
|
|
420
|
+
open={open}
|
|
421
|
+
onOpenChange={setOpen}
|
|
422
|
+
>
|
|
423
|
+
<DropdownMenuTrigger asChild>
|
|
424
|
+
<Button
|
|
425
|
+
type="button"
|
|
426
|
+
variant="ghost"
|
|
427
|
+
size="sm"
|
|
428
|
+
className="h-7 max-w-[16rem] shrink gap-2 px-2 text-sidebar-foreground hover:bg-sidebar-accent/60 hover:text-sidebar-foreground"
|
|
429
|
+
aria-label={t('desktopChrome.openNavigation')}
|
|
430
|
+
>
|
|
431
|
+
<AppsGridIcon className="size-4 shrink-0 text-muted-foreground" />
|
|
432
|
+
<span className="min-w-0 truncate text-xs font-medium">
|
|
433
|
+
{selected?.label ?? t('desktopChrome.navigation')}
|
|
434
|
+
</span>
|
|
435
|
+
</Button>
|
|
436
|
+
</DropdownMenuTrigger>
|
|
437
|
+
<DropdownMenuContent
|
|
438
|
+
align="start"
|
|
439
|
+
onCloseAutoFocus={(event) => event.preventDefault()}
|
|
440
|
+
className="w-max min-w-0 max-w-[calc(100vw-1.5rem)] max-h-[min(32rem,var(--radix-dropdown-menu-content-available-height,32rem))] overflow-y-auto p-3 pt-4 md:max-w-[50vw]"
|
|
441
|
+
>
|
|
442
|
+
<div className="flex flex-row flex-wrap items-start gap-x-2 gap-y-4">
|
|
443
|
+
{sections.map((section, sectionIndex) => {
|
|
444
|
+
if (section.type === 'group') {
|
|
445
|
+
const categoryLabel = resolveLocalizedLabel(section.title, currentLanguage);
|
|
446
|
+
return (
|
|
447
|
+
<div
|
|
448
|
+
key={`group-${categoryLabel}-${sectionIndex}`}
|
|
449
|
+
className="relative inline-flex max-w-full flex-row flex-wrap gap-1.5 rounded-xl bg-muted/50 px-1.5 py-0 ring-1 ring-border/50"
|
|
450
|
+
>
|
|
451
|
+
<span className="pointer-events-none absolute left-2.5 top-0 z-10 -translate-y-1/2 rounded-sm bg-popover px-1.5 text-[10px] font-medium leading-none text-muted-foreground">
|
|
452
|
+
{categoryLabel}
|
|
453
|
+
</span>
|
|
454
|
+
{section.items.map((item, index) => renderTile(item, index))}
|
|
455
|
+
</div>
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
return (
|
|
460
|
+
<Fragment key={`items-${sectionIndex}`}>
|
|
461
|
+
{section.items.map((item, index) => renderTile(item, index))}
|
|
462
|
+
</Fragment>
|
|
463
|
+
);
|
|
464
|
+
})}
|
|
465
|
+
</div>
|
|
466
|
+
</DropdownMenuContent>
|
|
467
|
+
</DropdownMenu>
|
|
468
|
+
</div>
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
|
|
54
472
|
/** End link: icon-only or first-letter badge with themed tooltip. */
|
|
55
473
|
function TopBarEndItem({
|
|
56
474
|
item,
|
|
@@ -71,17 +489,13 @@ function TopBarEndItem({
|
|
|
71
489
|
const firstLetter = label ? label.charAt(0).toUpperCase() : '?';
|
|
72
490
|
|
|
73
491
|
const iconEl = iconSrc ? (
|
|
74
|
-
<
|
|
492
|
+
<NavIcon
|
|
75
493
|
src={iconSrc}
|
|
76
|
-
|
|
77
|
-
className={cn(
|
|
78
|
-
'size-5 shrink-0 rounded-sm object-cover',
|
|
79
|
-
isAppIcon(iconSrc) && 'opacity-90 dark:opacity-100 dark:invert',
|
|
80
|
-
)}
|
|
494
|
+
className="size-4"
|
|
81
495
|
/>
|
|
82
496
|
) : (
|
|
83
497
|
<span
|
|
84
|
-
className="size-
|
|
498
|
+
className="flex size-5 shrink-0 items-center justify-center rounded-md bg-muted text-[10px] font-semibold text-muted-foreground"
|
|
85
499
|
aria-hidden
|
|
86
500
|
>
|
|
87
501
|
{firstLetter}
|
|
@@ -89,7 +503,7 @@ function TopBarEndItem({
|
|
|
89
503
|
);
|
|
90
504
|
|
|
91
505
|
const buttonClass = cn(
|
|
92
|
-
'flex items-center justify-center
|
|
506
|
+
'flex size-7 items-center justify-center rounded-md transition-colors cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
93
507
|
isActive
|
|
94
508
|
? 'bg-sidebar-accent text-sidebar-accent-foreground'
|
|
95
509
|
: 'text-muted-foreground hover:bg-sidebar-accent/50 hover:text-sidebar-foreground',
|
|
@@ -145,12 +559,15 @@ function TopBarEndItem({
|
|
|
145
559
|
);
|
|
146
560
|
}
|
|
147
561
|
|
|
148
|
-
export function AppBarLayout({ title,
|
|
562
|
+
export function AppBarLayout({ title, appIcon, navigation }: AppBarLayoutProps) {
|
|
149
563
|
const { i18n } = useTranslation();
|
|
150
564
|
const { isAuthenticated } = useAuth();
|
|
151
565
|
const { settings } = useSettings();
|
|
152
566
|
const location = useLocation();
|
|
153
|
-
const
|
|
567
|
+
const isMobile = useIsMobile();
|
|
568
|
+
const isTauriEnv = useIsTauriClient();
|
|
569
|
+
const overlay = useMacOverlayChrome();
|
|
570
|
+
const trafficLights = useMacTrafficLights();
|
|
154
571
|
const currentLanguage = i18n.language || 'en';
|
|
155
572
|
const hasCustomLoginNav = useMemo(() => hasLoginNavigationItem(navigation), [navigation]);
|
|
156
573
|
const authAwareNavigation = useMemo(
|
|
@@ -159,18 +576,20 @@ export function AppBarLayout({ title, logo, navigation }: AppBarLayoutProps) {
|
|
|
159
576
|
[navigation, isAuthenticated, settings.developerFeatures.enabled],
|
|
160
577
|
);
|
|
161
578
|
|
|
162
|
-
const { endNavItems, navigationItems,
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
579
|
+
const { endNavItems, navigationItems, startSections, activePathPrefix } = useMemo(() => {
|
|
580
|
+
const viewportNav = filterNavigationByViewport(
|
|
581
|
+
authAwareNavigation,
|
|
582
|
+
isMobile ? 'mobile' : 'desktop',
|
|
583
|
+
);
|
|
584
|
+
const { start, end } = splitNavigationByPosition(viewportNav);
|
|
166
585
|
const flat = flattenNavigationItems(authAwareNavigation);
|
|
167
586
|
return {
|
|
168
587
|
endNavItems: flattenNavigationItems(end).filter((i) => !i.hidden),
|
|
169
588
|
navigationItems: flat,
|
|
170
|
-
|
|
589
|
+
startSections: buildStartSections(start),
|
|
171
590
|
activePathPrefix: getActivePathPrefix(location.pathname, flat),
|
|
172
591
|
};
|
|
173
|
-
}, [authAwareNavigation, location.pathname]);
|
|
592
|
+
}, [authAwareNavigation, location.pathname, isMobile]);
|
|
174
593
|
|
|
175
594
|
useEffect(() => {
|
|
176
595
|
if (!title) return;
|
|
@@ -192,63 +611,57 @@ export function AppBarLayout({ title, logo, navigation }: AppBarLayoutProps) {
|
|
|
192
611
|
}
|
|
193
612
|
}, [location.pathname, title, navigationItems, currentLanguage]);
|
|
194
613
|
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
614
|
+
const chromeInset = trafficLights
|
|
615
|
+
? MAC_TRAFFIC_LIGHTS_WIDTH_PX + MAC_TRAFFIC_LIGHTS_GAP_PX
|
|
616
|
+
: undefined;
|
|
617
|
+
|
|
618
|
+
const hasStartNav = startSections.some((s) => s.items.length > 0);
|
|
199
619
|
|
|
200
620
|
return (
|
|
201
|
-
<div className="flex flex-col
|
|
202
|
-
{/* Top bar: max 42px */}
|
|
621
|
+
<div className="flex h-screen flex-col overflow-hidden bg-background">
|
|
203
622
|
<header
|
|
204
|
-
className="flex items-center gap-
|
|
205
|
-
style={{
|
|
623
|
+
className="relative z-[46] flex w-full shrink-0 items-center gap-1.5 border-b border-sidebar-border bg-sidebar text-sidebar-foreground select-none"
|
|
624
|
+
style={{
|
|
625
|
+
height: DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
626
|
+
paddingLeft: chromeInset ?? 12,
|
|
627
|
+
paddingRight: 8,
|
|
628
|
+
}}
|
|
206
629
|
data-layout="app-bar"
|
|
630
|
+
{...(trafficLights ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' } : {})}
|
|
207
631
|
>
|
|
208
|
-
{
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
className="h-8 max-w-[200px] text-sm leading-tight py-1.5 border-sidebar-border bg-sidebar-background"
|
|
228
|
-
value={currentPathPrefix}
|
|
229
|
-
onChange={(e) => {
|
|
230
|
-
const path = e.target.value;
|
|
231
|
-
if (path) {
|
|
232
|
-
navigate(path.startsWith('/') ? path : `/${path}`);
|
|
233
|
-
}
|
|
234
|
-
}}
|
|
235
|
-
>
|
|
236
|
-
{displayStartItems.map((item, index) => (
|
|
237
|
-
<option
|
|
238
|
-
key={`${item.path || 'root'}-${item.url}-${item.openIn || 'default'}-${index}`}
|
|
239
|
-
value={getNavPathPrefix(item)}
|
|
240
|
-
>
|
|
241
|
-
{resolveNavLabel(item.label, currentLanguage) || item.path || 'Home'}
|
|
242
|
-
</option>
|
|
243
|
-
))}
|
|
244
|
-
</Select>
|
|
245
|
-
)}
|
|
632
|
+
{appIcon ? (
|
|
633
|
+
<AppBrandIcon
|
|
634
|
+
appIcon={appIcon}
|
|
635
|
+
title={title}
|
|
636
|
+
data-shellui-no-drag=""
|
|
637
|
+
className="mr-1"
|
|
638
|
+
imgClassName="app-bar-app-icon"
|
|
639
|
+
/>
|
|
640
|
+
) : null}
|
|
641
|
+
|
|
642
|
+
{hasStartNav ? (
|
|
643
|
+
<AppBarLauncher
|
|
644
|
+
sections={startSections}
|
|
645
|
+
activePathPrefix={activePathPrefix}
|
|
646
|
+
currentLanguage={currentLanguage}
|
|
647
|
+
/>
|
|
648
|
+
) : null}
|
|
649
|
+
|
|
650
|
+
{isTauriEnv ? <DesktopHistoryButtons /> : null}
|
|
246
651
|
|
|
247
|
-
<div
|
|
652
|
+
<div
|
|
653
|
+
aria-hidden
|
|
654
|
+
className="min-h-full min-w-[8px] flex-1"
|
|
655
|
+
{...(trafficLights || overlay
|
|
656
|
+
? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
|
|
657
|
+
: {})}
|
|
658
|
+
/>
|
|
248
659
|
|
|
249
|
-
<div
|
|
250
|
-
|
|
251
|
-
|
|
660
|
+
<div
|
|
661
|
+
data-shellui-no-drag=""
|
|
662
|
+
className="flex shrink-0 items-center gap-0.5"
|
|
663
|
+
>
|
|
664
|
+
{endNavItems.length > 0 ? (
|
|
252
665
|
<TooltipProvider
|
|
253
666
|
delayDuration={200}
|
|
254
667
|
skipDelayDuration={0}
|
|
@@ -264,7 +677,7 @@ export function AppBarLayout({ title, logo, navigation }: AppBarLayoutProps) {
|
|
|
264
677
|
))}
|
|
265
678
|
</div>
|
|
266
679
|
</TooltipProvider>
|
|
267
|
-
)}
|
|
680
|
+
) : null}
|
|
268
681
|
<LoginButton
|
|
269
682
|
variant="appbar"
|
|
270
683
|
hideWhenLoggedOut={hasCustomLoginNav}
|
|
@@ -272,7 +685,7 @@ export function AppBarLayout({ title, logo, navigation }: AppBarLayoutProps) {
|
|
|
272
685
|
</div>
|
|
273
686
|
</header>
|
|
274
687
|
|
|
275
|
-
<main className="flex-
|
|
688
|
+
<main className="flex min-h-0 flex-1 flex-col overflow-auto">
|
|
276
689
|
<Outlet />
|
|
277
690
|
</main>
|
|
278
691
|
</div>
|