@shellui/core 0.7.0-alpha.8 → 0.7.0-beta.1

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.
Files changed (71) hide show
  1. package/README.md +1 -1
  2. package/package.json +23 -6
  3. package/src/components/ui/drawer.tsx +47 -30
  4. package/src/components/ui/sheet.tsx +18 -12
  5. package/src/components/ui/shell-divider.spec.tsx +63 -0
  6. package/src/components/ui/shell-divider.tsx +20 -0
  7. package/src/components/ui/sidebar.tsx +26 -12
  8. package/src/components/ui/tooltip.tsx +4 -2
  9. package/src/features/admin/AdminView.tsx +9 -6
  10. package/src/features/auth/AuthProvider.tsx +10 -1
  11. package/src/features/auth/components/LoginButton.spec.tsx +203 -0
  12. package/src/features/auth/components/LoginButton.tsx +77 -28
  13. package/src/features/auth/components/LoginButtonIcons.tsx +4 -8
  14. package/src/features/auth/utils/index.ts +1 -0
  15. package/src/features/auth/utils/resolveSdkLoginRedirectPath.spec.ts +41 -0
  16. package/src/features/auth/utils/resolveSdkLoginRedirectPath.ts +31 -0
  17. package/src/features/chromeActions/ChromeActionsHost.tsx +5 -1
  18. package/src/features/chromeActions/computeActionInsets.ts +7 -4
  19. package/src/features/layouts/OverlayShell.tsx +58 -40
  20. package/src/features/layouts/appbar/AppBarItemIcon.spec.tsx +45 -0
  21. package/src/features/layouts/appbar/AppBarItemIcon.tsx +19 -0
  22. package/src/features/layouts/appbar/AppBarLayout.tsx +115 -110
  23. package/src/features/layouts/appbar/appBarOverflow.spec.ts +27 -0
  24. package/src/features/layouts/appbar/appBarOverflow.ts +42 -0
  25. package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +13 -24
  26. package/src/features/layouts/chrome/ContentDragOverlay.tsx +5 -6
  27. package/src/features/layouts/chrome/DesktopChrome.tsx +37 -0
  28. package/src/features/layouts/chrome/DesktopHistoryButtons.tsx +15 -4
  29. package/src/features/layouts/chrome/MacStrip.tsx +33 -0
  30. package/src/features/layouts/chrome/constants.ts +36 -8
  31. package/src/features/layouts/chrome/index.ts +8 -0
  32. package/src/features/layouts/chrome/stripDragMap.ts +35 -0
  33. package/src/features/layouts/chrome/stripNoDrag.spec.tsx +103 -0
  34. package/src/features/layouts/chrome/useScrollHideChrome.ts +3 -8
  35. package/src/features/layouts/chrome/viewport.ts +11 -4
  36. package/src/features/layouts/filterNavigationForAuthState.spec.ts +5 -3
  37. package/src/features/layouts/floating/FloatingBottomDock.tsx +263 -43
  38. package/src/features/layouts/floating/FloatingLayout.tsx +14 -8
  39. package/src/features/layouts/floating/FloatingSidebar.tsx +178 -81
  40. package/src/features/layouts/floating/computeFloatingInsets.ts +22 -4
  41. package/src/features/layouts/floating/moreSections.spec.ts +28 -0
  42. package/src/features/layouts/floating/moreSections.ts +31 -0
  43. package/src/features/layouts/floating/useFloatingChrome.ts +3 -1
  44. package/src/features/layouts/floating/useSoftKeyboard.spec.ts +39 -0
  45. package/src/features/layouts/floating/useSoftKeyboard.ts +82 -0
  46. package/src/features/layouts/fullscreen/FullscreenLayout.spec.tsx +68 -0
  47. package/src/features/layouts/fullscreen/FullscreenLayout.tsx +47 -10
  48. package/src/features/layouts/sidebar/NavigationContent.tsx +17 -9
  49. package/src/features/layouts/sidebar/SidebarIcons.tsx +70 -9
  50. package/src/features/layouts/sidebar/SidebarInner.spec.tsx +149 -0
  51. package/src/features/layouts/sidebar/SidebarInner.tsx +103 -43
  52. package/src/features/layouts/sidebar/SidebarLayout.tsx +24 -17
  53. package/src/features/layouts/utils.ts +4 -3
  54. package/src/features/layouts/windows/DesktopDots.tsx +76 -0
  55. package/src/features/layouts/windows/WindowsLayout.tsx +265 -160
  56. package/src/features/layouts/windows/deskDots.spec.ts +54 -0
  57. package/src/features/layouts/windows/deskDots.ts +314 -0
  58. package/src/features/overlays/ResponsiveModal.tsx +5 -3
  59. package/src/features/overlays/overlaySize.spec.ts +56 -16
  60. package/src/features/overlays/overlaySize.ts +114 -31
  61. package/src/features/overlays/phoneDrawerAnchoring.spec.ts +187 -0
  62. package/src/features/overlays/useOverlayReportedSize.ts +8 -3
  63. package/src/features/theme/applyTheme.ts +8 -0
  64. package/src/features/theme/navContrast.spec.ts +49 -0
  65. package/src/features/theme/navContrast.ts +108 -0
  66. package/src/i18n/translations/en/common.json +26 -0
  67. package/src/i18n/translations/fr/common.json +26 -0
  68. package/src/index.css +1156 -77
  69. package/src/service-worker/devCaches.spec.ts +32 -0
  70. package/src/service-worker/devCaches.ts +27 -0
  71. 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 {
@@ -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
- MAC_TRAFFIC_LIGHTS_GAP_PX,
60
- MAC_TRAFFIC_LIGHTS_WIDTH_PX,
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 = 72;
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
- 'inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-2.5 text-sm font-medium transition-colors',
248
- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
249
- active
250
- ? 'bg-sidebar-accent text-sidebar-accent-foreground'
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 && 'bg-accent text-accent-foreground');
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
- <span>{t('desktopChrome.more')}</span>
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-medium text-muted-foreground">
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-5 shrink-0"
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<HTMLDivElement | null>(null);
504
+ const containerRef = useRef<HTMLElement | null>(null);
528
505
  const measureRefs = useRef<(HTMLElement | null)[]>([]);
