@shellui/core 0.7.0-alpha.9 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +24 -7
- package/src/components/ui/drawer.tsx +47 -30
- package/src/components/ui/sheet.tsx +18 -12
- package/src/components/ui/shell-divider.spec.tsx +63 -0
- package/src/components/ui/shell-divider.tsx +20 -0
- package/src/components/ui/sidebar.tsx +26 -12
- package/src/components/ui/tooltip.tsx +4 -2
- package/src/features/admin/AdminView.tsx +9 -6
- package/src/features/auth/components/LoginButton.spec.tsx +203 -0
- package/src/features/auth/components/LoginButton.tsx +77 -28
- package/src/features/auth/components/LoginButtonIcons.tsx +4 -8
- package/src/features/chromeActions/ChromeActionsHost.tsx +5 -1
- package/src/features/chromeActions/computeActionInsets.ts +7 -4
- package/src/features/layouts/OverlayShell.tsx +58 -40
- package/src/features/layouts/appbar/AppBarItemIcon.spec.tsx +45 -0
- package/src/features/layouts/appbar/AppBarItemIcon.tsx +19 -0
- package/src/features/layouts/appbar/AppBarLayout.tsx +115 -110
- package/src/features/layouts/appbar/appBarOverflow.spec.ts +27 -0
- package/src/features/layouts/appbar/appBarOverflow.ts +42 -0
- package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +13 -24
- package/src/features/layouts/chrome/ContentDragOverlay.tsx +5 -6
- package/src/features/layouts/chrome/DesktopChrome.tsx +37 -0
- package/src/features/layouts/chrome/DesktopHistoryButtons.tsx +15 -4
- package/src/features/layouts/chrome/MacStrip.tsx +33 -0
- package/src/features/layouts/chrome/constants.ts +36 -8
- package/src/features/layouts/chrome/index.ts +8 -0
- package/src/features/layouts/chrome/stripDragMap.ts +35 -0
- package/src/features/layouts/chrome/stripNoDrag.spec.tsx +103 -0
- package/src/features/layouts/chrome/useScrollHideChrome.ts +3 -8
- package/src/features/layouts/chrome/viewport.ts +11 -4
- package/src/features/layouts/floating/FloatingBottomDock.tsx +263 -43
- package/src/features/layouts/floating/FloatingLayout.tsx +14 -8
- package/src/features/layouts/floating/FloatingSidebar.tsx +178 -81
- package/src/features/layouts/floating/computeFloatingInsets.ts +22 -4
- package/src/features/layouts/floating/moreSections.spec.ts +28 -0
- package/src/features/layouts/floating/moreSections.ts +31 -0
- package/src/features/layouts/floating/useFloatingChrome.ts +3 -1
- package/src/features/layouts/floating/useSoftKeyboard.spec.ts +39 -0
- package/src/features/layouts/floating/useSoftKeyboard.ts +82 -0
- package/src/features/layouts/fullscreen/FullscreenLayout.spec.tsx +68 -0
- package/src/features/layouts/fullscreen/FullscreenLayout.tsx +47 -10
- package/src/features/layouts/sidebar/NavigationContent.tsx +17 -9
- package/src/features/layouts/sidebar/SidebarIcons.tsx +70 -9
- package/src/features/layouts/sidebar/SidebarInner.spec.tsx +149 -0
- package/src/features/layouts/sidebar/SidebarInner.tsx +103 -43
- package/src/features/layouts/sidebar/SidebarLayout.tsx +24 -17
- package/src/features/layouts/windows/DesktopDots.tsx +76 -0
- package/src/features/layouts/windows/WindowsLayout.tsx +265 -160
- package/src/features/layouts/windows/deskDots.spec.ts +54 -0
- package/src/features/layouts/windows/deskDots.ts +314 -0
- package/src/features/overlays/ResponsiveModal.tsx +5 -3
- package/src/features/overlays/overlaySize.spec.ts +56 -16
- package/src/features/overlays/overlaySize.ts +114 -31
- package/src/features/overlays/phoneDrawerAnchoring.spec.ts +187 -0
- package/src/features/overlays/useOverlayReportedSize.ts +8 -3
- package/src/features/theme/applyTheme.ts +8 -0
- package/src/features/theme/navContrast.spec.ts +49 -0
- package/src/features/theme/navContrast.ts +108 -0
- package/src/i18n/translations/en/common.json +26 -0
- package/src/i18n/translations/fr/common.json +26 -0
- package/src/index.css +1156 -77
- package/src/service-worker/devCaches.spec.ts +32 -0
- package/src/service-worker/devCaches.ts +27 -0
- package/src/service-worker/sw-dev.ts +23 -23
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
1
|
+
import { DESKTOP_TITLEBAR_HEIGHT_PX, MAC_LIGHTS_SAFE_PX } from './constants';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Narrow
|
|
4
|
+
* Narrow drag strip over the lights safe area only (0 to 80 x 0 to 32).
|
|
5
5
|
*
|
|
6
6
|
* A full-width overlay used to sit on top of iframes and steal clicks from
|
|
7
7
|
* embedded content. Dragging the window still works from layout chrome
|
|
8
|
-
* (app bar, sidebar header, admin header, windows
|
|
9
|
-
*
|
|
10
|
-
* clickable.
|
|
8
|
+
* (app bar, sidebar header, admin header, windows strip) and from this
|
|
9
|
+
* safe area. Interactive iframe content to the right stays clickable.
|
|
11
10
|
*
|
|
12
11
|
* Requires `core:window:allow-start-dragging` in Tauri capabilities.
|
|
13
12
|
*/
|
|
@@ -19,7 +18,7 @@ export function ContentDragOverlay() {
|
|
|
19
18
|
className="fixed top-0 left-0 z-[45]"
|
|
20
19
|
style={{
|
|
21
20
|
height: DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
22
|
-
width:
|
|
21
|
+
width: MAC_LIGHTS_SAFE_PX,
|
|
23
22
|
}}
|
|
24
23
|
/>
|
|
25
24
|
);
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
useIsHomeScreenPwa,
|
|
6
6
|
useIsTauriClient,
|
|
7
7
|
useIsTauriRuntime,
|
|
8
|
+
useMacOverlayChrome,
|
|
8
9
|
useMacTrafficLights,
|
|
9
10
|
} from './runtime';
|
|
10
11
|
|
|
@@ -18,12 +19,17 @@ import {
|
|
|
18
19
|
* Sets `data-shellui-host` to `browser` | `pwa` | `tauri` so CSS / layout can
|
|
19
20
|
* distinguish Safari Home Screen PWAs (iOS 27 system status gradient) from
|
|
20
21
|
* Tauri WKWebView (native-controlled chrome + CSS safe-area).
|
|
22
|
+
*
|
|
23
|
+
* macOS desktop: `data-shellui-mac-chrome` marks the 32px strip layouts (also in native
|
|
24
|
+
* fullscreen), and `data-shellui-window-inactive` dims strip text while the window is
|
|
25
|
+
* in the background, as AppKit greys the lights.
|
|
21
26
|
*/
|
|
22
27
|
export function DesktopChrome() {
|
|
23
28
|
const isTauriEnv = useIsTauriClient();
|
|
24
29
|
const tauriRuntime = useIsTauriRuntime();
|
|
25
30
|
const homeScreenPwa = useIsHomeScreenPwa();
|
|
26
31
|
const trafficLights = useMacTrafficLights();
|
|
32
|
+
const macChrome = useMacOverlayChrome();
|
|
27
33
|
|
|
28
34
|
useEffect(() => {
|
|
29
35
|
const root = document.documentElement;
|
|
@@ -39,6 +45,37 @@ export function DesktopChrome() {
|
|
|
39
45
|
};
|
|
40
46
|
}, [trafficLights, isTauriEnv, tauriRuntime, homeScreenPwa]);
|
|
41
47
|
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
const root = document.documentElement;
|
|
50
|
+
if (!macChrome) {
|
|
51
|
+
root.removeAttribute('data-shellui-mac-chrome');
|
|
52
|
+
root.removeAttribute('data-shellui-window-inactive');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
root.setAttribute('data-shellui-mac-chrome', '');
|
|
56
|
+
const sync = () => {
|
|
57
|
+
if (document.hasFocus()) root.removeAttribute('data-shellui-window-inactive');
|
|
58
|
+
else root.setAttribute('data-shellui-window-inactive', '');
|
|
59
|
+
};
|
|
60
|
+
// Focus moving into a content iframe also blurs this window: re-check after the move.
|
|
61
|
+
// `hasFocus()` stays true while a child frame holds focus.
|
|
62
|
+
let timer: number | undefined;
|
|
63
|
+
const syncLater = () => {
|
|
64
|
+
window.clearTimeout(timer);
|
|
65
|
+
timer = window.setTimeout(sync, 0);
|
|
66
|
+
};
|
|
67
|
+
sync();
|
|
68
|
+
window.addEventListener('focus', sync);
|
|
69
|
+
window.addEventListener('blur', syncLater);
|
|
70
|
+
return () => {
|
|
71
|
+
window.clearTimeout(timer);
|
|
72
|
+
window.removeEventListener('focus', sync);
|
|
73
|
+
window.removeEventListener('blur', syncLater);
|
|
74
|
+
root.removeAttribute('data-shellui-mac-chrome');
|
|
75
|
+
root.removeAttribute('data-shellui-window-inactive');
|
|
76
|
+
};
|
|
77
|
+
}, [macChrome]);
|
|
78
|
+
|
|
42
79
|
if (!trafficLights) return null;
|
|
43
80
|
return <ContentDragOverlay />;
|
|
44
81
|
}
|
|
@@ -2,15 +2,26 @@ import { cn } from '../../../lib/utils';
|
|
|
2
2
|
import { DesktopBackButton } from './DesktopBackButton';
|
|
3
3
|
import { DesktopForwardButton } from './DesktopForwardButton';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Browser-like Back + Forward for Tauri / desktop chrome.
|
|
7
|
+
* `strip` sizes them for the macOS strip (24px boxes, 16px icons).
|
|
8
|
+
*/
|
|
9
|
+
export function DesktopHistoryButtons({
|
|
10
|
+
className,
|
|
11
|
+
strip = false,
|
|
12
|
+
}: {
|
|
13
|
+
className?: string;
|
|
14
|
+
strip?: boolean;
|
|
15
|
+
}) {
|
|
16
|
+
const buttonClassName = strip ? 'size-6' : undefined;
|
|
7
17
|
return (
|
|
8
18
|
<div
|
|
9
19
|
data-shellui-no-drag=""
|
|
20
|
+
data-shellui-history=""
|
|
10
21
|
className={cn('flex shrink-0 items-center', className)}
|
|
11
22
|
>
|
|
12
|
-
<DesktopBackButton />
|
|
13
|
-
<DesktopForwardButton />
|
|
23
|
+
<DesktopBackButton className={buttonClassName} />
|
|
24
|
+
<DesktopForwardButton className={buttonClassName} />
|
|
14
25
|
</div>
|
|
15
26
|
);
|
|
16
27
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { cn } from '../../../lib/utils';
|
|
2
|
+
|
|
3
|
+
/** Drag attributes for strip backgrounds and flexible spacers. */
|
|
4
|
+
export const MAC_DRAG_REGION_PROPS = {
|
|
5
|
+
'data-shellui-drag-region': '',
|
|
6
|
+
'data-tauri-drag-region': '',
|
|
7
|
+
} as const;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Left safe area of the macOS strip: 80px next to the default traffic lights
|
|
11
|
+
* (12px in native fullscreen). Drag only, never holds a control.
|
|
12
|
+
*/
|
|
13
|
+
export function MacLightsSafeArea({ className }: { className?: string }) {
|
|
14
|
+
return (
|
|
15
|
+
<div
|
|
16
|
+
aria-hidden
|
|
17
|
+
data-shellui-mac-safe=""
|
|
18
|
+
{...MAC_DRAG_REGION_PROPS}
|
|
19
|
+
className={cn('shellui-mac-safe h-full shrink-0', className)}
|
|
20
|
+
/>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Flexible drag spacer inside the macOS strip. */
|
|
25
|
+
export function MacStripSpacer({ className }: { className?: string }) {
|
|
26
|
+
return (
|
|
27
|
+
<div
|
|
28
|
+
aria-hidden
|
|
29
|
+
{...MAC_DRAG_REGION_PROPS}
|
|
30
|
+
className={cn('min-h-full min-w-2 flex-1 self-stretch', className)}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -1,17 +1,45 @@
|
|
|
1
|
-
/** Height of the macOS overlay titlebar / traffic-light row. */
|
|
2
|
-
export const DESKTOP_TITLEBAR_HEIGHT_PX = 42;
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
|
-
*
|
|
6
|
-
* (
|
|
2
|
+
* macOS overlay strip height (rules v2). The traffic lights stay at the AppKit default
|
|
3
|
+
* (`trafficLightPosition` unset): 32px title bar on macOS 26, 28px on macOS 15.
|
|
4
|
+
* Every macOS desktop layout puts its top chrome in this one strip.
|
|
7
5
|
*/
|
|
8
|
-
export const
|
|
6
|
+
export const DESKTOP_TITLEBAR_HEIGHT_PX = 32;
|
|
7
|
+
|
|
8
|
+
/** Top inset inside the macOS strip. Controls centre on the lights line, no nudge. */
|
|
9
|
+
export const DESKTOP_TITLEBAR_PAD_TOP_PX = 0;
|
|
9
10
|
|
|
10
|
-
/**
|
|
11
|
-
export const
|
|
11
|
+
/** Vertical centre of the default traffic lights in the strip (`--shellui-mac-lights-cy`). */
|
|
12
|
+
export const MAC_TRAFFIC_LIGHTS_CENTER_Y_PX = 16;
|
|
13
|
+
|
|
14
|
+
/** Width reserved for the default traffic lights (group spans about x 8 to 64). */
|
|
15
|
+
export const MAC_TRAFFIC_LIGHTS_WIDTH_PX = 68;
|
|
12
16
|
|
|
13
17
|
/** Extra space between traffic lights and the first chrome control. */
|
|
14
18
|
export const MAC_TRAFFIC_LIGHTS_GAP_PX = 12;
|
|
15
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Drag-only safe area from the left window edge (`--shellui-mac-lights-safe`).
|
|
22
|
+
* Nothing interactive, no text and no focus ring enters 0 to 80 x 0 to 32.
|
|
23
|
+
*/
|
|
24
|
+
export const MAC_LIGHTS_SAFE_PX = MAC_TRAFFIC_LIGHTS_WIDTH_PX + MAC_TRAFFIC_LIGHTS_GAP_PX;
|
|
25
|
+
|
|
26
|
+
/** Safe area in native fullscreen, where AppKit hides the lights. */
|
|
27
|
+
export const MAC_LIGHTS_SAFE_FULLSCREEN_PX = 12;
|
|
28
|
+
|
|
29
|
+
/** Controls in the macOS strip: 24px boxes with 16px icons. */
|
|
30
|
+
export const MAC_STRIP_CONTROL_PX = 24;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Shell header height on the web, on phones and on Tauri hosts with a native caption bar
|
|
34
|
+
* (Windows, Linux). The macOS strip uses `DESKTOP_TITLEBAR_HEIGHT_PX` instead.
|
|
35
|
+
*/
|
|
36
|
+
export const SHELL_HEADER_HEIGHT_PX = 42;
|
|
37
|
+
|
|
38
|
+
/** Sidebar layout phone header height (spec: 48px, 40px trigger). */
|
|
39
|
+
export const MOBILE_SIDEBAR_HEADER_HEIGHT_PX = 48;
|
|
40
|
+
|
|
41
|
+
/** Top inset inside the shell header (web, phones, native caption bar hosts). */
|
|
42
|
+
export const SHELL_HEADER_PAD_TOP_PX = 2;
|
|
43
|
+
|
|
16
44
|
/** Set on an iframe after it navigates to a foreign origin (login pages, OAuth). */
|
|
17
45
|
export const IFRAME_FOREIGN_ATTR = 'data-shellui-iframe-foreign';
|
|
@@ -2,9 +2,17 @@ export {
|
|
|
2
2
|
DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
3
3
|
DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
4
4
|
IFRAME_FOREIGN_ATTR,
|
|
5
|
+
MAC_LIGHTS_SAFE_FULLSCREEN_PX,
|
|
6
|
+
MAC_LIGHTS_SAFE_PX,
|
|
7
|
+
MAC_STRIP_CONTROL_PX,
|
|
8
|
+
MAC_TRAFFIC_LIGHTS_CENTER_Y_PX,
|
|
5
9
|
MAC_TRAFFIC_LIGHTS_GAP_PX,
|
|
6
10
|
MAC_TRAFFIC_LIGHTS_WIDTH_PX,
|
|
11
|
+
SHELL_HEADER_HEIGHT_PX,
|
|
12
|
+
SHELL_HEADER_PAD_TOP_PX,
|
|
7
13
|
} from './constants';
|
|
14
|
+
export { MAC_DRAG_REGION_PROPS, MacLightsSafeArea, MacStripSpacer } from './MacStrip';
|
|
15
|
+
export { findSafeAreaControls, findStripDragLeaks } from './stripDragMap';
|
|
8
16
|
export {
|
|
9
17
|
goDesktopBack,
|
|
10
18
|
goBackInIframes,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const INTERACTIVE =
|
|
2
|
+
'button, a[href], input, select, textarea, summary, [role="button"], [role="link"], [role="tab"], [role="menuitem"], [role="combobox"], [tabindex]:not([tabindex="-1"])';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Controls in a macOS strip that would turn into window drag or zoom targets:
|
|
6
|
+
* interactive elements without `data-shellui-no-drag` on themselves or on an
|
|
7
|
+
* ancestor inside the strip, or carrying a drag attribute themselves.
|
|
8
|
+
*/
|
|
9
|
+
export function findStripDragLeaks(strip: Element): Element[] {
|
|
10
|
+
const leaks: Element[] = [];
|
|
11
|
+
for (const el of Array.from(strip.querySelectorAll(INTERACTIVE))) {
|
|
12
|
+
if (el.hasAttribute('data-tauri-drag-region') || el.hasAttribute('data-shellui-drag-region')) {
|
|
13
|
+
leaks.push(el);
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
let node: Element | null = el;
|
|
17
|
+
let guarded = false;
|
|
18
|
+
while (node && node !== strip.parentElement) {
|
|
19
|
+
if (node.hasAttribute('data-shellui-no-drag')) {
|
|
20
|
+
guarded = true;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
node = node.parentElement;
|
|
24
|
+
}
|
|
25
|
+
if (!guarded) leaks.push(el);
|
|
26
|
+
}
|
|
27
|
+
return leaks;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Interactive elements placed inside the drag-only lights safe area. */
|
|
31
|
+
export function findSafeAreaControls(strip: Element): Element[] {
|
|
32
|
+
return Array.from(strip.querySelectorAll('[data-shellui-mac-safe]')).flatMap((safe) =>
|
|
33
|
+
Array.from(safe.querySelectorAll(INTERACTIVE)),
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { act } from 'react';
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client';
|
|
4
|
+
import { MemoryRouter } from 'react-router';
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
6
|
+
import { SidebarProvider } from '../../../components/ui/sidebar';
|
|
7
|
+
import { CollapsedDesktopTitlebar } from './CollapsedDesktopTitlebar';
|
|
8
|
+
import { DesktopHistoryButtons } from './DesktopHistoryButtons';
|
|
9
|
+
import { MAC_DRAG_REGION_PROPS, MacLightsSafeArea, MacStripSpacer } from './MacStrip';
|
|
10
|
+
import { findSafeAreaControls, findStripDragLeaks } from './stripDragMap';
|
|
11
|
+
|
|
12
|
+
vi.mock('./runtime', async (importOriginal) => {
|
|
13
|
+
const actual = await importOriginal<typeof import('./runtime')>();
|
|
14
|
+
return {
|
|
15
|
+
...actual,
|
|
16
|
+
useMacOverlayChrome: () => true,
|
|
17
|
+
useMacTrafficLights: () => true,
|
|
18
|
+
useIsTauriClient: () => true,
|
|
19
|
+
useIsTauriRuntime: () => true,
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
vi.mock('../../modal/ModalContext', () => ({ useModal: () => ({ isOpen: false }) }));
|
|
23
|
+
vi.mock('../../drawer/DrawerContext', () => ({ useDrawer: () => ({ isOpen: false }) }));
|
|
24
|
+
vi.mock('../../storage/StoragePickerContext', () => ({
|
|
25
|
+
useStoragePicker: () => ({ isOpen: false }),
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
29
|
+
|
|
30
|
+
let container: HTMLDivElement;
|
|
31
|
+
let root: Root;
|
|
32
|
+
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
container = document.createElement('div');
|
|
35
|
+
document.body.appendChild(container);
|
|
36
|
+
root = createRoot(container);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
afterEach(() => {
|
|
40
|
+
act(() => root.unmount());
|
|
41
|
+
container.remove();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
function getStrip(): Element {
|
|
45
|
+
const strip = container.querySelector('[data-shellui-mac-strip]');
|
|
46
|
+
if (!strip) throw new Error('strip not rendered');
|
|
47
|
+
return strip;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function render(node: React.ReactNode) {
|
|
51
|
+
act(() => {
|
|
52
|
+
root.render(<MemoryRouter>{node}</MemoryRouter>);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
describe('macOS strip drag map', () => {
|
|
57
|
+
it('collapsed sidebar strip: every control is no-drag, the safe area holds none', () => {
|
|
58
|
+
render(
|
|
59
|
+
<SidebarProvider defaultOpen={false}>
|
|
60
|
+
<CollapsedDesktopTitlebar />
|
|
61
|
+
</SidebarProvider>,
|
|
62
|
+
);
|
|
63
|
+
const strip = getStrip();
|
|
64
|
+
expect(strip.hasAttribute('data-tauri-drag-region')).toBe(true);
|
|
65
|
+
// Expand trigger, Back, Forward.
|
|
66
|
+
expect(strip.querySelectorAll('button').length).toBe(3);
|
|
67
|
+
expect(findStripDragLeaks(strip)).toEqual([]);
|
|
68
|
+
expect(findSafeAreaControls(strip)).toEqual([]);
|
|
69
|
+
const safe = strip.firstElementChild;
|
|
70
|
+
if (!safe) throw new Error('safe area missing');
|
|
71
|
+
expect(safe.hasAttribute('data-shellui-mac-safe')).toBe(true);
|
|
72
|
+
expect(safe.hasAttribute('data-tauri-drag-region')).toBe(true);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('history buttons in a strip carry no-drag', () => {
|
|
76
|
+
render(
|
|
77
|
+
<div
|
|
78
|
+
data-shellui-mac-strip=""
|
|
79
|
+
{...MAC_DRAG_REGION_PROPS}
|
|
80
|
+
>
|
|
81
|
+
<MacLightsSafeArea />
|
|
82
|
+
<DesktopHistoryButtons strip />
|
|
83
|
+
<MacStripSpacer />
|
|
84
|
+
</div>,
|
|
85
|
+
);
|
|
86
|
+
const strip = getStrip();
|
|
87
|
+
expect(strip.querySelectorAll('button').length).toBe(2);
|
|
88
|
+
expect(findStripDragLeaks(strip)).toEqual([]);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('flags a control without no-drag, one marked as drag, and one in the safe area', () => {
|
|
92
|
+
container.innerHTML = `
|
|
93
|
+
<div data-shellui-mac-strip data-tauri-drag-region>
|
|
94
|
+
<div data-shellui-mac-safe data-tauri-drag-region><button id="in-safe" data-shellui-no-drag></button></div>
|
|
95
|
+
<button id="bare"></button>
|
|
96
|
+
<a id="drag-link" href="/x" data-shellui-no-drag data-tauri-drag-region></a>
|
|
97
|
+
<div data-shellui-no-drag><button id="ok"></button></div>
|
|
98
|
+
</div>`;
|
|
99
|
+
const strip = getStrip();
|
|
100
|
+
expect(findStripDragLeaks(strip).map((el) => el.id)).toEqual(['bare', 'drag-link']);
|
|
101
|
+
expect(findSafeAreaControls(strip).map((el) => el.id)).toEqual(['in-safe']);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import { resolveViewport } from '../../../hooks/use-viewport';
|
|
12
12
|
import { publishLayoutChrome } from '../floating/layoutChromeStore';
|
|
13
13
|
import { readShellSafeAreaPx } from '../floating/computeFloatingInsets';
|
|
14
|
-
import {
|
|
14
|
+
import { SHELL_HEADER_HEIGHT_PX } from './constants';
|
|
15
15
|
|
|
16
16
|
export type ScrollHideLayoutId = 'sidebar' | 'sidebar-inset' | 'app-bar' | 'app-bar-inset';
|
|
17
17
|
|
|
@@ -32,7 +32,7 @@ export function mobileShellHeaderHeightPx(options?: {
|
|
|
32
32
|
includeSafeArea?: boolean;
|
|
33
33
|
barHeightPx?: number;
|
|
34
34
|
}): number {
|
|
35
|
-
const bar = options?.barHeightPx ??
|
|
35
|
+
const bar = options?.barHeightPx ?? SHELL_HEADER_HEIGHT_PX;
|
|
36
36
|
if (options?.includeSafeArea === false) return bar;
|
|
37
37
|
const safe = typeof document !== 'undefined' ? readShellSafeAreaPx().top : 0;
|
|
38
38
|
return bar + safe;
|
|
@@ -78,12 +78,7 @@ export function useScrollHideChrome(options: {
|
|
|
78
78
|
/** When true (root shell), include safe-area-top in the header band height. */
|
|
79
79
|
includeSafeArea?: boolean;
|
|
80
80
|
}) {
|
|
81
|
-
const {
|
|
82
|
-
enabled,
|
|
83
|
-
layout,
|
|
84
|
-
barHeightPx = DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
85
|
-
includeSafeArea = true,
|
|
86
|
-
} = options;
|
|
81
|
+
const { enabled, layout, barHeightPx = SHELL_HEADER_HEIGHT_PX, includeSafeArea = true } = options;
|
|
87
82
|
const location = useLocation();
|
|
88
83
|
const [chromeVisible, setChromeVisible] = useState(true);
|
|
89
84
|
const scrollStateRef = useRef<ScrollChromeState>({ visible: true, lastY: 0 });
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
const APP_HEIGHT_VAR = '--shellui-app-height';
|
|
10
10
|
|
|
11
11
|
/** Read a CSS length on :root (px). `env(safe-area-*)` resolves through a probe. */
|
|
12
|
-
function
|
|
12
|
+
export function readCssLengthPx(cssLength: string): number {
|
|
13
13
|
if (typeof document === 'undefined') return 0;
|
|
14
14
|
const probe = document.createElement('div');
|
|
15
15
|
probe.style.cssText =
|
|
@@ -22,11 +22,18 @@ function readRootLengthPx(cssLength: string): number {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export function readSafeAreaInsetTop(): number {
|
|
25
|
-
return
|
|
25
|
+
return readCssLengthPx('var(--shellui-safe-area-top, env(safe-area-inset-top, 0px))');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Phone bottom sheet offset from the screen bottom: the drawer gap plus the home indicator. */
|
|
29
|
+
export function readDrawerBottomOffset(): number {
|
|
30
|
+
return readCssLengthPx(
|
|
31
|
+
'var(--shellui-drawer-bottom, calc(8px + env(safe-area-inset-bottom, 0px)))',
|
|
32
|
+
);
|
|
26
33
|
}
|
|
27
34
|
|
|
28
35
|
export function readSafeAreaInsetBottom(): number {
|
|
29
|
-
return
|
|
36
|
+
return readCssLengthPx('var(--shellui-safe-area-bottom, env(safe-area-inset-bottom, 0px))');
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
/** Current shell height in CSS pixels (falls back to innerHeight). */
|
|
@@ -40,7 +47,7 @@ export function readAppHeightPx(): number {
|
|
|
40
47
|
}
|
|
41
48
|
// Resolve dvh/vh/% via a probe so browser-tab fallback still works.
|
|
42
49
|
if (raw) {
|
|
43
|
-
const viaProbe =
|
|
50
|
+
const viaProbe = readCssLengthPx(raw);
|
|
44
51
|
if (viaProbe > 0) return viaProbe;
|
|
45
52
|
}
|
|
46
53
|
}
|