@brett_lamy/docstream 1.7.0 → 1.8.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.
@@ -0,0 +1,367 @@
1
+ /* The Code view's path header: a VS Code style breadcrumb for the active file.
2
+
3
+ One button per path part (the demo `src` first, then the folders, then the file), with a chevron
4
+ between them. A folder button opens a menu of that folder's siblings (everything in its parent
5
+ folder, the current one marked); the file button lists the files beside it. Picking a file selects
6
+ it, picking a folder opens the first file inside it. When the segments don't fit the container the
7
+ middle collapses into a single `…` that lists the hidden segments.
8
+
9
+ Plain accessible DOM (nav > ol, buttons, role="menu"), so docstream needs nothing beyond React.
10
+ The menu is portalled and `position: fixed`, so the viewer's overflow never clips it. The segment,
11
+ sibling and fit maths are pure and exported (see PathBreadcrumb.test.ts). */
12
+ import {
13
+ useCallback,
14
+ useEffect,
15
+ useId,
16
+ useLayoutEffect,
17
+ useRef,
18
+ useState,
19
+ type CSSProperties,
20
+ type KeyboardEvent as ReactKeyboardEvent,
21
+ } from "react"
22
+ import { createPortal } from "react-dom"
23
+ import { Check, ChevronRight, FileCode2, Folder } from "lucide-react"
24
+
25
+ export interface CrumbSegment {
26
+ /** Unique within the breadcrumb. */
27
+ key: string
28
+ name: string
29
+ /** `src`: a part of the demo id (it names the demo's root); `dir`/`file`: a part of the file path. */
30
+ kind: "src" | "dir" | "file"
31
+ /** The folder or file path within the demo's file list. Empty for `src` segments. */
32
+ path: string
33
+ }
34
+
35
+ export interface CrumbEntry {
36
+ kind: "dir" | "file"
37
+ name: string
38
+ /** The entry's path within the demo's file list (empty for a demo root). */
39
+ path: string
40
+ /** The file to open when the entry is picked: itself for a file, the first file inside for a folder. */
41
+ target: string
42
+ }
43
+
44
+ /** The hidden stretch of a collapsed breadcrumb: segments `start` up to (not including) `end`. */
45
+ export interface CrumbRange {
46
+ start: number
47
+ end: number
48
+ }
49
+
50
+ /** `src` parts, then the folders, then the file. */
51
+ export function buildCrumbs(src: string, filePath: string): CrumbSegment[] {
52
+ const out: CrumbSegment[] = []
53
+ for (const name of src.split("/").filter(Boolean)) out.push({ key: `s${out.length}:${name}`, name, kind: "src", path: "" })
54
+ const parts = filePath.split("/").filter(Boolean)
55
+ parts.forEach((name, index) => {
56
+ const path = parts.slice(0, index + 1).join("/")
57
+ out.push({ key: `p:${path}`, name, kind: index === parts.length - 1 ? "file" : "dir", path })
58
+ })
59
+ return out
60
+ }
61
+
62
+ const parentOf = (path: string) => path.slice(0, Math.max(0, path.lastIndexOf("/")))
63
+
64
+ /** The first file (in list order) at or below `folder`; `""` is the demo root. */
65
+ export function firstFileIn(paths: readonly string[], folder: string): string | undefined {
66
+ return folder === "" ? paths[0] : paths.find((p) => p.startsWith(`${folder}/`))
67
+ }
68
+
69
+ /** The direct children of `folder` (`""` is the root): folders first, then files, each A to Z. */
70
+ export function childEntries(paths: readonly string[], folder: string): CrumbEntry[] {
71
+ const prefix = folder === "" ? "" : `${folder}/`
72
+ const dirs = new Map<string, CrumbEntry>()
73
+ const files: CrumbEntry[] = []
74
+ for (const path of paths) {
75
+ if (!path.startsWith(prefix)) continue
76
+ const rest = path.slice(prefix.length)
77
+ const slash = rest.indexOf("/")
78
+ if (slash < 0) files.push({ kind: "file", name: rest, path, target: path })
79
+ else {
80
+ const name = rest.slice(0, slash)
81
+ if (!dirs.has(name)) dirs.set(name, { kind: "dir", name, path: prefix + name, target: path })
82
+ }
83
+ }
84
+ const byName = (a: CrumbEntry, b: CrumbEntry) => a.name.localeCompare(b.name, undefined, { numeric: true })
85
+ return [...[...dirs.values()].sort(byName), ...files.sort(byName)]
86
+ }
87
+
88
+ /** The menu a segment opens: the entries beside it. A `src` segment is the demo root, so it lists the
89
+ * root; the file segment lists only the files in its folder. */
90
+ export function siblingEntries(paths: readonly string[], segment: CrumbSegment): CrumbEntry[] {
91
+ if (segment.kind === "src") return childEntries(paths, "")
92
+ const entries = childEntries(paths, parentOf(segment.path))
93
+ return segment.kind === "file" ? entries.filter((e) => e.kind === "file") : entries
94
+ }
95
+
96
+ /** The menu behind `…`: the hidden segments, each opening like a folder picked in a sibling menu. */
97
+ export function hiddenEntries(paths: readonly string[], segments: readonly CrumbSegment[], range: CrumbRange): CrumbEntry[] {
98
+ return segments.slice(range.start, range.end).flatMap((segment) => {
99
+ const target = firstFileIn(paths, segment.path)
100
+ return target === undefined ? [] : [{ kind: segment.kind === "file" ? ("file" as const) : ("dir" as const), name: segment.name, path: segment.path, target }]
101
+ })
102
+ }
103
+
104
+ /** Whether the active file is this entry, or inside this folder. */
105
+ export function entryContains(entry: Pick<CrumbEntry, "path">, active: string): boolean {
106
+ return entry.path !== "" && (active === entry.path || active.startsWith(`${entry.path}/`))
107
+ }
108
+
109
+ /**
110
+ * Which middle segments to hide so the breadcrumb fits `available` px. `widths` are the full item
111
+ * widths (each includes its own chevron), `ellipsisWidth` the width of the `…` item. The first and
112
+ * last segments always stay; as many trailing segments as fit are kept; null when everything fits
113
+ * (or there is nothing to hide). With no room at all you still get first, `…`, last.
114
+ */
115
+ export function collapseRange(widths: readonly number[], ellipsisWidth: number, available: number): CrumbRange | null {
116
+ const n = widths.length
117
+ if (n < 3) return null
118
+ if (widths.reduce((sum, w) => sum + w, 0) <= available) return null
119
+ let tail = 0
120
+ for (let end = n - 1; end >= 2; end--) {
121
+ tail += widths[end]
122
+ if (widths[0] + ellipsisWidth + tail > available) return { start: 1, end: Math.min(n - 1, end + 1) }
123
+ }
124
+ return { start: 1, end: 2 }
125
+ }
126
+
127
+ const useIsoLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect
128
+
129
+ interface OpenMenu {
130
+ id: string
131
+ anchor: HTMLElement
132
+ label: string
133
+ entries: CrumbEntry[]
134
+ }
135
+
136
+ export interface PathBreadcrumbProps {
137
+ /** The demo id, shown as the leading segments. */
138
+ src: string
139
+ /** The active file's path. */
140
+ path: string
141
+ /** Every file path in the demo. */
142
+ paths: readonly string[]
143
+ onSelect: (path: string) => void
144
+ className?: string
145
+ }
146
+
147
+ export function PathBreadcrumb({ src, path, paths, onSelect, className }: PathBreadcrumbProps) {
148
+ const segments = buildCrumbs(src, path)
149
+ const nav = useRef<HTMLElement | null>(null)
150
+ const measure = useRef<HTMLOListElement | null>(null)
151
+ const [range, setRange] = useState<CrumbRange | null>(null)
152
+ const [menu, setMenu] = useState<OpenMenu | null>(null)
153
+ const menuId = useId()
154
+ const signature = segments.map((s) => s.name).join("/")
155
+
156
+ const fit = useCallback(() => {
157
+ const el = nav.current
158
+ const items = measure.current ? Array.from(measure.current.children) : []
159
+ if (!el || items.length < 2) return
160
+ const available = el.clientWidth
161
+ if (!available) return // hidden (display: none) or not laid out: keep what we have
162
+ const widths = items.map((item) => item.getBoundingClientRect().width)
163
+ const ellipsis = widths.pop() as number
164
+ const next = collapseRange(widths, ellipsis, available)
165
+ setRange((prev) => (prev?.start === next?.start && prev?.end === next?.end ? prev : next))
166
+ }, [])
167
+
168
+ useIsoLayoutEffect(fit, [fit, signature])
169
+ useEffect(() => {
170
+ const el = nav.current
171
+ if (!el || typeof ResizeObserver === "undefined") return
172
+ const observer = new ResizeObserver(fit)
173
+ observer.observe(el)
174
+ if (measure.current) observer.observe(measure.current)
175
+ return () => observer.disconnect()
176
+ }, [fit])
177
+
178
+ const close = useCallback((refocus: boolean) => {
179
+ setMenu((current) => {
180
+ if (current && refocus && current.anchor.isConnected) current.anchor.focus()
181
+ return null
182
+ })
183
+ }, [])
184
+
185
+ const choose = (entry: CrumbEntry) => {
186
+ setMenu(null)
187
+ onSelect(entry.target)
188
+ // The segments are re-keyed for the new file; park focus on its last segment.
189
+ requestAnimationFrame(() => nav.current?.querySelector<HTMLElement>("[data-crumb-last]")?.focus())
190
+ }
191
+
192
+ const open = (id: string, anchor: HTMLElement, label: string, entries: CrumbEntry[]) =>
193
+ setMenu((current) => (current?.id === id ? null : { id, anchor, label, entries }))
194
+
195
+ const visible: (CrumbSegment | "…")[] = range
196
+ ? [...segments.slice(0, range.start), "…", ...segments.slice(range.end)]
197
+ : segments
198
+
199
+ return (
200
+ <nav ref={nav} className={className ? `docs-demo-crumbs ${className}` : "docs-demo-crumbs"} aria-label="Breadcrumb">
201
+ <ol className="docs-demo-crumbs-list">
202
+ {visible.map((item, index) => {
203
+ const hidden = item === "…"
204
+ const id = hidden ? "…" : item.key
205
+ const last = !hidden && item.kind === "file"
206
+ const expanded = menu?.id === id
207
+ const label = hidden ? "Hidden path segments" : item.kind === "src" ? "Demo files" : `Files in ${parentOf(item.path) || "the demo root"}`
208
+ const entries = () => (hidden ? hiddenEntries(paths, segments, range as CrumbRange) : siblingEntries(paths, item))
209
+ return (
210
+ <li key={id} className="docs-demo-crumb-item" data-last={last || undefined}>
211
+ {index > 0 ? <ChevronRight className="docs-demo-crumb-sep" width={12} height={12} aria-hidden="true" /> : null}
212
+ <button
213
+ type="button"
214
+ className="docs-demo-crumb"
215
+ data-crumb-last={last || undefined}
216
+ data-current={last || undefined}
217
+ aria-current={last ? "page" : undefined}
218
+ aria-haspopup="menu"
219
+ aria-expanded={expanded}
220
+ aria-controls={expanded ? menuId : undefined}
221
+ aria-label={hidden ? "Show hidden path segments" : undefined}
222
+ title={hidden ? undefined : item.kind === "src" ? undefined : item.path}
223
+ onClick={(event) => open(id, event.currentTarget, label, entries())}
224
+ onKeyDown={(event) => {
225
+ if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return
226
+ event.preventDefault()
227
+ if (!expanded) setMenu({ id, anchor: event.currentTarget, label, entries: entries() })
228
+ }}
229
+ >
230
+ {last ? <FileCode2 width={13} height={13} aria-hidden="true" /> : null}
231
+ <span className="docs-demo-crumb-text">{hidden ? "…" : item.name}</span>
232
+ </button>
233
+ </li>
234
+ )
235
+ })}
236
+ </ol>
237
+ {/* The same segments, unclipped and unseen: measured to decide what fits. */}
238
+ <ol ref={measure} className="docs-demo-crumbs-list docs-demo-crumbs-measure" aria-hidden="true">
239
+ {[...segments.map((s) => s.name), "…"].map((name, index) => (
240
+ <li key={`${index}:${name}`} className="docs-demo-crumb-item">
241
+ {index > 0 ? <ChevronRight className="docs-demo-crumb-sep" width={12} height={12} /> : null}
242
+ <span className="docs-demo-crumb">
243
+ {index === segments.length - 1 ? <FileCode2 width={13} height={13} /> : null}
244
+ <span className="docs-demo-crumb-text">{name}</span>
245
+ </span>
246
+ </li>
247
+ ))}
248
+ </ol>
249
+ {menu ? <CrumbMenu key={menu.id} id={menuId} menu={menu} active={path} onPick={choose} onClose={close} /> : null}
250
+ </nav>
251
+ )
252
+ }
253
+
254
+ function CrumbMenu({ id, menu, active, onPick, onClose }: {
255
+ id: string
256
+ menu: OpenMenu
257
+ active: string
258
+ onPick: (entry: CrumbEntry) => void
259
+ onClose: (refocus: boolean) => void
260
+ }) {
261
+ const ref = useRef<HTMLDivElement | null>(null)
262
+ const { anchor } = menu
263
+ const [at, setAt] = useState(() => {
264
+ const rect = anchor.getBoundingClientRect()
265
+ return { x: rect.left, y: rect.bottom + 4 }
266
+ })
267
+
268
+ // Place under the trigger, kept inside the viewport (flipped above when there is no room below),
269
+ // and focus the current entry.
270
+ useIsoLayoutEffect(() => {
271
+ const el = ref.current
272
+ if (!el) return
273
+ const rect = anchor.getBoundingClientRect()
274
+ const { width, height } = el.getBoundingClientRect()
275
+ const x = Math.max(8, Math.min(rect.left, window.innerWidth - width - 8))
276
+ const below = rect.bottom + 4
277
+ const y = below + height > window.innerHeight - 8 && rect.top - 4 - height >= 8 ? rect.top - 4 - height : below
278
+ setAt({ x, y })
279
+ const items = Array.from(el.querySelectorAll<HTMLElement>("[role=menuitem]"))
280
+ ;(items.find((item) => item.hasAttribute("data-current")) ?? items[0])?.focus({ preventScroll: true })
281
+ }, [anchor])
282
+
283
+ useEffect(() => {
284
+ const onDown = (event: PointerEvent) => {
285
+ const target = event.target as Node
286
+ if (!ref.current?.contains(target) && !anchor.contains(target)) onClose(false)
287
+ }
288
+ const onScroll = (event: Event) => {
289
+ if (!ref.current?.contains(event.target as Node)) onClose(false)
290
+ }
291
+ const dismiss = () => onClose(false)
292
+ document.addEventListener("pointerdown", onDown, true)
293
+ window.addEventListener("scroll", onScroll, true)
294
+ window.addEventListener("resize", dismiss)
295
+ return () => {
296
+ document.removeEventListener("pointerdown", onDown, true)
297
+ window.removeEventListener("scroll", onScroll, true)
298
+ window.removeEventListener("resize", dismiss)
299
+ }
300
+ }, [anchor, onClose])
301
+
302
+ const onKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {
303
+ const items = Array.from(event.currentTarget.querySelectorAll<HTMLElement>("[role=menuitem]"))
304
+ const index = items.indexOf(document.activeElement as HTMLElement)
305
+ let next = -1
306
+ if (event.key === "ArrowDown") next = (index + 1) % items.length
307
+ else if (event.key === "ArrowUp") next = (index - 1 + items.length) % items.length
308
+ else if (event.key === "Home") next = 0
309
+ else if (event.key === "End") next = items.length - 1
310
+ else if (event.key === "Escape") {
311
+ event.preventDefault()
312
+ event.stopPropagation()
313
+ onClose(true)
314
+ return
315
+ } else if (event.key === "Tab") {
316
+ onClose(true) // focus returns to the trigger; the Tab then moves on from there
317
+ return
318
+ } else if (event.key.length === 1 && !event.metaKey && !event.ctrlKey && !event.altKey) {
319
+ const key = event.key.toLowerCase()
320
+ const from = Math.max(index, 0)
321
+ for (let step = 1; step <= items.length; step++) {
322
+ const candidate = (from + step) % items.length
323
+ if (items[candidate].textContent?.trim().toLowerCase().startsWith(key)) {
324
+ next = candidate
325
+ break
326
+ }
327
+ }
328
+ }
329
+ if (next < 0) return
330
+ event.preventDefault()
331
+ items[next]?.focus()
332
+ }
333
+
334
+ const host = anchor.closest("[data-docstream], .docs-article") ?? document.body
335
+ return createPortal(
336
+ <div
337
+ ref={ref}
338
+ id={id}
339
+ role="menu"
340
+ aria-label={menu.label}
341
+ className="docs-demo-crumb-menu"
342
+ style={{ "--crumb-x": `${Math.round(at.x)}px`, "--crumb-y": `${Math.round(at.y)}px` } as CSSProperties}
343
+ onKeyDown={onKeyDown}
344
+ >
345
+ {menu.entries.map((entry) => {
346
+ const current = entryContains(entry, active)
347
+ return (
348
+ <button
349
+ key={`${entry.kind}:${entry.path}:${entry.name}`}
350
+ type="button"
351
+ role="menuitem"
352
+ tabIndex={-1}
353
+ className="docs-demo-crumb-option"
354
+ data-current={current || undefined}
355
+ aria-current={current || undefined}
356
+ onClick={() => onPick(entry)}
357
+ >
358
+ {entry.kind === "dir" ? <Folder width={13} height={13} aria-hidden="true" /> : <FileCode2 width={13} height={13} aria-hidden="true" />}
359
+ <span className="docs-demo-crumb-option-text">{entry.name}</span>
360
+ {current ? <Check className="docs-demo-crumb-check" width={13} height={13} aria-hidden="true" /> : null}
361
+ </button>
362
+ )
363
+ })}
364
+ </div>,
365
+ host,
366
+ )
367
+ }
package/src/styles.css CHANGED
@@ -2064,13 +2064,76 @@
2064
2064
  .docs-demo-files {
2065
2065
  flex-shrink: 0;
2066
2066
  box-sizing: border-box;
2067
- width: 188px;
2067
+ /* --docs-demo-files-w is set (px) once the reader drags the handle; 188px until then. */
2068
+ width: var(--docs-demo-files-w, 188px);
2068
2069
  padding: 8px;
2069
2070
  overflow-y: auto;
2070
2071
  border-right: 1px solid var(--gb-border);
2071
2072
  background: var(--gb-muted);
2072
2073
  }
