@shellui/core 0.6.2 → 0.7.0-alpha.10

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 (85) hide show
  1. package/package.json +2 -2
  2. package/schemas/shellui.config.schema.json +147 -70
  3. package/src/app.tsx +2 -0
  4. package/src/components/ContentView.tsx +21 -30
  5. package/src/components/iframeUrlSafety.spec.ts +67 -0
  6. package/src/components/iframeUrlSafety.ts +50 -0
  7. package/src/components/ui/sidebar.tsx +11 -5
  8. package/src/features/admin/AdminView.tsx +9 -6
  9. package/src/features/auth/AuthProvider.tsx +49 -5
  10. package/src/features/auth/appBackend/AppBackendSessionHost.tsx +58 -0
  11. package/src/features/auth/appBackend/appBackendSessions.spec.ts +329 -0
  12. package/src/features/auth/appBackend/appBackendSessions.ts +443 -0
  13. package/src/features/auth/appBackend/childFrames.spec.ts +328 -0
  14. package/src/features/auth/appBackend/childFrames.ts +180 -0
  15. package/src/features/auth/appBackend/configSchema.spec.ts +41 -0
  16. package/src/features/auth/appBackend/frameAuth.ts +204 -0
  17. package/src/features/auth/appBackend/identity.spec.ts +201 -0
  18. package/src/features/auth/appBackend/identity.ts +173 -0
  19. package/src/features/auth/appBackend/silentSignIn.spec.ts +225 -0
  20. package/src/features/auth/appBackend/silentSignIn.ts +254 -0
  21. package/src/features/auth/appBackend/tokenExchange.spec.ts +98 -0
  22. package/src/features/auth/appBackend/tokenExchange.ts +76 -0
  23. package/src/features/auth/backends/shellui.spec.ts +51 -19
  24. package/src/features/auth/backends/shellui.ts +20 -5
  25. package/src/features/auth/backends/types.ts +7 -2
  26. package/src/features/auth/components/LoginView.tsx +40 -18
  27. package/src/features/auth/components/OAuthCallbackView.tsx +33 -4
  28. package/src/features/auth/utils/authRequestError.ts +3 -0
  29. package/src/features/auth/utils/buildOAuthSessionRedirectTo.spec.ts +42 -1
  30. package/src/features/auth/utils/buildOAuthSessionRedirectTo.ts +23 -0
  31. package/src/features/auth/utils/canRestoreStoredSession.spec.ts +29 -0
  32. package/src/features/auth/utils/canRestoreStoredSession.ts +12 -0
  33. package/src/features/auth/utils/index.ts +16 -1
  34. package/src/features/auth/utils/loginCancelTarget.spec.ts +73 -0
  35. package/src/features/auth/utils/loginCancelTarget.ts +45 -0
  36. package/src/features/auth/utils/loginPanelFrame.spec.ts +24 -0
  37. package/src/features/auth/utils/loginPanelFrame.ts +14 -0
  38. package/src/features/auth/utils/resolveSdkLoginRedirectPath.spec.ts +41 -0
  39. package/src/features/auth/utils/resolveSdkLoginRedirectPath.ts +31 -0
  40. package/src/features/auth/utils/webPkce.spec.ts +119 -0
  41. package/src/features/auth/utils/webPkce.ts +169 -0
  42. package/src/features/chromeActions/computeActionInsets.ts +7 -4
  43. package/src/features/config/types.ts +70 -3
  44. package/src/features/layouts/appbar/AppBarLayout.tsx +63 -30
  45. package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +12 -23
  46. package/src/features/layouts/chrome/ContentDragOverlay.tsx +5 -6
  47. package/src/features/layouts/chrome/DesktopChrome.tsx +37 -0
  48. package/src/features/layouts/chrome/DesktopHistoryButtons.tsx +15 -4
  49. package/src/features/layouts/chrome/MacStrip.tsx +33 -0
  50. package/src/features/layouts/chrome/constants.ts +33 -8
  51. package/src/features/layouts/chrome/index.ts +8 -0
  52. package/src/features/layouts/chrome/stripDragMap.ts +35 -0
  53. package/src/features/layouts/chrome/stripNoDrag.spec.tsx +103 -0
  54. package/src/features/layouts/chrome/useScrollHideChrome.ts +3 -8
  55. package/src/features/layouts/filterNavigationForAuthState.spec.ts +5 -3
  56. package/src/features/layouts/floating/FloatingBottomDock.tsx +199 -20
  57. package/src/features/layouts/floating/FloatingLayout.tsx +13 -8
  58. package/src/features/layouts/floating/FloatingSidebar.tsx +144 -70
  59. package/src/features/layouts/floating/computeFloatingInsets.ts +22 -4
  60. package/src/features/layouts/floating/useFloatingChrome.ts +3 -1
  61. package/src/features/layouts/floating/useSoftKeyboard.spec.ts +39 -0
  62. package/src/features/layouts/floating/useSoftKeyboard.ts +82 -0
  63. package/src/features/layouts/fullscreen/FullscreenLayout.tsx +38 -10
  64. package/src/features/layouts/sidebar/NavigationContent.tsx +14 -6
  65. package/src/features/layouts/sidebar/SidebarIcons.tsx +3 -9
  66. package/src/features/layouts/sidebar/SidebarInner.tsx +50 -39
  67. package/src/features/layouts/sidebar/SidebarLayout.tsx +8 -11
  68. package/src/features/layouts/utils.ts +4 -3
  69. package/src/features/layouts/windows/DesktopDots.tsx +76 -0
  70. package/src/features/layouts/windows/WindowsLayout.tsx +184 -125
  71. package/src/features/layouts/windows/deskDots.spec.ts +52 -0
  72. package/src/features/layouts/windows/deskDots.ts +314 -0
  73. package/src/features/settings/SettingsProvider.tsx +198 -29
  74. package/src/features/settings/utils/buildSettingsForPropagation.spec.ts +379 -4
  75. package/src/features/settings/utils/buildSettingsForPropagation.ts +65 -39
  76. package/src/features/theme/applyTheme.ts +8 -0
  77. package/src/features/theme/navContrast.spec.ts +49 -0
  78. package/src/features/theme/navContrast.ts +108 -0
  79. package/src/features/transfers/transferQueue.spec.ts +6 -2
  80. package/src/i18n/translations/en/common.json +27 -0
  81. package/src/i18n/translations/fr/common.json +27 -0
  82. package/src/index.css +935 -46
  83. package/src/index.ts +2 -0
  84. package/src/routes/hooks/useNavigationItems.ts +14 -3
  85. package/src/routes/hooks/withShellSearch.spec.ts +13 -0
