@justanarthur/modo-ui 2.7.0 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -92,6 +92,46 @@ With `titleBar="card"` nothing runs across the window: the traffic lights and th
92
92
  </div>
93
93
  </div>
94
94
 
95
+ # Folded sidebar
96
+
97
+ The sidebar starts folded. Hover the window's left edge or the sidebar toggle and it peeks: it slides in over the main card, which doesn't move, and folds back a beat after the pointer leaves; focus inside keeps it open. Click the toggle to pin it. The traffic lights, the toggle and the title share one centre line; `peek={false}` turns the peek off.
98
+
99
+ <div className="w-full overflow-x-auto">
100
+ <div className="h-[560px] w-[960px] overflow-hidden rounded-xl border border-border">
101
+ <DesktopShell
102
+ showControls
103
+ titleBar="card"
104
+ defaultLeftOpen={false}
105
+ title={<span className="truncate text-body weight-medium text-foreground">Businesses</span>}
106
+ trailing={
107
+ <Button variant="ghost" size="icon-compact" aria-label="Search">
108
+ <Search />
109
+ </Button>
110
+ }
111
+ left={
112
+ <Sidebar variant="inset" defaultValue="inbox">
113
+ <Sidebar.Content>
114
+ <Sidebar.Group>
115
+ <Sidebar.GroupLabel>Library</Sidebar.GroupLabel>
116
+ <Sidebar.Menu>
117
+ <Sidebar.MenuItem><Sidebar.MenuButton icon={Inbox} value="inbox">Inbox</Sidebar.MenuButton></Sidebar.MenuItem>
118
+ <Sidebar.MenuItem><Sidebar.MenuButton icon={Star} value="starred">Starred</Sidebar.MenuButton></Sidebar.MenuItem>
119
+ <Sidebar.MenuItem><Sidebar.MenuButton icon={Folder} value="projects">Projects</Sidebar.MenuButton></Sidebar.MenuItem>
120
+ </Sidebar.Menu>
121
+ </Sidebar.Group>
122
+ </Sidebar.Content>
123
+ </Sidebar>
124
+ }
125
+ main={
126
+ <div className="flex flex-1 flex-col gap-2 p-6">
127
+ <span className="text-title text-foreground">Businesses</span>
128
+ <span className="text-body text-muted-foreground">The peek floats over this card instead of pushing it aside.</span>
129
+ </div>
130
+ }
131
+ />
132
+ </div>
133
+ </div>
134
+
95
135
  # Windows and Linux
96
136
 
97
137
  Off macOS the title bar starts at the edge; the stand-in window controls sit at its end. Here the side pane starts folded and there is no left sidebar.
@@ -6,7 +6,17 @@
6
6
 
7
7
  'use client'
8
8
 