2073
2074
 
2075
+ /* The drag handle between the file list and the source: zero layout width, with a wider hit area
2076
+ and the same grip as the preview handle straddling the divider. */
2077
+ .docs-demo-files-handle {
2078
+ position: relative;
2079
+ z-index: 2;
2080
+ flex: 0 0 0;
2081
+ width: 0;
2082
+ cursor: col-resize;
2083
+ touch-action: none;
2084
+ }
2085
+
2086
+ .docs-demo-files-handle::before {
2087
+ position: absolute;
2088
+ top: 0;
2089
+ bottom: 0;
2090
+ left: -5px;
2091
+ width: 10px;
2092
+ content: "";
2093
+ }
2094
+
2095
+ .docs-demo-files-handle::after {
2096
+ position: absolute;
2097
+ top: 50%;
2098
+ left: -2.5px;
2099
+ width: 5px;
2100
+ height: 40px;
2101
+ margin-top: -20px;
2102
+ border-radius: 3px;
2103
+ background: var(--gb-stage-dot);
2104
+ content: "";
2105
+ opacity: 0;
2106
+ transition: opacity 150ms ease, background 150ms ease, height 200ms ease, margin 200ms ease;
2107
+ }
2108
+
2109
+ .docs-demo-code:hover .docs-demo-files-handle::after {
2110
+ opacity: 1;
2111
+ }
2112
+
2113
+ .docs-demo-files-handle:hover::after,
2114
+ .docs-demo-files-handle:focus-visible::after,
2115
+ .docs-demo-files-handle[data-dragging]::after {
2116
+ height: 56px;
2117
+ margin-top: -28px;
2118
+ background: var(--gb-primary);
2119
+ opacity: 1;
2120
+ }
2121
+
2122
+ .docs-demo-files-handle:focus-visible {
2123
+ outline: none;
2124
+ }
2125
+
2126
+ .docs-demo-files-handle:focus-visible::before {
2127
+ outline: 2px solid var(--gb-primary);
2128
+ outline-offset: -1px;
2129
+ border-radius: 2px;
2130
+ }
2131
+
2132
+ .docs-demo-code[data-dragging] {
2133
+ cursor: col-resize;
2134
+ user-select: none;
2135
+ }
2136
+
2074
2137
  .docs-demo-files-h {
2075
2138
  padding: 6px 8px 8px;
2076
2139
  color: var(--gb-muted-foreground);
@@ -2143,18 +2206,174 @@
2143
2206
  align-items: center;
2144
2207
  justify-content: space-between;
2145
2208
  gap: 8px;
2146
- padding: 5px 6px 5px 14px;
2209
+ padding: 5px 6px 5px 8px;
2147
2210
  border-bottom: 1px solid var(--gb-border);
2148
2211
  color: var(--gb-muted-foreground);
2149
2212
  font: 12px/1 var(--docs-demo-mono);
2150
2213
  }
