@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
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { act } from 'react';
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client';
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
5
|
+
import type { NavigationItem } from '../../config/types';
|
|
6
|
+
import { AppBarItemIcon } from './AppBarItemIcon';
|
|
7
|
+
|
|
8
|
+
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
9
|
+
|
|
10
|
+
let container: HTMLDivElement;
|
|
11
|
+
let root: Root;
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
container = document.createElement('div');
|
|
15
|
+
document.body.appendChild(container);
|
|
16
|
+
root = createRoot(container);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
act(() => root.unmount());
|
|
21
|
+
container.remove();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
function render(item: Partial<NavigationItem>) {
|
|
25
|
+
act(() =>
|
|
26
|
+
root.render(<AppBarItemIcon item={{ path: 'x', url: '/x', label: 'Docs', ...item }} />),
|
|
27
|
+
);
|
|
28
|
+
return container.firstElementChild as HTMLElement;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
describe('AppBarItemIcon', () => {
|
|
32
|
+
it('renders a plain 16px icon with no muted tile', () => {
|
|
33
|
+
const el = render({ icon: '/icons/book.svg' });
|
|
34
|
+
expect(el.className).toContain('size-4');
|
|
35
|
+
expect(el.className).not.toContain('bg-muted');
|
|
36
|
+
expect(el.className).not.toContain('rounded-md');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('falls back to the default 16px glyph instead of a letter tile', () => {
|
|
40
|
+
const el = render({});
|
|
41
|
+
expect(el.tagName.toLowerCase()).toBe('svg');
|
|
42
|
+
expect(el.getAttribute('class')).toContain('size-4');
|
|
43
|
+
expect(container.textContent).toBe('');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { NavigationItem } from '../../config/types';
|
|
2
|
+
import { NavIcon } from '../sidebar/SidebarIcons';
|
|
3
|
+
import { getExternalFaviconUrl } from '../sidebar/sidebarUtils';
|
|
4
|
+
|
|
5
|
+
function itemIconSrc(item: NavigationItem): string | null {
|
|
6
|
+
if (item.icon) return item.icon;
|
|
7
|
+
if (item.openIn === 'external') return getExternalFaviconUrl(item.url);
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Plain 16px icon for start-nav links and their menus (no tile, like the mock). */
|
|
12
|
+
export function AppBarItemIcon({ item }: { item: NavigationItem }) {
|
|
13
|
+
return (
|
|
14
|
+
<NavIcon
|
|
15
|
+
src={itemIconSrc(item)}
|
|
16
|
+
className="size-4"
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -43,7 +43,9 @@ import { useIsMobile } from '../../../hooks/use-mobile';
|
|
|
43
43
|
import { LoginButton } from '../../auth/components/LoginButton';
|
|
44
44
|
import { useAuth } from '../../auth/hooks/useAuth';
|
|
45
45
|
import { useSettings } from '../../settings/hooks/useSettings';
|
|
46
|
-
import { NavIcon } from '../sidebar/SidebarIcons';
|
|
46
|
+
import { EllipsisIcon, NavIcon } from '../sidebar/SidebarIcons';
|
|
47
|
+
import { pickVisibleEntries } from './appBarOverflow';
|
|
48
|
+
import { AppBarItemIcon } from './AppBarItemIcon';
|
|
47
49
|
import { getExternalFaviconUrl } from '../sidebar/sidebarUtils';
|
|
48
50
|
import { DesktopHistoryButtons } from '../chrome/DesktopHistoryButtons';
|
|
49
51
|
import {
|
|
@@ -56,8 +58,10 @@ import { InsetMobileRadiusOverlay } from '../chrome/InsetMobileRadiusOverlay';
|
|
|
56
58
|
import {
|
|
57
59
|
DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
58
60
|
DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
MAC_LIGHTS_SAFE_FULLSCREEN_PX,
|
|
62
|
+
MAC_LIGHTS_SAFE_PX,
|
|
63
|
+
SHELL_HEADER_HEIGHT_PX,
|
|
64
|
+
SHELL_HEADER_PAD_TOP_PX,
|
|
61
65
|
} from '../chrome/constants';
|
|
62
66
|
import { useIsTauriRuntime, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
|
|
63
67
|
|
|
@@ -87,7 +91,7 @@ type NavEntry =
|
|
|
87
91
|
|
|
88
92
|
const NAV_GAP_PX = 4;
|
|
89
93
|
/** Reserved width guess before More is measured; kept close to the real control. */
|
|
90
|
-
const MORE_FALLBACK_PX =
|
|
94
|
+
const MORE_FALLBACK_PX = 36;
|
|
91
95
|
|
|
92
96
|
function resolveLocalizedLabel(
|
|
93
97
|
value: string | { en: string; fr: string; [key: string]: string },
|
|
@@ -208,47 +212,13 @@ function CaretDownIcon({ className }: { className?: string }) {
|
|
|
208
212
|
);
|
|
209
213
|
}
|
|
210
214
|
|
|
211
|
-
function itemIconSrc(item: NavigationItem): string | null {
|
|
212
|
-
if (item.icon) return item.icon;
|
|
213
|
-
if (item.openIn === 'external') return getExternalFaviconUrl(item.url);
|
|
214
|
-
return null;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/** Compact icon (or first-letter fallback) for start-nav links. */
|
|
218
|
-
function AppBarItemIcon({ item, label }: { item: NavigationItem; label: string }) {
|
|
219
|
-
const iconSrc = itemIconSrc(item);
|
|
220
|
-
const firstLetter = label ? label.charAt(0).toUpperCase() : '?';
|
|
221
|
-
if (iconSrc) {
|
|
222
|
-
return (
|
|
223
|
-
<span
|
|
224
|
-
className="flex size-5 shrink-0 items-center justify-center rounded-md bg-muted/60 p-0.5"
|
|
225
|
-
aria-hidden
|
|
226
|
-
>
|
|
227
|
-
<NavIcon
|
|
228
|
-
src={iconSrc}
|
|
229
|
-
className="size-3"
|
|
230
|
-
/>
|
|
231
|
-
</span>
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
return (
|
|
235
|
-
<span
|
|
236
|
-
className="flex size-5 shrink-0 items-center justify-center rounded-md bg-muted p-0.5 text-[9px] font-semibold leading-none text-muted-foreground"
|
|
237
|
-
aria-hidden
|
|
238
|
-
>
|
|
239
|
-
{firstLetter}
|
|
240
|
-
</span>
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
215
|
const navTriggerClass = (active: boolean) =>
|
|
245
216
|
cn(
|
|
246
|
-
// h-8 fills the taller app-bar after the top pad.
|
|
247
|
-
|
|
248
|
-
'
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
: 'text-sidebar-foreground/85 hover:bg-sidebar-accent hover:text-sidebar-foreground',
|
|
217
|
+
// h-8 fills the taller app-bar after the top pad. Colours, hover and the
|
|
218
|
+
// active indicator live in index.css (`.shellui-appbar-item`).
|
|
219
|
+
'shellui-appbar-item inline-flex h-8 shrink-0 items-center gap-1.5 px-2.5 text-sm font-medium',
|
|
220
|
+
'focus-visible:outline-none',
|
|
221
|
+
active && 'is-active',
|
|
252
222
|
);
|
|
253
223
|
|
|
254
224
|
/** Text link / action used in the bar (not inside a dropdown). */
|
|
@@ -266,10 +236,7 @@ function AppBarNavLink({
|
|
|
266
236
|
const className = navTriggerClass(isActive);
|
|
267
237
|
const content = (
|
|
268
238
|
<>
|
|
269
|
-
<AppBarItemIcon
|
|
270
|
-
item={item}
|
|
271
|
-
label={label}
|
|
272
|
-
/>
|
|
239
|
+
<AppBarItemIcon item={item} />
|
|
273
240
|
<span className="truncate">{label}</span>
|
|
274
241
|
</>
|
|
275
242
|
);
|
|
@@ -279,6 +246,8 @@ function AppBarNavLink({
|
|
|
279
246
|
<button
|
|
280
247
|
type="button"
|
|
281
248
|
className={className}
|
|
249
|
+
data-shellui-no-drag=""
|
|
250
|
+
data-active={isActive ? 'true' : undefined}
|
|
282
251
|
onClick={() => navigateToItem(item)}
|
|
283
252
|
>
|
|
284
253
|
{content}
|
|
@@ -290,6 +259,9 @@ function AppBarNavLink({
|
|
|
290
259
|
<Link
|
|
291
260
|
to={pathPrefix}
|
|
292
261
|
className={className}
|
|
262
|
+
data-shellui-no-drag=""
|
|
263
|
+
data-active={isActive ? 'true' : undefined}
|
|
264
|
+
aria-current={isActive ? 'page' : undefined}
|
|
293
265
|
>
|
|
294
266
|
{content}
|
|
295
267
|
</Link>
|
|
@@ -309,13 +281,10 @@ function AppBarNavMenuItem({
|
|
|
309
281
|
}) {
|
|
310
282
|
const isActive = navItemIsActive(item, activePathPrefix);
|
|
311
283
|
const pathPrefix = getNavPathPrefix(item);
|
|
312
|
-
const itemClass = cn('gap-2 text-sm', isActive && '
|
|
284
|
+
const itemClass = cn('shellui-appbar-menu-item gap-2 text-sm', isActive && 'is-active');
|
|
313
285
|
const content = (
|
|
314
286
|
<>
|
|
315
|
-
<AppBarItemIcon
|
|
316
|
-
item={item}
|
|
317
|
-
label={label}
|
|
318
|
-
/>
|
|
287
|
+
<AppBarItemIcon item={item} />
|
|
319
288
|
<span className="truncate">{label}</span>
|
|
320
289
|
</>
|
|
321
290
|
);
|
|
@@ -342,6 +311,7 @@ function AppBarNavMenuItem({
|
|
|
342
311
|
<Link
|
|
343
312
|
to={pathPrefix}
|
|
344
313
|
onClick={onNavigate}
|
|
314
|
+
aria-current={isActive ? 'page' : undefined}
|
|
345
315
|
>
|
|
346
316
|
{content}
|
|
347
317
|
</Link>
|
|
@@ -375,14 +345,18 @@ function AppBarNavCategory({
|
|
|
375
345
|
variant="ghost"
|
|
376
346
|
size="sm"
|
|
377
347
|
className={cn(navTriggerClass(active))}
|
|
348
|
+
data-shellui-no-drag=""
|
|
349
|
+
data-active={active ? 'true' : undefined}
|
|
350
|
+
aria-haspopup="menu"
|
|
378
351
|
aria-expanded={open}
|
|
379
352
|
>
|
|
380
353
|
<span className="truncate">{label}</span>
|
|
381
|
-
<CaretDownIcon className="size-3 shrink-0 opacity-70" />
|
|
354
|
+
<CaretDownIcon className="size-3.5 shrink-0 opacity-70" />
|
|
382
355
|
</Button>
|
|
383
356
|
</DropdownMenuTrigger>
|
|
384
357
|
<DropdownMenuContent
|
|
385
358
|
align="start"
|
|
359
|
+
className="shellui-appbar-menu"
|
|
386
360
|
onCloseAutoFocus={(event) => event.preventDefault()}
|
|
387
361
|
>
|
|
388
362
|
{items.map((item, index) => (
|
|
@@ -427,17 +401,20 @@ function AppBarNavMore({
|
|
|
427
401
|
variant="ghost"
|
|
428
402
|
size="sm"
|
|
429
403
|
className={cn(navTriggerClass(moreActive))}
|
|
404
|
+
data-shellui-no-drag=""
|
|
405
|
+
data-active={moreActive ? 'true' : undefined}
|
|
430
406
|
aria-label={t('desktopChrome.more')}
|
|
407
|
+
aria-haspopup="menu"
|
|
431
408
|
aria-expanded={open}
|
|
409
|
+
data-shellui-appbar-more=""
|
|
432
410
|
>
|
|
433
|
-
<
|
|
434
|
-
<CaretDownIcon className="size-3 shrink-0 opacity-70" />
|
|
411
|
+
<EllipsisIcon className="size-4" />
|
|
435
412
|
</Button>
|
|
436
413
|
</DropdownMenuTrigger>
|
|
437
414
|
<DropdownMenuContent
|
|
438
415
|
align="start"
|
|
439
416
|
onCloseAutoFocus={(event) => event.preventDefault()}
|
|
440
|
-
className="min-w-[12rem]"
|
|
417
|
+
className="shellui-appbar-menu min-w-[12rem]"
|
|
441
418
|
>
|
|
442
419
|
{entries.map((entry, entryIndex) => {
|
|
443
420
|
if (entry.type === 'link') {
|
|
@@ -458,7 +435,7 @@ function AppBarNavMore({
|
|
|
458
435
|
return (
|
|
459
436
|
<div key={entry.key}>
|
|
460
437
|
{entryIndex > 0 ? <DropdownMenuSeparator /> : null}
|
|
461
|
-
<DropdownMenuLabel className="text-xs font-
|
|
438
|
+
<DropdownMenuLabel className="shellui-appbar-menu-label text-xs font-semibold text-muted-foreground">
|
|
462
439
|
{categoryLabel}
|
|
463
440
|
</DropdownMenuLabel>
|
|
464
441
|
{entry.items.map((item, index) => (
|
|
@@ -497,12 +474,12 @@ function AppBarNavMeasureChip({
|
|
|
497
474
|
>
|
|
498
475
|
{withIcon ? (
|
|
499
476
|
<span
|
|
500
|
-
className="size-
|
|
477
|
+
className="size-4 shrink-0"
|
|
501
478
|
aria-hidden
|
|
502
479
|
/>
|
|
503
480
|
) : null}
|
|
504
481
|
{label}
|
|
505
|
-
{withCaret ? <CaretDownIcon className="size-3 shrink-0 opacity-70" /> : null}
|
|
482
|
+
{withCaret ? <CaretDownIcon className="size-3.5 shrink-0 opacity-70" /> : null}
|
|
506
483
|
</span>
|
|
507
484
|
);
|
|
508
485
|
}
|
|
@@ -524,10 +501,20 @@ function AppBarNav({
|
|
|
524
501
|
}) {
|
|
525
502
|
const { t } = useTranslation();
|
|
526
503
|
const entries = useMemo(() => sectionsToEntries(sections), [sections]);
|
|
527
|
-
const containerRef = useRef<
|
|
504
|
+
const containerRef = useRef<HTMLElement | null>(null);
|
|
528
505
|
const measureRefs = useRef<(HTMLElement | null)[]>([]);
|
|
529
506
|
const moreMeasureRef = useRef<HTMLElement | null>(null);
|
|
530
|
-
const
|
|
507
|
+
const allIndices = useMemo(() => entries.map((_, i) => i), [entries]);
|
|
508
|
+
const [visibleIndices, setVisibleIndices] = useState<number[]>(allIndices);
|
|
509
|
+
const activeIndex = useMemo(
|
|
510
|
+
() =>
|
|
511
|
+
entries.findIndex((entry) =>
|
|
512
|
+
entry.type === 'link'
|
|
513
|
+
? navItemIsActive(entry.item, activePathPrefix)
|
|
514
|
+
: categoryIsActive(entry.items, activePathPrefix),
|
|
515
|
+
),
|
|
516
|
+
[entries, activePathPrefix],
|
|
517
|
+
);
|
|
531
518
|
|
|
532
519
|
const setMeasureRef = useCallback((index: number, node: HTMLElement | null) => {
|
|
533
520
|
measureRefs.current[index] = node;
|
|
@@ -536,37 +523,25 @@ function AppBarNav({
|
|
|
536
523
|
const recompute = useCallback(() => {
|
|
537
524
|
const container = containerRef.current;
|
|
538
525
|
if (!container || entries.length === 0) {
|
|
539
|
-
|
|
526
|
+
setVisibleIndices(allIndices);
|
|
540
527
|
return;
|
|
541
528
|
}
|
|
542
529
|
|
|
543
|
-
const available = container.clientWidth;
|
|
544
530
|
const widths = entries.map((_, i) => measureRefs.current[i]?.offsetWidth ?? 0);
|
|
545
531
|
if (widths.some((w) => w <= 0)) return;
|
|
546
532
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
let count = 0;
|
|
560
|
-
for (let i = 0; i < widths.length; i++) {
|
|
561
|
-
const gap = count > 0 ? NAV_GAP_PX : 0;
|
|
562
|
-
const nextUsed = used + gap + widths[i];
|
|
563
|
-
const needed = nextUsed + NAV_GAP_PX + moreWidth;
|
|
564
|
-
if (needed > available) break;
|
|
565
|
-
used = nextUsed;
|
|
566
|
-
count += 1;
|
|
567
|
-
}
|
|
568
|
-
setVisibleCount(count);
|
|
569
|
-
}, [entries]);
|
|
533
|
+
// The active entry never hides inside More (phones especially).
|
|
534
|
+
const next = pickVisibleEntries({
|
|
535
|
+
widths,
|
|
536
|
+
available: container.clientWidth,
|
|
537
|
+
moreWidth: moreMeasureRef.current?.offsetWidth || MORE_FALLBACK_PX,
|
|
538
|
+
gap: NAV_GAP_PX,
|
|
539
|
+
activeIndex,
|
|
540
|
+
});
|
|
541
|
+
setVisibleIndices((prev) =>
|
|
542
|
+
prev.length === next.length && prev.every((v, k) => v === next[k]) ? prev : next,
|
|
543
|
+
);
|
|
544
|
+
}, [entries, allIndices, activeIndex]);
|
|
570
545
|
|
|
571
546
|
useLayoutEffect(() => {
|
|
572
547
|
measureRefs.current = measureRefs.current.slice(0, entries.length);
|
|
@@ -581,15 +556,17 @@ function AppBarNav({
|
|
|
581
556
|
return () => observer.disconnect();
|
|
582
557
|
}, [recompute]);
|
|
583
558
|
|
|
584
|
-
const
|
|
585
|
-
const
|
|
559
|
+
const visibleSet = new Set(visibleIndices);
|
|
560
|
+
const visible = entries.filter((_, i) => visibleSet.has(i));
|
|
561
|
+
const overflow = entries.filter((_, i) => !visibleSet.has(i));
|
|
586
562
|
const showMore = overflow.length > 0;
|
|
587
|
-
const moreLabel = t('desktopChrome.more');
|
|
588
563
|
|
|
589
564
|
return (
|
|
590
|
-
<
|
|
565
|
+
<nav
|
|
591
566
|
ref={containerRef}
|
|
592
|
-
|
|
567
|
+
aria-label={t('shellChrome.mainNav')}
|
|
568
|
+
// overflow-x clip only, so the active underline can reach the bar's bottom border.
|
|
569
|
+
className="relative flex min-w-0 flex-1 items-center gap-0.5 overflow-x-clip overflow-y-visible"
|
|
593
570
|
>
|
|
594
571
|
{/* Off-screen width probes (no DropdownMenu — avoids portal noise). */}
|
|
595
572
|
<div
|
|
@@ -618,13 +595,14 @@ function AppBarNav({
|
|
|
618
595
|
/>
|
|
619
596
|
);
|
|
620
597
|
})}
|
|
621
|
-
<
|
|
622
|
-
|
|
623
|
-
withCaret
|
|
624
|
-
measureRef={(node) => {
|
|
598
|
+
<span
|
|
599
|
+
ref={(node) => {
|
|
625
600
|
moreMeasureRef.current = node;
|
|
626
601
|
}}
|
|
627
|
-
|
|
602
|
+
className={cn(navTriggerClass(false), 'whitespace-nowrap')}
|
|
603
|
+
>
|
|
604
|
+
<EllipsisIcon className="size-4" />
|
|
605
|
+
</span>
|
|
628
606
|
</div>
|
|
629
607
|
|
|
630
608
|
{visible.map((entry) => {
|
|
@@ -665,7 +643,7 @@ function AppBarNav({
|
|
|
665
643
|
className="h-full min-h-8 min-w-2 flex-1 self-stretch"
|
|
666
644
|
/>
|
|
667
645
|
) : null}
|
|
668
|
-
</
|
|
646
|
+
</nav>
|
|
669
647
|
);
|
|
670
648
|
}
|
|
671
649
|
|
|
@@ -679,6 +657,7 @@ function TopBarEndItem({
|
|
|
679
657
|
label: string;
|
|
680
658
|
activePathPrefix: string | null;
|
|
681
659
|
}) {
|
|
660
|
+
const { t } = useTranslation();
|
|
682
661
|
const pathPrefix = getNavPathPrefix(item);
|
|
683
662
|
const isOverlay = item.openIn === 'modal' || item.openIn === 'drawer';
|
|
684
663
|
const isExternal = item.openIn === 'external';
|
|
@@ -703,10 +682,8 @@ function TopBarEndItem({
|
|
|
703
682
|
);
|
|
704
683
|
|
|
705
684
|
const buttonClass = cn(
|
|
706
|
-
'flex size-8 items-center justify-center
|
|
707
|
-
isActive
|
|
708
|
-
? 'bg-sidebar-accent text-sidebar-accent-foreground'
|
|
709
|
-
: 'text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-foreground',
|
|
685
|
+
'shellui-appbar-end flex size-8 items-center justify-center cursor-pointer focus-visible:outline-none',
|
|
686
|
+
isActive && 'is-active',
|
|
710
687
|
);
|
|
711
688
|
|
|
712
689
|
const wrap = (node: ReactNode) => <AppBarTooltip label={label}>{node}</AppBarTooltip>;
|
|
@@ -742,7 +719,7 @@ function TopBarEndItem({
|
|
|
742
719
|
target="_blank"
|
|
743
720
|
rel="noopener noreferrer"
|
|
744
721
|
className={buttonClass}
|
|
745
|
-
aria-label={label}
|
|
722
|
+
aria-label={`${label} (${t('shellChrome.externalLink')})`}
|
|
746
723
|
>
|
|
747
724
|
{iconEl}
|
|
748
725
|
</a>,
|
|
@@ -753,6 +730,7 @@ function TopBarEndItem({
|
|
|
753
730
|
to={pathPrefix}
|
|
754
731
|
className={buttonClass}
|
|
755
732
|
aria-label={label}
|
|
733
|
+
aria-current={isActive ? 'page' : undefined}
|
|
756
734
|
>
|
|
757
735
|
{iconEl}
|
|
758
736
|
</Link>,
|
|
@@ -780,8 +758,18 @@ export function AppBarLayout({
|
|
|
780
758
|
const showSafeAreaTopbar = isShellUiRootWindow();
|
|
781
759
|
const scrollHideLayout = isInset ? 'app-bar-inset' : 'app-bar';
|
|
782
760
|
const titlebarAligned = isTauriRuntime && !isMobile;
|
|
783
|
-
|
|
784
|
-
const
|
|
761
|
+
// macOS: the bar is the 32px strip. Windows / Linux (native caption bar above): 42px.
|
|
762
|
+
const macStrip = overlay;
|
|
763
|
+
const barHeightPx = macStrip
|
|
764
|
+
? DESKTOP_TITLEBAR_HEIGHT_PX
|
|
765
|
+
: titlebarAligned
|
|
766
|
+
? SHELL_HEADER_HEIGHT_PX
|
|
767
|
+
: APP_BAR_HEIGHT_PX;
|
|
768
|
+
const barPadTopPx = macStrip
|
|
769
|
+
? DESKTOP_TITLEBAR_PAD_TOP_PX
|
|
770
|
+
: titlebarAligned
|
|
771
|
+
? SHELL_HEADER_PAD_TOP_PX
|
|
772
|
+
: APP_BAR_PAD_TOP_PX;
|
|
785
773
|
const { chromeVisible } = useScrollHideChrome({
|
|
786
774
|
enabled: isMobile,
|
|
787
775
|
layout: scrollHideLayout,
|
|
@@ -834,9 +822,12 @@ export function AppBarLayout({
|
|
|
834
822
|
}
|
|
835
823
|
}, [location.pathname, title, navigationItems, currentLanguage]);
|
|
836
824
|
|
|
825
|
+
// Drag-only safe area next to the lights: 80px, 12px in native fullscreen (lights hidden).
|
|
837
826
|
const chromeInset = trafficLights
|
|
838
|
-
?
|
|
839
|
-
:
|
|
827
|
+
? MAC_LIGHTS_SAFE_PX
|
|
828
|
+
: macStrip
|
|
829
|
+
? MAC_LIGHTS_SAFE_FULLSCREEN_PX
|
|
830
|
+
: undefined;
|
|
840
831
|
|
|
841
832
|
const hasStartNav = startSections.some((s) => s.items.length > 0);
|
|
842
833
|
// Keep in sync with <main> inset frame pad — bar content aligns to the card border.
|
|
@@ -987,8 +978,12 @@ export function AppBarLayout({
|
|
|
987
978
|
)}
|
|
988
979
|
style={headerStyle}
|
|
989
980
|
data-layout={isInset ? 'app-bar-inset' : 'app-bar'}
|
|
990
|
-
{...(
|
|
991
|
-
? {
|
|
981
|
+
{...(macStrip
|
|
982
|
+
? {
|
|
983
|
+
'data-shellui-drag-region': '',
|
|
984
|
+
'data-tauri-drag-region': '',
|
|
985
|
+
'data-shellui-mac-strip': '',
|
|
986
|
+
}
|
|
992
987
|
: {})}
|
|
993
988
|
>
|
|
994
989
|
{appIcon ? (
|
|
@@ -997,9 +992,18 @@ export function AppBarLayout({
|
|
|
997
992
|
title={title}
|
|
998
993
|
data-shellui-no-drag=""
|
|
999
994
|
className="mr-1 shrink-0"
|
|
1000
|
-
imgClassName=
|
|
995
|
+
imgClassName={cn('app-bar-app-icon', macStrip ? 'size-5' : 'size-6')}
|
|
1001
996
|
/>
|
|
1002
997
|
) : null}
|
|
998
|
+
{appIcon && title && !isTauriRuntime ? (
|
|
999
|
+
<span
|
|
1000
|
+
aria-hidden
|
|
1001
|
+
data-shellui-appbar-brand-name=""
|
|
1002
|
+
className="mr-2 max-w-48 shrink-0 truncate text-sm font-semibold"
|
|
1003
|
+
>
|
|
1004
|
+
{title}
|
|
1005
|
+
</span>
|
|
1006
|
+
) : null}
|
|
1003
1007
|
|
|
1004
1008
|
{hasStartNav ? (
|
|
1005
1009
|
<AppBarNav
|
|
@@ -1022,7 +1026,7 @@ export function AppBarLayout({
|
|
|
1022
1026
|
data-shellui-no-drag=""
|
|
1023
1027
|
className="shrink-0"
|
|
1024
1028
|
>
|
|
1025
|
-
<DesktopHistoryButtons />
|
|
1029
|
+
<DesktopHistoryButtons strip={macStrip} />
|
|
1026
1030
|
</div>
|
|
1027
1031
|
) : null}
|
|
1028
1032
|
|
|
@@ -1036,6 +1040,7 @@ export function AppBarLayout({
|
|
|
1036
1040
|
|
|
1037
1041
|
<div
|
|
1038
1042
|
data-shellui-no-drag=""
|
|
1043
|
+
data-shellui-strip-end=""
|
|
1039
1044
|
className="flex shrink-0 items-center gap-0.5"
|
|
1040
1045
|
>
|
|
1041
1046
|
{endNavItems.length > 0 ? (
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { pickVisibleEntries } from './appBarOverflow';
|
|
3
|
+
|
|
4
|
+
const base = { widths: [60, 60, 60, 60, 60], moreWidth: 32, gap: 4 };
|
|
5
|
+
|
|
6
|
+
describe('pickVisibleEntries', () => {
|
|
7
|
+
it('shows everything when it fits', () => {
|
|
8
|
+
expect(pickVisibleEntries({ ...base, available: 400 })).toEqual([0, 1, 2, 3, 4]);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('fills in order and leaves room for More', () => {
|
|
12
|
+
// budget 200 - 4 - 32 = 164: two 60px items plus a gap.
|
|
13
|
+
expect(pickVisibleEntries({ ...base, available: 200 })).toEqual([0, 1]);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('keeps the active entry visible when it would overflow', () => {
|
|
17
|
+
expect(pickVisibleEntries({ ...base, available: 200, activeIndex: 4 })).toEqual([0, 4]);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('keeps order when the active entry already fits', () => {
|
|
21
|
+
expect(pickVisibleEntries({ ...base, available: 200, activeIndex: 1 })).toEqual([0, 1]);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('returns nothing when even the active entry does not fit', () => {
|
|
25
|
+
expect(pickVisibleEntries({ ...base, available: 60, activeIndex: 2 })).toEqual([]);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pick which app-bar entries stay in the bar; the rest go into More.
|
|
3
|
+
* The active entry always stays visible (it is placed first in the budget),
|
|
4
|
+
* then the others fill the remaining width in their configured order.
|
|
5
|
+
*
|
|
6
|
+
* @returns sorted indices of the visible entries.
|
|
7
|
+
*/
|
|
8
|
+
export function pickVisibleEntries({
|
|
9
|
+
widths,
|
|
10
|
+
available,
|
|
11
|
+
moreWidth,
|
|
12
|
+
gap,
|
|
13
|
+
activeIndex = -1,
|
|
14
|
+
}: {
|
|
15
|
+
widths: number[];
|
|
16
|
+
available: number;
|
|
17
|
+
moreWidth: number;
|
|
18
|
+
gap: number;
|
|
19
|
+
activeIndex?: number;
|
|
20
|
+
}): number[] {
|
|
21
|
+
const all = widths.map((_, i) => i);
|
|
22
|
+
const total = widths.reduce((sum, w, i) => sum + w + (i > 0 ? gap : 0), 0);
|
|
23
|
+
if (total <= available) return all;
|
|
24
|
+
|
|
25
|
+
const budget = available - gap - moreWidth;
|
|
26
|
+
const picked: number[] = [];
|
|
27
|
+
let used = 0;
|
|
28
|
+
const tryAdd = (i: number): boolean => {
|
|
29
|
+
const next = used + (picked.length > 0 ? gap : 0) + widths[i];
|
|
30
|
+
if (next > budget) return false;
|
|
31
|
+
used = next;
|
|
32
|
+
picked.push(i);
|
|
33
|
+
return true;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
if (activeIndex >= 0 && activeIndex < widths.length) tryAdd(activeIndex);
|
|
37
|
+
for (const i of all) {
|
|
38
|
+
if (i === activeIndex) continue;
|
|
39
|
+
if (!tryAdd(i)) break;
|
|
40
|
+
}
|
|
41
|
+
return picked.sort((a, b) => a - b);
|
|
42
|
+
}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import { SidebarTrigger, useSidebar } from '../../../components/ui/sidebar';
|
|
2
2
|
import { cn } from '../../../lib/utils';
|
|
3
3
|
import { DesktopHistoryButtons } from './DesktopHistoryButtons';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
MAC_TRAFFIC_LIGHTS_GAP_PX,
|
|
8
|
-
MAC_TRAFFIC_LIGHTS_WIDTH_PX,
|
|
9
|
-
} from './constants';
|
|
10
|
-
import { useIsTauriClient, useMacOverlayChrome, useMacTrafficLights } from './runtime';
|
|
4
|
+
import { DESKTOP_TITLEBAR_HEIGHT_PX, DESKTOP_TITLEBAR_PAD_TOP_PX } from './constants';
|
|
5
|
+
import { MAC_DRAG_REGION_PROPS, MacLightsSafeArea, MacStripSpacer } from './MacStrip';
|
|
6
|
+
import { useIsTauriClient, useMacOverlayChrome } from './runtime';
|
|
11
7
|
|
|
12
8
|
/**
|
|
13
|
-
* Full-width
|
|
14
|
-
*
|
|
15
|
-
* Stays visible in native fullscreen
|
|
9
|
+
* Full-width 32px macOS strip when the sidebar is collapsed in a Tauri overlay window:
|
|
10
|
+
* lights safe area (80px, 12px in native fullscreen), expand trigger, Back, Forward,
|
|
11
|
+
* then a drag spacer. Stays visible in native fullscreen.
|
|
16
12
|
*/
|
|
17
13
|
export function CollapsedDesktopTitlebar({ className }: { className?: string }) {
|
|
18
14
|
const overlay = useMacOverlayChrome();
|
|
19
|
-
const trafficLights = useMacTrafficLights();
|
|
20
15
|
const isTauriEnv = useIsTauriClient();
|
|
21
16
|
const { state, isMobile } = useSidebar();
|
|
22
17
|
const collapsed = state === 'collapsed' && !isMobile;
|
|
@@ -26,10 +21,10 @@ export function CollapsedDesktopTitlebar({ className }: { className?: string })
|
|
|
26
21
|
return (
|
|
27
22
|
<div
|
|
28
23
|
data-shellui-collapsed-titlebar=""
|
|
29
|
-
data-shellui-
|
|
30
|
-
|
|
24
|
+
data-shellui-mac-strip=""
|
|
25
|
+
{...MAC_DRAG_REGION_PROPS}
|
|
31
26
|
className={cn(
|
|
32
|
-
'fixed inset-x-0 top-0 z-[47] flex w-full items-center
|
|
27
|
+
'fixed inset-x-0 top-0 z-[47] flex w-full items-center bg-sidebar text-sidebar-foreground select-none',
|
|
33
28
|
className,
|
|
34
29
|
)}
|
|
35
30
|
style={{
|
|
@@ -37,21 +32,15 @@ export function CollapsedDesktopTitlebar({ className }: { className?: string })
|
|
|
37
32
|
paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
38
33
|
}}
|
|
39
34
|
>
|
|
40
|
-
|
|
41
|
-
<div
|
|
42
|
-
className="h-full shrink-0"
|
|
43
|
-
style={{ width: MAC_TRAFFIC_LIGHTS_WIDTH_PX }}
|
|
44
|
-
aria-hidden
|
|
45
|
-
/>
|
|
46
|
-
) : null}
|
|
35
|
+
<MacLightsSafeArea />
|
|
47
36
|
<div
|
|
48
37
|
data-shellui-no-drag=""
|
|
49
38
|
className="flex h-full items-center gap-0.5"
|
|
50
|
-
style={{ paddingLeft: trafficLights ? MAC_TRAFFIC_LIGHTS_GAP_PX : 8 }}
|
|
51
39
|
>
|
|
52
|
-
<SidebarTrigger className="size-
|
|
53
|
-
{isTauriEnv ? <DesktopHistoryButtons /> : null}
|
|
40
|
+
<SidebarTrigger className="size-6 touch-manipulation" />
|
|
41
|
+
{isTauriEnv ? <DesktopHistoryButtons strip /> : null}
|
|
54
42
|
</div>
|
|
43
|
+
<MacStripSpacer />
|
|
55
44
|
</div>
|
|
56
45
|
);
|
|
57
46
|
}
|