9
- import { type ReactNode, useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react'
9
+ import {
10
+ type FocusEvent,
11
+ type PointerEvent,
12
+ type ReactNode,
13
+ useCallback,
14
+ useEffect,
15
+ useLayoutEffect,
16
+ useMemo,
17
+ useRef,
18
+ useState,
19
+ } from 'react'
10
20
  import Button from '../../components/actions/button'
11
21
  import Sidebar from '../../components/navigation/sidebar'
12
22
  import { useSidebarShortcut } from '../../components/navigation/sidebar/sidebar-shortcut'
@@ -41,6 +51,25 @@ const CORNER_ROOM: Record<DesktopPlatform, string> = {
41
51
  linux: 'w-6 shrink-0',
42
52
  }
43
53
 
54
+ // While it peeks, the folded sidebar floats over the main card, on the card's own 8px inset, instead of reflowing it.
55
+ // The panel's side padding is that inset; it also leaves the shadow room inside the sidebar's clip.
56
+ const PEEK_OVERLAY =
57
+ '[&>[data-slot=sidebar]]:absolute [&>[data-slot=sidebar]]:inset-y-0 [&>[data-slot=sidebar]]:left-0 [&>[data-slot=sidebar]]:z-10 [&>[data-slot=sidebar]>div]:px-2 [&>[data-slot=sidebar]_[data-sidebar=sidebar]]:shadow-surface-3'
58
+ const PEEK_BG: Record<number, string> = {
59
+ 4: '[&>[data-slot=sidebar]_[data-sidebar=sidebar]]:bg-surface-4',
60
+ 5: '[&>[data-slot=sidebar]_[data-sidebar=sidebar]]:bg-surface-5',
61
+ 6: '[&>[data-slot=sidebar]_[data-sidebar=sidebar]]:bg-surface-6',
62
+ 7: '[&>[data-slot=sidebar]_[data-sidebar=sidebar]]:bg-surface-7',
63
+ 8: '[&>[data-slot=sidebar]_[data-sidebar=sidebar]]:bg-surface-8',
64
+ }
65
+ const PEEK_RADIUS = {
66
+ rounded: '[&>[data-slot=sidebar]_[data-sidebar=sidebar]]:rounded-xl',
67
+ pill: '[&>[data-slot=sidebar]_[data-sidebar=sidebar]]:rounded-3xl',
68
+ }
69
+
70
+ // The peek folds back this long after the pointer leaves, like Sidebar's open on hover.
71
+ const PEEK_CLOSE_MS = 300
72
+
44
73
  // Below this window width the side pane takes the main card's place.
45
74
  const NARROW = 768
46
75
 
@@ -71,6 +100,8 @@ interface DesktopShellProps {
71
100
  defaultLeftOpen?: boolean
72
101
  /** Called when the left sidebar opens or folds. */
73
102
  onLeftOpenChange?: (open: boolean) => void
103
+ /** While the left sidebar is folded, hovering the window's left edge or the sidebar toggle slides it in over the main card without reflowing it; it folds back a beat after the pointer leaves, and stays while focus is inside it. Defaults to `true`. */
104
+ peek?: boolean
74
105
  /** Controlled open state of the side pane. */
75
106
  rightOpen?: boolean
76
107
  /** The side pane's open state at first. Defaults to `true`. */
@@ -148,6 +179,64 @@ function WindowControls() {
148
179
  )
149
180
  }
150
181
 
182
+ /**
183
+ * The folded sidebar's peek. Zones (`data-peek`) are the edge strip, the
184
+ * toggle, the corner and the sidebar: entering an opening one (the strip,
185
+ * the toggle) with a mouse peeks; leaving for anything that isn't a zone
186
+ * folds it back after `PEEK_CLOSE_MS`, unless focus is inside the sidebar.
187
+ */
188
+ function usePeek(enabled: boolean) {
189
+ const [open, setOpen] = useState(false)
190
+ // The last opening was a peek: the sidebar stays out of flow until it is pinned, so folding back never reflows the card.
191
+ const [overlay, setOverlay] = useState(false)
192
+ const sidebar = useRef<HTMLDivElement | null>(null)
193
+ const over = useRef(false)
194
+ const timer = useRef<ReturnType<typeof setTimeout>>()
195
+
196
+ useEffect(() => {
197
+ if (enabled) return
198
+ clearTimeout(timer.current)
199
+ setOpen(false)
200
+ setOverlay(false)
201
+ }, [enabled])
202
+ useEffect(() => () => clearTimeout(timer.current), [])
203
+
204
+ const close = () => {
205
+ clearTimeout(timer.current)
206
+ timer.current = setTimeout(() => {
207
+ if (!over.current && !sidebar.current?.contains(document.activeElement)) setOpen(false)
208
+ }, PEEK_CLOSE_MS)
209
+ }
210
+ const zone = (opens: boolean) => ({
211
+ 'data-peek': '',
212
+ onPointerEnter: (event: PointerEvent) => {
213
+ over.current = true
214
+ clearTimeout(timer.current)
215
+ if (!opens || !enabled || event.pointerType !== 'mouse') return
216
+ setOpen(true)
217
+ setOverlay(true)
218
+ },
219
+ onPointerLeave: (event: PointerEvent) => {
220
+ if (event.relatedTarget instanceof Element && event.relatedTarget.closest('[data-peek]')) return
221
+ over.current = false
222
+ close()
223
+ },
224
+ })
225
+ const onBlur = (event: FocusEvent) => {
226
+ if (!(event.relatedTarget instanceof Node && event.currentTarget.contains(event.relatedTarget))) close()
227
+ }
228
+
229
+ return {
230
+ enabled,
231
+ open: enabled && open,
232
+ overlay: enabled && overlay,
233
+ dismiss: () => setOpen(false),
234
+ sidebar,
235
+ zone,
236
+ onBlur,
237
+ }
238
+ }
239
+
151
240
  /** The main region: an inset card two surface levels up, like Sidebar.Inset. */
152
241
  function MainCard({ children }: { children: ReactNode }) {
153
242
  const level = useLift(2)
@@ -183,7 +272,18 @@ function MainCard({ children }: { children: ReactNode }) {
183
272
  * sidebar's content starts below them), and the title, `trailing` and the
184
273
  * side pane toggle head the main card, which drags the window too. With the
185
274
  * sidebar folded, the corner controls stay put and the card's header makes
186
- * room for them.
275
+ * room for them. The corner sits on the card's 8px inset, so the window
276
+ * controls, the toggle and the title share one centre line, 26px from the
277
+ * window's top (22px compact). A native macOS window must put its traffic
278
+ * lights on that line too: with an overlay title bar, set the window's traffic
279
+ * light position (Tauri's `trafficLightPosition`) so they centre there,
280
+ * inside the 72px the corner keeps for them.
281
+ *
282
+ * While the sidebar is folded, hovering the window's left edge or the sidebar
283
+ * toggle peeks it: it slides in over the main card as a card of its own,
284
+ * without reflowing it, stays while the pointer is over it or focus is inside
285
+ * it, and folds back a beat after the pointer leaves. Clicking the toggle
286
+ * pins it open. `peek={false}` turns it off.
187
287
  *
188
288
  * Under it, the main content is an inset card. The left Sidebar is yours
189
289
  * (`left`): it resizes from its rail and folds from its toggle, its rail or
@@ -211,6 +311,7 @@ export default function DesktopShell({
211
311
  leftOpen: leftOpenProp,
212
312
  defaultLeftOpen = true,
213
313
  onLeftOpenChange,
314
+ peek = true,
214
315
  rightOpen: rightOpenProp,
215
316
  defaultRightOpen = true,
216
317
  onRightOpenChange,
@@ -229,6 +330,10 @@ export default function DesktopShell({
229
330
  const hasRight = right !== undefined
230
331
  const paneOpen = hasRight && rightOpen
231
332
  const inCard = titleBar === 'card'
333
+ const shape = useShape()
334
+ const substrate = useLift(0)
335
+ const peekLevel = useLift(3)
336
+ const peeking = usePeek(peek && hasLeft && !leftOpen)
232
337
  const paneSizes = useMemo(() => (paneOpen ? [100 - paneSize, paneSize] : [100, 0]), [paneOpen, paneSize])
233
338
 
234
339
  // The window's own width, not the viewport's: a framed or resized window doesn't follow the viewport.
@@ -259,7 +364,11 @@ export default function DesktopShell({
259
364
  {showControls && <TrafficLights />}
260
365
  </div>
261
366
  )}
262
- {hasLeft && <Toggle side="left" label={leftLabel} open={leftOpen} onClick={() => setLeftOpen(!leftOpen)} />}
367
+ {hasLeft && (
368
+ <span className="contents" {...peeking.zone(true)}>
369
+ <Toggle side="left" label={leftLabel} open={leftOpen} onClick={() => setLeftOpen(!leftOpen)} />
370
+ </span>
371
+ )}
263
372
  {leading}
264
373
  </>
265
374
  )
@@ -294,7 +403,8 @@ export default function DesktopShell({
294
403
  <div ref={root} className={cn('relative flex h-full w-full flex-col bg-background', className)}>
295
404
  <SizeProvider size={size.variant}>
296
405
  {inCard ? (
297
- <div data-tauri-drag-region className={cn(bar, 'absolute top-0 left-0 z-20')}>
406
+ // On the card's 8px inset, so the corner and the card's header share one centre line.
407
+ <div data-tauri-drag-region className={cn(bar, 'absolute top-2 left-0 z-20')} {...peeking.zone(false)}>
298
408
  {corner}
299
409
  </div>
300
410
  ) : (
@@ -306,14 +416,37 @@ export default function DesktopShell({
306
416
  </SizeProvider>
307
417
  {/* Sidebar defaults to the viewport's height; under the title bar it takes the body's. */}
308
418
  <Sidebar.Provider
309
- className={cn('min-h-0 flex-1 [&>[data-slot=sidebar]]:h-full', inCard && CORNER_CLEARANCE[size.variant])}
419
+ className="min-h-0 flex-1"
310
420
  persist={false}
311
421
  mobileBreakpoint={0}
312
422
  shortcut={hasLeft ? undefined : null}
313
- open={leftOpen}
314
- onOpenChange={setLeftOpen}
423
+ open={leftOpen || peeking.open}
424
+ onOpenChange={open => {
425
+ // `[` or the rail folds a peek; only the toggle pins it.
426
+ if (!open) peeking.dismiss()
427
+ setLeftOpen(open)
428
+ }}
315
429
  >
316
- {left}
430
+ {peeking.enabled && <div className="absolute inset-y-0 left-0 z-10 w-2" {...peeking.zone(true)} />}
431
+ <SurfaceProvider value={peeking.overlay ? peekLevel : substrate}>
432
+ {/* biome-ignore lint/a11y/noStaticElementInteractions: it only watches focus leaving the sidebar; the controls inside are the focusable ones. */}
433
+ <div
434
+ ref={peeking.sidebar}
435
+ className={cn(
436
+ 'contents [&>[data-slot=sidebar]]:h-full',
437
+ inCard && CORNER_CLEARANCE[size.variant],
438
+ peeking.overlay && [
439
+ PEEK_OVERLAY,
440
+ PEEK_BG[peekLevel],
441
+ PEEK_RADIUS[shape.bgRadius >= 20 ? 'pill' : 'rounded'],
442
+ ],
443
+ )}
444
+ onBlur={peeking.onBlur}
445
+ {...peeking.zone(false)}
446
+ >
447
+ {left}
448
+ </div>
449
+ </SurfaceProvider>
317
450
  {/* Flush with an open sidebar (its rows bring their own gutter), 8px from the window edge once it folds. */}
318
451
  <div
319
452
  className={cn(
@@ -31,6 +31,8 @@ interface DesktopShellProps {
31
31
  defaultLeftOpen?: boolean;
32
32
  /** Called when the left sidebar opens or folds. */
33
33
  onLeftOpenChange?: (open: boolean) => void;
34
+ /** While the left sidebar is folded, hovering the window's left edge or the sidebar toggle slides it in over the main card without reflowing it; it folds back a beat after the pointer leaves, and stays while focus is inside it. Defaults to `true`. */
35
+ peek?: boolean;
34
36
  /** Controlled open state of the side pane. */
35
37
  rightOpen?: boolean;
36
38
  /** The side pane's open state at first. Defaults to `true`. */
@@ -66,7 +68,18 @@ type Element_12xgc = JSX_1kxb["Element"];
66
68
  * sidebar's content starts below them), and the title, `trailing` and the
67
69
  * side pane toggle head the main card, which drags the window too. With the
68
70
  * sidebar folded, the corner controls stay put and the card's header makes
69
- * room for them.
71
+ * room for them. The corner sits on the card's 8px inset, so the window
72
+ * controls, the toggle and the title share one centre line, 26px from the
73
+ * window's top (22px compact). A native macOS window must put its traffic
74
+ * lights on that line too: with an overlay title bar, set the window's traffic
75
+ * light position (Tauri's `trafficLightPosition`) so they centre there,
76
+ * inside the 72px the corner keeps for them.
77
+ *
78
+ * While the sidebar is folded, hovering the window's left edge or the sidebar
79
+ * toggle peeks it: it slides in over the main card as a card of its own,
80
+ * without reflowing it, stays while the pointer is over it or focus is inside
81
+ * it, and folds back a beat after the pointer leaves. Clicking the toggle
82
+ * pins it open. `peek={false}` turns it off.
70
83
  *
71
84
  * Under it, the main content is an inset card. The left Sidebar is yours
72
85
  * (`left`): it resizes from its rail and folds from its toggle, its rail or
@@ -80,5 +93,5 @@ type Element_12xgc = JSX_1kxb["Element"];
80
93
  *
81
94
  * @example {@include ./examples.mdx}
82
95
  */
83
- declare function DesktopShell({ platform, showControls, titleBar, size: sizeProp, title, leading, trailing, left, right, main, leftOpen: leftOpenProp, defaultLeftOpen, onLeftOpenChange, rightOpen: rightOpenProp, defaultRightOpen, onRightOpenChange, defaultPaneSize, minPaneSize, maxPaneSize, leftLabel, rightLabel, className }: DesktopShellProps): Element_12xgc;
96
+ declare function DesktopShell({ platform, showControls, titleBar, size: sizeProp, title, leading, trailing, left, right, main, leftOpen: leftOpenProp, defaultLeftOpen, onLeftOpenChange, peek, rightOpen: rightOpenProp, defaultRightOpen, onRightOpenChange, defaultPaneSize, minPaneSize, maxPaneSize, leftLabel, rightLabel, className }: DesktopShellProps): Element_12xgc;
84
97
  export { DesktopPlatform, DesktopShell, DesktopShellProps, DesktopTitleBar, DesktopShell as default };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DesktopShell2
3
- } from "../../shared/components-4dk61qbj.js";
3
+ } from "../../shared/components-fcgk55r4.js";
4
4
  import"../../shared/components-mpeg6ca5.js";
5
5
  import"../../shared/components-2myjk2zf.js";
6
6
  import"../../shared/components-8wp8d8q1.js";
package/dist/index.d.ts CHANGED
@@ -121,6 +121,8 @@ interface DesktopShellProps {
121
121
  defaultLeftOpen?: boolean;
122
122
  /** Called when the left sidebar opens or folds. */
123
123
  onLeftOpenChange?: (open: boolean) => void;
124
+ /** While the left sidebar is folded, hovering the window's left edge or the sidebar toggle slides it in over the main card without reflowing it; it folds back a beat after the pointer leaves, and stays while focus is inside it. Defaults to `true`. */
125
+ peek?: boolean;
124
126
  /** Controlled open state of the side pane. */
125
127
  rightOpen?: boolean;
126
128
  /** The side pane's open state at first. Defaults to `true`. */
@@ -156,7 +158,18 @@ type Element_12xgc = JSX_1kxb["Element"];
156
158
  * sidebar's content starts below them), and the title, `trailing` and the
157
159
  * side pane toggle head the main card, which drags the window too. With the
158
160
  * sidebar folded, the corner controls stay put and the card's header makes
159
- * room for them.
161
+ * room for them. The corner sits on the card's 8px inset, so the window
162
+ * controls, the toggle and the title share one centre line, 26px from the
163
+ * window's top (22px compact). A native macOS window must put its traffic
164
+ * lights on that line too: with an overlay title bar, set the window's traffic
165
+ * light position (Tauri's `trafficLightPosition`) so they centre there,
166
+ * inside the 72px the corner keeps for them.
167
+ *
168
+ * While the sidebar is folded, hovering the window's left edge or the sidebar
169
+ * toggle peeks it: it slides in over the main card as a card of its own,
170
+ * without reflowing it, stays while the pointer is over it or focus is inside
171
+ * it, and folds back a beat after the pointer leaves. Clicking the toggle
172
+ * pins it open. `peek={false}` turns it off.
160
173
  *
161
174
  * Under it, the main content is an inset card. The left Sidebar is yours
162
175
  * (`left`): it resizes from its rail and folds from its toggle, its rail or
@@ -170,7 +183,7 @@ type Element_12xgc = JSX_1kxb["Element"];
170
183
  *
171
184
  * @example {@include ./examples.mdx}
172
185
  */
173
- declare function DesktopShell({ platform, showControls, titleBar, size: sizeProp, title, leading, trailing, left, right, main, leftOpen: leftOpenProp, defaultLeftOpen, onLeftOpenChange, rightOpen: rightOpenProp, defaultRightOpen, onRightOpenChange, defaultPaneSize, minPaneSize, maxPaneSize, leftLabel, rightLabel, className }: DesktopShellProps): Element_12xgc;
186
+ declare function DesktopShell({ platform, showControls, titleBar, size: sizeProp, title, leading, trailing, left, right, main, leftOpen: leftOpenProp, defaultLeftOpen, onLeftOpenChange, peek, rightOpen: rightOpenProp, defaultRightOpen, onRightOpenChange, defaultPaneSize, minPaneSize, maxPaneSize, leftLabel, rightLabel, className }: DesktopShellProps): Element_12xgc;
174
187
  import { HTMLAttributes, ReactNode as ReactNode2 } from "react";
175
188
  import { JSX as JSX_1kxb2 } from "react";
176
189
  interface ShellCardInnerProps extends HTMLAttributes<HTMLDivElement> {
package/dist/index.js CHANGED
@@ -154,7 +154,7 @@ import {
154
154
  } from "./shared/components-ez2psjey.js";
155
155
  import {
156
156
  DesktopShell2
157
- } from "./shared/components-4dk61qbj.js";
157
+ } from "./shared/components-fcgk55r4.js";
158
158
  import {
159
159
  ShellCard2
160
160
  } from "./shared/components-q0qv0fen.js";
@@ -44,7 +44,14 @@ import {
44
44
  } from "./components-ez2psjey.js";
45
45
 
46
46
  // blocks/desktop-shell/index.tsx
47
- import { useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
47
+ import {
48
+ useCallback,
49
+ useEffect,
50
+ useLayoutEffect,
51
+ useMemo,
52
+ useRef,
53
+ useState
54
+ } from "react";
48
55
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
49
56
  var CORNER_CLEARANCE = {
50
57
  default: "[&>[data-slot=sidebar]_[data-sidebar=sidebar]]:pt-9",
@@ -55,6 +62,19 @@ var CORNER_ROOM = {
55
62
  windows: "w-6 shrink-0",
56
63
  linux: "w-6 shrink-0"
57
64
  };
65
+ var PEEK_OVERLAY = "[&>[data-slot=sidebar]]:absolute [&>[data-slot=sidebar]]:inset-y-0 [&>[data-slot=sidebar]]:left-0 [&>[data-slot=sidebar]]:z-10 [&>[data-slot=sidebar]>div]:px-2 [&>[data-slot=sidebar]_[data-sidebar=sidebar]]:shadow-surface-3";
66
+ var PEEK_BG = {
67
+ 4: "[&>[data-slot=sidebar]_[data-sidebar=sidebar]]:bg-surface-4",
68
+ 5: "[&>[data-slot=sidebar]_[data-sidebar=sidebar]]:bg-surface-5",
69
+ 6: "[&>[data-slot=sidebar]_[data-sidebar=sidebar]]:bg-surface-6",
70
+ 7: "[&>[data-slot=sidebar]_[data-sidebar=sidebar]]:bg-surface-7",
71
+ 8: "[&>[data-slot=sidebar]_[data-sidebar=sidebar]]:bg-surface-8"
72
+ };
73
+ var PEEK_RADIUS = {
74
+ rounded: "[&>[data-slot=sidebar]_[data-sidebar=sidebar]]:rounded-xl",
75
+ pill: "[&>[data-slot=sidebar]_[data-sidebar=sidebar]]:rounded-3xl"
76
+ };
77
+ var PEEK_CLOSE_MS = 300;
58
78
  var NARROW = 768;
59
79
  function Toggle({
60
80
  label,
@@ -122,6 +142,58 @@ function WindowControls() {
122
142
  ]
123
143
  });
124
144
  }
145
+ function usePeek(enabled) {
146
+ const [open, setOpen] = useState(false);
147
+ const [overlay, setOverlay] = useState(false);
148
+ const sidebar = useRef(null);
149
+ const over = useRef(false);
150
+ const timer = useRef();
151
+ useEffect(() => {
152
+ if (enabled)
153
+ return;
154
+ clearTimeout(timer.current);
155
+ setOpen(false);
156
+ setOverlay(false);
157
+ }, [enabled]);
158
+ useEffect(() => () => clearTimeout(timer.current), []);
159
+ const close = () => {
160
+ clearTimeout(timer.current);
161
+ timer.current = setTimeout(() => {
162
+ if (!over.current && !sidebar.current?.contains(document.activeElement))
163
+ setOpen(false);
164
+ }, PEEK_CLOSE_MS);
165
+ };
166
+ const zone = (opens) => ({
167
+ "data-peek": "",
168
+ onPointerEnter: (event) => {
169
+ over.current = true;
170
+ clearTimeout(timer.current);
171
+ if (!opens || !enabled || event.pointerType !== "mouse")
172
+ return;
173
+ setOpen(true);
174
+ setOverlay(true);
175
+ },
176
+ onPointerLeave: (event) => {
177
+ if (event.relatedTarget instanceof Element && event.relatedTarget.closest("[data-peek]"))
178
+ return;
179
+ over.current = false;
180
+ close();
181
+ }
182
+ });
183
+ const onBlur = (event) => {
184
+ if (!(event.relatedTarget instanceof Node && event.currentTarget.contains(event.relatedTarget)))
185
+ close();
186
+ };
187
+ return {
188
+ enabled,
189
+ open: enabled && open,
190
+ overlay: enabled && overlay,
191
+ dismiss: () => setOpen(false),
192
+ sidebar,
193
+ zone,
194
+ onBlur
195
+ };
196
+ }
125
197
  function MainCard({ children }) {
126
198
  const level = useLift2(2);
127
199
  const shape = useShape2();
@@ -147,6 +219,7 @@ function DesktopShell2({
147
219
  leftOpen: leftOpenProp,
148
220
  defaultLeftOpen = true,
149
221
  onLeftOpenChange,
222
+ peek = true,
150
223
  rightOpen: rightOpenProp,
151
224
  defaultRightOpen = true,
152
225
  onRightOpenChange,
@@ -165,6 +238,10 @@ function DesktopShell2({
165
238
  const hasRight = right !== undefined;
166
239
  const paneOpen = hasRight && rightOpen;
167
240
  const inCard = titleBar === "card";
241
+ const shape = useShape2();
242
+ const substrate = useLift2(0);
243
+ const peekLevel = useLift2(3);
244
+ const peeking = usePeek(peek && hasLeft && !leftOpen);
168
245
  const paneSizes = useMemo(() => paneOpen ? [100 - paneSize, paneSize] : [100, 0], [paneOpen, paneSize]);
169
246
  const root = useRef(null);
170
247
  const [narrow, setNarrow] = useState(false);
@@ -192,11 +269,15 @@ function DesktopShell2({
192
269
  className: "flex h-full w-18 shrink-0 items-center",
193
270
  children: showControls && /* @__PURE__ */ jsx(TrafficLights, {})
194
271
  }),
195
- hasLeft && /* @__PURE__ */ jsx(Toggle, {
196
- side: "left",
197
- label: leftLabel,
198
- open: leftOpen,
199
- onClick: () => setLeftOpen(!leftOpen)
272
+ hasLeft && /* @__PURE__ */ jsx("span", {
273
+ className: "contents",
274
+ ...peeking.zone(true),
275
+ children: /* @__PURE__ */ jsx(Toggle, {
276
+ side: "left",
277
+ label: leftLabel,
278
+ open: leftOpen,
279
+ onClick: () => setLeftOpen(!leftOpen)
280
+ })
200
281
  }),
201
282
  leading
202
283
  ]
@@ -249,7 +330,8 @@ function DesktopShell2({
249
330
  size: size.variant,
250
331
  children: inCard ? /* @__PURE__ */ jsx("div", {
251
332
  "data-tauri-drag-region": true,
252
- className: cn2(bar, "absolute top-0 left-0 z-20"),
333
+ className: cn2(bar, "absolute top-2 left-0 z-20"),
334
+ ...peeking.zone(false),
253
335
  children: corner
254
336
  }) : /* @__PURE__ */ jsxs("header", {
255
337
  "data-tauri-drag-region": true,
@@ -261,14 +343,35 @@ function DesktopShell2({
261
343
  })
262
344
  }),
263
345
  /* @__PURE__ */ jsxs(sidebar_default.Provider, {
264
- className: cn2("min-h-0 flex-1 [&>[data-slot=sidebar]]:h-full", inCard && CORNER_CLEARANCE[size.variant]),
346
+ className: "min-h-0 flex-1",
265
347
  persist: false,
266
348
  mobileBreakpoint: 0,
267
349
  shortcut: hasLeft ? undefined : null,
268
- open: leftOpen,
269
- onOpenChange: setLeftOpen,
350
+ open: leftOpen || peeking.open,
351
+ onOpenChange: (open) => {
352
+ if (!open)
353
+ peeking.dismiss();
354
+ setLeftOpen(open);
355
+ },
270
356
  children: [
271
- left,
357
+ peeking.enabled && /* @__PURE__ */ jsx("div", {
358
+ className: "absolute inset-y-0 left-0 z-10 w-2",
359
+ ...peeking.zone(true)
360
+ }),
361
+ /* @__PURE__ */ jsx(SurfaceProvider2, {
362
+ value: peeking.overlay ? peekLevel : substrate,
363
+ children: /* @__PURE__ */ jsx("div", {
364
+ ref: peeking.sidebar,
365
+ className: cn2("contents [&>[data-slot=sidebar]]:h-full", inCard && CORNER_CLEARANCE[size.variant], peeking.overlay && [
366
+ PEEK_OVERLAY,
367
+ PEEK_BG[peekLevel],
368
+ PEEK_RADIUS[shape.bgRadius >= 20 ? "pill" : "rounded"]
369
+ ]),
370
+ onBlur: peeking.onBlur,
371
+ ...peeking.zone(false),
372
+ children: left
373
+ })
374
+ }),
272
375
  /* @__PURE__ */ jsx("div", {
273
376
  className: cn2("flex min-h-0 min-w-0 flex-1 py-2 pl-2 transition-[padding] duration-fast", hasLeft && leftOpen && "pl-0", (!hasRight || narrow) && "pr-2"),
274
377
  children: !hasRight || narrow ? card(narrow && paneOpen ? right : main) : /* @__PURE__ */ jsxs(resizable_default, {
package/dist/styles.css CHANGED
@@ -62,7 +62,7 @@
62
62
  }
63
63
  /* layer: theme */
64
64
  @layer theme{
65
- :root, :host { --spacing: 0.25rem; --default-transition-timingFunction: cubic-bezier(0.4, 0, 0.2, 1); --default-transition-duration: 150ms; --radius-none: 0; --radius-lg: 0.5rem; --radius-xl: 0.75rem; --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace; --leading-relaxed: 1.625; --ease-DEFAULT: cubic-bezier(0.4, 0, 0.2, 1); --radius-sm: 0.25rem; --radius-3xl: 1.5rem; --ease-out: cubic-bezier(0, 0, 0.2, 1); --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1); --radius-xs: 0.125rem; --leading-snug: 1.375; --leading-normal: 1.5; --leading-none: 1; --font-sans: 'Inter Variable', ui-sans-serif, system-ui, sans-serif; --leading-tight: 1.25; --radius-md: 0.375rem; --radius-DEFAULT: 0.25rem; --radius-2xl: 1rem; --container-2xl: 42rem; --container-sm: 24rem; --default-font-family: var(--font-sans); --default-monoFont-family: var(--font-mono); }
65
+ :root, :host { --spacing: 0.25rem; --default-transition-timingFunction: cubic-bezier(0.4, 0, 0.2, 1); --default-transition-duration: 150ms; --radius-none: 0; --radius-lg: 0.5rem; --radius-xl: 0.75rem; --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace; --leading-relaxed: 1.625; --ease-DEFAULT: cubic-bezier(0.4, 0, 0.2, 1); --radius-sm: 0.25rem; --ease-out: cubic-bezier(0, 0, 0.2, 1); --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1); --radius-xs: 0.125rem; --leading-snug: 1.375; --leading-normal: 1.5; --leading-none: 1; --font-sans: 'Inter Variable', ui-sans-serif, system-ui, sans-serif; --leading-tight: 1.25; --radius-md: 0.375rem; --radius-DEFAULT: 0.25rem; --radius-3xl: 1.5rem; --radius-2xl: 1rem; --container-2xl: 42rem; --container-sm: 24rem; --default-font-family: var(--font-sans); --default-monoFont-family: var(--font-mono); }
66
66
  }
67
67
  /* layer: base */
68
68
  @layer base{
@@ -200,6 +200,8 @@
200
200
  .px1{padding-inline:calc(var(--spacing) * 1);}
201
201
  .\[\&\:not\(\:empty\)\]\:py-6:not(:empty),
202
202
  .py-6{padding-block:calc(var(--spacing) * 6);}
203
+ .\[\&\>\[data-slot\=sidebar\]\>div\]\:px-2>[data-slot=sidebar]>div,
204
+ .px-2{padding-inline:calc(var(--spacing) * 2);}
203
205
  .px,
204
206
  .px-4{padding-inline:calc(var(--spacing) * 4);}
205
207
  .px-\[var\(--space-2\)\]{padding-inline:var(--space-2);}
@@ -208,7 +210,6 @@
208
210
  .px0{padding-inline:calc(var(--spacing) * 0);}
209
211
  .px-0\.5{padding-inline:calc(var(--spacing) * 0.5);}
210
212
  .px-1\.5{padding-inline:calc(var(--spacing) * 1.5);}
211
- .px-2{padding-inline:calc(var(--spacing) * 2);}
212
213
  .px-2\.5{padding-inline:calc(var(--spacing) * 2.5);}
213
214
  .px-3{padding-inline:calc(var(--spacing) * 3);}
214
215
  .px-6{padding-inline:calc(var(--spacing) * 6);}
@@ -322,8 +323,10 @@
322
323
  .data-\[dragging\=reject\]\:\!border-destructive\/50[data-dragging=reject]{border-color:color-mix(in srgb, var(--destructive) 50%, transparent) !important;}
323
324
  .data-\[invalid\]\:border-destructive\/50[data-invalid]{border-color:color-mix(in srgb, var(--destructive) 50%, transparent);}
324
325
  .border-l-2{border-left-width:2px;}
326
+ .\[\&\>\[data-slot\=sidebar\]_\[data-sidebar\=sidebar\]\]\:rounded-3xl>[data-slot=sidebar] [data-sidebar=sidebar],
325
327
  .data-\[active\]\:rounded-3xl[data-active],
326
328
  .rounded-3xl{border-radius:var(--radius-3xl);}
329
+ .\[\&\>\[data-slot\=sidebar\]_\[data-sidebar\=sidebar\]\]\:rounded-xl>[data-slot=sidebar] [data-sidebar=sidebar],
327
330
  .data-\[active\]\:rounded-xl[data-active],
328
331
  .rounded-xl{border-radius:var(--radius-xl);}
329
332
  .rounded{border-radius:var(--radius-DEFAULT);}
@@ -352,6 +355,21 @@
352
355
  .\[\&_\:not\(pre\)\>code\]\:bg-active :not(pre)>code,
353
356
  .bg-active,
354
357
  .group:active .group-active\:bg-active{background-color:color-mix(in srgb, var(--active) var(--un-bg-opacity), transparent);}
358
+ .\[\&\>\[data-slot\=sidebar\]_\[data-sidebar\=sidebar\]\]\:bg-surface-4>[data-slot=sidebar] [data-sidebar=sidebar],
359
+ .bg-surface-4,
360
+ .dark .dark\:bg-surface-4{background-color:color-mix(in srgb, var(--surface-4) var(--un-bg-opacity), transparent);}
361
+ .\[\&\>\[data-slot\=sidebar\]_\[data-sidebar\=sidebar\]\]\:bg-surface-5>[data-slot=sidebar] [data-sidebar=sidebar],
362
+ .bg-surface-5,
363
+ .dark .dark\:bg-surface-5{background-color:color-mix(in srgb, var(--surface-5) var(--un-bg-opacity), transparent);}
364
+ .\[\&\>\[data-slot\=sidebar\]_\[data-sidebar\=sidebar\]\]\:bg-surface-6>[data-slot=sidebar] [data-sidebar=sidebar],
365
+ .bg-surface-6,
366
+ .dark .dark\:bg-surface-6{background-color:color-mix(in srgb, var(--surface-6) var(--un-bg-opacity), transparent);}
367
+ .\[\&\>\[data-slot\=sidebar\]_\[data-sidebar\=sidebar\]\]\:bg-surface-7>[data-slot=sidebar] [data-sidebar=sidebar],
368
+ .bg-surface-7,
369
+ .dark .dark\:bg-surface-7{background-color:color-mix(in srgb, var(--surface-7) var(--un-bg-opacity), transparent);}
370
+ .\[\&\>\[data-slot\=sidebar\]_\[data-sidebar\=sidebar\]\]\:bg-surface-8>[data-slot=sidebar] [data-sidebar=sidebar],
371
+ .bg-surface-8,
372
+ .dark .dark\:bg-surface-8{background-color:color-mix(in srgb, var(--surface-8) var(--un-bg-opacity), transparent);}
355
373
  .bg-\[var\(--btn-bg\)\]{background-color:color-mix(in oklab, var(--btn-bg) var(--un-bg-opacity), transparent);}
356
374
  .bg-accent{background-color:color-mix(in srgb, var(--accent) var(--un-bg-opacity), transparent);}
357
375
  .bg-accent-hover{background-color:color-mix(in srgb, var(--accent-hover) var(--un-bg-opacity), transparent);}
@@ -399,16 +417,6 @@
399
417
  .dark .dark\:bg-surface-2{background-color:color-mix(in srgb, var(--surface-2) var(--un-bg-opacity), transparent);}
400
418
  .bg-surface-3,
401
419
  .dark .dark\:bg-surface-3{background-color:color-mix(in srgb, var(--surface-3) var(--un-bg-opacity), transparent);}
402
- .bg-surface-4,
403
- .dark .dark\:bg-surface-4{background-color:color-mix(in srgb, var(--surface-4) var(--un-bg-opacity), transparent);}
404
- .bg-surface-5,
405
- .dark .dark\:bg-surface-5{background-color:color-mix(in srgb, var(--surface-5) var(--un-bg-opacity), transparent);}
406
- .bg-surface-6,
407
- .dark .dark\:bg-surface-6{background-color:color-mix(in srgb, var(--surface-6) var(--un-bg-opacity), transparent);}
408
- .bg-surface-7,
409
- .dark .dark\:bg-surface-7{background-color:color-mix(in srgb, var(--surface-7) var(--un-bg-opacity), transparent);}
410
- .bg-surface-8,
411
- .dark .dark\:bg-surface-8{background-color:color-mix(in srgb, var(--surface-8) var(--un-bg-opacity), transparent);}
412
420
  .bg-thumb{background-color:color-mix(in srgb, var(--thumb) var(--un-bg-opacity), transparent);}
413
421
  .bg-transparent{background-color:transparent;}
414
422
  .dark .dark\:bg-accent\/12{background-color:color-mix(in srgb, var(--accent) 12%, transparent);}
@@ -771,6 +779,8 @@
771
779
  .focus-visible\:ring-offset-2:focus-visible{--un-ring-offset-width:2px;--un-ring-offset-shadow:var(--un-ring-inset,) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color);}
772
780
  .focus-visible\:ring-offset-background:focus-visible{--un-ring-offset-color:color-mix(in srgb, var(--background) var(--un-ring-offset-opacity), transparent);}
773
781
  .ring-inset{--un-ring-inset:inset;}
782
+ .\[\&\>\[data-slot\=sidebar\]_\[data-sidebar\=sidebar\]\]\:shadow-surface-3>[data-slot=sidebar] [data-sidebar=sidebar],
783
+ .shadow-surface-3{--un-shadow:var(--shadow-3);box-shadow:var(--un-inset-shadow), var(--un-inset-ring-shadow), var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);}
774
784
  .shadow,
775
785
  .shadow\)\,,
776
786
  .shadowLevel\)\)\){--un-shadow:0 1px 3px 0 var(--un-shadow-color, rgb(0 0 0 / 0.1)),0 1px 2px -1px var(--un-shadow-color, rgb(0 0 0 / 0.1));box-shadow:var(--un-inset-shadow), var(--un-inset-ring-shadow), var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);}
@@ -787,7 +797,6 @@
787
797
  .shadow-picker-thumb{--un-shadow:var(--shadow-picker-thumb);box-shadow:var(--un-inset-shadow), var(--un-inset-ring-shadow), var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);}
788
798
  .shadow-surface-1{--un-shadow:var(--shadow-1);box-shadow:var(--un-inset-shadow), var(--un-inset-ring-shadow), var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);}
789
799
  .shadow-surface-2{--un-shadow:var(--shadow-2);box-shadow:var(--un-inset-shadow), var(--un-inset-ring-shadow), var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);}
790
- .shadow-surface-3{--un-shadow:var(--shadow-3);box-shadow:var(--un-inset-shadow), var(--un-inset-ring-shadow), var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);}
791
800
  .shadow-surface-4{--un-shadow:var(--shadow-4);box-shadow:var(--un-inset-shadow), var(--un-inset-ring-shadow), var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);}
792
801
  .shadow-surface-5{--un-shadow:var(--shadow-5);box-shadow:var(--un-inset-shadow), var(--un-inset-ring-shadow), var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);}
793
802
  .shadow-surface-6{--un-shadow:var(--shadow-6);box-shadow:var(--un-inset-shadow), var(--un-inset-ring-shadow), var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);}
@@ -904,13 +913,16 @@
904
913
  .-inset-x-1{inset-inline:calc(var(--spacing) * -1);}
905
914
  .-inset-y-0\.5{inset-block:calc(var(--spacing) * -0.5);}
906
915
  .-inset-y-1{inset-block:calc(var(--spacing) * -1);}
916
+ .\[\&\>\[data-slot\=sidebar\]\]\:inset-y-0>[data-slot=sidebar],
917
+ .inset-y-0{inset-block:calc(var(--spacing) * 0);}
907
918
  .inset-x-0{inset-inline:calc(var(--spacing) * 0);}
908
919
  .inset-x-2{inset-inline:calc(var(--spacing) * 2);}
909
- .inset-y-0{inset-block:calc(var(--spacing) * 0);}
910
920
  .inset-y-2{inset-block:calc(var(--spacing) * 2);}
911
921
  .before\:inset-y-0::before{inset-block:calc(var(--spacing) * 0);}
912
922
  .after\:inset-y-0::after{inset-block:calc(var(--spacing) * 0);}
913
923
  .after\:inset-y-2::after{inset-block:calc(var(--spacing) * 2);}
924
+ .\[\&\>\[data-slot\=sidebar\]\]\:left-0>[data-slot=sidebar],
925
+ .left-0{left:calc(var(--spacing) * 0);}
914
926
  .bottom-\[var\(--space-3\)\]{bottom:var(--space-3);}
915
927
  .bottom-\[var\(--space-4\)\]{bottom:var(--space-4);}
916
928
  .bottom-0{bottom:calc(var(--spacing) * 0);}
@@ -920,7 +932,6 @@
920
932
  .group\/menu-item:has(>[data-sidebar=menu-badge]) .group-has-\[\>\[data-sidebar\=menu-badge\]\]\/menu-item\:right-8\.5,
921
933
  .group\/menu-sub-item:has(>[data-sidebar=menu-badge]) .group-has-\[\>\[data-sidebar\=menu-badge\]\]\/menu-sub-item\:right-8\.5{right:calc(var(--spacing) * 8.5);}
922
934
  .left-\[var\(--space-4\)\]{left:var(--space-4);}
923
- .left-0{left:calc(var(--spacing) * 0);}
924
935
  .left-1{left:calc(var(--spacing) * 1);}
925
936
  .left-1\.5{left:calc(var(--spacing) * 1.5);}
926
937
  .left-1\/2{left:50%;}
@@ -959,6 +970,7 @@
959
970
  .order-first{order:calc(-infinity);}
960
971
  .order-last{order:calc(infinity);}
961
972
  .place-items-center{place-items:center;}
973
+ .\[\&\>\[data-slot\=sidebar\]\]\:absolute>[data-slot=sidebar],
962
974
  .absolute{position:absolute;}
963
975
  .fixed{position:fixed;}
964
976
  .relative{position:relative;}
@@ -966,6 +978,7 @@
966
978
  .before\:absolute::before{position:absolute;}
967
979
  .after\:absolute::after{position:absolute;}
968
980
  .-z-10{z-index:-10;}
981
+ .\[\&\>\[data-slot\=sidebar\]\]\:z-10>[data-slot=sidebar],
969
982
  .\[\&\>\*\:focus-visible\]\:z-10>*:focus-visible,
970
983
  .z-10{z-index:10;}
971
984
  .z-\[1\],
package/docs/chrome.css CHANGED
@@ -173,3 +173,37 @@
173
173
  [data-modo-ui="nav-controls"] {
174
174
  padding-inline: var(--space-2);
175
175
  }
176
+
177
+ /* The site view's indicator (/site): the badge and its menu as one of the
178
+ design system's popups, a surface lifted off the page on its shadow. */
179
+ [data-modo="site-badge"],
180
+ [data-modo="site-menu"] {
181
+ border-color: transparent;
182
+ background-color: var(--surface-3);
183
+ box-shadow: var(--shadow-3);
184
+ }
185
+
186
+ [data-modo="site-badge"] {
187
+ transition: background-color var(--duration-fast);
188
+ }
189
+
190
+ [data-modo="site-badge"]:hover {
191
+ background-image: linear-gradient(var(--hover), var(--hover));
192
+ }
193
+
194
+ [data-modo="site-menu"] {
195
+ border-radius: var(--radius-shell);
196
+ }
197
+
198
+ [data-modo="site-menu-page"] {
199
+ border-radius: var(--radius);
200
+ transition: background-color var(--duration-fast);
201
+ }
202
+
203
+ [data-modo="site-menu-page"]:hover {
204
+ background-color: var(--hover);
205
+ }
206
+
207
+ [data-modo="site-menu-page"][aria-current="page"] {
208
+ background-color: var(--active);
209
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justanarthur/modo-ui",
3
3
  "type": "module",
4
- "version": "2.7.0",
4
+ "version": "2.9.0",
5
5
  "description": "Fluid Functionalism (Base UI flavor, MIT © 2026 Micka Touillaud) ported to UnoCSS: motion springs, fluid hover, a two-step size ladder and an eight-level elevated surface system. Documented with modo.",
6
6
  "license": "MIT",
7
7
  "keywords": [
@@ -349,7 +349,7 @@
349
349
  }
350
350
  },
351
351
  "devDependencies": {
352
- "@justanarthur/modo": "1.1.0",
352
+ "@justanarthur/modo": "1.2.0",
353
353
  "@types/react": "^18.3.0",
354
354
  "@types/react-dom": "^18.3.0",
355
355
  "bunup": "^0.16.0",