@@ -56,8 +56,10 @@ import { InsetMobileRadiusOverlay } from '../chrome/InsetMobileRadiusOverlay';
56
56
  import {
57
57
  DESKTOP_TITLEBAR_HEIGHT_PX,
58
58
  DESKTOP_TITLEBAR_PAD_TOP_PX,
59
- MAC_TRAFFIC_LIGHTS_GAP_PX,
60
- MAC_TRAFFIC_LIGHTS_WIDTH_PX,
59
+ MAC_LIGHTS_SAFE_FULLSCREEN_PX,
60
+ MAC_LIGHTS_SAFE_PX,
61
+ SHELL_HEADER_HEIGHT_PX,
62
+ SHELL_HEADER_PAD_TOP_PX,
61
63
  } from '../chrome/constants';
62
64
  import { useIsTauriRuntime, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
63
65
 
@@ -243,12 +245,11 @@ function AppBarItemIcon({ item, label }: { item: NavigationItem; label: string }
243
245
 
244
246
  const navTriggerClass = (active: boolean) =>
245
247
  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',
248
+ // h-8 fills the taller app-bar after the top pad. Colours, hover and the
249
+ // active indicator live in index.css (`.shellui-appbar-item`).
250
+ 'shellui-appbar-item inline-flex h-8 shrink-0 items-center gap-1.5 px-2.5 text-sm font-medium',
251
+ 'focus-visible:outline-none',
252
+ active && 'is-active',
252
253
  );
253
254
 
254
255
  /** Text link / action used in the bar (not inside a dropdown). */
@@ -279,6 +280,8 @@ function AppBarNavLink({
279
280
  <button
280
281
  type="button"
281
282
  className={className}
283
+ data-shellui-no-drag=""
284
+ data-active={isActive ? 'true' : undefined}
282
285
  onClick={() => navigateToItem(item)}
283
286
  >
284
287
  {content}
@@ -290,6 +293,9 @@ function AppBarNavLink({
290
293
  <Link
291
294
  to={pathPrefix}
292
295
  className={className}
296
+ data-shellui-no-drag=""
297
+ data-active={isActive ? 'true' : undefined}
298
+ aria-current={isActive ? 'page' : undefined}
293
299
  >
294
300
  {content}
295
301
  </Link>
@@ -309,7 +315,7 @@ function AppBarNavMenuItem({
309
315
  }) {
310
316
  const isActive = navItemIsActive(item, activePathPrefix);
311
317
  const pathPrefix = getNavPathPrefix(item);
312
- const itemClass = cn('gap-2 text-sm', isActive && 'bg-accent text-accent-foreground');
318
+ const itemClass = cn('shellui-appbar-menu-item gap-2 text-sm', isActive && 'is-active');
313
319
  const content = (
314
320
  <>
315
321
  <AppBarItemIcon
@@ -342,6 +348,7 @@ function AppBarNavMenuItem({
342
348
  <Link
343
349
  to={pathPrefix}
344
350
  onClick={onNavigate}
351
+ aria-current={isActive ? 'page' : undefined}
345
352
  >
346
353
  {content}
347
354
  </Link>
@@ -375,14 +382,18 @@ function AppBarNavCategory({
375
382
  variant="ghost"
376
383
  size="sm"
377
384
  className={cn(navTriggerClass(active))}
385
+ data-shellui-no-drag=""
386
+ data-active={active ? 'true' : undefined}
387
+ aria-haspopup="menu"
378
388
  aria-expanded={open}
379
389
  >
380
390
  <span className="truncate">{label}</span>
381
- <CaretDownIcon className="size-3 shrink-0 opacity-70" />
391
+ <CaretDownIcon className="size-3.5 shrink-0 opacity-70" />
382
392
  </Button>
383
393
  </DropdownMenuTrigger>
384
394
  <DropdownMenuContent
385
395
  align="start"
396
+ className="shellui-appbar-menu"
386
397
  onCloseAutoFocus={(event) => event.preventDefault()}
387
398
  >
388
399
  {items.map((item, index) => (
@@ -427,17 +438,20 @@ function AppBarNavMore({
427
438
  variant="ghost"
428
439
  size="sm"
429
440
  className={cn(navTriggerClass(moreActive))}
441
+ data-shellui-no-drag=""
442
+ data-active={moreActive ? 'true' : undefined}
430
443
  aria-label={t('desktopChrome.more')}
444
+ aria-haspopup="menu"
431
445
  aria-expanded={open}
432
446
  >
433
447
  <span>{t('desktopChrome.more')}</span>
434
- <CaretDownIcon className="size-3 shrink-0 opacity-70" />
448
+ <CaretDownIcon className="size-3.5 shrink-0 opacity-70" />
435
449
  </Button>
436
450
  </DropdownMenuTrigger>
437
451
  <DropdownMenuContent
438
452
  align="start"
439
453
  onCloseAutoFocus={(event) => event.preventDefault()}
440
- className="min-w-[12rem]"
454
+ className="shellui-appbar-menu min-w-[12rem]"
441
455
  >
442
456
  {entries.map((entry, entryIndex) => {
443
457
  if (entry.type === 'link') {
@@ -458,7 +472,7 @@ function AppBarNavMore({
458
472
  return (
459
473
  <div key={entry.key}>
460
474
  {entryIndex > 0 ? <DropdownMenuSeparator /> : null}
461
- <DropdownMenuLabel className="text-xs font-medium text-muted-foreground">
475
+ <DropdownMenuLabel className="shellui-appbar-menu-label text-xs font-semibold text-muted-foreground">
462
476
  {categoryLabel}
463
477
  </DropdownMenuLabel>
464
478
  {entry.items.map((item, index) => (
@@ -502,7 +516,7 @@ function AppBarNavMeasureChip({
502
516
  />
503
517
  ) : null}
504
518
  {label}
505
- {withCaret ? <CaretDownIcon className="size-3 shrink-0 opacity-70" /> : null}
519
+ {withCaret ? <CaretDownIcon className="size-3.5 shrink-0 opacity-70" /> : null}
506
520
  </span>
507
521
  );
508
522
  }
@@ -524,7 +538,7 @@ function AppBarNav({
524
538
  }) {
525
539
  const { t } = useTranslation();
526
540
  const entries = useMemo(() => sectionsToEntries(sections), [sections]);
527
- const containerRef = useRef<HTMLDivElement | null>(null);
541
+ const containerRef = useRef<HTMLElement | null>(null);
528
542
  const measureRefs = useRef<(HTMLElement | null)[]>([]);
529
543
  const moreMeasureRef = useRef<HTMLElement | null>(null);
530
544
  const [visibleCount, setVisibleCount] = useState(entries.length);
@@ -587,8 +601,9 @@ function AppBarNav({
587
601
  const moreLabel = t('desktopChrome.more');
588
602
 
589
603
  return (
590
- <div
604
+ <nav
591
605
  ref={containerRef}
606
+ aria-label={t('shellChrome.mainNav')}
592
607
  className="relative flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden"
593
608
  >
594
609
  {/* Off-screen width probes (no DropdownMenu — avoids portal noise). */}
@@ -665,7 +680,7 @@ function AppBarNav({
665
680
  className="h-full min-h-8 min-w-2 flex-1 self-stretch"
666
681
  />
667
682
  ) : null}
668
- </div>
683
+ </nav>
669
684
  );
670
685
  }
671
686
 
@@ -679,6 +694,7 @@ function TopBarEndItem({
679
694
  label: string;
680
695
  activePathPrefix: string | null;
681
696
  }) {
697
+ const { t } = useTranslation();
682
698
  const pathPrefix = getNavPathPrefix(item);
683
699
  const isOverlay = item.openIn === 'modal' || item.openIn === 'drawer';
684
700
  const isExternal = item.openIn === 'external';
@@ -703,10 +719,8 @@ function TopBarEndItem({
703
719
  );
704
720
 
705
721
  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',
722
+ 'shellui-appbar-end flex size-8 items-center justify-center cursor-pointer focus-visible:outline-none',
723
+ isActive && 'is-active',
710
724
  );
711
725
 
712
726
  const wrap = (node: ReactNode) => <AppBarTooltip label={label}>{node}</AppBarTooltip>;
@@ -742,7 +756,7 @@ function TopBarEndItem({
742
756
  target="_blank"
743
757
  rel="noopener noreferrer"
744
758
  className={buttonClass}
745
- aria-label={label}
759
+ aria-label={`${label} (${t('shellChrome.externalLink')})`}
746
760
  >
747
761
  {iconEl}
748
762
  </a>,
@@ -753,6 +767,7 @@ function TopBarEndItem({
753
767
  to={pathPrefix}
754
768
  className={buttonClass}
755
769
  aria-label={label}
770
+ aria-current={isActive ? 'page' : undefined}
756
771
  >
757
772
  {iconEl}
758
773
  </Link>,
@@ -780,8 +795,18 @@ export function AppBarLayout({
780
795
  const showSafeAreaTopbar = isShellUiRootWindow();
781
796
  const scrollHideLayout = isInset ? 'app-bar-inset' : 'app-bar';
782
797
  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;
798
+ // macOS: the bar is the 32px strip. Windows / Linux (native caption bar above): 42px.
799
+ const macStrip = overlay;
800
+ const barHeightPx = macStrip
801
+ ? DESKTOP_TITLEBAR_HEIGHT_PX
802
+ : titlebarAligned
803
+ ? SHELL_HEADER_HEIGHT_PX
804
+ : APP_BAR_HEIGHT_PX;
805
+ const barPadTopPx = macStrip
806
+ ? DESKTOP_TITLEBAR_PAD_TOP_PX
807
+ : titlebarAligned
808
+ ? SHELL_HEADER_PAD_TOP_PX
809
+ : APP_BAR_PAD_TOP_PX;
785
810
  const { chromeVisible } = useScrollHideChrome({
786
811
  enabled: isMobile,
787
812
  layout: scrollHideLayout,
@@ -834,9 +859,12 @@ export function AppBarLayout({
834
859
  }
835
860
  }, [location.pathname, title, navigationItems, currentLanguage]);
836
861
 
862
+ // Drag-only safe area next to the lights: 80px, 12px in native fullscreen (lights hidden).
837
863
  const chromeInset = trafficLights
838
- ? MAC_TRAFFIC_LIGHTS_WIDTH_PX + MAC_TRAFFIC_LIGHTS_GAP_PX
839
- : undefined;
864
+ ? MAC_LIGHTS_SAFE_PX
865
+ : macStrip
866
+ ? MAC_LIGHTS_SAFE_FULLSCREEN_PX
867
+ : undefined;
840
868
 
841
869
  const hasStartNav = startSections.some((s) => s.items.length > 0);
842
870
  // Keep in sync with <main> inset frame pad — bar content aligns to the card border.
@@ -987,8 +1015,12 @@ export function AppBarLayout({
987
1015
  )}
988
1016
  style={headerStyle}
989
1017
  data-layout={isInset ? 'app-bar-inset' : 'app-bar'}
990
- {...(trafficLights
991
- ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
1018
+ {...(macStrip
1019
+ ? {
1020
+ 'data-shellui-drag-region': '',
1021
+ 'data-tauri-drag-region': '',
1022
+ 'data-shellui-mac-strip': '',
1023
+ }
992
1024
  : {})}
993
1025
  >
994
1026
  {appIcon ? (
@@ -997,7 +1029,7 @@ export function AppBarLayout({
997
1029
  title={title}
998
1030
  data-shellui-no-drag=""
999
1031
  className="mr-1 shrink-0"
1000
- imgClassName="app-bar-app-icon size-6"
1032
+ imgClassName={cn('app-bar-app-icon', macStrip ? 'size-5' : 'size-6')}
1001
1033
  />
1002
1034
  ) : null}
1003
1035
 
@@ -1022,7 +1054,7 @@ export function AppBarLayout({
1022
1054
  data-shellui-no-drag=""
1023
1055
  className="shrink-0"
1024
1056
  >
1025
- <DesktopHistoryButtons />
1057
+ <DesktopHistoryButtons strip={macStrip} />
1026
1058
  </div>
1027
1059
  ) : null}
1028
1060
 
@@ -1036,6 +1068,7 @@ export function AppBarLayout({
1036
1068
 
1037
1069
  <div
1038
1070
  data-shellui-no-drag=""
1071
+ data-shellui-strip-end=""
1039
1072
  className="flex shrink-0 items-center gap-0.5"
1040
1073
  >
1041
1074
  {endNavItems.length > 0 ? (
@@ -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,8 +21,8 @@ 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
27
  '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',
33
28
  className,
@@ -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
  }
@@ -2,15 +2,26 @@ import { cn } from '../../../lib/utils';
2
2
  import { DesktopBackButton } from './DesktopBackButton';
3
3
  import { DesktopForwardButton } from './DesktopForwardButton';
4
4
 
5
- /** Browser-like Back + Forward for Tauri / desktop chrome. */
6
- export function DesktopHistoryButtons({ className }: { className?: string }) {
5
+ /**
6
+ * Browser-like Back + Forward for Tauri / desktop chrome.
7
+ * `strip` sizes them for the macOS strip (24px boxes, 16px icons).
8
+ */
9
+ export function DesktopHistoryButtons({
10
+ className,
11
+ strip = false,
12
+ }: {
13
+ className?: string;
14
+ strip?: boolean;
15
+ }) {
16
+ const buttonClassName = strip ? 'size-6' : undefined;
7
17
  return (
8
18
  <div
9
19
  data-shellui-no-drag=""
20
+ data-shellui-history=""
10
21
  className={cn('flex shrink-0 items-center', className)}
11
22
  >
12
- <DesktopBackButton />
13
- <DesktopForwardButton />
23
+ <DesktopBackButton className={buttonClassName} />
24
+ <DesktopForwardButton className={buttonClassName} />
14
25
  </div>
15
26
  );
16
27
  }
@@ -0,0 +1,33 @@
1
+ import { cn } from '../../../lib/utils';
2
+
3
+ /** Drag attributes for strip backgrounds and flexible spacers. */
4
+ export const MAC_DRAG_REGION_PROPS = {
5
+ 'data-shellui-drag-region': '',
6
+ 'data-tauri-drag-region': '',
7
+ } as const;
8
+
9
+ /**
10
+ * Left safe area of the macOS strip: 80px next to the default traffic lights
11
+ * (12px in native fullscreen). Drag only, never holds a control.
12
+ */
13
+ export function MacLightsSafeArea({ className }: { className?: string }) {
14
+ return (
15
+ <div
16
+ aria-hidden
17
+ data-shellui-mac-safe=""
18
+ {...MAC_DRAG_REGION_PROPS}
19
+ className={cn('shellui-mac-safe h-full shrink-0', className)}
20
+ />
21
+ );
22
+ }
23
+
24
+ /** Flexible drag spacer inside the macOS strip. */
25
+ export function MacStripSpacer({ className }: { className?: string }) {
26
+ return (
27
+ <div
28
+ aria-hidden
29
+ {...MAC_DRAG_REGION_PROPS}
30
+ className={cn('min-h-full min-w-2 flex-1 self-stretch', className)}
31
+ />
32
+ );
33
+ }
@@ -1,17 +1,42 @@
1
- /** Height of the macOS overlay titlebar / traffic-light row. */
2
- export const DESKTOP_TITLEBAR_HEIGHT_PX = 42;
3
-
4
1
  /**
5
- * Top inset inside the titlebar so web controls optically match macOS traffic lights
6
- * (lights stay vertically centered in the full height).
2
+ * macOS overlay strip height (rules v2). The traffic lights stay at the AppKit default
3
+ * (`trafficLightPosition` unset): 32px title bar on macOS 26, 28px on macOS 15.
4
+ * Every macOS desktop layout puts its top chrome in this one strip.
7
5
  */
8
- export const DESKTOP_TITLEBAR_PAD_TOP_PX = 2;
6
+ export const DESKTOP_TITLEBAR_HEIGHT_PX = 32;
7
+
8
+ /** Top inset inside the macOS strip. Controls centre on the lights line, no nudge. */
9
+ export const DESKTOP_TITLEBAR_PAD_TOP_PX = 0;
10
+
11
+ /** Vertical centre of the default traffic lights in the strip (`--shellui-mac-lights-cy`). */
12
+ export const MAC_TRAFFIC_LIGHTS_CENTER_Y_PX = 16;
9
13
 
10
- /** Width reserved for macOS traffic lights (close / minimize / zoom). */
11
- export const MAC_TRAFFIC_LIGHTS_WIDTH_PX = 78;
14
+ /** Width reserved for the default traffic lights (group spans about x 8 to 64). */
15
+ export const MAC_TRAFFIC_LIGHTS_WIDTH_PX = 68;
12
16
 
13
17
  /** Extra space between traffic lights and the first chrome control. */
14
18
  export const MAC_TRAFFIC_LIGHTS_GAP_PX = 12;
15
19
 
20
+ /**
21
+ * Drag-only safe area from the left window edge (`--shellui-mac-lights-safe`).
22
+ * Nothing interactive, no text and no focus ring enters 0 to 80 x 0 to 32.
23
+ */
24
+ export const MAC_LIGHTS_SAFE_PX = MAC_TRAFFIC_LIGHTS_WIDTH_PX + MAC_TRAFFIC_LIGHTS_GAP_PX;
25
+
26
+ /** Safe area in native fullscreen, where AppKit hides the lights. */
27
+ export const MAC_LIGHTS_SAFE_FULLSCREEN_PX = 12;
28
+
29
+ /** Controls in the macOS strip: 24px boxes with 16px icons. */
30
+ export const MAC_STRIP_CONTROL_PX = 24;
31
+
32
+ /**
33
+ * Shell header height on the web, on phones and on Tauri hosts with a native caption bar
34
+ * (Windows, Linux). The macOS strip uses `DESKTOP_TITLEBAR_HEIGHT_PX` instead.
35
+ */
36
+ export const SHELL_HEADER_HEIGHT_PX = 42;
37
+
38
+ /** Top inset inside the shell header (web, phones, native caption bar hosts). */
39
+ export const SHELL_HEADER_PAD_TOP_PX = 2;
40
+
16
41
  /** Set on an iframe after it navigates to a foreign origin (login pages, OAuth). */
17
42
  export const IFRAME_FOREIGN_ATTR = 'data-shellui-iframe-foreign';
@@ -2,9 +2,17 @@ export {
2
2
  DESKTOP_TITLEBAR_HEIGHT_PX,
3
3
  DESKTOP_TITLEBAR_PAD_TOP_PX,
4
4
  IFRAME_FOREIGN_ATTR,
5
+ MAC_LIGHTS_SAFE_FULLSCREEN_PX,
6
+ MAC_LIGHTS_SAFE_PX,
7
+ MAC_STRIP_CONTROL_PX,
8
+ MAC_TRAFFIC_LIGHTS_CENTER_Y_PX,
5
9
  MAC_TRAFFIC_LIGHTS_GAP_PX,
6
10
  MAC_TRAFFIC_LIGHTS_WIDTH_PX,
11
+ SHELL_HEADER_HEIGHT_PX,
12
+ SHELL_HEADER_PAD_TOP_PX,
7
13
  } from './constants';
14
+ export { MAC_DRAG_REGION_PROPS, MacLightsSafeArea, MacStripSpacer } from './MacStrip';
15
+ export { findSafeAreaControls, findStripDragLeaks } from './stripDragMap';
8
16
  export {
9
17
  goDesktopBack,
10
18
  goBackInIframes,
@@ -0,0 +1,35 @@
1
+ const INTERACTIVE =
2
+ 'button, a[href], input, select, textarea, summary, [role="button"], [role="link"], [role="tab"], [role="menuitem"], [role="combobox"], [tabindex]:not([tabindex="-1"])';
3
+
4
+ /**
5
+ * Controls in a macOS strip that would turn into window drag or zoom targets:
6
+ * interactive elements without `data-shellui-no-drag` on themselves or on an
7
+ * ancestor inside the strip, or carrying a drag attribute themselves.
8
+ */
9
+ export function findStripDragLeaks(strip: Element): Element[] {
10
+ const leaks: Element[] = [];
11
+ for (const el of Array.from(strip.querySelectorAll(INTERACTIVE))) {
12
+ if (el.hasAttribute('data-tauri-drag-region') || el.hasAttribute('data-shellui-drag-region')) {
13
+ leaks.push(el);
14
+ continue;
15
+ }
16
+ let node: Element | null = el;
17
+ let guarded = false;
18
+ while (node && node !== strip.parentElement) {
19
+ if (node.hasAttribute('data-shellui-no-drag')) {
20
+ guarded = true;
21
+ break;
22
+ }
23
+ node = node.parentElement;
24
+ }
25
+ if (!guarded) leaks.push(el);
26
+ }
27
+ return leaks;
28
+ }
29
+
30
+ /** Interactive elements placed inside the drag-only lights safe area. */
31
+ export function findSafeAreaControls(strip: Element): Element[] {
32
+ return Array.from(strip.querySelectorAll('[data-shellui-mac-safe]')).flatMap((safe) =>
33
+ Array.from(safe.querySelectorAll(INTERACTIVE)),
34
+ );
35
+ }