@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,49 +1,167 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import type { NavigationItem, NavigationGroup, ThemeAsset } from '../../config/types';
|
|
2
|
+
import {
|
|
3
|
+
SidebarHeader,
|
|
4
|
+
SidebarContent,
|
|
5
|
+
SidebarFooter,
|
|
6
|
+
SidebarTrigger,
|
|
7
|
+
useSidebar,
|
|
8
|
+
} from '../../../components/ui/sidebar';
|
|
4
9
|
import { NavigationContent } from './NavigationContent';
|
|
5
10
|
import { LoginButton } from '../../auth/components/LoginButton';
|
|
11
|
+
import { cn } from '../../../lib/utils';
|
|
12
|
+
import { DesktopHistoryButtons } from '../chrome/DesktopHistoryButtons';
|
|
13
|
+
import { useIsTauriClient, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
|
|
14
|
+
import {
|
|
15
|
+
DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
16
|
+
MAC_TRAFFIC_LIGHTS_GAP_PX,
|
|
17
|
+
MAC_TRAFFIC_LIGHTS_WIDTH_PX,
|
|
18
|
+
} from '../chrome/constants';
|
|
19
|
+
import { AppBrandIcon } from '../branding/AppBrandIcon';
|
|
6
20
|
|
|
7
|
-
/** Reusable sidebar inner: header, main nav, footer. Used in desktop Sidebar and mobile
|
|
21
|
+
/** Reusable sidebar inner: header, main nav, footer. Used in desktop Sidebar and mobile Sheet. */
|
|
8
22
|
export function SidebarInner({
|
|
9
|
-
title,
|
|
10
|
-
logo,
|
|
11
23
|
startNav,
|
|
12
24
|
endItems,
|
|
13
25
|
showAuthButton,
|
|
26
|
+
title,
|
|
27
|
+
appIcon,
|
|
14
28
|
}: {
|
|
15
|
-
title?: string;
|
|
16
|
-
logo?: string;
|
|
17
29
|
startNav: (NavigationItem | NavigationGroup)[];
|
|
18
30
|
endItems: (NavigationItem | NavigationGroup)[];
|
|
19
31
|
showAuthButton: boolean;
|
|
32
|
+
title?: string;
|
|
33
|
+
appIcon?: ThemeAsset;
|
|
20
34
|
}) {
|
|
35
|
+
const isTauriEnv = useIsTauriClient();
|
|
36
|
+
const overlay = useMacOverlayChrome();
|
|
37
|
+
const trafficLights = useMacTrafficLights();
|
|
38
|
+
const { state, isMobile } = useSidebar();
|
|
39
|
+
const collapsed = state === 'collapsed' && !isMobile;
|
|
40
|
+
// Collapsed Tauri: Back + trigger live in CollapsedDesktopTitlebar instead.
|
|
41
|
+
const showCollapsedTopBar = overlay && collapsed;
|
|
42
|
+
const showOverlayHeader = overlay && !collapsed;
|
|
43
|
+
// Narrow Tauri window: sheet header must clear native traffic lights.
|
|
44
|
+
const mobileSheetHeader = isMobile && trafficLights;
|
|
45
|
+
const mobileTrafficInset = mobileSheetHeader
|
|
46
|
+
? MAC_TRAFFIC_LIGHTS_WIDTH_PX + MAC_TRAFFIC_LIGHTS_GAP_PX
|
|
47
|
+
: undefined;
|
|
48
|
+
// Keep trigger on the right whenever an icon is configured (even while collapsed),
|
|
49
|
+
// so it rides the sidebar width animation instead of jumping left.
|
|
50
|
+
const hasAppIcon = Boolean(appIcon);
|
|
51
|
+
|
|
52
|
+
const brandIcon = hasAppIcon ? (
|
|
53
|
+
<AppBrandIcon
|
|
54
|
+
appIcon={appIcon}
|
|
55
|
+
title={title}
|
|
56
|
+
data-shellui-no-drag=""
|
|
57
|
+
className={cn(
|
|
58
|
+
'ml-1 w-5 min-w-0 shrink-0 overflow-hidden transition-[width,opacity,margin] duration-200 ease-linear',
|
|
59
|
+
// Sync with sidebar collapse; icon fades/shrinks while trigger stays put.
|
|
60
|
+
'group-data-[collapsible=icon]:pointer-events-none group-data-[collapsible=icon]:ml-0 group-data-[collapsible=icon]:w-0 group-data-[collapsible=icon]:opacity-0',
|
|
61
|
+
)}
|
|
62
|
+
imgClassName="sidebar-app-icon"
|
|
63
|
+
/>
|
|
64
|
+
) : null;
|
|
65
|
+
|
|
66
|
+
// Right twin of the logo's ml-1. When collapsed it grows so the trigger stays centered
|
|
67
|
+
// with the nav icons (same role as the left flex-1 spacer when expanded).
|
|
68
|
+
const trailingInset = hasAppIcon ? (
|
|
69
|
+
<div
|
|
70
|
+
aria-hidden
|
|
71
|
+
className="w-1 shrink-0 transition-[flex-grow,width] duration-200 ease-linear group-data-[collapsible=icon]:w-auto group-data-[collapsible=icon]:flex-1"
|
|
72
|
+
/>
|
|
73
|
+
) : null;
|
|
74
|
+
|
|
21
75
|
return (
|
|
22
76
|
<>
|
|
23
|
-
<SidebarHeader
|
|
24
|
-
{(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
77
|
+
<SidebarHeader
|
|
78
|
+
className={cn(
|
|
79
|
+
'border-b border-sidebar-border select-none',
|
|
80
|
+
showOverlayHeader && 'gap-0 p-0',
|
|
81
|
+
showCollapsedTopBar && 'hidden',
|
|
82
|
+
mobileSheetHeader && 'gap-0 p-0',
|
|
83
|
+
)}
|
|
84
|
+
style={
|
|
85
|
+
mobileSheetHeader
|
|
86
|
+
? {
|
|
87
|
+
height: DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
88
|
+
paddingLeft: mobileTrafficInset,
|
|
89
|
+
}
|
|
90
|
+
: undefined
|
|
91
|
+
}
|
|
92
|
+
{...(showOverlayHeader
|
|
93
|
+
? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
|
|
94
|
+
: {})}
|
|
95
|
+
>
|
|
96
|
+
{showOverlayHeader ? (
|
|
97
|
+
<div
|
|
98
|
+
className="flex w-full shrink-0 items-stretch"
|
|
99
|
+
style={{ height: DESKTOP_TITLEBAR_HEIGHT_PX }}
|
|
100
|
+
data-shellui-drag-region=""
|
|
101
|
+
data-tauri-drag-region=""
|
|
28
102
|
>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
103
|
+
<div
|
|
104
|
+
className="h-full shrink-0"
|
|
105
|
+
style={{ width: MAC_TRAFFIC_LIGHTS_WIDTH_PX }}
|
|
106
|
+
aria-hidden
|
|
107
|
+
/>
|
|
108
|
+
<div
|
|
109
|
+
className="flex h-full min-w-0 flex-1 items-center gap-1"
|
|
110
|
+
style={{ paddingLeft: MAC_TRAFFIC_LIGHTS_GAP_PX }}
|
|
111
|
+
>
|
|
112
|
+
{hasAppIcon ? brandIcon : null}
|
|
113
|
+
{!hasAppIcon ? (
|
|
114
|
+
<SidebarTrigger
|
|
115
|
+
data-shellui-no-drag=""
|
|
116
|
+
className="size-8 shrink-0 touch-manipulation"
|
|
117
|
+
/>
|
|
118
|
+
) : null}
|
|
119
|
+
<div
|
|
120
|
+
aria-hidden
|
|
121
|
+
data-shellui-drag-region=""
|
|
122
|
+
data-tauri-drag-region=""
|
|
123
|
+
className="min-h-full min-w-[8px] flex-1 self-stretch"
|
|
124
|
+
/>
|
|
125
|
+
{isTauriEnv ? <DesktopHistoryButtons className="self-center" /> : null}
|
|
126
|
+
{hasAppIcon ? (
|
|
127
|
+
<SidebarTrigger
|
|
128
|
+
data-shellui-no-drag=""
|
|
129
|
+
className="size-8 shrink-0 touch-manipulation"
|
|
130
|
+
/>
|
|
131
|
+
) : null}
|
|
132
|
+
{hasAppIcon ? trailingInset : null}
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
) : (
|
|
136
|
+
<div
|
|
137
|
+
className={cn(
|
|
138
|
+
'flex w-full items-center',
|
|
139
|
+
hasAppIcon ? 'gap-0' : 'gap-0.5',
|
|
140
|
+
mobileSheetHeader && 'h-full',
|
|
141
|
+
)}
|
|
142
|
+
>
|
|
143
|
+
{brandIcon}
|
|
144
|
+
{hasAppIcon ? (
|
|
145
|
+
<div
|
|
146
|
+
aria-hidden
|
|
147
|
+
className="min-w-0 flex-1"
|
|
34
148
|
/>
|
|
35
|
-
) : title ? (
|
|
36
|
-
<span className="leading-none">{title}</span>
|
|
37
149
|
) : null}
|
|
38
|
-
|
|
150
|
+
<SidebarTrigger className="size-8 shrink-0 touch-manipulation" />
|
|
151
|
+
{trailingInset}
|
|
152
|
+
</div>
|
|
39
153
|
)}
|
|
40
154
|
</SidebarHeader>
|
|
41
155
|
<SidebarContent className="gap-1">
|
|
42
156
|
<NavigationContent navigation={startNav} />
|
|
43
157
|
</SidebarContent>
|
|
44
|
-
<SidebarFooter>
|
|
45
|
-
{endItems.length > 0
|
|
46
|
-
|
|
158
|
+
<SidebarFooter className="gap-0 border-t border-sidebar-border p-0">
|
|
159
|
+
{(endItems.length > 0 || showAuthButton) && (
|
|
160
|
+
<NavigationContent
|
|
161
|
+
navigation={endItems}
|
|
162
|
+
trailing={showAuthButton ? <LoginButton variant="sidebar" /> : undefined}
|
|
163
|
+
/>
|
|
164
|
+
)}
|
|
47
165
|
</SidebarFooter>
|
|
48
166
|
</>
|
|
49
167
|
);
|
|
@@ -1,29 +1,76 @@
|
|
|
1
|
-
import { Outlet } from 'react-router';
|
|
1
|
+
import { Outlet, useLocation } from 'react-router';
|
|
2
2
|
import { useMemo, useEffect } from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
Sidebar,
|
|
6
|
+
SidebarInset,
|
|
7
|
+
SidebarProvider,
|
|
8
|
+
SidebarRail,
|
|
9
|
+
SidebarTrigger,
|
|
10
|
+
useSidebar,
|
|
11
|
+
} from '../../../components/ui/sidebar';
|
|
6
12
|
import {
|
|
7
13
|
filterNavigationForAuthState,
|
|
8
14
|
filterNavigationByViewport,
|
|
9
15
|
filterNavigationForSidebar,
|
|
10
|
-
flattenNavigationItems,
|
|
11
16
|
hasLoginNavigationItem,
|
|
12
17
|
resolveLocalizedString as resolveLocalizedLabel,
|
|
13
18
|
splitNavigationByPosition,
|
|
14
19
|
} from '../utils';
|
|
15
20
|
import { SidebarInner } from './SidebarInner';
|
|
16
|
-
import { MobileBottomNav } from './MobileBottomNav';
|
|
17
21
|
import type { SidebarLayoutProps } from './types';
|
|
18
22
|
import { useNavigationItems } from '../../../routes/hooks/useNavigationItems';
|
|
19
23
|
import { useAuth } from '../../auth/hooks/useAuth';
|
|
20
24
|
import { useSettings } from '../../settings/hooks/useSettings';
|
|
25
|
+
import { useIsMobile } from '../../../hooks/use-mobile';
|
|
26
|
+
import { DesktopHistoryButtons } from '../chrome/DesktopHistoryButtons';
|
|
27
|
+
import { CollapsedDesktopTitlebar } from '../chrome/CollapsedDesktopTitlebar';
|
|
28
|
+
import { useIsTauriClient, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
|
|
29
|
+
import {
|
|
30
|
+
MAC_TRAFFIC_LIGHTS_GAP_PX,
|
|
31
|
+
MAC_TRAFFIC_LIGHTS_WIDTH_PX,
|
|
32
|
+
DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
33
|
+
} from '../chrome/constants';
|
|
34
|
+
|
|
35
|
+
/** Close the mobile sheet when the route changes. */
|
|
36
|
+
function CloseMobileSidebarOnNavigate() {
|
|
37
|
+
const location = useLocation();
|
|
38
|
+
const { setOpenMobile } = useSidebar();
|
|
39
|
+
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
setOpenMobile(false);
|
|
42
|
+
}, [location.pathname, setOpenMobile]);
|
|
43
|
+
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
21
46
|
|
|
22
|
-
|
|
47
|
+
/** Sync collapsed-titlebar layout offset onto <html> for CSS. */
|
|
48
|
+
function CollapsedTitlebarOffset() {
|
|
49
|
+
const overlay = useMacOverlayChrome();
|
|
50
|
+
const { state, isMobile } = useSidebar();
|
|
51
|
+
const collapsed = state === 'collapsed' && !isMobile;
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
const root = document.documentElement;
|
|
55
|
+
if (overlay && collapsed) root.setAttribute('data-shellui-collapsed-titlebar', '');
|
|
56
|
+
else root.removeAttribute('data-shellui-collapsed-titlebar');
|
|
57
|
+
return () => root.removeAttribute('data-shellui-collapsed-titlebar');
|
|
58
|
+
}, [overlay, collapsed]);
|
|
59
|
+
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const SidebarLayoutContent = ({ title, appIcon, navigation }: SidebarLayoutProps) => {
|
|
23
64
|
const { i18n } = useTranslation();
|
|
24
65
|
const { isAuthenticated } = useAuth();
|
|
25
66
|
const { settings } = useSettings();
|
|
26
|
-
const { navigationItem
|
|
67
|
+
const { navigationItem } = useNavigationItems();
|
|
68
|
+
const isMobile = useIsMobile();
|
|
69
|
+
const isTauriEnv = useIsTauriClient();
|
|
70
|
+
const trafficLights = useMacTrafficLights();
|
|
71
|
+
const mobileTrafficInset = trafficLights
|
|
72
|
+
? MAC_TRAFFIC_LIGHTS_WIDTH_PX + MAC_TRAFFIC_LIGHTS_GAP_PX
|
|
73
|
+
: undefined;
|
|
27
74
|
|
|
28
75
|
const currentLanguage = useMemo(() => {
|
|
29
76
|
return i18n.language || 'en';
|
|
@@ -35,18 +82,18 @@ const SidebarLayoutContent = ({ title, logo, navigation }: SidebarLayoutProps) =
|
|
|
35
82
|
filterNavigationForAuthState(navigation, isAuthenticated, settings.developerFeatures.enabled),
|
|
36
83
|
[navigation, isAuthenticated, settings.developerFeatures.enabled],
|
|
37
84
|
);
|
|
38
|
-
const { startNav, endItems
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
85
|
+
const { startNav, endItems } = useMemo(() => {
|
|
86
|
+
const viewportNav = filterNavigationByViewport(
|
|
87
|
+
authAwareNavigation,
|
|
88
|
+
isMobile ? 'mobile' : 'desktop',
|
|
89
|
+
);
|
|
90
|
+
const { start, end } = splitNavigationByPosition(viewportNav);
|
|
43
91
|
|
|
44
92
|
return {
|
|
45
93
|
startNav: filterNavigationForSidebar(start),
|
|
46
94
|
endItems: end,
|
|
47
|
-
mobileNavItems: mobileFlat,
|
|
48
95
|
};
|
|
49
|
-
}, [authAwareNavigation]);
|
|
96
|
+
}, [authAwareNavigation, isMobile]);
|
|
50
97
|
|
|
51
98
|
useEffect(() => {
|
|
52
99
|
if (!title) return;
|
|
@@ -59,31 +106,47 @@ const SidebarLayoutContent = ({ title, logo, navigation }: SidebarLayoutProps) =
|
|
|
59
106
|
}, [navigationItem, title, currentLanguage]);
|
|
60
107
|
|
|
61
108
|
return (
|
|
62
|
-
<
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
109
|
+
<SidebarProvider className="h-svh overflow-hidden">
|
|
110
|
+
<CloseMobileSidebarOnNavigate />
|
|
111
|
+
<CollapsedTitlebarOffset />
|
|
112
|
+
<CollapsedDesktopTitlebar />
|
|
113
|
+
<Sidebar
|
|
114
|
+
collapsible="icon"
|
|
115
|
+
className="border-sidebar-border"
|
|
116
|
+
>
|
|
117
|
+
<SidebarInner
|
|
118
|
+
startNav={startNav}
|
|
119
|
+
endItems={endItems}
|
|
120
|
+
showAuthButton={!hasCustomLoginNav || isAuthenticated}
|
|
121
|
+
title={title}
|
|
122
|
+
appIcon={appIcon}
|
|
123
|
+
/>
|
|
124
|
+
<SidebarRail />
|
|
125
|
+
</Sidebar>
|
|
73
126
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
127
|
+
<SidebarInset className="relative min-w-0 overflow-hidden">
|
|
128
|
+
<header
|
|
129
|
+
className="relative z-[46] flex shrink-0 items-center gap-0.5 border-b border-border bg-background px-3 select-none md:hidden"
|
|
130
|
+
style={{
|
|
131
|
+
height: DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
132
|
+
...(mobileTrafficInset !== undefined ? { paddingLeft: mobileTrafficInset } : {}),
|
|
133
|
+
}}
|
|
134
|
+
{...(trafficLights
|
|
135
|
+
? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
|
|
136
|
+
: {})}
|
|
137
|
+
>
|
|
138
|
+
<SidebarTrigger
|
|
139
|
+
data-shellui-no-drag=""
|
|
140
|
+
className="relative size-8 touch-manipulation text-foreground"
|
|
141
|
+
/>
|
|
142
|
+
{isTauriEnv ? <DesktopHistoryButtons /> : null}
|
|
143
|
+
</header>
|
|
80
144
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
</div>
|
|
145
|
+
<div className="flex min-h-0 flex-1 flex-col overflow-auto">
|
|
146
|
+
<Outlet />
|
|
147
|
+
</div>
|
|
148
|
+
</SidebarInset>
|
|
149
|
+
</SidebarProvider>
|
|
87
150
|
);
|
|
88
151
|
};
|
|
89
152
|
|
|
@@ -10,13 +10,6 @@ export function getExternalFaviconUrl(url: string): string | null {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
/** Approximate width per slot (icon + label + padding) and gap for dynamic slot count. */
|
|
14
|
-
export const BOTTOM_NAV_SLOT_WIDTH = 64;
|
|
15
|
-
export const BOTTOM_NAV_GAP = 4;
|
|
16
|
-
export const BOTTOM_NAV_PX = 12;
|
|
17
|
-
/** Max slots in the row (Home + nav + optional More) to avoid overflow/duplicated wrap. */
|
|
18
|
-
export const BOTTOM_NAV_MAX_SLOTS = 6;
|
|
19
|
-
|
|
20
13
|
/** True when the icon is a local app icon (/icons/); external images (avatars, favicons) are shown as-is. */
|
|
21
14
|
export function isAppIcon(src: string): boolean {
|
|
22
15
|
return src.startsWith('/icons/');
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { NavigationItem, NavigationGroup } from '../../config/types';
|
|
1
|
+
import type { NavigationItem, NavigationGroup, ThemeAsset } from '../../config/types';
|
|
2
2
|
|
|
3
3
|
export interface SidebarLayoutProps {
|
|
4
4
|
title?: string;
|
|
5
|
-
appIcon?:
|
|
6
|
-
logo?:
|
|
5
|
+
appIcon?: ThemeAsset;
|
|
6
|
+
logo?: ThemeAsset;
|
|
7
7
|
navigation: (NavigationItem | NavigationGroup)[];
|
|
8
8
|
}
|
|
@@ -34,16 +34,84 @@ export function getHashPathFromUrl(url: string): string {
|
|
|
34
34
|
return hash.startsWith('/') ? hash : `/${hash}`;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
const toAbsoluteUrl = (url: string): URL | null => {
|
|
38
|
+
try {
|
|
39
|
+
return new URL(
|
|
40
|
+
url,
|
|
41
|
+
typeof window !== 'undefined' ? window.location.origin : 'http://localhost',
|
|
42
|
+
);
|
|
43
|
+
} catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const normalizePathname = (value: string): string => {
|
|
49
|
+
const trimmed = value.trim();
|
|
50
|
+
if (!trimmed) return '/';
|
|
51
|
+
const withoutTrailing = trimmed.replace(/\/+$/, '');
|
|
52
|
+
return withoutTrailing || '/';
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const normalizeHashPath = (value: string): string => {
|
|
56
|
+
return value.replace(/^#\/?/, '').replace(/\/+$/, '');
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Whether an iframe `src` belongs to an embedded app URL (same origin + path/hash prefix).
|
|
61
|
+
* Site-root apps (`https://files.example/`) also match deep links (`…/company/docs`).
|
|
62
|
+
*/
|
|
63
|
+
export function isFrameForAppUrl(frameSrc: string, appUrl: string): boolean {
|
|
64
|
+
const frame = toAbsoluteUrl(frameSrc);
|
|
65
|
+
const app = toAbsoluteUrl(appUrl);
|
|
66
|
+
if (!frame || !app) return false;
|
|
67
|
+
if (frame.origin !== app.origin) return false;
|
|
68
|
+
|
|
69
|
+
const appPathname = normalizePathname(app.pathname);
|
|
70
|
+
const framePathname = normalizePathname(frame.pathname);
|
|
71
|
+
// Root app URL: `${appPathname}/` would be `//` and wrongly reject `/company/…`.
|
|
72
|
+
const pathMatches =
|
|
73
|
+
appPathname === '/'
|
|
74
|
+
? true
|
|
75
|
+
: framePathname === appPathname || framePathname.startsWith(`${appPathname}/`);
|
|
76
|
+
if (!pathMatches) return false;
|
|
77
|
+
|
|
78
|
+
const appHashPath = normalizeHashPath(app.hash || getHashPathFromUrl(appUrl));
|
|
79
|
+
if (!appHashPath) return true;
|
|
80
|
+
|
|
81
|
+
const frameHashPath = normalizeHashPath(frame.hash);
|
|
82
|
+
return frameHashPath === appHashPath || frameHashPath.startsWith(`${appHashPath}/`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Match a nav item for routing: root (`/` / path '') matches any pathname so in-app
|
|
87
|
+
* deep links from `/` stay on the root app; more specific prefixes win (e.g. `/home`).
|
|
88
|
+
*/
|
|
89
|
+
export function findMatchingNavigationItem(
|
|
90
|
+
items: NavigationItem[],
|
|
91
|
+
pathname: string,
|
|
92
|
+
): NavigationItem | undefined {
|
|
93
|
+
const matching = items.filter((item) => {
|
|
94
|
+
const pathPrefix = getNavPathPrefix(item);
|
|
95
|
+
if (pathPrefix === '/') {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
return pathname === pathPrefix || pathname.startsWith(`${pathPrefix}/`);
|
|
99
|
+
});
|
|
100
|
+
if (matching.length === 0) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
return matching.reduce((best, item) =>
|
|
104
|
+
getNavPathPrefix(item).length > getNavPathPrefix(best).length ? item : best,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
37
108
|
/** Among items that match the current pathname, return the longest path prefix. Used so only one nav item is active when URLs nest (e.g. /foo and /foo/bar). */
|
|
38
109
|
export function getActivePathPrefix(pathname: string, items: NavigationItem[]): string | null {
|
|
39
110
|
const linkItems = items.filter(
|
|
40
111
|
(i) => i.openIn !== 'modal' && i.openIn !== 'drawer' && i.openIn !== 'external',
|
|
41
112
|
);
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
.filter((p) => pathname === p || pathname.startsWith(p === '/' ? '/' : `${p}/`));
|
|
45
|
-
if (matching.length === 0) return null;
|
|
46
|
-
return matching.reduce((a, b) => (a.length >= b.length ? a : b));
|
|
113
|
+
const matched = findMatchingNavigationItem(linkItems, pathname);
|
|
114
|
+
return matched ? getNavPathPrefix(matched) : null;
|
|
47
115
|
}
|
|
48
116
|
|
|
49
117
|
/** Resolve a localized string to a single string for the given language. */
|