ember-joinery 1.0.1 → 1.1.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,459 @@
1
+ import { isBoolean, isNumber, isUndefined } from '@sindresorhus/is'
2
+ import Component from '@glimmer/component'
3
+ import { tracked } from '@glimmer/tracking'
4
+ import { hash } from '@ember/helper'
5
+ import { on } from '@ember/modifier'
6
+ import { htmlSafe, type SafeString } from '@ember/template'
7
+ import type { TOC } from '@ember/component/template-only'
8
+ import type { WithBoundArgs } from '@glint/template'
9
+ import { PanelRight } from 'lucide'
10
+ import { controllable } from '@ember-joinery/primitives/controllable-state'
11
+ import { idFor } from '@ember-joinery/primitives/id'
12
+ import { t } from '@ember-joinery/primitives/i18n'
13
+ import { part, type PartModifier } from '@ember-joinery/primitives/part'
14
+ import { visuallyHidden } from '@ember-joinery/primitives/visually-hidden'
15
+ import Button from './button.gts'
16
+ import Icon, { type IconNode } from './icon.gts'
17
+ import Sheet from './sheet.gts'
18
+ import { messages } from '../messages.ts'
19
+
20
+ /** The cookie the inspector keeps its open state and its width in. */
21
+ export const INSPECTOR_COOKIE_NAME = 'inspector_state'
22
+ /** How long the cookie lasts, in seconds: a week, as the sidebar's. */
23
+ export const INSPECTOR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
24
+ /** The width in pixels below which an inspector shows its pane in a sheet. */
25
+ export const INSPECTOR_COMPACT_BREAKPOINT = 768
26
+ /** The smallest and the largest width of the pane in pixels, without `@minWidth` and `@maxWidth`. */
27
+ export const INSPECTOR_MIN_WIDTH = 240
28
+ export const INSPECTOR_MAX_WIDTH = 480
29
+
30
+ /** How far an arrow key moves the resize handle, in pixels. */
31
+ const STEP = 16
32
+
33
+ /** What the cookie holds: the open state, and the width of the pane in pixels. */
34
+ export interface InspectorState {
35
+ open?: boolean
36
+ width?: number
37
+ }
38
+
39
+ /**
40
+ * The state that the inspector keeps in its cookie each time the user changes it. An empty
41
+ * object when there is no cookie. Give its values back to the inspector:
42
+ *
43
+ * const saved = inspectorStateFromCookie()
44
+ *
45
+ * <Inspector @defaultOpen={{saved.open}} @defaultWidth={{saved.width}} as |inspector|>
46
+ */
47
+ export function inspectorStateFromCookie(
48
+ cookieName: string = INSPECTOR_COOKIE_NAME,
49
+ doc: Document | undefined = isUndefined(globalThis.document) ? undefined : document,
50
+ ): InspectorState {
51
+ const prefix = `${cookieName}=`
52
+ const entry = doc?.cookie
53
+ .split(';')
54
+ .map(cookie => cookie.trim())
55
+ .find(cookie => cookie.startsWith(prefix))
56
+ if (entry === undefined) return {}
57
+ let saved: Record<string, unknown>
58
+ try {
59
+ saved = JSON.parse(decodeURIComponent(entry.slice(prefix.length))) as Record<string, unknown>
60
+ } catch {
61
+ return {}
62
+ }
63
+ const state: InspectorState = {}
64
+ const { open, width } = saved ?? {}
65
+ if (isBoolean(open)) state.open = open
66
+ if (isNumber(width) && Number.isFinite(width) && width > 0) state.width = width
67
+ return state
68
+ }
69
+
70
+ export interface InspectorSectionSignature {
71
+ Blocks: { default: [] }
72
+ Element: HTMLElement
73
+ }
74
+
75
+ const Content: TOC<InspectorSectionSignature> = <template>
76
+ <div data-jn-inspector-content ...attributes>{{yield}}</div>
77
+ </template>
78
+
79
+ const Header: TOC<InspectorSectionSignature> = <template>
80
+ <div data-jn-inspector-header ...attributes>{{yield}}</div>
81
+ </template>
82
+
83
+ const Title: TOC<InspectorSectionSignature> = <template>
84
+ <h2 data-jn-inspector-title ...attributes>{{yield}}</h2>
85
+ </template>
86
+
87
+ const Body: TOC<InspectorSectionSignature> = <template>
88
+ <div data-jn-inspector-body ...attributes>{{yield}}</div>
89
+ </template>
90
+
91
+ /** What the pane yields: its optional sections. */
92
+ export interface InspectorPaneParts {
93
+ /** A row at the top, for the title and controls. */
94
+ Header: typeof Header
95
+ /** An `<h2>` in the header. */
96
+ Title: typeof Title
97
+ /** The rest of the pane, padded. It scrolls when it does not fit. */
98
+ Body: typeof Body
99
+ }
100
+
101
+ export interface InspectorPaneSignature {
102
+ Args: {
103
+ /** Its name for assistive technology, and the name of the sheet. Default `Inspector`. */
104
+ label?: string
105
+ /**
106
+ * Whether the `<aside>` is a material (`jn-material`, the `sidebar` surface). Default
107
+ * `false`. The sheet of a compact inspector keeps the look of a sheet.
108
+ */
109
+ material?: boolean
110
+ /** @internal Bound by the inspector. */
111
+ inspector: Inspector
112
+ }
113
+ Blocks: { default: [InspectorPaneParts] }
114
+ Element: HTMLElement
115
+ }
116
+
117
+ const materialClass = (material: boolean | undefined): string | undefined =>
118
+ material ? 'jn-material' : undefined
119
+
120
+ /** The inspector: an `<aside>` after the content, or a sheet in a compact inspector. */
121
+ const Pane: TOC<InspectorPaneSignature> = <template>
122
+ {{#if @inspector.isCompact}}
123
+ <Sheet @open={{@inspector.compactOpen}} @onOpenChange={{@inspector.setOpen}} as |sheet|>
124
+ <sheet.Content @side={{@inspector.compactSide}} data-jn-inspector-pane="sheet" ...attributes>
125
+ <sheet.Header {{visuallyHidden}}>
126
+ <sheet.Title>{{if @label @label (t messages.inspectorLabel)}}</sheet.Title>
127
+ </sheet.Header>
128
+ {{yield (hash Header=Header Title=Title Body=Body)}}
129
+ </sheet.Content>
130
+ </Sheet>
131
+ {{else if @inspector.open}}
132
+ {{#if @inspector.isResizable}}
133
+ <div
134
+ role="separator"
135
+ tabindex="0"
136
+ aria-orientation="vertical"
137
+ aria-label={{t messages.inspectorResize}}
138
+ aria-controls={{@inspector.paneId}}
139
+ aria-valuenow={{@inspector.paneWidth}}
140
+ aria-valuemin={{@inspector.minWidth}}
141
+ aria-valuemax={{@inspector.maxWidth}}
142
+ data-jn-inspector-separator
143
+ {{on "keydown" @inspector.onSeparatorKeyDown}}
144
+ {{on "pointerdown" @inspector.onSeparatorPointerDown}}
145
+ ></div>
146
+ {{/if}}
147
+ <aside
148
+ id={{@inspector.paneId}}
149
+ class={{materialClass @material}}
150
+ data-material="sidebar"
151
+ aria-label={{if @label @label (t messages.inspectorLabel)}}
152
+ style={{@inspector.paneStyle}}
153
+ data-jn-inspector-pane="inline"
154
+ ...attributes
155
+ {{@inspector.pane}}
156
+ >
157
+ {{yield (hash Header=Header Title=Title Body=Body)}}
158
+ </aside>
159
+ {{/if}}
160
+ </template>
161
+
162
+ export interface InspectorTriggerSignature {
163
+ Args: {
164
+ /** Its name for assistive technology. Default `Toggle Inspector`. */
165
+ label?: string
166
+ /** Its icon: one from `lucide`. Default `PanelRight`. */
167
+ icon?: IconNode
168
+ /** @internal Bound by the inspector. */
169
+ inspector: Inspector
170
+ }
171
+ /** A ghost, small icon Button. */
172
+ Element: HTMLButtonElement | HTMLAnchorElement
173
+ }
174
+
175
+ /** A button that opens and closes the pane. */
176
+ const Trigger: TOC<InspectorTriggerSignature> = <template>
177
+ <Button
178
+ @variant="ghost"
179
+ @size="icon-sm"
180
+ type="button"
181
+ aria-expanded={{if @inspector.open "true" "false"}}
182
+ aria-controls={{unless @inspector.isCompact @inspector.paneId}}
183
+ aria-haspopup={{if @inspector.isCompact "dialog"}}
184
+ data-jn-inspector-trigger
185
+ ...attributes
186
+ {{on "click" @inspector.toggle}}
187
+ >
188
+ <Icon @icon={{if @icon @icon PanelRight}} class="jn-rtl-flip" />
189
+ <span {{visuallyHidden}}>{{if @label @label (t messages.inspectorToggle)}}</span>
190
+ </Button>
191
+ </template>
192
+
193
+ /** What an inspector yields: its parts and its state. */
194
+ export interface InspectorParts {
195
+ /** The content that it inspects. */
196
+ Content: typeof Content
197
+ /** The inspector's pane: an `<aside>` named `Inspector`, or a sheet. */
198
+ Pane: WithBoundArgs<typeof Pane, 'inspector'>
199
+ /** A button that opens and closes the pane. */
200
+ Trigger: WithBoundArgs<typeof Trigger, 'inspector'>
201
+ /** Whether the pane is open: the sheet, in a compact inspector. */
202
+ open: boolean
203
+ /** Opens (`true`) or closes (`false`) the pane. */
204
+ setOpen: (open: boolean) => void
205
+ /** Opens the pane if it is closed, and closes it if it is open. */
206
+ toggle: () => void
207
+ /** Whether the inspector is narrower than `@compactBreakpoint`, so the pane is a sheet. */
208
+ isCompact: boolean
209
+ }
210
+
211
+ export interface InspectorSignature {
212
+ Args: {
213
+ /** Whether the pane is open, controlled. */
214
+ open?: boolean
215
+ /** Whether the pane is open at the start, uncontrolled. Default `true`. */
216
+ defaultOpen?: boolean
217
+ /** Called with each change of the pane beside the content. The sheet has its own state. */
218
+ onOpenChange?: (open: boolean) => void
219
+ /** The pane's first width in pixels. Default: `--inspector-width`, 18rem. */
220
+ defaultWidth?: number
221
+ /** The pane's smallest width in pixels. Default 240. */
222
+ minWidth?: number
223
+ /** The pane's largest width in pixels. Default 480. */
224
+ maxWidth?: number
225
+ /** Whether a `role="separator"` before the pane resizes it. Default `false`. */
226
+ resizable?: boolean
227
+ /** The width in pixels below which the pane is a sheet. Default 768. */
228
+ compactBreakpoint?: number
229
+ /** The edge the sheet comes from. Default `bottom`. */
230
+ compactSide?: 'bottom' | 'right'
231
+ /** A key that toggles the pane with Ctrl+Alt (⌘⌥ on a Mac), such as `i`. Default `false`. */
232
+ keyboardShortcut?: string | false
233
+ /**
234
+ * The cookie for the open state and the width. Default `inspector_state`; `false` keeps no
235
+ * cookie. Read it with `inspectorStateFromCookie()`.
236
+ */
237
+ cookieName?: string | false
238
+ /** Its name, for `InspectorHarness` (`data-test-jn-name`). */
239
+ name?: string
240
+ }
241
+ Blocks: { default: [InspectorParts] }
242
+ Element: HTMLDivElement
243
+ }
244
+
245
+ /**
246
+ * A pane after the content it inspects, which is a sheet when there is no room. Joinery's own
247
+ * (shadcn/ui has no inspector), after SwiftUI's `.inspector(isPresented:)`.
248
+ *
249
+ * <Inspector as |inspector|>
250
+ * <inspector.Content><inspector.Trigger /> …</inspector.Content>
251
+ * <inspector.Pane as |pane|>
252
+ * <pane.Header><pane.Title>Details</pane.Title></pane.Header>
253
+ * <pane.Body>…</pane.Body>
254
+ * </inspector.Pane>
255
+ * </Inspector>
256
+ *
257
+ * It wraps the app, so it is a wrapper for the harnesses (`data-test-jn-wrapper`), and its
258
+ * elements are styled by `data-jn-inspector-*` attributes. `--inspector-width` (18rem) is the
259
+ * width of the pane.
260
+ */
261
+ export default class Inspector extends Component<InspectorSignature> {
262
+ openState = controllable(this, 'open', true)
263
+
264
+ /** Whether the sheet of a compact inspector is open. */
265
+ @tracked compactOpen = false
266
+
267
+ /** The inspector's own width in CSS pixels. Infinity before the first measure. */
268
+ @tracked rootWidth = Infinity
269
+
270
+ /** The pane's width in pixels, after the user resized it or the handle measured it. */
271
+ @tracked width: number | undefined
272
+
273
+ #root: HTMLElement | undefined
274
+ #pane: HTMLElement | undefined
275
+
276
+ get isCompact(): boolean {
277
+ return this.rootWidth < (this.args.compactBreakpoint ?? INSPECTOR_COMPACT_BREAKPOINT)
278
+ }
279
+
280
+ get open(): boolean {
281
+ return this.isCompact ? this.compactOpen : this.openState.value
282
+ }
283
+
284
+ get compactSide(): 'bottom' | 'right' {
285
+ return this.args.compactSide ?? 'bottom'
286
+ }
287
+
288
+ get isResizable(): boolean {
289
+ return this.args.resizable === true
290
+ }
291
+
292
+ get minWidth(): number {
293
+ return this.args.minWidth ?? INSPECTOR_MIN_WIDTH
294
+ }
295
+
296
+ get maxWidth(): number {
297
+ return this.args.maxWidth ?? INSPECTOR_MAX_WIDTH
298
+ }
299
+
300
+ get paneId(): string {
301
+ return idFor(this, 'pane')
302
+ }
303
+
304
+ /** The pane's width in pixels, in its limits. `undefined` while `--inspector-width` sets it. */
305
+ get paneWidth(): number | undefined {
306
+ const width = this.width ?? this.args.defaultWidth
307
+ return isUndefined(width) ? undefined : this.#clamp(width)
308
+ }
309
+
310
+ /** The pane's width and limits. A caller's `style` on the pane replaces them. */
311
+ get paneStyle(): SafeString | undefined {
312
+ const { minWidth, maxWidth } = this.args
313
+ const rules = [
314
+ isUndefined(this.paneWidth) ? '' : `--inspector-width: ${this.paneWidth}px`,
315
+ isUndefined(minWidth) ? '' : `min-width: ${Number(minWidth)}px`,
316
+ isUndefined(maxWidth) ? '' : `max-width: ${Number(maxWidth)}px`,
317
+ ].filter(Boolean)
318
+ return rules.length ? htmlSafe(rules.join('; ')) : undefined
319
+ }
320
+
321
+ #clamp(width: number): number {
322
+ return Math.round(Math.min(Math.max(Number(width), this.minWidth), this.maxWidth))
323
+ }
324
+
325
+ setOpen = (open: boolean): void => {
326
+ if (this.isCompact) {
327
+ this.compactOpen = open
328
+ return
329
+ }
330
+ // The pane goes from the page when it closes, so focus in it goes to the trigger first.
331
+ if (!open && this.#pane?.contains(this.#root?.ownerDocument.activeElement ?? null)) {
332
+ this.#root?.querySelector<HTMLElement>('[data-jn-inspector-trigger]')?.focus()
333
+ }
334
+ this.openState.set(open)
335
+ this.#save()
336
+ }
337
+
338
+ toggle = (): void => this.setOpen(!this.open)
339
+
340
+ #save(): void {
341
+ const name = this.args.cookieName ?? INSPECTOR_COOKIE_NAME
342
+ const doc = this.#root?.ownerDocument
343
+ if (name === false || !doc) return
344
+ const state: InspectorState = { open: this.openState.value, width: this.paneWidth }
345
+ const value = encodeURIComponent(JSON.stringify(state))
346
+ doc.cookie = `${name}=${value}; path=/; max-age=${INSPECTOR_COOKIE_MAX_AGE}`
347
+ }
348
+
349
+ #isRtl(element: Element): boolean {
350
+ return getComputedStyle(element).direction === 'rtl'
351
+ }
352
+
353
+ /** The arrow keys, Home and End on the resize handle. The pane is at the inline end. */
354
+ onSeparatorKeyDown = (event: KeyboardEvent): void => {
355
+ const from = this.paneWidth ?? this.#pane?.offsetWidth ?? this.minWidth
356
+ const wider = this.#isRtl(event.currentTarget as Element) ? 'ArrowRight' : 'ArrowLeft'
357
+ let width: number
358
+ if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
359
+ width = from + (event.key === wider ? STEP : -STEP)
360
+ } else if (event.key === 'Home') width = this.minWidth
361
+ else if (event.key === 'End') width = this.maxWidth
362
+ else return
363
+ event.preventDefault()
364
+ this.width = this.#clamp(width)
365
+ this.#save()
366
+ }
367
+
368
+ /** A drag on the resize handle. */
369
+ onSeparatorPointerDown = (event: PointerEvent): void => {
370
+ const handle = event.currentTarget as HTMLElement
371
+ const from = this.#pane?.offsetWidth ?? this.minWidth
372
+ const sign = this.#isRtl(handle) ? 1 : -1
373
+ const move = (moved: PointerEvent) => {
374
+ this.width = this.#clamp(from + sign * (moved.clientX - event.clientX))
375
+ }
376
+ const end = () => {
377
+ handle.removeEventListener('pointermove', move)
378
+ handle.removeEventListener('pointerup', end)
379
+ handle.removeEventListener('pointercancel', end)
380
+ this.#save()
381
+ }
382
+ event.preventDefault()
383
+ handle.setPointerCapture(event.pointerId)
384
+ handle.addEventListener('pointermove', move)
385
+ handle.addEventListener('pointerup', end)
386
+ handle.addEventListener('pointercancel', end)
387
+ }
388
+
389
+ /** @internal Measures the root (not the window), and hears the keyboard shortcut. */
390
+ setup: PartModifier = part(() => ({
391
+ element: element => {
392
+ this.#root = element
393
+ const measure = () => {
394
+ if (!this.isDestroying && element.offsetWidth !== this.rootWidth) {
395
+ this.rootWidth = element.offsetWidth
396
+ }
397
+ }
398
+ // Not during this render, which has read the width already.
399
+ queueMicrotask(measure)
400
+ const observer = new ResizeObserver(measure)
401
+ observer.observe(element)
402
+ const view = element.ownerDocument.defaultView
403
+ const onKeyDown = (event: KeyboardEvent) => {
404
+ const key = this.args.keyboardShortcut
405
+ if (!key || !event.altKey || !(event.metaKey || event.ctrlKey)) return
406
+ // With Alt, a Mac gives another character as the key: the code still names the letter.
407
+ if (event.key.toLowerCase() !== key && event.code !== `Key${key.toUpperCase()}`) return
408
+ event.preventDefault()
409
+ this.toggle()
410
+ }
411
+ view?.addEventListener('keydown', onKeyDown)
412
+ return () => {
413
+ observer.disconnect()
414
+ view?.removeEventListener('keydown', onKeyDown)
415
+ }
416
+ },
417
+ }))
418
+
419
+ /** @internal Keeps the `<aside>`, and gives the resize handle its first value. */
420
+ pane: PartModifier = part(() => ({
421
+ element: element => {
422
+ this.#pane = element
423
+ if (this.isResizable && isUndefined(this.paneWidth)) {
424
+ // Not during this render, which has read the width already.
425
+ queueMicrotask(() => {
426
+ if (!this.isDestroying && element.isConnected) this.width ??= element.offsetWidth
427
+ })
428
+ }
429
+ return () => {
430
+ this.#pane = undefined
431
+ }
432
+ },
433
+ }))
434
+
435
+ <template>
436
+ <div
437
+ data-jn-inspector
438
+ data-state={{if this.open "open" "closed"}}
439
+ data-compact={{if this.isCompact ""}}
440
+ data-test-jn="inspector"
441
+ data-test-jn-wrapper
442
+ data-test-jn-name={{@name}}
443
+ ...attributes
444
+ {{this.setup}}
445
+ >
446
+ {{yield
447
+ (hash
448
+ Content=Content
449
+ Pane=(component Pane inspector=this)
450
+ Trigger=(component Trigger inspector=this)
451
+ open=this.open
452
+ setOpen=this.setOpen
453
+ toggle=this.toggle
454
+ isCompact=this.isCompact
455
+ )
456
+ }}
457
+ </div>
458
+ </template>
459
+ }
@@ -0,0 +1,101 @@
1
+ import type { TOC } from '@ember/component/template-only'
2
+ import type { ComponentLike } from '@glint/template'
3
+ import { staticPart, type StaticPartSignature } from '../-private/static-part.gts'
4
+ import { taggedPart, type TaggedPartSignature } from '../-private/tagged-part.gts'
5
+
6
+ /** What the bar draws where content scrolls under it: a fade, a line, or nothing. */
7
+ export type NavigationBarScrollEdge = 'soft' | 'hard' | 'none'
8
+
9
+ const Leading = staticPart({
10
+ class: 'jn-navigation-bar-leading',
11
+ slot: 'navigation-bar-leading',
12
+ part: 'leading',
13
+ })
14
+ const Trailing = staticPart({
15
+ class: 'jn-navigation-bar-trailing',
16
+ slot: 'navigation-bar-trailing',
17
+ part: 'trailing',
18
+ })
19
+ const Title = taggedPart<HTMLHeadingElement>({
20
+ tag: 'h1',
21
+ class: 'jn-navigation-bar-title',
22
+ slot: 'navigation-bar-title',
23
+ part: 'title',
24
+ })
25
+
26
+ /**
27
+ * The large title of a `<NavigationBar @largeTitle={{true}}>`. Render it as the first thing in
28
+ * the content that scrolls, after the bar, with the same text as the bar's `Title`:
29
+ *
30
+ * <NavigationBar @largeTitle={{true}} as |bar|>
31
+ * <bar.Title>Contacts</bar.Title>
32
+ * </NavigationBar>
33
+ * <NavigationBarLargeTitle>Contacts</NavigationBarLargeTitle>
34
+ *
35
+ * It is a copy for the eye (`aria-hidden="true"`): the bar's `Title` is the heading.
36
+ */
37
+ export const NavigationBarLargeTitle = taggedPart({
38
+ tag: 'div',
39
+ class: 'jn-navigation-bar-large-title',
40
+ slot: 'navigation-bar-large-title',
41
+ part: 'large-title',
42
+ attributes: { 'aria-hidden': 'true' },
43
+ })
44
+
45
+ /** What a navigation bar yields: its parts. */
46
+ export interface NavigationBarParts {
47
+ /** The start of the bar: the back button goes here. */
48
+ Leading: ComponentLike<StaticPartSignature>
49
+ /** The title, in the centre: an `<h1>` (or `@as`) that truncates. */
50
+ Title: ComponentLike<TaggedPartSignature<HTMLHeadingElement>>
51
+ /** The end of the bar: the screen's actions. */
52
+ Trailing: ComponentLike<StaticPartSignature>
53
+ }
54
+
55
+ const PARTS: NavigationBarParts = { Leading, Title, Trailing }
56
+
57
+ const edge = (value: NavigationBarScrollEdge | undefined): string | undefined =>
58
+ value === 'none' ? undefined : (value ?? 'soft')
59
+
60
+ export interface NavigationBarSignature {
61
+ Args: {
62
+ /**
63
+ * Whether the screen has a `NavigationBarLargeTitle` at the top of its content. The bar
64
+ * then shows its `Title`, its material and its edge only when the content scrolls under it
65
+ * (where the browser has scroll-driven animations). Default `false`.
66
+ */
67
+ largeTitle?: boolean
68
+ /** What it draws where content scrolls under it. Default `soft`, a fade. */
69
+ scrollEdge?: NavigationBarScrollEdge
70
+ /** Its name, for `NavigationBarHarness` (`data-test-jn-name`). */
71
+ name?: string
72
+ }
73
+ Blocks: { default: [NavigationBarParts] }
74
+ Element: HTMLElement
75
+ }
76
+
77
+ /**
78
+ * The bar at the top of a screen on a phone, as the iOS navigation bar: a back button, a title
79
+ * in the centre, and actions. Joinery's own (shadcn/ui has none). It is a `<header>`, 2.75rem
80
+ * tall, sticky at the top of what scrolls, and a material that keeps clear of the safe areas.
81
+ *
82
+ * <NavigationBar as |bar|>
83
+ * <bar.Leading><stack.BackButton /></bar.Leading>
84
+ * <bar.Title>Ada Lovelace</bar.Title>
85
+ * <bar.Trailing><Button @variant="ghost" @size="sm">Edit</Button></bar.Trailing>
86
+ * </NavigationBar>
87
+ */
88
+ const NavigationBar: TOC<NavigationBarSignature> = <template>
89
+ <header
90
+ class="jn-navigation-bar jn-material"
91
+ data-material="bar"
92
+ data-scroll-edge={{edge @scrollEdge}}
93
+ data-large-title={{if @largeTitle ""}}
94
+ data-slot="navigation-bar"
95
+ data-test-jn="navigation-bar"
96
+ data-test-jn-name={{@name}}
97
+ ...attributes
98
+ >{{yield PARTS}}</header>
99
+ </template>
100
+
101
+ export default NavigationBar