@shellui/core 0.5.0-alpha.5 → 0.5.0-beta.2
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/src/components/ContentView.tsx +1 -1
- package/src/components/ui/alert-dialog.tsx +51 -34
- package/src/components/ui/drawer.tsx +57 -40
- package/src/components/ui/sidebar.tsx +12 -5
- package/src/components/ui/sonner.tsx +20 -2
- package/src/features/admin/AdminView.tsx +31 -2
- package/src/features/alertDialog/DialogContext.tsx +11 -5
- package/src/features/auth/components/AccessPendingView.tsx +1 -1
- package/src/features/auth/components/LoginButton.tsx +2 -2
- package/src/features/auth/components/LoginView.tsx +77 -30
- package/src/features/layouts/LayoutFallback.tsx +1 -1
- package/src/features/layouts/OverlayShell.tsx +76 -44
- package/src/features/layouts/appbar/AppBarLayout.tsx +501 -293
- package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +18 -10
- package/src/features/layouts/chrome/ContentDragOverlay.tsx +1 -1
- package/src/features/layouts/chrome/DesktopChrome.tsx +1 -1
- package/src/features/layouts/chrome/SafeAreaTopbar.tsx +48 -0
- package/src/features/layouts/chrome/constants.ts +7 -1
- package/src/features/layouts/chrome/index.ts +5 -0
- package/src/features/layouts/chrome/runtime.ts +157 -7
- package/src/features/layouts/chrome/viewport.ts +66 -0
- package/src/features/layouts/fullscreen/FullscreenLayout.tsx +10 -5
- package/src/features/layouts/sidebar/SidebarInner.tsx +26 -30
- package/src/features/layouts/sidebar/SidebarLayout.tsx +90 -39
- package/src/features/layouts/windows/WindowsLayout.tsx +138 -42
- package/src/features/overlays/ResponsiveModal.tsx +36 -17
- package/src/features/overlays/overlaySize.spec.ts +27 -1
- package/src/features/overlays/overlaySize.ts +73 -18
- package/src/features/overlays/useOverlayReportedSize.ts +5 -4
- package/src/features/settings/SettingsView.tsx +9 -2
- package/src/features/storage/uploads/UploadToastCard.tsx +1 -1
- package/src/features/storage/uploads/UploadToaster.tsx +6 -3
- package/src/features/theme/applyTheme.ts +20 -1
- package/src/i18n/translations/en/common.json +2 -1
- package/src/i18n/translations/fr/common.json +2 -1
- package/src/index.css +177 -18
- package/src/index.html +32 -3
- package/src/routes/components/RouteErrorBoundary.tsx +1 -1
- package/src/routes/components/RouteFallback.tsx +1 -1
|
@@ -3,17 +3,20 @@ import { cn } from '../../../lib/utils';
|
|
|
3
3
|
import { DesktopHistoryButtons } from './DesktopHistoryButtons';
|
|
4
4
|
import {
|
|
5
5
|
DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
6
|
+
DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
6
7
|
MAC_TRAFFIC_LIGHTS_GAP_PX,
|
|
7
8
|
MAC_TRAFFIC_LIGHTS_WIDTH_PX,
|
|
8
9
|
} from './constants';
|
|
9
|
-
import { useIsTauriClient, useMacOverlayChrome } from './runtime';
|
|
10
|
+
import { useIsTauriClient, useMacOverlayChrome, useMacTrafficLights } from './runtime';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
|
-
* Full-width
|
|
13
|
+
* Full-width 42px chrome when the sidebar is collapsed in a Tauri overlay window.
|
|
13
14
|
* Open-sidebar first, then Back; room for more controls later.
|
|
15
|
+
* Stays visible in native fullscreen (no traffic-light spacer there).
|
|
14
16
|
*/
|
|
15
17
|
export function CollapsedDesktopTitlebar({ className }: { className?: string }) {
|
|
16
18
|
const overlay = useMacOverlayChrome();
|
|
19
|
+
const trafficLights = useMacTrafficLights();
|
|
17
20
|
const isTauriEnv = useIsTauriClient();
|
|
18
21
|
const { state, isMobile } = useSidebar();
|
|
19
22
|
const collapsed = state === 'collapsed' && !isMobile;
|
|
@@ -29,19 +32,24 @@ export function CollapsedDesktopTitlebar({ className }: { className?: string })
|
|
|
29
32
|
'fixed inset-x-0 top-0 z-[47] flex w-full items-center border-b border-sidebar-border bg-sidebar text-sidebar-foreground select-none',
|
|
30
33
|
className,
|
|
31
34
|
)}
|
|
32
|
-
style={{
|
|
35
|
+
style={{
|
|
36
|
+
height: DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
37
|
+
paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
38
|
+
}}
|
|
33
39
|
>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
{trafficLights ? (
|
|
41
|
+
<div
|
|
42
|
+
className="h-full shrink-0"
|
|
43
|
+
style={{ width: MAC_TRAFFIC_LIGHTS_WIDTH_PX }}
|
|
44
|
+
aria-hidden
|
|
45
|
+
/>
|
|
46
|
+
) : null}
|
|
39
47
|
<div
|
|
40
48
|
data-shellui-no-drag=""
|
|
41
49
|
className="flex h-full items-center gap-0.5"
|
|
42
|
-
style={{ paddingLeft: MAC_TRAFFIC_LIGHTS_GAP_PX }}
|
|
50
|
+
style={{ paddingLeft: trafficLights ? MAC_TRAFFIC_LIGHTS_GAP_PX : 8 }}
|
|
43
51
|
>
|
|
44
|
-
<SidebarTrigger className="size-
|
|
52
|
+
<SidebarTrigger className="size-7 touch-manipulation" />
|
|
45
53
|
{isTauriEnv ? <DesktopHistoryButtons /> : null}
|
|
46
54
|
</div>
|
|
47
55
|
</div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DESKTOP_TITLEBAR_HEIGHT_PX } from './constants';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Full-width invisible
|
|
4
|
+
* Full-width invisible 42px strip at the top of the Tauri window.
|
|
5
5
|
*
|
|
6
6
|
* Uses Tauri's official `data-tauri-drag-region` (requires
|
|
7
7
|
* `core:window:allow-start-dragging` in capabilities). Shell controls must sit
|
|
@@ -3,7 +3,7 @@ import { ContentDragOverlay } from './ContentDragOverlay';
|
|
|
3
3
|
import { useIsTauriClient, useMacTrafficLights } from './runtime';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Global Tauri desktop chrome: document flags + the
|
|
6
|
+
* Global Tauri desktop chrome: document flags + the 42px top drag strip.
|
|
7
7
|
* Mounted at the app root so it stays available on every page (layouts, login,
|
|
8
8
|
* settings, route error boundary, empty config) — including narrow/mobile widths.
|
|
9
9
|
*/
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { cn } from '../../../lib/utils';
|
|
3
|
+
|
|
4
|
+
/** True when this window is the outermost shell (not nested in an iframe). */
|
|
5
|
+
export function isShellUiRootWindow(): boolean {
|
|
6
|
+
return typeof window !== 'undefined' && window.parent === window;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Root shell only: advertise the safe-area topbar on <html> so fixed chrome
|
|
11
|
+
* (sidebar, drawers) can clear it. Nested iframe shells skip this.
|
|
12
|
+
*/
|
|
13
|
+
export function SafeAreaTopbarOffset({ enabled }: { enabled: boolean }) {
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!enabled) return;
|
|
16
|
+
const root = document.documentElement;
|
|
17
|
+
root.setAttribute('data-shellui-safe-area-topbar', '');
|
|
18
|
+
return () => root.removeAttribute('data-shellui-safe-area-topbar');
|
|
19
|
+
}, [enabled]);
|
|
20
|
+
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Tablet / desktop band for top safe-area. Height is 0 when the inset is 0;
|
|
26
|
+
* overflow clips the border so no stray hairline. Hidden below md — mobile
|
|
27
|
+
* headers pad into the status band instead.
|
|
28
|
+
*/
|
|
29
|
+
export function SafeAreaTopbarStrip({
|
|
30
|
+
enabled,
|
|
31
|
+
className,
|
|
32
|
+
}: {
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
/** Outer strip classes (defaults match sidebar chrome). */
|
|
35
|
+
className?: string;
|
|
36
|
+
}) {
|
|
37
|
+
if (!enabled) return null;
|
|
38
|
+
return (
|
|
39
|
+
<div
|
|
40
|
+
aria-hidden
|
|
41
|
+
data-slot="shellui-safe-area-top"
|
|
42
|
+
className={cn('relative z-0 hidden shrink-0 overflow-hidden md:block', className)}
|
|
43
|
+
style={{ height: 'var(--shellui-safe-area-top)' }}
|
|
44
|
+
>
|
|
45
|
+
<div className="box-border h-full border-b border-sidebar-border bg-sidebar" />
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
/** Height of the macOS overlay titlebar / traffic-light row. */
|
|
2
|
-
export const DESKTOP_TITLEBAR_HEIGHT_PX =
|
|
2
|
+
export const DESKTOP_TITLEBAR_HEIGHT_PX = 42;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Top inset inside the titlebar so web controls optically match macOS traffic lights
|
|
6
|
+
* (lights stay vertically centered in the full height).
|
|
7
|
+
*/
|
|
8
|
+
export const DESKTOP_TITLEBAR_PAD_TOP_PX = 2;
|
|
3
9
|
|
|
4
10
|
/** Width reserved for macOS traffic lights (close / minimize / zoom). */
|
|
5
11
|
export const MAC_TRAFFIC_LIGHTS_WIDTH_PX = 78;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export {
|
|
2
2
|
DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
3
|
+
DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
3
4
|
IFRAME_FOREIGN_ATTR,
|
|
4
5
|
MAC_TRAFFIC_LIGHTS_GAP_PX,
|
|
5
6
|
MAC_TRAFFIC_LIGHTS_WIDTH_PX,
|
|
@@ -14,9 +15,12 @@ export {
|
|
|
14
15
|
} from './goDesktopBack';
|
|
15
16
|
export {
|
|
16
17
|
useIsTauriClient,
|
|
18
|
+
useIsTauriRuntime,
|
|
19
|
+
useIsTauriFullscreen,
|
|
17
20
|
useMacOverlayChrome,
|
|
18
21
|
useMacTrafficLights,
|
|
19
22
|
isMacOSDesktop,
|
|
23
|
+
isTauriRuntime,
|
|
20
24
|
} from './runtime';
|
|
21
25
|
export { DesktopBackButton } from './DesktopBackButton';
|
|
22
26
|
export { DesktopForwardButton } from './DesktopForwardButton';
|
|
@@ -24,3 +28,4 @@ export { DesktopHistoryButtons } from './DesktopHistoryButtons';
|
|
|
24
28
|
export { ContentDragOverlay } from './ContentDragOverlay';
|
|
25
29
|
export { DesktopChrome } from './DesktopChrome';
|
|
26
30
|
export { CollapsedDesktopTitlebar } from './CollapsedDesktopTitlebar';
|
|
31
|
+
export { isShellUiRootWindow, SafeAreaTopbarOffset, SafeAreaTopbarStrip } from './SafeAreaTopbar';
|
|
@@ -10,6 +10,84 @@ export function isMacOSDesktop(): boolean {
|
|
|
10
10
|
return platform.startsWith('Mac') && !touchIpad;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
type TauriInternals = {
|
|
14
|
+
invoke: (cmd: string, args?: Record<string, unknown>) => Promise<unknown>;
|
|
15
|
+
transformCallback: (callback: (data: unknown) => void, once: boolean) => number;
|
|
16
|
+
unregisterCallback?: (id: number) => void;
|
|
17
|
+
metadata?: { currentWindow?: { label?: string } };
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function getTauriInternals(): TauriInternals | null {
|
|
21
|
+
if (typeof window === 'undefined') return null;
|
|
22
|
+
return (window as Window & { __TAURI_INTERNALS__?: TauriInternals }).__TAURI_INTERNALS__ ?? null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* True only inside a real Tauri webview (`__TAURI__` / `__TAURI_INTERNALS__`).
|
|
27
|
+
* Unlike `isTauri()`, this ignores the CLI `--target tauri` build flag
|
|
28
|
+
* (`__SHELLUI_TAURI__`) so a browser tab opened against the same URL does not
|
|
29
|
+
* get traffic-light padding.
|
|
30
|
+
*/
|
|
31
|
+
export function isTauriRuntime(): boolean {
|
|
32
|
+
if (typeof window === 'undefined') return false;
|
|
33
|
+
const w = window as Window & {
|
|
34
|
+
__TAURI__?: unknown;
|
|
35
|
+
__TAURI_INTERNALS__?: unknown;
|
|
36
|
+
};
|
|
37
|
+
return !!(w.__TAURI__ ?? w.__TAURI_INTERNALS__);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function currentWindowLabel(internals: TauriInternals): string {
|
|
41
|
+
return internals.metadata?.currentWindow?.label || 'main';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Native macOS / OS fullscreen via Tauri window plugin (no npm import required). */
|
|
45
|
+
async function readTauriFullscreen(): Promise<boolean> {
|
|
46
|
+
const internals = getTauriInternals();
|
|
47
|
+
if (!internals?.invoke) return false;
|
|
48
|
+
try {
|
|
49
|
+
return Boolean(
|
|
50
|
+
await internals.invoke('plugin:window|is_fullscreen', {
|
|
51
|
+
label: currentWindowLabel(internals),
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
} catch {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Listen for window resize (includes fullscreen transitions on macOS).
|
|
61
|
+
* Uses Tauri event IPC when available; falls back to DOM `resize`.
|
|
62
|
+
*/
|
|
63
|
+
async function listenTauriWindowResized(handler: () => void): Promise<() => void> {
|
|
64
|
+
const internals = getTauriInternals();
|
|
65
|
+
if (internals?.invoke && internals.transformCallback) {
|
|
66
|
+
const label = currentWindowLabel(internals);
|
|
67
|
+
const callbackId = internals.transformCallback(() => {
|
|
68
|
+
handler();
|
|
69
|
+
}, false);
|
|
70
|
+
try {
|
|
71
|
+
const eventId = (await internals.invoke('plugin:event|listen', {
|
|
72
|
+
event: 'tauri://resize',
|
|
73
|
+
target: { kind: 'Window', label },
|
|
74
|
+
handler: callbackId,
|
|
75
|
+
})) as number;
|
|
76
|
+
return () => {
|
|
77
|
+
internals.unregisterCallback?.(callbackId);
|
|
78
|
+
void internals
|
|
79
|
+
.invoke('plugin:event|unlisten', { event: 'tauri://resize', eventId })
|
|
80
|
+
.catch(() => undefined);
|
|
81
|
+
};
|
|
82
|
+
} catch {
|
|
83
|
+
internals.unregisterCallback?.(callbackId);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
window.addEventListener('resize', handler);
|
|
88
|
+
return () => window.removeEventListener('resize', handler);
|
|
89
|
+
}
|
|
90
|
+
|
|
13
91
|
export function useIsTauriClient(): boolean {
|
|
14
92
|
const [value, setValue] = useState(() => isTauri());
|
|
15
93
|
|
|
@@ -22,24 +100,96 @@ export function useIsTauriClient(): boolean {
|
|
|
22
100
|
return value;
|
|
23
101
|
}
|
|
24
102
|
|
|
25
|
-
/**
|
|
103
|
+
/** Live Tauri webview (not merely a tauri-targeted web build). */
|
|
104
|
+
export function useIsTauriRuntime(): boolean {
|
|
105
|
+
const [value, setValue] = useState(() => isTauriRuntime());
|
|
106
|
+
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
setValue(isTauriRuntime());
|
|
109
|
+
// __TAURI_INTERNALS__ can appear slightly after first paint in dev.
|
|
110
|
+
const timer = window.setTimeout(() => setValue(isTauriRuntime()), 200);
|
|
111
|
+
return () => window.clearTimeout(timer);
|
|
112
|
+
}, []);
|
|
113
|
+
|
|
114
|
+
return value;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Native window fullscreen (Tauri `is_fullscreen` + resize listener).
|
|
119
|
+
* Resize can fire before macOS updates fullscreen state, so we re-check after a short delay.
|
|
120
|
+
* @see https://v2.tauri.app/reference/javascript/api/namespacewindow/#isfullscreen
|
|
121
|
+
*/
|
|
122
|
+
export function useIsTauriFullscreen(): boolean {
|
|
123
|
+
const tauriRuntime = useIsTauriRuntime();
|
|
124
|
+
const [fullscreen, setFullscreen] = useState(false);
|
|
125
|
+
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
if (!tauriRuntime) {
|
|
128
|
+
setFullscreen(false);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
let cancelled = false;
|
|
133
|
+
let unlisten: (() => void) | undefined;
|
|
134
|
+
let debounceTimer: number | undefined;
|
|
135
|
+
|
|
136
|
+
const sync = async () => {
|
|
137
|
+
const next = await readTauriFullscreen();
|
|
138
|
+
if (!cancelled) setFullscreen(next);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
void (async () => {
|
|
142
|
+
await sync();
|
|
143
|
+
unlisten = await listenTauriWindowResized(() => {
|
|
144
|
+
void sync();
|
|
145
|
+
window.clearTimeout(debounceTimer);
|
|
146
|
+
// macOS often flips isFullscreen after the resize notification.
|
|
147
|
+
debounceTimer = window.setTimeout(() => {
|
|
148
|
+
void sync();
|
|
149
|
+
}, 400);
|
|
150
|
+
});
|
|
151
|
+
})();
|
|
152
|
+
|
|
153
|
+
return () => {
|
|
154
|
+
cancelled = true;
|
|
155
|
+
window.clearTimeout(debounceTimer);
|
|
156
|
+
unlisten?.();
|
|
157
|
+
};
|
|
158
|
+
}, [tauriRuntime]);
|
|
159
|
+
|
|
160
|
+
return fullscreen;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* macOS Tauri desktop chrome (history buttons, collapsed titlebar, drag regions).
|
|
165
|
+
* Desktop viewport only — narrow/mobile layouts use the sheet / top header instead.
|
|
166
|
+
* Stays on in native fullscreen; only the traffic-light *inset* goes away there.
|
|
167
|
+
*/
|
|
26
168
|
export function useMacOverlayChrome(): boolean {
|
|
27
|
-
const
|
|
169
|
+
const tauriRuntime = useIsTauriRuntime();
|
|
28
170
|
const isMobile = useIsMobile();
|
|
29
|
-
|
|
171
|
+
const [isMac, setIsMac] = useState(false);
|
|
172
|
+
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
setIsMac(isMacOSDesktop());
|
|
175
|
+
}, []);
|
|
176
|
+
|
|
177
|
+
return tauriRuntime && isMac && !isMobile;
|
|
30
178
|
}
|
|
31
179
|
|
|
32
180
|
/**
|
|
33
|
-
* Native macOS traffic lights
|
|
34
|
-
*
|
|
181
|
+
* Native macOS traffic lights that need chrome inset: live Tauri webview on
|
|
182
|
+
* macOS, windowed (not native fullscreen — lights are hidden there).
|
|
183
|
+
* Applies at any viewport width (narrow window / mobile layout included).
|
|
35
184
|
*/
|
|
36
185
|
export function useMacTrafficLights(): boolean {
|
|
37
|
-
const
|
|
186
|
+
const tauriRuntime = useIsTauriRuntime();
|
|
187
|
+
const fullscreen = useIsTauriFullscreen();
|
|
38
188
|
const [isMac, setIsMac] = useState(false);
|
|
39
189
|
|
|
40
190
|
useEffect(() => {
|
|
41
191
|
setIsMac(isMacOSDesktop());
|
|
42
192
|
}, []);
|
|
43
193
|
|
|
44
|
-
return
|
|
194
|
+
return tauriRuntime && isMac && !fullscreen;
|
|
45
195
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shell / overlay viewport helpers.
|
|
3
|
+
*
|
|
4
|
+
* `--shellui-app-height` is defined in CSS as `100dvh` (see index.html / index.css).
|
|
5
|
+
* Overlay clamps and CSS max-heights should derive from that — never raw
|
|
6
|
+
* `innerHeight` alone.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const APP_HEIGHT_VAR = '--shellui-app-height';
|
|
10
|
+
|
|
11
|
+
/** Read a CSS length on :root (px). `env(safe-area-*)` resolves through a probe. */
|
|
12
|
+
function readRootLengthPx(cssLength: string): number {
|
|
13
|
+
if (typeof document === 'undefined') return 0;
|
|
14
|
+
const probe = document.createElement('div');
|
|
15
|
+
probe.style.cssText =
|
|
16
|
+
'position:fixed;top:0;left:0;width:0;height:0;visibility:hidden;pointer-events:none;' +
|
|
17
|
+
`padding-top:${cssLength}`;
|
|
18
|
+
document.documentElement.appendChild(probe);
|
|
19
|
+
const value = Number.parseFloat(getComputedStyle(probe).paddingTop);
|
|
20
|
+
probe.remove();
|
|
21
|
+
return Number.isFinite(value) ? value : 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function readSafeAreaInsetTop(): number {
|
|
25
|
+
return readRootLengthPx('var(--shellui-safe-area-top, env(safe-area-inset-top, 0px))');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function readSafeAreaInsetBottom(): number {
|
|
29
|
+
return readRootLengthPx('var(--shellui-safe-area-bottom, env(safe-area-inset-bottom, 0px))');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Current shell height in CSS pixels (falls back to innerHeight). */
|
|
33
|
+
export function readAppHeightPx(): number {
|
|
34
|
+
if (typeof window === 'undefined') return 0;
|
|
35
|
+
if (typeof document !== 'undefined') {
|
|
36
|
+
const raw = getComputedStyle(document.documentElement).getPropertyValue(APP_HEIGHT_VAR).trim();
|
|
37
|
+
if (raw.endsWith('px')) {
|
|
38
|
+
const px = Number.parseFloat(raw);
|
|
39
|
+
if (Number.isFinite(px) && px > 0) return px;
|
|
40
|
+
}
|
|
41
|
+
// Resolve dvh/vh/% via a probe so browser-tab fallback still works.
|
|
42
|
+
if (raw) {
|
|
43
|
+
const viaProbe = readRootLengthPx(raw);
|
|
44
|
+
if (viaProbe > 0) return viaProbe;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return window.innerHeight;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Max height for modals / sheets / drawers (content-sized clamps).
|
|
52
|
+
* Leaves the top safe area + a small margin so a bottom sheet cannot cover the
|
|
53
|
+
* status bar controls; the sheet itself may still paint into the home-indicator
|
|
54
|
+
* band (footer chrome owns that inset).
|
|
55
|
+
*/
|
|
56
|
+
export function overlayMaxHeightPx(ratio = 0.92): number {
|
|
57
|
+
const appH = readAppHeightPx();
|
|
58
|
+
const top = readSafeAreaInsetTop();
|
|
59
|
+
const available = Math.max(0, appH - top - 8);
|
|
60
|
+
return Math.floor(available * ratio);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** CSS expression matching {@link overlayMaxHeightPx} for inline styles. */
|
|
64
|
+
export function overlayMaxHeightCss(): string {
|
|
65
|
+
return 'var(--shellui-overlay-max-height)';
|
|
66
|
+
}
|
|
@@ -4,8 +4,12 @@ import { useTranslation } from 'react-i18next';
|
|
|
4
4
|
import type { NavigationItem, NavigationGroup } from '../../config/types';
|
|
5
5
|
import { flattenNavigationItems } from '../utils';
|
|
6
6
|
import { DesktopHistoryButtons } from '../chrome/DesktopHistoryButtons';
|
|
7
|
-
import { useIsTauriClient,
|
|
8
|
-
import {
|
|
7
|
+
import { useIsTauriClient, useMacTrafficLights } from '../chrome/runtime';
|
|
8
|
+
import {
|
|
9
|
+
DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
10
|
+
DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
11
|
+
MAC_TRAFFIC_LIGHTS_WIDTH_PX,
|
|
12
|
+
} from '../chrome/constants';
|
|
9
13
|
|
|
10
14
|
interface FullscreenLayoutProps {
|
|
11
15
|
title?: string;
|
|
@@ -26,7 +30,7 @@ export function FullscreenLayout({ title, navigation, children }: FullscreenLayo
|
|
|
26
30
|
const location = useLocation();
|
|
27
31
|
const { i18n } = useTranslation();
|
|
28
32
|
const isTauriEnv = useIsTauriClient();
|
|
29
|
-
const
|
|
33
|
+
const trafficLights = useMacTrafficLights();
|
|
30
34
|
const currentLanguage = i18n.language || 'en';
|
|
31
35
|
const navigationItems = useMemo(() => flattenNavigationItems(navigation), [navigation]);
|
|
32
36
|
|
|
@@ -48,13 +52,14 @@ export function FullscreenLayout({ title, navigation, children }: FullscreenLayo
|
|
|
48
52
|
}, [location.pathname, title, navigationItems, currentLanguage]);
|
|
49
53
|
|
|
50
54
|
return (
|
|
51
|
-
<main className="relative flex
|
|
55
|
+
<main className="relative flex h-full max-h-full w-full flex-col overflow-hidden bg-background">
|
|
52
56
|
{isTauriEnv ? (
|
|
53
57
|
<div
|
|
54
58
|
className="pointer-events-auto absolute top-0 left-0 z-[46] flex items-center"
|
|
55
59
|
style={{
|
|
56
60
|
height: DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
57
|
-
|
|
61
|
+
paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
62
|
+
paddingLeft: trafficLights ? MAC_TRAFFIC_LIGHTS_WIDTH_PX : 8,
|
|
58
63
|
}}
|
|
59
64
|
>
|
|
60
65
|
<DesktopHistoryButtons />
|
|
@@ -13,6 +13,7 @@ import { DesktopHistoryButtons } from '../chrome/DesktopHistoryButtons';
|
|
|
13
13
|
import { useIsTauriClient, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
|
|
14
14
|
import {
|
|
15
15
|
DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
16
|
+
DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
16
17
|
MAC_TRAFFIC_LIGHTS_GAP_PX,
|
|
17
18
|
MAC_TRAFFIC_LIGHTS_WIDTH_PX,
|
|
18
19
|
} from '../chrome/constants';
|
|
@@ -76,44 +77,45 @@ export function SidebarInner({
|
|
|
76
77
|
<>
|
|
77
78
|
<SidebarHeader
|
|
78
79
|
className={cn(
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
// Always pin to titlebar height — default SidebarHeader p-2 is taller on web.
|
|
81
|
+
'gap-0 border-b border-sidebar-border select-none',
|
|
82
|
+
showOverlayHeader || mobileSheetHeader ? 'p-0' : 'px-2 py-0',
|
|
81
83
|
showCollapsedTopBar && 'hidden',
|
|
82
|
-
mobileSheetHeader && 'gap-0 p-0',
|
|
83
84
|
)}
|
|
84
|
-
style={
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
: undefined
|
|
91
|
-
}
|
|
85
|
+
style={{
|
|
86
|
+
height: DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
87
|
+
// Nudge controls down so they optically match centered traffic lights.
|
|
88
|
+
paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
89
|
+
...(mobileSheetHeader ? { paddingLeft: mobileTrafficInset } : {}),
|
|
90
|
+
}}
|
|
92
91
|
{...(showOverlayHeader
|
|
93
92
|
? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
|
|
94
93
|
: {})}
|
|
95
94
|
>
|
|
96
95
|
{showOverlayHeader ? (
|
|
97
96
|
<div
|
|
98
|
-
className="flex w-full shrink-0 items-stretch"
|
|
99
|
-
style={{ height: DESKTOP_TITLEBAR_HEIGHT_PX }}
|
|
97
|
+
className="flex h-full w-full shrink-0 items-stretch"
|
|
100
98
|
data-shellui-drag-region=""
|
|
101
99
|
data-tauri-drag-region=""
|
|
102
100
|
>
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
101
|
+
{trafficLights ? (
|
|
102
|
+
<div
|
|
103
|
+
className="h-full shrink-0"
|
|
104
|
+
style={{ width: MAC_TRAFFIC_LIGHTS_WIDTH_PX }}
|
|
105
|
+
aria-hidden
|
|
106
|
+
/>
|
|
107
|
+
) : null}
|
|
108
108
|
<div
|
|
109
109
|
className="flex h-full min-w-0 flex-1 items-center gap-1"
|
|
110
|
-
style={{
|
|
110
|
+
style={{
|
|
111
|
+
paddingLeft: trafficLights ? MAC_TRAFFIC_LIGHTS_GAP_PX : 8,
|
|
112
|
+
}}
|
|
111
113
|
>
|
|
112
114
|
{hasAppIcon ? brandIcon : null}
|
|
113
115
|
{!hasAppIcon ? (
|
|
114
116
|
<SidebarTrigger
|
|
115
117
|
data-shellui-no-drag=""
|
|
116
|
-
className="size-
|
|
118
|
+
className="size-7 shrink-0 touch-manipulation"
|
|
117
119
|
/>
|
|
118
120
|
) : null}
|
|
119
121
|
<div
|
|
@@ -126,20 +128,14 @@ export function SidebarInner({
|
|
|
126
128
|
{hasAppIcon ? (
|
|
127
129
|
<SidebarTrigger
|
|
128
130
|
data-shellui-no-drag=""
|
|
129
|
-
className="size-
|
|
131
|
+
className="size-7 shrink-0 touch-manipulation"
|
|
130
132
|
/>
|
|
131
133
|
) : null}
|
|
132
134
|
{hasAppIcon ? trailingInset : null}
|
|
133
135
|
</div>
|
|
134
136
|
</div>
|
|
135
137
|
) : (
|
|
136
|
-
<div
|
|
137
|
-
className={cn(
|
|
138
|
-
'flex w-full items-center',
|
|
139
|
-
hasAppIcon ? 'gap-0' : 'gap-0.5',
|
|
140
|
-
mobileSheetHeader && 'h-full',
|
|
141
|
-
)}
|
|
142
|
-
>
|
|
138
|
+
<div className={cn('flex h-full w-full items-center', hasAppIcon ? 'gap-0' : 'gap-0.5')}>
|
|
143
139
|
{brandIcon}
|
|
144
140
|
{hasAppIcon ? (
|
|
145
141
|
<div
|
|
@@ -147,7 +143,7 @@ export function SidebarInner({
|
|
|
147
143
|
className="min-w-0 flex-1"
|
|
148
144
|
/>
|
|
149
145
|
) : null}
|
|
150
|
-
<SidebarTrigger className="size-
|
|
146
|
+
<SidebarTrigger className="size-7 shrink-0 touch-manipulation" />
|
|
151
147
|
{trailingInset}
|
|
152
148
|
</div>
|
|
153
149
|
)}
|
|
@@ -155,7 +151,7 @@ export function SidebarInner({
|
|
|
155
151
|
<SidebarContent className="gap-1">
|
|
156
152
|
<NavigationContent navigation={startNav} />
|
|
157
153
|
</SidebarContent>
|
|
158
|
-
<SidebarFooter className="gap-0 border-t border-sidebar-border
|
|
154
|
+
<SidebarFooter className="gap-0 border-t border-sidebar-border px-0 pt-0 pb-[max(0.5rem,var(--shellui-safe-area-bottom))]">
|
|
159
155
|
{(endItems.length > 0 || showAuthButton) && (
|
|
160
156
|
<NavigationContent
|
|
161
157
|
navigation={endItems}
|