@shellui/core 0.5.0-beta.2 → 0.5.0-beta.3
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/package.json +2 -2
- package/schemas/shellui.config.schema.json +10 -2
- package/src/components/ContentView.tsx +12 -5
- package/src/components/ui/alert-dialog.tsx +1 -1
- package/src/components/ui/sidebar.tsx +59 -20
- package/src/features/config/types.ts +16 -2
- package/src/features/layouts/AppLayout.tsx +30 -3
- package/src/features/layouts/OverlayShell.tsx +3 -1
- package/src/features/layouts/app-bar-inset/AppBarInsetLayout.tsx +22 -0
- package/src/features/layouts/appbar/AppBarLayout.tsx +51 -12
- package/src/features/layouts/floating/FloatingFadeMask.tsx +22 -0
- package/src/features/layouts/floating/FloatingLayout.tsx +142 -0
- package/src/features/layouts/floating/FloatingSidebar.tsx +327 -0
- package/src/features/layouts/floating/FloatingTabBar.tsx +437 -0
- package/src/features/layouts/floating/FloatingTabIndicator.tsx +216 -0
- package/src/features/layouts/floating/computeFloatingInsets.spec.ts +83 -0
- package/src/features/layouts/floating/computeFloatingInsets.ts +103 -0
- package/src/features/layouts/floating/isShellOwnedPath.spec.ts +23 -0
- package/src/features/layouts/floating/isShellOwnedPath.ts +16 -0
- package/src/features/layouts/floating/layoutChromeStore.ts +46 -0
- package/src/features/layouts/floating/scrollChrome.spec.ts +49 -0
- package/src/features/layouts/floating/useFloatingChrome.ts +216 -0
- package/src/features/layouts/sidebar/SidebarLayout.tsx +32 -6
- package/src/features/layouts/sidebar/types.ts +4 -0
- package/src/features/layouts/sidebar-inset/SidebarInsetLayout.tsx +15 -0
- package/src/features/settings/SettingsProvider.tsx +7 -0
- package/src/features/settings/SettingsView.tsx +6 -6
- package/src/features/settings/components/Develop.tsx +31 -13
- package/src/features/settings/utils/buildSettingsForPropagation.ts +16 -0
- package/src/features/storage/StoragePickerContext.tsx +1 -0
- package/src/hooks/use-viewport.ts +40 -0
- package/src/i18n/translations/en/settings.json +8 -2
- package/src/i18n/translations/fr/settings.json +8 -2
- package/src/index.css +321 -0
- package/src/routes/components/RouteFallback.tsx +6 -2
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Outlet } from 'react-router';
|
|
2
|
+
import { useEffect, useMemo } from 'react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import type { NavigationItem, NavigationGroup, ThemeAsset } from '../../config/types';
|
|
5
|
+
import {
|
|
6
|
+
filterNavigationForAuthState,
|
|
7
|
+
filterNavigationByViewport,
|
|
8
|
+
flattenNavigationItems,
|
|
9
|
+
hasLoginNavigationItem,
|
|
10
|
+
resolveLocalizedString,
|
|
11
|
+
splitNavigationByPosition,
|
|
12
|
+
} from '../utils';
|
|
13
|
+
import { useNavigationItems } from '../../../routes/hooks/useNavigationItems';
|
|
14
|
+
import { useAuth } from '../../auth/hooks/useAuth';
|
|
15
|
+
import { useSettings } from '../../settings/hooks/useSettings';
|
|
16
|
+
import { useViewport } from '../../../hooks/use-viewport';
|
|
17
|
+
import { DesktopHistoryButtons } from '../chrome/DesktopHistoryButtons';
|
|
18
|
+
import { useIsTauriClient, useMacTrafficLights } from '../chrome/runtime';
|
|
19
|
+
import {
|
|
20
|
+
DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
21
|
+
DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
22
|
+
MAC_TRAFFIC_LIGHTS_WIDTH_PX,
|
|
23
|
+
} from '../chrome/constants';
|
|
24
|
+
import { FloatingFadeMask } from './FloatingFadeMask';
|
|
25
|
+
import { FloatingTabBar } from './FloatingTabBar';
|
|
26
|
+
import { FloatingSidebar } from './FloatingSidebar';
|
|
27
|
+
import { useFloatingChrome } from './useFloatingChrome';
|
|
28
|
+
|
|
29
|
+
export interface FloatingLayoutProps {
|
|
30
|
+
title?: string;
|
|
31
|
+
appIcon?: ThemeAsset;
|
|
32
|
+
logo?: ThemeAsset;
|
|
33
|
+
navigation?: (NavigationItem | NavigationGroup)[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Adaptive layout: floating glass tabs / sidebar over full-bleed content. */
|
|
37
|
+
export function FloatingLayout({ title, appIcon, navigation = [] }: FloatingLayoutProps) {
|
|
38
|
+
const { i18n } = useTranslation();
|
|
39
|
+
const { isAuthenticated } = useAuth();
|
|
40
|
+
const { settings } = useSettings();
|
|
41
|
+
const { navigationItem } = useNavigationItems();
|
|
42
|
+
const viewport = useViewport();
|
|
43
|
+
const { chromeVisible, sidebarCollapsed, toggleSidebarCollapsed, scrollEdges } =
|
|
44
|
+
useFloatingChrome(viewport);
|
|
45
|
+
const isTauriEnv = useIsTauriClient();
|
|
46
|
+
const trafficLights = useMacTrafficLights();
|
|
47
|
+
const currentLanguage = i18n.language || 'en';
|
|
48
|
+
|
|
49
|
+
const hasCustomLoginNav = useMemo(() => hasLoginNavigationItem(navigation), [navigation]);
|
|
50
|
+
// Same rule as sidebar / app-bar: show account menu when logged in (login nav item is filtered out).
|
|
51
|
+
const showAuthButton = !hasCustomLoginNav || isAuthenticated;
|
|
52
|
+
|
|
53
|
+
const authAwareNavigation = useMemo(
|
|
54
|
+
() =>
|
|
55
|
+
filterNavigationForAuthState(navigation, isAuthenticated, settings.developerFeatures.enabled),
|
|
56
|
+
[navigation, isAuthenticated, settings.developerFeatures.enabled],
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const { startNav, endItems } = useMemo(() => {
|
|
60
|
+
const navViewport = viewport === 'mobile' ? 'mobile' : 'desktop';
|
|
61
|
+
const viewportNav = filterNavigationByViewport(authAwareNavigation, navViewport);
|
|
62
|
+
const { start, end } = splitNavigationByPosition(viewportNav);
|
|
63
|
+
return { startNav: start, endItems: end };
|
|
64
|
+
}, [authAwareNavigation, viewport]);
|
|
65
|
+
|
|
66
|
+
const tabItems = useMemo(() => flattenNavigationItems(startNav), [startNav]);
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (!title) return;
|
|
70
|
+
if (navigationItem) {
|
|
71
|
+
const label = resolveLocalizedString(navigationItem.label, currentLanguage);
|
|
72
|
+
document.title = `${label} | ${title}`;
|
|
73
|
+
} else {
|
|
74
|
+
document.title = title;
|
|
75
|
+
}
|
|
76
|
+
}, [navigationItem, title, currentLanguage]);
|
|
77
|
+
|
|
78
|
+
const showTabBar = viewport === 'mobile' || viewport === 'tablet';
|
|
79
|
+
const showSidebar = viewport === 'desktop';
|
|
80
|
+
const showFades = showTabBar;
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<div
|
|
84
|
+
data-shellui-floating-layout=""
|
|
85
|
+
data-viewport={viewport}
|
|
86
|
+
className="relative flex h-full max-h-full w-full flex-col overflow-hidden bg-background"
|
|
87
|
+
>
|
|
88
|
+
{isTauriEnv ? (
|
|
89
|
+
<div
|
|
90
|
+
className="pointer-events-auto absolute top-0 left-0 z-[46] flex items-center"
|
|
91
|
+
style={{
|
|
92
|
+
height: DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
93
|
+
paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
94
|
+
paddingLeft: trafficLights ? MAC_TRAFFIC_LIGHTS_WIDTH_PX : 8,
|
|
95
|
+
}}
|
|
96
|
+
>
|
|
97
|
+
<DesktopHistoryButtons />
|
|
98
|
+
</div>
|
|
99
|
+
) : null}
|
|
100
|
+
|
|
101
|
+
<main className="relative min-h-0 min-w-0 flex-1 overflow-hidden">
|
|
102
|
+
<Outlet />
|
|
103
|
+
</main>
|
|
104
|
+
|
|
105
|
+
{showFades ? (
|
|
106
|
+
<>
|
|
107
|
+
<FloatingFadeMask
|
|
108
|
+
placement="top"
|
|
109
|
+
visible={!scrollEdges.atTop}
|
|
110
|
+
/>
|
|
111
|
+
<FloatingFadeMask
|
|
112
|
+
placement="bottom"
|
|
113
|
+
visible={!scrollEdges.atBottom}
|
|
114
|
+
/>
|
|
115
|
+
</>
|
|
116
|
+
) : null}
|
|
117
|
+
|
|
118
|
+
{showTabBar ? (
|
|
119
|
+
<FloatingTabBar
|
|
120
|
+
items={tabItems}
|
|
121
|
+
endItems={endItems}
|
|
122
|
+
showAuthButton={showAuthButton}
|
|
123
|
+
placement="bottom"
|
|
124
|
+
chromeVisible={chromeVisible}
|
|
125
|
+
viewport={viewport}
|
|
126
|
+
/>
|
|
127
|
+
) : null}
|
|
128
|
+
|
|
129
|
+
{showSidebar ? (
|
|
130
|
+
<FloatingSidebar
|
|
131
|
+
title={title}
|
|
132
|
+
appIcon={appIcon}
|
|
133
|
+
navigation={startNav}
|
|
134
|
+
endItems={endItems}
|
|
135
|
+
showAuthButton={showAuthButton}
|
|
136
|
+
collapsed={sidebarCollapsed}
|
|
137
|
+
onToggleCollapsed={toggleSidebarCollapsed}
|
|
138
|
+
/>
|
|
139
|
+
) : null}
|
|
140
|
+
</div>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
@@ -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
|
+
}
|