2151
2214
 
2152
- .docs-demo-source-path {
2215
+ /* Breadcrumb path: one button per segment. The list is clipped to the header; the fit logic in
2216
+ PathBreadcrumb collapses the middle to a "…" before that matters. */
2217
+ .docs-demo-crumbs {
2218
+ position: relative;
2219
+ flex: 1;
2220
+ min-width: 0;
2221
+ overflow: hidden;
2222
+ }
2223
+
2224
+ .docs-demo-crumbs > .docs-demo-crumbs-list {
2225
+ display: flex;
2226
+ align-items: center;
2227
+ margin: 0;
2228
+ padding: 0;
2229
+ list-style: none;
2230
+ white-space: nowrap;
2231
+ }
2232
+
2233
+ .docs-demo-crumbs > .docs-demo-crumbs-measure {
2234
+ position: absolute;
2235
+ top: 0;
2236
+ left: 0;
2237
+ height: 0;
2238
+ visibility: hidden;
2239
+ pointer-events: none;
2240
+ }
2241
+
2242
+ .docs-demo-crumbs-list > .docs-demo-crumb-item {
2243
+ display: flex;
2244
+ flex: 0 0 auto;
2245
+ align-items: center;
2246
+ min-width: 0;
2247
+ margin: 0;
2248
+ padding: 0;
2249
+ }
2250
+
2251
+ .docs-demo-crumbs-list > .docs-demo-crumb-item[data-last] {
2252
+ flex: 0 1 auto;
2253
+ }
2254
+
2255
+ .docs-demo-crumb-sep {
2256
+ flex-shrink: 0;
2257
+ color: var(--gb-muted-foreground);
2258
+ opacity: 0.7;
2259
+ }
2260
+
2261
+ .docs-demo-crumb {
2262
+ display: inline-flex;
2263
+ align-items: center;
2264
+ gap: 5px;
2265
+ min-width: 0;
2266
+ box-sizing: border-box;
2267
+ height: 24px;
2268
+ padding: 0 6px;
2269
+ border: 0;
2270
+ border-radius: 6px;
2271
+ background: none;
2272
+ color: var(--gb-muted-foreground);
2273
+ font: inherit;
2274
+ cursor: pointer;
2275
+ transition: background 150ms ease, color 150ms ease;
2276
+ }
2277
+
2278
+ .docs-demo-crumb svg {
2279
+ flex-shrink: 0;
2280
+ }
2281
+
2282
+ .docs-demo-crumb-text {
2153
2283
  overflow: hidden;
2154
2284
  text-overflow: ellipsis;
2155
2285
  white-space: nowrap;
2156
2286
  }
2157
2287
 
2288
+ .docs-demo-crumb:hover,
2289
+ .docs-demo-crumb[aria-expanded="true"] {
2290
+ background: var(--gb-hover);
2291
+ color: var(--gb-panel-foreground);
2292
+ }
2293
+
2294
+ .docs-demo-crumb[data-current] {
2295
+ color: var(--gb-panel-foreground);
2296
+ font-weight: 600;
2297
+ }
2298
+
2299
+ .docs-demo-crumb[data-current] svg {
2300
+ color: var(--gb-primary);
2301
+ }
2302
+
2303
+ .docs-demo-crumb:focus-visible {
2304
+ outline: 2px solid var(--gb-primary);
2305
+ outline-offset: -2px;
2306
+ }
2307
+
2308
+ /* The sibling / hidden-segment menu. Portalled next to the docs root (so it isn't clipped by the
2309
+ viewer) and fixed under its trigger; --crumb-x / --crumb-y are set from the trigger's rect. */
2310
+ .docs-demo-crumb-menu {
2311
+ position: fixed;
2312
+ top: var(--crumb-y, 0);
2313
+ left: var(--crumb-x, 0);
2314
+ z-index: 60;
2315
+ box-sizing: border-box;
2316
+ min-width: 160px;
2317
+ max-width: min(320px, calc(100vw - 16px));
2318
+ max-height: min(320px, calc(100vh - 16px));
2319
+ padding: 4px;
2320
+ overflow-y: auto;
2321
+ border: 1px solid var(--gb-border);
2322
+ border-radius: 10px;
2323
+ background: var(--gb-panel);
2324
+ box-shadow: var(--gb-menu-shadow);
2325
+ color: var(--gb-panel-foreground);
2326
+ font: 12.5px/1.3 var(--docs-demo-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
2327
+ }
2328
+
2329
+ .docs-demo-crumb-option {
2330
+ display: flex;
2331
+ align-items: center;
2332
+ gap: 7px;
2333
+ box-sizing: border-box;
2334
+ width: 100%;
2335
+ padding: 6px 8px;
2336
+ border: 0;
2337
+ border-radius: 6px;
2338
+ background: none;
2339
+ color: inherit;
2340
+ font: inherit;
2341
+ text-align: left;
2342
+ cursor: pointer;
2343
+ }
2344
+
2345
+ .docs-demo-crumb-option svg {
2346
+ flex-shrink: 0;
2347
+ color: var(--gb-muted-foreground);
2348
+ }
2349
+
2350
+ .docs-demo-crumb-option:hover,
2351
+ .docs-demo-crumb-option:focus-visible {
2352
+ outline: none;
2353
+ background: var(--gb-hover);
2354
+ }
2355
+
2356
+ .docs-demo-crumb-option[data-current] {
2357
+ color: var(--gb-primary);
2358
+ font-weight: 600;
2359
+ }
2360
+
2361
+ .docs-demo-crumb-option[data-current] svg {
2362
+ color: var(--gb-primary);
2363
+ }
2364
+
2365
+ .docs-demo-crumb-option-text {
2366
+ flex: 1;
2367
+ min-width: 0;
2368
+ overflow: hidden;
2369
+ text-overflow: ellipsis;
2370
+ white-space: nowrap;
2371
+ }
2372
+
2373
+ .docs-demo-crumb-option .docs-demo-crumb-check {
2374
+ margin-left: auto;
2375
+ }
2376
+
2158
2377
  .docs-demo-source-body {
2159
2378
  flex: 1;
2160
2379
  min-height: 0;
@@ -2195,7 +2414,8 @@
2195
2414
  }
2196
2415
 
2197
2416
  .docs-demo-files-h,
2198
- .docs-demo-dir {
2417
+ .docs-demo-dir,
2418
+ .docs-demo-files-handle {
2199
2419
  display: none;
2200
2420
  }
2201
2421
 
@@ -2338,6 +2558,8 @@
2338
2558
  }
2339
2559
 
2340
2560
  .docs-demo-handle::after,
2561
+ .docs-demo-files-handle::after,
2562
+ .docs-demo-crumb,
2341
2563
  .docs-page-actions-more svg {
2342
2564
  transition: none;
2343
2565
  }