529
506
  const moreMeasureRef = useRef<HTMLElement | null>(null);
530
- const [visibleCount, setVisibleCount] = useState(entries.length);
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
- setVisibleCount(entries.length);
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
- const moreWidth = moreMeasureRef.current?.offsetWidth || MORE_FALLBACK_PX;
548
-
549
- let total = 0;
550
- for (let i = 0; i < widths.length; i++) {
551
- total += widths[i] + (i > 0 ? NAV_GAP_PX : 0);
552
- }
553
- if (total <= available) {
554
- setVisibleCount(entries.length);
555
- return;
556
- }
557
-
558
- let used = 0;
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 visible = entries.slice(0, visibleCount);
585
- const overflow = entries.slice(visibleCount);
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
- <div
565
+ <nav
591
566
  ref={containerRef}
592
- className="relative flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden"
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
- <AppBarNavMeasureChip
622
- label={moreLabel}
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
- </div>
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 rounded-md transition-colors cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
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
- const barHeightPx = titlebarAligned ? DESKTOP_TITLEBAR_HEIGHT_PX : APP_BAR_HEIGHT_PX;
784
- const barPadTopPx = titlebarAligned ? DESKTOP_TITLEBAR_PAD_TOP_PX : APP_BAR_PAD_TOP_PX;
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
- ? MAC_TRAFFIC_LIGHTS_WIDTH_PX + MAC_TRAFFIC_LIGHTS_GAP_PX
839
- : undefined;
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
- {...(trafficLights
991
- ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
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="app-bar-app-icon size-6"
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
- DESKTOP_TITLEBAR_HEIGHT_PX,
6
- DESKTOP_TITLEBAR_PAD_TOP_PX,
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 42px chrome when the sidebar is collapsed in a Tauri overlay window.
14
- * Open-sidebar first, then Back; room for more controls later.
15
- * Stays visible in native fullscreen (no traffic-light spacer there).
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-drag-region=""
30
- data-tauri-drag-region=""
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 border-b border-sidebar-border bg-sidebar text-sidebar-foreground select-none',
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
- {trafficLights ? (
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-7 touch-manipulation" />
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
  }
@@ -1,13 +1,12 @@
1
- import { DESKTOP_TITLEBAR_HEIGHT_PX, MAC_TRAFFIC_LIGHTS_WIDTH_PX } from './constants';
1
+ import { DESKTOP_TITLEBAR_HEIGHT_PX, MAC_LIGHTS_SAFE_PX } from './constants';
2
2
 
3
3
  /**
4
- * Narrow left strip over the traffic-light band only.
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 titlebar) and from this
9
- * empty traffic-light spacer. Interactive iframe content to the right stays
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: MAC_TRAFFIC_LIGHTS_WIDTH_PX,
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
  }