@shellui/core 0.7.0-alpha.10 → 0.7.0-alpha.11

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 (44) hide show
  1. package/package.json +2 -2
  2. package/src/components/ui/drawer.tsx +47 -30
  3. package/src/components/ui/sheet.tsx +18 -12
  4. package/src/components/ui/sidebar.tsx +14 -6
  5. package/src/components/ui/tooltip.tsx +4 -2
  6. package/src/features/auth/components/LoginButton.spec.tsx +155 -0
  7. package/src/features/auth/components/LoginButton.tsx +52 -27
  8. package/src/features/auth/components/LoginButtonIcons.tsx +4 -8
  9. package/src/features/chromeActions/ChromeActionsHost.tsx +5 -1
  10. package/src/features/layouts/OverlayShell.tsx +58 -40
  11. package/src/features/layouts/appbar/AppBarItemIcon.spec.tsx +45 -0
  12. package/src/features/layouts/appbar/AppBarItemIcon.tsx +19 -0
  13. package/src/features/layouts/appbar/AppBarLayout.tsx +53 -81
  14. package/src/features/layouts/appbar/appBarOverflow.spec.ts +27 -0
  15. package/src/features/layouts/appbar/appBarOverflow.ts +42 -0
  16. package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +1 -1
  17. package/src/features/layouts/chrome/constants.ts +3 -0
  18. package/src/features/layouts/chrome/viewport.ts +11 -4
  19. package/src/features/layouts/floating/FloatingBottomDock.tsx +66 -25
  20. package/src/features/layouts/floating/FloatingLayout.tsx +1 -0
  21. package/src/features/layouts/floating/FloatingSidebar.tsx +26 -8
  22. package/src/features/layouts/floating/moreSections.spec.ts +28 -0
  23. package/src/features/layouts/floating/moreSections.ts +31 -0
  24. package/src/features/layouts/fullscreen/FullscreenLayout.spec.tsx +68 -0
  25. package/src/features/layouts/fullscreen/FullscreenLayout.tsx +10 -1
  26. package/src/features/layouts/sidebar/NavigationContent.tsx +4 -4
  27. package/src/features/layouts/sidebar/SidebarIcons.tsx +67 -0
  28. package/src/features/layouts/sidebar/SidebarInner.spec.tsx +109 -0
  29. package/src/features/layouts/sidebar/SidebarInner.tsx +49 -9
  30. package/src/features/layouts/sidebar/SidebarLayout.tsx +23 -13
  31. package/src/features/layouts/windows/WindowsLayout.tsx +75 -44
  32. package/src/features/layouts/windows/deskDots.spec.ts +6 -4
  33. package/src/features/layouts/windows/deskDots.ts +8 -8
  34. package/src/features/overlays/ResponsiveModal.tsx +5 -3
  35. package/src/features/overlays/overlaySize.spec.ts +56 -16
  36. package/src/features/overlays/overlaySize.ts +114 -31
  37. package/src/features/overlays/phoneDrawerAnchoring.spec.ts +187 -0
  38. package/src/features/overlays/useOverlayReportedSize.ts +8 -3
  39. package/src/i18n/translations/en/common.json +1 -0
  40. package/src/i18n/translations/fr/common.json +1 -0
  41. package/src/index.css +211 -32
  42. package/src/service-worker/devCaches.spec.ts +32 -0
  43. package/src/service-worker/devCaches.ts +27 -0
  44. package/src/service-worker/sw-dev.ts +23 -23
@@ -7,6 +7,7 @@ import {
7
7
  SidebarTrigger,
8
8
  useSidebar,
9
9
  } from '../../../components/ui/sidebar';
10
+ import { CloseIcon } from './SidebarIcons';
10
11
  import { NavigationContent } from './NavigationContent';
11
12
  import { LoginButton } from '../../auth/components/LoginButton';
12
13
  import { cn } from '../../../lib/utils';
@@ -22,6 +23,9 @@ import {
22
23
  } from '../chrome/constants';
23
24
  import { AppBrandIcon } from '../branding/AppBrandIcon';
24
25
 
26
+ /** Mobile sheet brand row height (spec: 52px). */
27
+ const MOBILE_SHEET_HEADER_HEIGHT_PX = 52;
28
+
25
29
  /** Reusable sidebar inner: header, main nav, footer. Used in desktop Sidebar and mobile Sheet. */
