@shellui/core 0.7.0-alpha.10 → 0.7.0-alpha.12
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/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 +15 -7
- package/src/components/ui/tooltip.tsx +4 -2
- 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/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 +53 -81
- 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 +1 -1
- package/src/features/layouts/chrome/constants.ts +3 -0
- package/src/features/layouts/chrome/viewport.ts +11 -4
- package/src/features/layouts/floating/FloatingBottomDock.tsx +67 -26
- package/src/features/layouts/floating/FloatingLayout.tsx +1 -0
- package/src/features/layouts/floating/FloatingSidebar.tsx +43 -20
- package/src/features/layouts/floating/moreSections.spec.ts +28 -0
- package/src/features/layouts/floating/moreSections.ts +31 -0
- package/src/features/layouts/fullscreen/FullscreenLayout.spec.tsx +68 -0
- package/src/features/layouts/fullscreen/FullscreenLayout.tsx +10 -1
- package/src/features/layouts/sidebar/NavigationContent.tsx +4 -4
- package/src/features/layouts/sidebar/SidebarIcons.tsx +67 -0
- package/src/features/layouts/sidebar/SidebarInner.spec.tsx +149 -0
- package/src/features/layouts/sidebar/SidebarInner.tsx +60 -11
- package/src/features/layouts/sidebar/SidebarLayout.tsx +23 -13
- package/src/features/layouts/windows/WindowsLayout.tsx +93 -47
- package/src/features/layouts/windows/deskDots.spec.ts +6 -4
- package/src/features/layouts/windows/deskDots.ts +8 -8
- 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/i18n/translations/en/common.json +1 -0
- package/src/i18n/translations/fr/common.json +1 -0
- package/src/index.css +232 -42
- 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
|
@@ -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 {
|
|
@@ -89,7 +91,7 @@ type NavEntry =
|
|
|
89
91
|
|
|
90
92
|
const NAV_GAP_PX = 4;
|
|
91
93
|
/** Reserved width guess before More is measured; kept close to the real control. */
|
|
92
|
-
const MORE_FALLBACK_PX =
|
|
94
|
+
const MORE_FALLBACK_PX = 36;
|
|
93
95
|
|
|
94
96
|
function resolveLocalizedLabel(
|
|
95
97
|
value: string | { en: string; fr: string; [key: string]: string },
|
|
@@ -210,39 +212,6 @@ function CaretDownIcon({ className }: { className?: string }) {
|
|
|
210
212
|
);
|
|
211
213
|
}
|
|
212
214
|
|
|
213
|
-
function itemIconSrc(item: NavigationItem): string | null {
|
|
214
|
-
if (item.icon) return item.icon;
|
|
215
|
-
if (item.openIn === 'external') return getExternalFaviconUrl(item.url);
|
|
216
|
-
return null;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/** Compact icon (or first-letter fallback) for start-nav links. */
|
|
220
|
-
function AppBarItemIcon({ item, label }: { item: NavigationItem; label: string }) {
|
|
221
|
-
const iconSrc = itemIconSrc(item);
|
|
222
|
-
const firstLetter = label ? label.charAt(0).toUpperCase() : '?';
|
|
223
|
-
if (iconSrc) {
|
|
224
|
-
return (
|
|
225
|
-
<span
|
|
226
|
-
className="flex size-5 shrink-0 items-center justify-center rounded-md bg-muted/60 p-0.5"
|
|
227
|
-
aria-hidden
|
|
228
|
-
>
|
|
229
|
-
<NavIcon
|
|
230
|
-
src={iconSrc}
|
|
231
|
-
className="size-3"
|
|
232
|
-
/>
|
|
233
|
-
</span>
|
|
234
|
-
);
|
|
235
|
-
}
|
|
236
|
-
return (
|
|
237
|
-
<span
|
|
238
|
-
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"
|
|
239
|
-
aria-hidden
|
|
240
|
-
>
|
|
241
|
-
{firstLetter}
|
|
242
|
-
</span>
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
215
|
const navTriggerClass = (active: boolean) =>
|
|
247
216
|
cn(
|
|
248
217
|
// h-8 fills the taller app-bar after the top pad. Colours, hover and the
|
|
@@ -267,10 +236,7 @@ function AppBarNavLink({
|
|
|
267
236
|
const className = navTriggerClass(isActive);
|
|
268
237
|
const content = (
|
|
269
238
|
<>
|
|
270
|
-
<AppBarItemIcon
|
|
271
|
-
item={item}
|
|
272
|
-
label={label}
|
|
273
|
-
/>
|
|
239
|
+
<AppBarItemIcon item={item} />
|
|
274
240
|
<span className="truncate">{label}</span>
|
|
275
241
|
</>
|
|
276
242
|
);
|
|
@@ -318,10 +284,7 @@ function AppBarNavMenuItem({
|
|
|
318
284
|
const itemClass = cn('shellui-appbar-menu-item gap-2 text-sm', isActive && 'is-active');
|
|
319
285
|
const content = (
|
|
320
286
|
<>
|
|
321
|
-
<AppBarItemIcon
|
|
322
|
-
item={item}
|
|
323
|
-
label={label}
|
|
324
|
-
/>
|
|
287
|
+
<AppBarItemIcon item={item} />
|
|
325
288
|
<span className="truncate">{label}</span>
|
|
326
289
|
</>
|
|
327
290
|
);
|
|
@@ -443,9 +406,9 @@ function AppBarNavMore({
|
|
|
443
406
|
aria-label={t('desktopChrome.more')}
|
|
444
407
|
aria-haspopup="menu"
|
|
445
408
|
aria-expanded={open}
|
|
409
|
+
data-shellui-appbar-more=""
|
|
446
410
|
>
|
|
447
|
-
<
|
|
448
|
-
<CaretDownIcon className="size-3.5 shrink-0 opacity-70" />
|
|
411
|
+
<EllipsisIcon className="size-4" />
|
|
449
412
|
</Button>
|
|
450
413
|
</DropdownMenuTrigger>
|
|
451
414
|
<DropdownMenuContent
|
|
@@ -511,7 +474,7 @@ function AppBarNavMeasureChip({
|
|
|
511
474
|
>
|
|
512
475
|
{withIcon ? (
|
|
513
476
|
<span
|
|
514
|
-
className="size-
|
|
477
|
+
className="size-4 shrink-0"
|
|
515
478
|
aria-hidden
|
|
516
479
|
/>
|
|
517
480
|
) : null}
|
|
@@ -541,7 +504,17 @@ function AppBarNav({
|
|
|
541
504
|
const containerRef = useRef<HTMLElement | null>(null);
|
|
542
505
|
const measureRefs = useRef<(HTMLElement | null)[]>([]);
|
|
543
506
|
const moreMeasureRef = useRef<HTMLElement | null>(null);
|
|
544
|
-
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
|
+
);
|
|
545
518
|
|
|
546
519
|
const setMeasureRef = useCallback((index: number, node: HTMLElement | null) => {
|
|
547
520
|
measureRefs.current[index] = node;
|
|
@@ -550,37 +523,25 @@ function AppBarNav({
|
|
|
550
523
|
const recompute = useCallback(() => {
|
|
551
524
|
const container = containerRef.current;
|
|
552
525
|
if (!container || entries.length === 0) {
|
|
553
|
-
|
|
526
|
+
setVisibleIndices(allIndices);
|
|
554
527
|
return;
|
|
555
528
|
}
|
|
556
529
|
|
|
557
|
-
const available = container.clientWidth;
|
|
558
530
|
const widths = entries.map((_, i) => measureRefs.current[i]?.offsetWidth ?? 0);
|
|
559
531
|
if (widths.some((w) => w <= 0)) return;
|
|
560
532
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
let count = 0;
|
|
574
|
-
for (let i = 0; i < widths.length; i++) {
|
|
575
|
-
const gap = count > 0 ? NAV_GAP_PX : 0;
|
|
576
|
-
const nextUsed = used + gap + widths[i];
|
|
577
|
-
const needed = nextUsed + NAV_GAP_PX + moreWidth;
|
|
578
|
-
if (needed > available) break;
|
|
579
|
-
used = nextUsed;
|
|
580
|
-
count += 1;
|
|
581
|
-
}
|
|
582
|
-
setVisibleCount(count);
|
|
583
|
-
}, [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]);
|
|
584
545
|
|
|
585
546
|
useLayoutEffect(() => {
|
|
586
547
|
measureRefs.current = measureRefs.current.slice(0, entries.length);
|
|
@@ -595,16 +556,17 @@ function AppBarNav({
|
|
|
595
556
|
return () => observer.disconnect();
|
|
596
557
|
}, [recompute]);
|
|
597
558
|
|
|
598
|
-
const
|
|
599
|
-
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));
|
|
600
562
|
const showMore = overflow.length > 0;
|
|
601
|
-
const moreLabel = t('desktopChrome.more');
|
|
602
563
|
|
|
603
564
|
return (
|
|
604
565
|
<nav
|
|
605
566
|
ref={containerRef}
|
|
606
567
|
aria-label={t('shellChrome.mainNav')}
|
|
607
|
-
|
|
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"
|
|
608
570
|
>
|
|
609
571
|
{/* Off-screen width probes (no DropdownMenu — avoids portal noise). */}
|
|
610
572
|
<div
|
|
@@ -633,13 +595,14 @@ function AppBarNav({
|
|
|
633
595
|
/>
|
|
634
596
|
);
|
|
635
597
|
})}
|
|
636
|
-
<
|
|
637
|
-
|
|
638
|
-
withCaret
|
|
639
|
-
measureRef={(node) => {
|
|
598
|
+
<span
|
|
599
|
+
ref={(node) => {
|
|
640
600
|
moreMeasureRef.current = node;
|
|
641
601
|
}}
|
|
642
|
-
|
|
602
|
+
className={cn(navTriggerClass(false), 'whitespace-nowrap')}
|
|
603
|
+
>
|
|
604
|
+
<EllipsisIcon className="size-4" />
|
|
605
|
+
</span>
|
|
643
606
|
</div>
|
|
644
607
|
|
|
645
608
|
{visible.map((entry) => {
|
|
@@ -1032,6 +995,15 @@ export function AppBarLayout({
|
|
|
1032
995
|
imgClassName={cn('app-bar-app-icon', macStrip ? 'size-5' : 'size-6')}
|
|
1033
996
|
/>
|
|
1034
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}
|
|
1035
1007
|
|
|
1036
1008
|
{hasStartNav ? (
|
|
1037
1009
|
<AppBarNav
|
|
@@ -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
|
+
}
|
|
@@ -24,7 +24,7 @@ export function CollapsedDesktopTitlebar({ className }: { className?: string })
|
|
|
24
24
|
data-shellui-mac-strip=""
|
|
25
25
|
{...MAC_DRAG_REGION_PROPS}
|
|
26
26
|
className={cn(
|
|
27
|
-
'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',
|
|
28
28
|
className,
|
|
29
29
|
)}
|
|
30
30
|
style={{
|
|
@@ -35,6 +35,9 @@ export const MAC_STRIP_CONTROL_PX = 24;
|
|
|
35
35
|
*/
|
|
36
36
|
export const SHELL_HEADER_HEIGHT_PX = 42;
|
|
37
37
|
|
|
38
|
+
/** Sidebar layout phone header height (spec: 48px, 40px trigger). */
|
|
39
|
+
export const MOBILE_SIDEBAR_HEADER_HEIGHT_PX = 48;
|
|
40
|
+
|
|
38
41
|
/** Top inset inside the shell header (web, phones, native caption bar hosts). */
|
|
39
42
|
export const SHELL_HEADER_PAD_TOP_PX = 2;
|
|
40
43
|
|
|
@@ -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
|
}
|
|
@@ -3,7 +3,8 @@ import { Drawer as VaulDrawer } from 'vaul';
|
|
|
3
3
|
import { useLocation, useNavigate } from 'react-router';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { shellui } from '@shellui/sdk';
|
|
6
|
-
import type { NavigationItem } from '../../config/types';
|
|
6
|
+
import type { NavigationGroup, NavigationItem } from '../../config/types';
|
|
7
|
+
import { groupMoreItems, type MoreSection } from './moreSections';
|
|
7
8
|
import {
|
|
8
9
|
flattenNavigationItems,
|
|
9
10
|
getActivePathPrefix,
|
|
@@ -19,6 +20,7 @@ import {
|
|
|
19
20
|
DropdownMenu,
|
|
20
21
|
DropdownMenuContent,
|
|
21
22
|
DropdownMenuItem,
|
|
23
|
+
DropdownMenuLabel,
|
|
22
24
|
DropdownMenuSeparator,
|
|
23
25
|
DropdownMenuTrigger,
|
|
24
26
|
} from '../../../components/ui/dropdown-menu';
|
|
@@ -125,12 +127,15 @@ function tabChangeHaptic() {
|
|
|
125
127
|
*/
|
|
126
128
|
export function FloatingBottomDock({
|
|
127
129
|
items,
|
|
130
|
+
navigation = [],
|
|
128
131
|
endItems = [],
|
|
129
132
|
showAuthButton = false,
|
|
130
133
|
chromeVisible,
|
|
131
134
|
viewport,
|
|
132
135
|
}: {
|
|
133
136
|
items: NavigationItem[];
|
|
137
|
+
/** Start navigation tree, so More can label items by their group. */
|
|
138
|
+
navigation?: (NavigationItem | NavigationGroup)[];
|
|
134
139
|
endItems?: NavigationItem[];
|
|
135
140
|
showAuthButton?: boolean;
|
|
136
141
|
chromeVisible: boolean;
|
|
@@ -188,6 +193,10 @@ export function FloatingBottomDock({
|
|
|
188
193
|
const primaryCap = showMoreFinal ? Math.max(1, maxSlots - 1) : maxSlots;
|
|
189
194
|
const primary = useMemo(() => flat.slice(0, primaryCap), [flat, primaryCap]);
|
|
190
195
|
const moreOverflowItems = useMemo(() => flat.slice(primaryCap), [flat, primaryCap]);
|
|
196
|
+
const moreSections = useMemo(
|
|
197
|
+
() => groupMoreItems(moreOverflowItems, navigation),
|
|
198
|
+
[moreOverflowItems, navigation],
|
|
199
|
+
);
|
|
191
200
|
const moreEndItems = endItems;
|
|
192
201
|
const moreItems = useMemo(
|
|
193
202
|
() => [...moreOverflowItems, ...moreEndItems],
|
|
@@ -387,29 +396,39 @@ export function FloatingBottomDock({
|
|
|
387
396
|
sideOffset={10}
|
|
388
397
|
className="min-w-[12rem]"
|
|
389
398
|
>
|
|
390
|
-
{
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
399
|
+
{moreSections.map((section, sectionIndex) => (
|
|
400
|
+
<div key={`more-section-${sectionIndex}`}>
|
|
401
|
+
{sectionIndex > 0 ? <DropdownMenuSeparator /> : null}
|
|
402
|
+
{section.group ? (
|
|
403
|
+
<DropdownMenuLabel className="text-xs font-semibold text-muted-foreground">
|
|
404
|
+
{resolveLocalizedString(section.group.title, lang)}
|
|
405
|
+
</DropdownMenuLabel>
|
|
406
|
+
) : null}
|
|
407
|
+
{section.items.map((item) => {
|
|
408
|
+
const label = resolveLocalizedString(item.label, lang);
|
|
409
|
+
const pathPrefix = getNavPathPrefix(item);
|
|
410
|
+
const isActive =
|
|
411
|
+
item.openIn !== 'modal' &&
|
|
412
|
+
item.openIn !== 'drawer' &&
|
|
413
|
+
item.openIn !== 'external' &&
|
|
414
|
+
pathPrefix === activePathPrefix;
|
|
415
|
+
return (
|
|
416
|
+
<DropdownMenuItem
|
|
417
|
+
key={itemKey(item)}
|
|
418
|
+
className={cn(isActive && 'bg-accent font-medium')}
|
|
419
|
+
aria-current={isActive ? 'page' : undefined}
|
|
420
|
+
onSelect={() => activateItem(item)}
|
|
421
|
+
>
|
|
422
|
+
<TabGlyph
|
|
423
|
+
item={item}
|
|
424
|
+
label={label}
|
|
425
|
+
/>
|
|
426
|
+
<span className="min-w-0 flex-1 truncate">{label}</span>
|
|
427
|
+
</DropdownMenuItem>
|
|
428
|
+
);
|
|
429
|
+
})}
|
|
430
|
+
</div>
|
|
431
|
+
))}
|
|
413
432
|
{moreOverflowItems.length > 0 && (moreEndItems.length > 0 || showAuthButton) ? (
|
|
414
433
|
<DropdownMenuSeparator />
|
|
415
434
|
) : null}
|
|
@@ -473,6 +492,7 @@ export function FloatingBottomDock({
|
|
|
473
492
|
externalLabel={tc('shellChrome.externalLink')}
|
|
474
493
|
lang={lang}
|
|
475
494
|
overflowItems={moreOverflowItems}
|
|
495
|
+
sections={moreSections}
|
|
476
496
|
endItems={moreEndItems}
|
|
477
497
|
showAuthButton={showAuthButton}
|
|
478
498
|
activePathPrefix={activePathPrefix}
|
|
@@ -496,6 +516,7 @@ function FloatingMoreSheet({
|
|
|
496
516
|
externalLabel,
|
|
497
517
|
lang,
|
|
498
518
|
overflowItems,
|
|
519
|
+
sections,
|
|
499
520
|
endItems,
|
|
500
521
|
showAuthButton,
|
|
501
522
|
activePathPrefix,
|
|
@@ -508,6 +529,7 @@ function FloatingMoreSheet({
|
|
|
508
529
|
externalLabel: string;
|
|
509
530
|
lang: string;
|
|
510
531
|
overflowItems: NavigationItem[];
|
|
532
|
+
sections: MoreSection[];
|
|
511
533
|
endItems: NavigationItem[];
|
|
512
534
|
showAuthButton: boolean;
|
|
513
535
|
activePathPrefix: string | null;
|
|
@@ -567,11 +589,30 @@ function FloatingMoreSheet({
|
|
|
567
589
|
aria-label={title}
|
|
568
590
|
className="min-h-0 flex-1 overflow-y-auto px-2 pb-2"
|
|
569
591
|
>
|
|
570
|
-
{
|
|
592
|
+
{sections.map((section, sectionIndex) => (
|
|
593
|
+
<div
|
|
594
|
+
key={`more-sheet-section-${sectionIndex}`}
|
|
595
|
+
role={section.group ? 'group' : undefined}
|
|
596
|
+
aria-label={
|
|
597
|
+
section.group ? resolveLocalizedString(section.group.title, lang) : undefined
|
|
598
|
+
}
|
|
599
|
+
>
|
|
600
|
+
{section.group ? (
|
|
601
|
+
<div
|
|
602
|
+
aria-hidden
|
|
603
|
+
data-shellui-more-sheet-label=""
|
|
604
|
+
className="shellui-more-sheet-label"
|
|
605
|
+
>
|
|
606
|
+
{resolveLocalizedString(section.group.title, lang)}
|
|
607
|
+
</div>
|
|
608
|
+
) : null}
|
|
609
|
+
{section.items.map(renderRow)}
|
|
610
|
+
</div>
|
|
611
|
+
))}
|
|
571
612
|
{overflowItems.length > 0 && (endItems.length > 0 || showAuthButton) ? (
|
|
572
613
|
<div
|
|
573
614
|
aria-hidden
|
|
574
|
-
className="
|
|
615
|
+
className="h-2"
|
|
575
616
|
/>
|
|
576
617
|
) : null}
|
|
577
618
|
{endItems.map(renderRow)}
|
|
@@ -142,6 +142,7 @@ export function FloatingLayout({ title, appIcon, navigation = [] }: FloatingLayo
|
|
|
142
142
|
{showTabBar ? (
|
|
143
143
|
<FloatingBottomDock
|
|
144
144
|
items={tabItems}
|
|
145
|
+
navigation={startNav}
|
|
145
146
|
endItems={endItems}
|
|
146
147
|
showAuthButton={showAuthButton}
|
|
147
148
|
chromeVisible={chromeVisible}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import { getExternalFaviconUrl } from '../sidebar/sidebarUtils';
|
|
14
14
|
import { NavIcon, ExternalLinkIcon } from '../sidebar/SidebarIcons';
|
|
15
15
|
import { AppBrandIcon } from '../branding/AppBrandIcon';
|
|
16
|
+
import { ShellDivider } from '../../../components/ui/shell-divider';
|
|
16
17
|
import { LoginButton } from '../../auth/components/LoginButton';
|
|
17
18
|
import { cn } from '../../../lib/utils';
|
|
18
19
|
import { DesktopHistoryButtons } from '../chrome/DesktopHistoryButtons';
|
|
@@ -83,6 +84,9 @@ function SidebarPanelIcon({ className }: { className?: string }) {
|
|
|
83
84
|
);
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
/** Web brand row height (spec: 52px). */
|
|
88
|
+
const FLOATING_BRAND_ROW_PX = 52;
|
|
89
|
+
|
|
86
90
|
/** Floating glass sidebar for desktop floating layout (collapsible). */
|
|
87
91
|
export function FloatingSidebar({
|
|
88
92
|
title,
|
|
@@ -104,7 +108,7 @@ export function FloatingSidebar({
|
|
|
104
108
|
onToggleCollapsed: () => void;
|
|
105
109
|
}) {
|
|
106
110
|
const location = useLocation();
|
|
107
|
-
const { i18n
|
|
111
|
+
const { i18n } = useTranslation('settings');
|
|
108
112
|
const { t: tc } = useTranslation('common');
|
|
109
113
|
const lang = i18n.language || 'en';
|
|
110
114
|
const isTauriEnv = useIsTauriClient();
|
|
@@ -144,8 +148,8 @@ export function FloatingSidebar({
|
|
|
144
148
|
};
|
|
145
149
|
|
|
146
150
|
const toggleLabel = collapsed
|
|
147
|
-
?
|
|
148
|
-
:
|
|
151
|
+
? tc('shellChrome.expandSidebar')
|
|
152
|
+
: tc('shellChrome.collapseSidebar');
|
|
149
153
|
|
|
150
154
|
const renderItem = (navItem: NavigationItem) => {
|
|
151
155
|
const pathPrefix = getNavPathPrefix(navItem);
|
|
@@ -350,7 +354,7 @@ export function FloatingSidebar({
|
|
|
350
354
|
</button>
|
|
351
355
|
</div>
|
|
352
356
|
{/* Brand row under the strip: not a drag region. */}
|
|
353
|
-
<div className="flex h-10 shrink-0 items-center gap-2
|
|
357
|
+
<div className="flex h-10 shrink-0 items-center gap-2 px-3 text-sidebar-foreground">
|
|
354
358
|
{appIcon ? (
|
|
355
359
|
<AppBrandIcon
|
|
356
360
|
appIcon={appIcon}
|
|
@@ -365,21 +369,23 @@ export function FloatingSidebar({
|
|
|
365
369
|
</>
|
|
366
370
|
) : (
|
|
367
371
|
<div
|
|
368
|
-
className={cn(
|
|
369
|
-
'flex shrink-0 items-center border-b border-sidebar-border/80',
|
|
370
|
-
tauriRuntime ? 'pr-2.5' : 'gap-2 px-2.5 py-2.5',
|
|
371
|
-
)}
|
|
372
|
+
className={cn('flex shrink-0 items-center', tauriRuntime ? 'pr-2.5' : 'pr-2 pl-3.5')}
|
|
372
373
|
style={
|
|
373
374
|
tauriRuntime
|
|
374
375
|
? {
|
|
375
376
|
height: SHELL_HEADER_HEIGHT_PX,
|
|
376
377
|
paddingTop: SHELL_HEADER_PAD_TOP_PX,
|
|
377
378
|
}
|
|
378
|
-
:
|
|
379
|
+
: { height: FLOATING_BRAND_ROW_PX }
|
|
379
380
|
}
|
|
380
381
|
{...(tauriRuntime ? MAC_DRAG_REGION_PROPS : {})}
|
|
381
382
|
>
|
|
382
|
-
<div
|
|
383
|
+
<div
|
|
384
|
+
className={cn(
|
|
385
|
+
'flex h-full min-w-0 flex-1 items-center',
|
|
386
|
+
tauriRuntime ? 'gap-1' : 'gap-1.5',
|
|
387
|
+
)}
|
|
388
|
+
>
|
|
383
389
|
{isTauriEnv && !collapsed ? (
|
|
384
390
|
<DesktopHistoryButtons className="self-center" />
|
|
385
391
|
) : null}
|
|
@@ -387,9 +393,19 @@ export function FloatingSidebar({
|
|
|
387
393
|
<AppBrandIcon
|
|
388
394
|
appIcon={appIcon}
|
|
389
395
|
title={title}
|
|
390
|
-
className=
|
|
396
|
+
className={cn('shrink-0', tauriRuntime ? 'size-7' : 'size-5')}
|
|
391
397
|
/>
|
|
392
398
|
) : null}
|
|
399
|
+
{/* Web brand row: logo + name (the Tauri bar hides the name, like the mock). */}
|
|
400
|
+
{!tauriRuntime && title ? (
|
|
401
|
+
<span
|
|
402
|
+
aria-hidden={appIcon ? true : undefined}
|
|
403
|
+
data-shellui-floating-brand-name=""
|
|
404
|
+
className="ml-0.5 min-w-0 truncate text-sm font-semibold text-sidebar-foreground"
|
|
405
|
+
>
|
|
406
|
+
{title}
|
|
407
|
+
</span>
|
|
408
|
+
) : null}
|
|
393
409
|
<span
|
|
394
410
|
className="min-h-full min-w-0 flex-1 self-stretch"
|
|
395
411
|
{...(tauriRuntime ? MAC_DRAG_REGION_PROPS : {})}
|
|
@@ -398,7 +414,7 @@ export function FloatingSidebar({
|
|
|
398
414
|
type="button"
|
|
399
415
|
tabIndex={collapsed ? -1 : 0}
|
|
400
416
|
data-shellui-no-drag=""
|
|
401
|
-
className="shellui-floating-nav-control flex size-
|
|
417
|
+
className="shellui-floating-nav-control flex size-9 shrink-0 items-center justify-center text-sidebar-foreground transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"
|
|
402
418
|
aria-label={toggleLabel}
|
|
403
419
|
aria-expanded={!collapsed}
|
|
404
420
|
onClick={onToggleCollapsed}
|
|
@@ -408,6 +424,7 @@ export function FloatingSidebar({
|
|
|
408
424
|
</div>
|
|
409
425
|
</div>
|
|
410
426
|
)}
|
|
427
|
+
<ShellDivider />
|
|
411
428
|
|
|
412
429
|
<div className="flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto p-2">
|
|
413
430
|
{sections.map((section, sectionIndex) => {
|
|
@@ -441,14 +458,20 @@ export function FloatingSidebar({
|
|
|
441
458
|
</div>
|
|
442
459
|
|
|
443
460
|
{endItems.length > 0 || showAuthButton ? (
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
461
|
+
<>
|
|
462
|
+
<ShellDivider />
|
|
463
|
+
<div className="flex shrink-0 flex-col gap-0.5 px-2 pt-1.5 pb-2">
|
|
464
|
+
{endItems.map(renderItem)}
|
|
465
|
+
{showAuthButton ? (
|
|
466
|
+
<div className="pt-0.5">
|
|
467
|
+
<LoginButton
|
|
468
|
+
variant="sidebar"
|
|
469
|
+
dividerAbove={endItems.length > 0}
|
|
470
|
+
/>
|
|
471
|
+
</div>
|
|
472
|
+
) : null}
|
|
473
|
+
</div>
|
|
474
|
+
</>
|
|
452
475
|
) : null}
|
|
453
476
|
</nav>
|
|
454
477
|
</aside>
|