26
30
  export function SidebarInner({
27
31
  startNav,
@@ -43,7 +47,7 @@ export function SidebarInner({
43
47
  const isTauriEnv = useIsTauriClient();
44
48
  const overlay = useMacOverlayChrome();
45
49
  const trafficLights = useMacTrafficLights();
46
- const { state, isMobile } = useSidebar();
50
+ const { state, isMobile, setOpenMobile } = useSidebar();
47
51
  const collapsed = state === 'collapsed' && !isMobile;
48
52
  // Collapsed Tauri: Back + trigger live in CollapsedDesktopTitlebar instead.
49
53
  const showCollapsedTopBar = overlay && collapsed;
@@ -85,16 +89,28 @@ export function SidebarInner({
85
89
  <SidebarHeader
86
90
  className={cn(
87
91
  // Always pin to titlebar height — default SidebarHeader p-2 is taller on web.
88
- 'gap-0 border-b border-sidebar-border select-none',
92
+ 'gap-0 select-none',
89
93
  showOverlayHeader || mobileSheetHeader ? 'p-0' : 'px-2 py-0',
94
+ // Mobile sheet: brand row with a close button, 14px left like the mock.
95
+ isMobile && !mobileSheetHeader && 'pr-2 pl-3.5',
90
96
  showCollapsedTopBar && 'hidden',
91
97
  // Inset `p-3` sits this row 12px under the lights. Pull it to the window edge.
92
98
  inset && showOverlayHeader && '-mt-3 -ml-3 w-[calc(100%+1.5rem)]',
99
+ // Web: same pull, so the brand row lines up with the plain sidebar header.
100
+ inset && !showOverlayHeader && !isMobile && '-mt-3 -ml-3 w-[calc(100%+0.75rem)] pl-5',
93
101
  )}
94
102
  style={{
95
103
  // macOS: the header is the 32px strip. Web, phones and caption bar hosts: 42px.
96
- height: showOverlayHeader ? DESKTOP_TITLEBAR_HEIGHT_PX : SHELL_HEADER_HEIGHT_PX,
97
- paddingTop: showOverlayHeader ? DESKTOP_TITLEBAR_PAD_TOP_PX : SHELL_HEADER_PAD_TOP_PX,
104
+ height: showOverlayHeader
105
+ ? DESKTOP_TITLEBAR_HEIGHT_PX
106
+ : isMobile
107
+ ? MOBILE_SHEET_HEADER_HEIGHT_PX
108
+ : SHELL_HEADER_HEIGHT_PX,
109
+ paddingTop: showOverlayHeader
110
+ ? DESKTOP_TITLEBAR_PAD_TOP_PX
111
+ : isMobile
112
+ ? 0
113
+ : SHELL_HEADER_PAD_TOP_PX,
98
114
  ...(mobileSheetHeader ? { paddingLeft: mobileTrafficInset } : {}),
99
115
  }}
100
116
  {...(showOverlayHeader
@@ -137,24 +153,48 @@ export function SidebarInner({
137
153
  {hasAppIcon ? trailingInset : null}
138
154
  </div>
139
155
  </div>
156
+ ) : isMobile ? (
157
+ <div className="flex h-full w-full items-center gap-1.5">
158
+ {brandIcon}
159
+ <span
160
+ aria-hidden
161
+ className="min-w-0 flex-1 truncate text-sm font-semibold text-sidebar-foreground"
162
+ >
163
+ {title}
164
+ </span>
165
+ <button
166
+ type="button"
167
+ aria-label={t('shellChrome.closeMenu')}
168
+ onClick={() => setOpenMobile(false)}
169
+ className="inline-flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-[var(--shellui-r-row)] text-[var(--shellui-nav-icon)] hover:bg-[var(--shellui-nav-hover)] hover:text-sidebar-foreground focus-visible:outline-2 focus-visible:outline-[var(--sidebar-ring)]"
170
+ >
171
+ <CloseIcon className="size-5" />
172
+ </button>
173
+ </div>
140
174
  ) : (
141
175
  <div className={cn('flex h-full w-full items-center', hasAppIcon ? 'gap-0' : 'gap-0.5')}>
142
176
  {brandIcon}
143
177
  {hasAppIcon ? (
144
178
  <div
145
179
  aria-hidden
146
- className="min-w-0 flex-1"
147
- />
180
+ className="min-w-0 flex-1 overflow-hidden"
181
+ >
182
+ {title ? (
183
+ <span className="block truncate pl-2 text-sm font-semibold text-sidebar-foreground transition-opacity duration-200 ease-linear group-data-[collapsible=icon]:opacity-0 motion-reduce:transition-none">
184
+ {title}
185
+ </span>
186
+ ) : null}
187
+ </div>
148
188
  ) : null}
149
189
  <SidebarTrigger className="size-7 shrink-0 touch-manipulation" />
150
190
  {trailingInset}
151
191
  </div>
152
192
  )}
153
193
  </SidebarHeader>
154
- <SidebarContent className="shellui-nav gap-1">
194
+ <SidebarContent className="shellui-nav gap-0">
155
195
  <nav
156
196
  aria-label={t('shellChrome.mainNav')}
157
- className="flex min-w-0 flex-col gap-1"
197
+ className="flex min-w-0 flex-col gap-0.5 py-2"
158
198
  >
159
199
  <NavigationContent navigation={startNav} />
160
200
  </nav>
@@ -166,7 +206,7 @@ export function SidebarInner({
166
206
  {(endItems.length > 0 || showAuthButton) && (
167
207
  <nav
168
208
  aria-label={t('shellChrome.accountNav')}
169
- className="flex min-w-0 flex-col"
209
+ className="flex min-w-0 flex-col gap-0.5 pb-1"
170
210
  >
171
211
  <NavigationContent
172
212
  navigation={endItems}
@@ -36,11 +36,7 @@ import {
36
36
  import { useScrollHideChrome } from '../chrome/useScrollHideChrome';
37
37
  import { InsetMobileRadiusOverlay } from '../chrome/InsetMobileRadiusOverlay';
38
38
  import { useIsTauriClient, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
39
- import {
40
- MAC_LIGHTS_SAFE_PX,
41
- SHELL_HEADER_HEIGHT_PX,
42
- SHELL_HEADER_PAD_TOP_PX,
43
- } from '../chrome/constants';
39
+ import { MAC_LIGHTS_SAFE_PX, MOBILE_SIDEBAR_HEADER_HEIGHT_PX } from '../chrome/constants';
44
40
  import { WindowTitleBarActions } from '../../chromeActions';
45
41
  import { cn } from '../../../lib/utils';
46
42
 
@@ -106,6 +102,7 @@ const SidebarLayoutContent = ({
106
102
  const { chromeVisible } = useScrollHideChrome({
107
103
  enabled: isMobile,
108
104
  layout: scrollHideLayout,
105
+ barHeightPx: MOBILE_SIDEBAR_HEADER_HEIGHT_PX,
109
106
  includeSafeArea: showSafeAreaTopbar,
110
107
  });
111
108
  const contentRef = useRef<HTMLDivElement>(null);
@@ -158,6 +155,10 @@ const SidebarLayoutContent = ({
158
155
  };
159
156
  }, [authAwareNavigation, isMobile]);
160
157
 
158
+ const pageTitle = navigationItem
159
+ ? resolveLocalizedLabel(navigationItem.label, currentLanguage)
160
+ : title;
161
+
161
162
  useEffect(() => {
162
163
  if (!title) return;
163
164
  if (navigationItem) {
@@ -233,18 +234,16 @@ const SidebarLayoutContent = ({
233
234
  <header
234
235
  data-shellui-scroll-hide-header=""
235
236
  className={cn(
236
- 'pointer-events-auto relative z-[1] flex items-center gap-0.5 px-3 select-none',
237
+ 'pointer-events-auto relative z-[1] flex items-center gap-0.5 px-1.5 select-none',
237
238
  variant === 'inset'
238
239
  ? 'border-transparent bg-transparent text-sidebar-foreground'
239
240
  : 'border-b border-border bg-background',
240
241
  )}
241
242
  style={{
242
- paddingTop: showSafeAreaTopbar
243
- ? `calc(var(--shellui-safe-area-top) + ${SHELL_HEADER_PAD_TOP_PX}px)`
244
- : SHELL_HEADER_PAD_TOP_PX,
243
+ paddingTop: showSafeAreaTopbar ? 'var(--shellui-safe-area-top)' : 0,
245
244
  height: showSafeAreaTopbar
246
- ? `calc(${SHELL_HEADER_HEIGHT_PX}px + var(--shellui-safe-area-top))`
247
- : SHELL_HEADER_HEIGHT_PX,
245
+ ? `calc(${MOBILE_SIDEBAR_HEADER_HEIGHT_PX}px + var(--shellui-safe-area-top))`
246
+ : MOBILE_SIDEBAR_HEADER_HEIGHT_PX,
248
247
  ...(mobileTrafficInset !== undefined ? { paddingLeft: mobileTrafficInset } : {}),
249
248
  }}
250
249
  {...(trafficLights
@@ -253,7 +252,7 @@ const SidebarLayoutContent = ({
253
252
  >
254
253
  <SidebarTrigger
255
254
  data-shellui-no-drag=""
256
- className="relative size-8 shrink-0 touch-manipulation text-foreground"
255
+ className="relative size-10 shrink-0 touch-manipulation text-foreground [&_svg]:size-5"
257
256
  />
258
257
  {isTauriEnv ? <DesktopHistoryButtons /> : null}
259
258
  {isMobile ? (
@@ -261,9 +260,20 @@ const SidebarLayoutContent = ({
261
260
  data-shellui-no-drag=""
262
261
  className="flex min-w-0 flex-1 items-center"
263
262
  >
264
- <WindowTitleBarActions frameUuid={frameUuid} />
263
+ <WindowTitleBarActions
264
+ frameUuid={frameUuid}
265
+ fallbackTitle={pageTitle}
266
+ centerTitle
267
+ />
265
268
  </div>
266
269
  ) : null}
270
+ {/* Balances the trigger so the title sits in the middle. */}
271
+ {isMobile && !isTauriEnv ? (
272
+ <span
273
+ aria-hidden
274
+ className="size-10 shrink-0"
275
+ />
276
+ ) : null}
267
277
  </header>
268
278
  {variant === 'inset' ? <InsetMobileRadiusOverlay /> : null}
269
279
  </div>
@@ -30,7 +30,9 @@ import { cn } from '../../../lib/utils';
30
30
  import { Z_INDEX } from '../../../lib/z-index';
31
31
  import { LoginButton } from '../../auth/components/LoginButton';
32
32
  import { useAuth } from '../../auth/hooks/useAuth';
33
- import { ExternalLinkIcon, NavIcon } from '../sidebar/SidebarIcons';
33
+ import { ExternalLinkIcon, NavIcon, SettingsIcon } from '../sidebar/SidebarIcons';
34
+ import { AppBarTooltip, TooltipProvider } from '../../../components/ui/tooltip';
35
+ import urls from '../../../constants/urls';
34
36
  import { getExternalFaviconUrl, isAppIcon } from '../sidebar/sidebarUtils';
35
37
  import { AppBrandIcon } from '../branding/AppBrandIcon';
36
38
  import { useIsMobile } from '../../../hooks/use-mobile';
@@ -934,12 +936,16 @@ export function WindowsLayout({ title, appIcon, logo: _logo, navigation }: Windo
934
936
  useEffect(() => {
935
937
  if (!startMenuOpen) return;
936
938
  const onDocClick = (e: MouseEvent) => {
939
+ // The footer account menu renders in a portal: clicks there stay in the start menu.
940
+ if (e.target instanceof Element && e.target.closest('[data-auth-menu-content]')) return;
937
941
  if (startPanelRef.current && !startPanelRef.current.contains(e.target as Node)) {
938
942
  setStartMenuOpen(false);
939
943
  }
940
944
  };
941
945
  const onKeyDown = (e: KeyboardEvent) => {
942
946
  if (e.key !== 'Escape') return;
947
+ // Escape closes the open account menu first.
948
+ if (document.querySelector('[data-auth-menu-content][data-state="open"]')) return;
943
949
  e.preventDefault();
944
950
  setStartMenuOpen(false);
945
951
  startButtonRef.current?.focus();
@@ -1002,7 +1008,7 @@ export function WindowsLayout({ title, appIcon, logo: _logo, navigation }: Windo
1002
1008
  className="fixed inset-0 overflow-hidden bg-background"
1003
1009
  style={{ paddingBottom: TASKBAR_SLOT_CSS }}
1004
1010
  >
1005
- {/* Desktop: two low primary washes at the bottom, under the calm dot field. */}
1011
+ {/* Desktop: two low primary washes at the bottom, under the dot field. */}
1006
1012
  <div
1007
1013
  aria-hidden
1008
1014
  className="shellui-desk-wash pointer-events-none absolute inset-0"
@@ -1154,10 +1160,7 @@ export function WindowsLayout({ title, appIcon, logo: _logo, navigation }: Windo
1154
1160
  className={cn('space-y-1.5', isEndSection && 'shellui-start-foot pt-3')}
1155
1161
  >
1156
1162
  {categoryLabel ? (
1157
- <h2
1158
- className="px-2.5 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground"
1159
- style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
1160
- >
1163
+ <h2 className="shellui-start-label px-2.5 text-xs font-semibold text-muted-foreground">
1161
1164
  {categoryLabel}
1162
1165
  </h2>
1163
1166
  ) : null}
@@ -1215,6 +1218,30 @@ export function WindowsLayout({ title, appIcon, logo: _logo, navigation }: Windo
1215
1218
  })
1216
1219
  )}
1217
1220
  </div>
1221
+ {/* Footer: account and settings (spec). */}
1222
+ <div
1223
+ data-shellui-start-footer=""
1224
+ className="shellui-start-foot flex shrink-0 items-center gap-1 px-2 py-1.5"
1225
+ >
1226
+ <div className="min-w-0 flex-1">
1227
+ <LoginButton
1228
+ variant="sidebar"
1229
+ hideWhenLoggedOut={hasCustomLoginNav}
1230
+ />
1231
+ </div>
1232
+ <button
1233
+ type="button"
1234
+ className="shellui-start-settings shellui-chrome-focus"
1235
+ aria-label={t('settings')}
1236
+ title={t('settings')}
1237
+ onClick={() => {
1238
+ setStartMenuOpen(false);
1239
+ shellui.openModal(urls.settings);
1240
+ }}
1241
+ >
1242
+ <SettingsIcon className="size-4" />
1243
+ </button>
1244
+ </div>
1218
1245
  </div>
1219
1246
  )}
1220
1247
  </div>
@@ -1270,44 +1297,48 @@ export function WindowsLayout({ title, appIcon, logo: _logo, navigation }: Windo
1270
1297
 
1271
1298
  {/* End navigation items (right side of taskbar) — desktop only; phone uses start menu */}
1272
1299
  {!phoneMode && endNavItems.length > 0 && (
1273
- <div className="flex items-center gap-0.5 shrink-0 border-l border-sidebar-border pl-2 ml-1">
1274
- {endNavItems.map((item) => {
1275
- const label =
1276
- typeof item.label === 'string'
1277
- ? item.label
1278
- : resolveNavLabel(item.label, currentLanguage);
1279
- const icon =
1280
- item.icon ?? (item.openIn === 'external' ? getExternalFaviconUrl(item.url) : null);
1281
- return (
1282
- <button
1283
- key={item.path}
1284
- type="button"
1285
- onClick={() => handleNavClick(item)}
1286
- className="shellui-task shellui-chrome-focus"
1287
- title={label}
1288
- aria-label={
1289
- item.openIn === 'external'
1290
- ? `${label} (${t('shellChrome.externalLink')})`
1291
- : label
1292
- }
1293
- >
1294
- {icon ? (
1295
- <img
1296
- src={icon}
1297
- alt=""
1298
- className={cn(
1299
- 'h-4 w-4 shrink-0 rounded-sm object-cover',
1300
- isAppIcon(icon) && 'opacity-90 dark:opacity-100 dark:invert',
1301
- )}
1302
- />
1303
- ) : (
1304
- <span className="h-4 w-4 shrink-0 rounded-sm bg-muted" />
1305
- )}
1306
- <span className="truncate max-w-[100px]">{label}</span>
1307
- </button>
1308
- );
1309
- })}
1310
- </div>
1300
+ <TooltipProvider
1301
+ delayDuration={200}
1302
+ skipDelayDuration={0}
1303
+ >
1304
+ <div
1305
+ data-shellui-taskbar-end=""
1306
+ className="ml-1 flex shrink-0 items-center gap-0.5 border-l border-sidebar-border pl-2"
1307
+ >
1308
+ {endNavItems.map((item) => {
1309
+ const label =
1310
+ typeof item.label === 'string'
1311
+ ? item.label
1312
+ : resolveNavLabel(item.label, currentLanguage);
1313
+ const icon =
1314
+ item.icon ??
1315
+ (item.openIn === 'external' ? getExternalFaviconUrl(item.url) : null);
1316
+ return (
1317
+ <AppBarTooltip
1318
+ key={item.path}
1319
+ label={label}
1320
+ side="top"
1321
+ >
1322
+ <button
1323
+ type="button"
1324
+ onClick={() => handleNavClick(item)}
1325
+ className="shellui-task shellui-task-icon shellui-chrome-focus"
1326
+ aria-label={
1327
+ item.openIn === 'external'
1328
+ ? `${label} (${t('shellChrome.externalLink')})`
1329
+ : label
1330
+ }
1331
+ >
1332
+ <NavIcon
1333
+ src={icon}
1334
+ className="size-4"
1335
+ />
1336
+ </button>
1337
+ </AppBarTooltip>
1338
+ );
1339
+ })}
1340
+ </div>
1341
+ </TooltipProvider>
1311
1342
  )}
1312
1343
 
1313
1344
  <div className="flex items-center shrink-0 border-l border-sidebar-border pl-2 ml-1">
@@ -4,12 +4,14 @@ import { DESK_DOTS, bucketAlpha, gridSize, isAccentDot } from './deskDots';
4
4
  import { isDesktopCovered } from './DesktopDots';
5
5
 
6
6
  describe('DESK_DOTS', () => {
7
- it('keeps the calm parameters from the spec', () => {
7
+ it('runs at the website normal speed, capped at 30 fps', () => {
8
8
  expect(DESK_DOTS.fps).toBe(30);
9
9
  expect(DESK_DOTS.dprMax).toBe(2);
10
- expect(DESK_DOTS.gustPx).toBe(3.5);
11
- expect(DESK_DOTS.crossMs).toEqual([30000, 40000]);
12
- expect(DESK_DOTS.everyMs).toEqual([9000, 15000]);
10
+ expect(DESK_DOTS.gustPx).toBe(7);
11
+ expect(DESK_DOTS.frontWidth).toBe(70);
12
+ expect(DESK_DOTS.crossMs).toEqual([6700, 10000]);
13
+ expect(DESK_DOTS.everyMs).toEqual([1000, 3000]);
14
+ expect([DESK_DOTS.spring, DESK_DOTS.damp]).toEqual([0.06, 0.82]);
13
15
  });
14
16
  });
15
17
 
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Windows layout desktop: calm dot field on a canvas.
2
+ * Windows layout desktop: dot field on a canvas.
3
3
  * Ported from the layouts redesign reference (`desk-dots.js`), itself derived from
4
- * the shellui.com hero dots: three to four times slower, half the travel, no pointer play.
4
+ * the shellui.com hero dots at the website's normal speed and travel, no pointer play.
5
5
  * Decorative only. The caller mounts it on an `aria-hidden` host.
6
6
  */
7
7
  export const DESK_DOTS = {
@@ -20,17 +20,17 @@ export const DESK_DOTS = {
20
20
  /** Extra alpha at full displacement. */
21
21
  gustLift: 0.16,
22
22
  /** Max displacement in px. */
23
- gustPx: 3.5,
23
+ gustPx: 7,
24
24
  /** Width of a wind front in px. */
25
- frontWidth: 170,
25
+ frontWidth: 70,
26
26
  /** Front slant in degrees. */
27
27
  slantDeg: 18,
28
28
  /** Time for one front to cross the desktop, ms range. */
29
- crossMs: [30000, 40000] as const,
29
+ crossMs: [6700, 10000] as const,
30
30
  /** Gap between fronts, ms range. */
31
- everyMs: [9000, 15000] as const,
32
- spring: 0.035,
33
- damp: 0.88,
31
+ everyMs: [1000, 3000] as const,
32
+ spring: 0.06,
33
+ damp: 0.82,
34
34
  /** Frame cap. */
35
35
  fps: 30,
36
36
  /** Device pixel ratio cap. */
@@ -11,6 +11,7 @@ import {
11
11
  import { Dialog, DialogContent, DialogDescription, DialogTitle } from '../../components/ui/dialog';
12
12
  import { cn } from '../../lib/utils';
13
13
  import { sheetExpandedHeightPx } from './overlaySize';
14
+ import { readDrawerBottomOffset } from '../layouts/chrome/viewport';
14
15
 
15
16
  export type ResponsiveModalPresentation = 'dialog' | 'sheet';
16
17
 
@@ -452,7 +453,8 @@ export function ResponsiveModal({
452
453
  (rawDelta >= SWIPE_DISMISS_PX || rawDelta >= height * SWIPE_DISMISS_RATIO);
453
454
  if (shouldDismiss) {
454
455
  setDismissMode('swipe');
455
- setSheetDragOffset(Math.max(rawDelta, height));
456
+ // Past the bottom offset and shadow so no strip stays on screen
457
+ setSheetDragOffset(Math.max(rawDelta, height + readDrawerBottomOffset() + 48));
456
458
  setSheetDragHeight(null);
457
459
  onOpenChange(false);
458
460
  return;
@@ -570,7 +572,7 @@ export function ResponsiveModal({
570
572
  className={cn(
571
573
  'gap-0 p-0 overflow-hidden flex flex-col',
572
574
  isSheet
573
- ? 'left-0 right-0 top-auto bottom-0 max-w-none w-full translate-x-0 translate-y-0 rounded-t-xl rounded-b-none border-x-0 border-b-0 pb-[var(--shellui-safe-area-bottom)]'
575
+ ? 'left-[var(--shellui-drawer-left)] right-[var(--shellui-drawer-right)] top-auto bottom-[var(--shellui-drawer-bottom)] max-w-none w-auto translate-x-0 translate-y-0 rounded-[var(--shellui-sheet-radius)] border border-[var(--shellui-drawer-border)] shadow-[var(--shellui-drawer-shadow)]'
574
576
  : cn('rounded-lg', hasCustomGeometry && 'translate-x-0 translate-y-0 max-w-none'),
575
577
  className,
576
578
  )}
@@ -647,7 +649,7 @@ export function ResponsiveModal({
647
649
  >
648
650
  {/* Centered tall hit target only — rest of the strip is click-through */}
649
651
  <div
650
- className="pointer-events-auto relative h-11 w-28 shrink-0 cursor-grab touch-none active:cursor-grabbing after:absolute after:left-1/2 after:top-1.5 after:h-[3px] after:w-8 after:-translate-x-1/2 after:rounded-full after:bg-muted-foreground/70 after:content-['']"
652
+ className="pointer-events-auto relative h-11 w-28 shrink-0 cursor-grab touch-none active:cursor-grabbing after:absolute after:left-1/2 after:top-1.5 after:h-[5px] after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-[color-mix(in_oklch,var(--foreground)_22%,transparent)] after:content-['']"
651
653
  onPointerDown={handleSheetPointerDown}
652
654
  onPointerMove={handleSheetPointerMove}
653
655
  onPointerUp={handleSheetPointerUp}
@@ -9,7 +9,7 @@ import {
9
9
  resolveDrawerSize,
10
10
  resolveDrawerSizeForViewport,
11
11
  resolveEffectiveDrawerPosition,
12
- sheetExpandedSnapFraction,
12
+ sheetExpandedHeightPx,
13
13
  SHEET_EXPANDED_TOP_GAP_PX,
14
14
  toCssLength,
15
15
  } from './overlaySize';
@@ -69,18 +69,32 @@ describe('overlaySize', () => {
69
69
  expect(resolveEffectiveDrawerPosition('right', false)).toBe('right');
70
70
  });
71
71
 
72
- it('remaps horizontal freeform size to default height on mobile', () => {
72
+ it('sizes phone sheets to content, keeping the requested height as fallback', () => {
73
73
  const desktop = resolveDrawerSizeForViewport({ size: '60vw' }, 'right', false);
74
74
  expect(desktop.drawerSize).toBe('60vw');
75
+ expect(desktop.contentSized).toBe(false);
75
76
 
77
+ const cap = 'var(--shellui-drawer-max-height)';
76
78
  const mobile = resolveDrawerSizeForViewport({ size: '60vw' }, 'right', true);
77
- expect(mobile.drawerSize).toBe('calc(var(--shellui-overlay-max-height) * 0.8)');
79
+ expect(mobile.contentSized).toBe(true);
80
+ expect(mobile.drawerSize).toBeNull();
81
+ expect(mobile.style.height).toBe('auto');
82
+ expect(mobile.style.maxHeight).toBe(cap);
83
+ // Horizontal freeform width never becomes a sheet height
84
+ expect(mobile.fallbackHeight).toBe(
85
+ `min(calc(var(--shellui-overlay-max-height) * 0.8), ${cap})`,
86
+ );
78
87
 
79
88
  const preset = resolveDrawerSizeForViewport({ size: 'md' }, 'right', true);
80
- expect(preset.drawerSize).toBe('calc(var(--shellui-overlay-max-height) * 0.55)');
89
+ expect(preset.fallbackHeight).toBe(
90
+ `min(calc(var(--shellui-overlay-max-height) * 0.55), ${cap})`,
91
+ );
81
92
 
82
93
  const fromTop = resolveDrawerSizeForViewport({ size: '60vh' }, 'top', true);
83
- expect(fromTop.drawerSize).toBe('60vh');
94
+ expect(fromTop.fallbackHeight).toBe(`min(60vh, ${cap})`);
95
+
96
+ const content = resolveDrawerSizeForViewport({ size: 'content' }, 'left', true);
97
+ expect(content.fallbackHeight).toBeNull();
84
98
  });
85
99
 
86
100
  it('defaults dismiss options', () => {
@@ -99,17 +113,43 @@ describe('overlaySize', () => {
99
113
  });
100
114
 
101
115
  it('resolves bottom sheet snap points for expand / collapse', () => {
102
- // viewport 1000, no safe-area → expanded = 1000 - 60
103
- const expanded = sheetExpandedSnapFraction(1000, 0);
104
- expect(expanded).toBe(Number(((1000 - SHEET_EXPANDED_TOP_GAP_PX) / 1000).toFixed(4)));
105
- expect(resolveBottomSheetSnapPoints({ size: 'md' }, null, 1000, 0)).toEqual([0.55, expanded]);
106
- expect(resolveBottomSheetSnapPoints(null, null, 1000, 0)).toEqual([0.8, expanded]);
107
- expect(resolveBottomSheetSnapPoints({ size: '400px' }, null, 1000, 0)).toEqual([0.4, expanded]);
108
- expect(resolveBottomSheetSnapPoints({ size: 'full' }, null, 1000, 0)).toBeNull();
109
- expect(resolveBottomSheetSnapPoints({ size: 'sm' }, 700, 1000, 0)).toEqual([0.7, expanded]);
110
- // With notch inset, expanded shrinks further
111
- expect(sheetExpandedSnapFraction(1000, 47)).toBe(
112
- Number(((1000 - 47 - SHEET_EXPANDED_TOP_GAP_PX) / 1000).toFixed(4)),
116
+ // viewport 1000, no safe area, 8px bottom gap → sheet 932px, Vaul offset 68px
117
+ expect(sheetExpandedHeightPx(1000, 0, 8)).toBe(1000 - SHEET_EXPANDED_TOP_GAP_PX - 8);
118
+ expect(resolveBottomSheetSnapPoints({ size: 'md' }, null, 1000, 0, 8)).toEqual([0.618, 1]);
119
+ expect(resolveBottomSheetSnapPoints(null, null, 1000, 0, 8)).toEqual([0.868, 1]);
120
+ expect(resolveBottomSheetSnapPoints({ size: '400px' }, null, 1000, 0, 8)).toEqual([0.468, 1]);
121
+ expect(resolveBottomSheetSnapPoints({ size: 'full' }, null, 1000, 0, 8)).toBeNull();
122
+ expect(resolveBottomSheetSnapPoints({ size: 'sm' }, 700, 1000, 0, 8)).toEqual([0.768, 1]);
123
+ // Content close to the expanded height: nothing to expand to
124
+ expect(resolveBottomSheetSnapPoints({ size: 'sm' }, 920, 1000, 0, 8)).toBeNull();
125
+ });
126
+
127
+ it('keeps the expanded phone sheet on screen (390 x 844, notch)', () => {
128
+ const H = 844;
129
+ const safeTop = 47;
130
+ const bottom = 8 + 34; // gap + home indicator
131
+ const h = sheetExpandedHeightPx(H, safeTop, bottom);
132
+ expect(h).toBe(695);
133
+ const snaps = resolveBottomSheetSnapPoints({ size: 'md' }, null, H, safeTop, bottom);
134
+ expect(snaps).not.toBeNull();
135
+ const [normal, expanded] = snaps ?? [0, 0];
136
+ // Expanded snap = no translate: top at 60px + safe area, bottom 8px above the indicator
137
+ expect(expanded).toBe(1);
138
+ const sheetTop = H - bottom - h;
139
+ const translate = (snap: number) => H - snap * H;
140
+ expect(sheetTop + translate(expanded)).toBe(SHEET_EXPANDED_TOP_GAP_PX + safeTop);
141
+ expect(sheetTop + translate(expanded) + h).toBe(H - bottom);
142
+ // First snap still shows the requested height (55%) above the bottom offset
143
+ const visibleAboveGap = H - bottom - (sheetTop + translate(normal));
144
+ expect(Math.abs(visibleAboveGap - 0.55 * H)).toBeLessThan(1);
145
+ });
146
+
147
+ it('leaves the drawer gap around full drawers', () => {
148
+ expect(resolveDrawerSize({ size: 'full' }, 'right').drawerSize).toBe(
149
+ 'calc(100% - 2 * var(--shellui-drawer-gap))',
150
+ );
151
+ expect(resolveDrawerSize({ size: 'full' }, 'top').drawerSize).toBe(
152
+ 'var(--shellui-drawer-max-height)',
113
153
  );
114
154
  });
115
155
  });