rift-ds 1.32.0 → 1.34.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.
- package/README.md +4 -4
- package/behaviors/chat-card.css +11 -6
- package/behaviors/clipboard.d.ts +7 -0
- package/behaviors/clipboard.js +35 -0
- package/behaviors/headingSlug.d.ts +8 -0
- package/behaviors/headingSlug.js +4 -0
- package/behaviors/shell.css +64 -0
- package/behaviors/syncedChoice.d.ts +2 -0
- package/behaviors/syncedChoice.js +48 -0
- package/behaviors/useLayer.d.ts +15 -2
- package/behaviors/useLayer.js +3 -2
- package/bin/templates/blocks/app/guide/PageFeedback.tsx +55 -0
- package/bin/templates/blocks/app/guide/page.module.css +94 -0
- package/bin/templates/blocks/app/guide/page.tsx +168 -0
- package/bin/templates/blocks/components/blocks/AppShell.module.css +3 -1
- package/bin/templates/blocks/components/blocks/AppShell.tsx +8 -0
- package/bin/templates/blocks/components/blocks/DocsShell.module.css +18 -0
- package/bin/templates/blocks/components/blocks/DocsShell.tsx +179 -0
- package/bin/templates/blocks/registry.json +13 -0
- package/chat/AssistantTurn.d.ts +2 -0
- package/chat/AssistantTurn.js +18 -7
- package/chat/ChatProvider.js +14 -0
- package/chat/ChatWidget.css +10 -0
- package/chat/ChatWidget.d.ts +7 -3
- package/chat/ChatWidget.js +6 -3
- package/chat/agentState.d.ts +2 -1
- package/chat/agentState.js +4 -1
- package/chat/awaiting.d.ts +19 -0
- package/chat/awaiting.js +21 -0
- package/chat/context.d.ts +4 -0
- package/chat/index.d.ts +1 -0
- package/chat/index.js +3 -1
- package/chat/server.d.ts +8 -3
- package/chat/server.js +1 -1
- package/code/highlight.d.ts +4 -0
- package/code/highlight.js +34 -0
- package/code/index.d.ts +16 -0
- package/code/index.js +23 -0
- package/components/ActionCard/ActionCard.css +3 -3
- package/components/AgentStatus/AgentStatus.css +114 -22
- package/components/AgentStatus/AgentStatus.d.ts +10 -7
- package/components/AgentStatus/AgentStatus.js +10 -0
- package/components/AiButton/AiButton.d.ts +3 -3
- package/components/AnchorNav/AnchorNav.d.ts +29 -3
- package/components/AnchorNav/AnchorNav.js +69 -5
- package/components/AppLayout/AppLayout.css +8 -4
- package/components/AppLayout/AppLayout.d.ts +13 -3
- package/components/AppLayout/AppLayout.js +2 -0
- package/components/ArtifactPanel/ArtifactPanel.css +46 -0
- package/components/ArtifactPanel/ArtifactPanel.d.ts +14 -4
- package/components/ArtifactPanel/ArtifactPanel.js +8 -5
- package/components/BackToTop/BackToTop.css +28 -0
- package/components/BackToTop/BackToTop.d.ts +28 -0
- package/components/BackToTop/BackToTop.js +47 -0
- package/components/BentoTile/BentoTile.css +3 -0
- package/components/CodeBlock/CodeBlock.css +63 -24
- package/components/CodeBlock/CodeBlock.d.ts +62 -6
- package/components/CodeBlock/CodeBlock.js +90 -48
- package/components/Composer/Composer.css +14 -9
- package/components/Composer/Composer.d.ts +10 -8
- package/components/Composer/Composer.js +2 -1
- package/components/CopyButton/CopyButton.d.ts +42 -0
- package/components/CopyButton/CopyButton.js +72 -0
- package/components/DescriptionList/DescriptionListCopy.d.ts +2 -2
- package/components/DescriptionList/DescriptionListCopy.js +7 -35
- package/components/Figure/Figure.css +26 -0
- package/components/Figure/Figure.d.ts +10 -1
- package/components/Figure/Figure.js +15 -3
- package/components/Heading/Heading.css +43 -0
- package/components/Heading/Heading.d.ts +14 -3
- package/components/Heading/Heading.js +22 -4
- package/components/HoverCard/HoverCard.js +1 -0
- package/components/Link/Link.css +38 -0
- package/components/Link/Link.d.ts +3 -3
- package/components/Link/Link.js +1 -1
- package/components/Menubar/Menubar.css +82 -0
- package/components/Menubar/Menubar.d.ts +40 -0
- package/components/Menubar/Menubar.js +97 -0
- package/components/MessageCard/MessageCard.css +1 -1
- package/components/NavList/NavList.css +197 -0
- package/components/NavList/NavList.d.ts +54 -6
- package/components/NavList/NavList.js +136 -8
- package/components/Pagination/Pagination.css +80 -0
- package/components/Pagination/Pagination.d.ts +29 -3
- package/components/Pagination/Pagination.js +49 -5
- package/components/Rating/Rating.css +26 -0
- package/components/Rating/Rating.d.ts +18 -5
- package/components/Rating/Rating.js +16 -7
- package/components/SectionTitle/SectionTitle.css +36 -0
- package/components/SectionTitle/SectionTitle.d.ts +10 -1
- package/components/SectionTitle/SectionTitle.js +7 -2
- package/components/ShaderScene/ShaderScene.d.ts +2 -1
- package/components/ShaderScene/ShaderScene.js +20 -2
- package/components/SiteFooter/SiteFooter.css +157 -0
- package/components/SiteFooter/SiteFooter.d.ts +53 -0
- package/components/SiteFooter/SiteFooter.js +61 -0
- package/components/SiteHeader/SiteHeader.css +106 -4
- package/components/SiteHeader/SiteHeader.d.ts +25 -2
- package/components/SiteHeader/SiteHeader.js +46 -8
- package/components/SiteLayout/SiteLayout.css +361 -0
- package/components/SiteLayout/SiteLayout.d.ts +103 -0
- package/components/SiteLayout/SiteLayout.js +68 -0
- package/components/SourceTrail/SourceTrail.css +1 -1
- package/components/Table/Table.css +14 -0
- package/components/Table/Table.d.ts +2 -0
- package/components/Table/Table.js +1 -1
- package/components/ToolCall/ToolCall.css +2 -2
- package/components/Tooltip/Tooltip.js +1 -0
- package/components/UsageCard/UsageCard.css +4 -3
- package/components/keyboard-patterns.json.d.ts +57 -0
- package/components/keyboard-patterns.json.js +1 -1
- package/components/registry.json +89 -19
- package/components/registry.json.d.ts +89 -19
- package/components/registry.json.js +1 -1
- package/index.d.ts +5 -0
- package/index.js +14 -1
- package/package.json +14 -2
- package/tokens/breakpoints.js +3 -3
- package/tokens/registry.json +5 -0
- package/tokens/registry.json.d.ts +5 -0
- package/tokens/registry.json.js +1 -1
- package/tokens/tokens-dark.css +12 -0
- package/tokens/tokens-light.css +12 -0
- package/tokens/values.json.js +1 -1
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import "./SiteFooter.css";
|
|
4
|
+
import "../../behaviors/visually-hidden.css";
|
|
5
|
+
import "../../fonts/material-symbols.css";
|
|
6
|
+
function SiteFooter({
|
|
7
|
+
columns = [],
|
|
8
|
+
brand,
|
|
9
|
+
description,
|
|
10
|
+
social,
|
|
11
|
+
legal,
|
|
12
|
+
navLabel = "Site",
|
|
13
|
+
externalLabel = "(opens in a new tab)",
|
|
14
|
+
linkComponent,
|
|
15
|
+
className = "",
|
|
16
|
+
ref,
|
|
17
|
+
...rest
|
|
18
|
+
}) {
|
|
19
|
+
const Anchor = linkComponent ?? "a";
|
|
20
|
+
const baseClass = "ds-site-footer";
|
|
21
|
+
const uid = useId();
|
|
22
|
+
return /* @__PURE__ */ jsxs("footer", { ...rest, ref, className: [baseClass, className].filter(Boolean).join(" "), children: [
|
|
23
|
+
(brand || description || columns.length > 0) && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__top`, children: [
|
|
24
|
+
(brand || description) && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__about`, children: [
|
|
25
|
+
brand && /* @__PURE__ */ jsx("div", { className: `${baseClass}__brand`, children: brand }),
|
|
26
|
+
description && /* @__PURE__ */ jsx("p", { className: `${baseClass}__description`, children: description })
|
|
27
|
+
] }),
|
|
28
|
+
columns.length > 0 && /* @__PURE__ */ jsx("nav", { className: `${baseClass}__columns`, "aria-label": navLabel, children: columns.map((column, index) => /* @__PURE__ */ jsxs("div", { className: `${baseClass}__column`, children: [
|
|
29
|
+
/* @__PURE__ */ jsx("p", { className: `${baseClass}__title`, id: `${uid}-${index}`, children: column.label }),
|
|
30
|
+
/* @__PURE__ */ jsx("ul", { className: `${baseClass}__links`, "aria-labelledby": `${uid}-${index}`, children: column.links.map((link) => {
|
|
31
|
+
const ExternalOrRouted = link.external ? "a" : Anchor;
|
|
32
|
+
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
|
|
33
|
+
ExternalOrRouted,
|
|
34
|
+
{
|
|
35
|
+
className: `${baseClass}__link`,
|
|
36
|
+
href: link.href,
|
|
37
|
+
...link.external ? { target: "_blank", rel: "noopener noreferrer" } : {},
|
|
38
|
+
children: [
|
|
39
|
+
link.label,
|
|
40
|
+
link.external && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
41
|
+
/* @__PURE__ */ jsx("span", { className: `${baseClass}__external material-symbols-rounded`, "aria-hidden": "true", children: "arrow_outward" }),
|
|
42
|
+
/* @__PURE__ */ jsxs("span", { className: "ds-visually-hidden", children: [
|
|
43
|
+
" ",
|
|
44
|
+
externalLabel
|
|
45
|
+
] })
|
|
46
|
+
] })
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
) }, `${link.href}-${link.label}`);
|
|
50
|
+
}) })
|
|
51
|
+
] }, column.label)) })
|
|
52
|
+
] }),
|
|
53
|
+
(legal || social) && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__bottom`, children: [
|
|
54
|
+
legal && /* @__PURE__ */ jsx("div", { className: `${baseClass}__legal`, children: legal }),
|
|
55
|
+
social && /* @__PURE__ */ jsx("div", { className: `${baseClass}__social`, children: social })
|
|
56
|
+
] })
|
|
57
|
+
] });
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
SiteFooter
|
|
61
|
+
};
|
|
@@ -36,6 +36,41 @@
|
|
|
36
36
|
z-index: -1;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/* Behind an open menu on a full-width bar, a second progressive blur: the
|
|
40
|
+
window's width from the top down past the menu's bottom edge (its height
|
|
41
|
+
measured into --ds-site-header-menu-height as it opens), dissolving below
|
|
42
|
+
it, so the menu floats over a softened page rather than a hard band. It
|
|
43
|
+
sits with the bar's own blur, behind the bar and the menu, and only a
|
|
44
|
+
full-width bar shows it; a contained bar's menu needs no help. */
|
|
45
|
+
.ds-site-header__menu-blur.ds-progressive-blur {
|
|
46
|
+
position: fixed;
|
|
47
|
+
inset: 0 0 auto;
|
|
48
|
+
height: calc(
|
|
49
|
+
var(--ds-site-header-height) + var(--gap-200) + var(--ds-site-header-menu-height, 0px) +
|
|
50
|
+
var(--ds-site-header-blur-reach) * 2
|
|
51
|
+
);
|
|
52
|
+
z-index: -1;
|
|
53
|
+
display: none;
|
|
54
|
+
opacity: 0;
|
|
55
|
+
visibility: hidden;
|
|
56
|
+
transition:
|
|
57
|
+
opacity var(--motion-duration-slow) var(--motion-ease-standard),
|
|
58
|
+
visibility 0s linear var(--motion-duration-slow);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.ds-site-header[data-ds-width='full'] .ds-site-header__menu-blur.ds-progressive-blur,
|
|
62
|
+
:where([data-ds-width='full']) > .ds-site-header:not([data-ds-width]) .ds-site-header__menu-blur.ds-progressive-blur {
|
|
63
|
+
display: block;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.ds-site-header__menu-blur.ds-progressive-blur[data-open] {
|
|
67
|
+
opacity: 1;
|
|
68
|
+
visibility: visible;
|
|
69
|
+
transition:
|
|
70
|
+
opacity var(--motion-duration-slow) var(--motion-ease-standard),
|
|
71
|
+
visibility 0s;
|
|
72
|
+
}
|
|
73
|
+
|
|
39
74
|
/* The bar: brand, pills, then the end cluster pushed to the far side. */
|
|
40
75
|
.ds-site-header__bar {
|
|
41
76
|
position: relative;
|
|
@@ -52,6 +87,18 @@
|
|
|
52
87
|
overflow-clip-margin: var(--gap-200);
|
|
53
88
|
}
|
|
54
89
|
|
|
90
|
+
/* A set width (the shell recipe's width axis): the bar takes the side
|
|
91
|
+
gutter, and contained centres it at the contained width so it lines up
|
|
92
|
+
with a contained page; full leaves the maximum at none. */
|
|
93
|
+
.ds-site-header--width .ds-site-header__bar {
|
|
94
|
+
max-width: var(--ds-shell-content-max, var(--ds-shell-contained-width));
|
|
95
|
+
margin-inline: auto;
|
|
96
|
+
padding-inline: var(--ds-shell-gutter);
|
|
97
|
+
/* The bar's side padding, read by the menu panel so it lines up with
|
|
98
|
+
the bar's content rather than its outer edge. */
|
|
99
|
+
--_bar-inset: var(--ds-shell-gutter);
|
|
100
|
+
}
|
|
101
|
+
|
|
55
102
|
.ds-site-header__brand {
|
|
56
103
|
display: flex;
|
|
57
104
|
align-items: center;
|
|
@@ -190,9 +237,11 @@
|
|
|
190
237
|
visibility: hidden;
|
|
191
238
|
}
|
|
192
239
|
|
|
193
|
-
/* The mega menu hangs under the bar across
|
|
194
|
-
|
|
195
|
-
|
|
240
|
+
/* The mega menu hangs under the bar across the bar's content, inside its
|
|
241
|
+
side padding, so its edges meet the brand and the last action and the
|
|
242
|
+
page's content below. It is not anchored to a control
|
|
243
|
+
(useAnchoredPosition's job): it belongs to the bar and spans it, so it
|
|
244
|
+
rides the bar's own box.
|
|
196
245
|
The wrapper keeps the height of the last section shown after the menu
|
|
197
246
|
closes, so it never takes a press itself: a transparent box that size
|
|
198
247
|
would sit over the page and swallow its clicks. Only the menu does, and a
|
|
@@ -200,7 +249,7 @@
|
|
|
200
249
|
.ds-site-header__panel {
|
|
201
250
|
position: absolute;
|
|
202
251
|
inset-block-start: calc(100% + var(--gap-200));
|
|
203
|
-
inset-inline:
|
|
252
|
+
inset-inline: var(--_bar-inset, 0px);
|
|
204
253
|
pointer-events: none;
|
|
205
254
|
}
|
|
206
255
|
|
|
@@ -208,6 +257,50 @@
|
|
|
208
257
|
pointer-events: auto;
|
|
209
258
|
}
|
|
210
259
|
|
|
260
|
+
/* A full-width bar wider than the contained width keeps its menu at the
|
|
261
|
+
contained width and opens it where the reader is looking: the panel
|
|
262
|
+
starts under the section pills (--ds-site-header-nav-start, measured as
|
|
263
|
+
it opens), runs at most the shell recipe's contained width, and never
|
|
264
|
+
comes closer to the window's end than the side padding, so a wide window
|
|
265
|
+
neither stretches the menu's columns apart nor strands it in the middle.
|
|
266
|
+
On a bar no wider than --ds-site-header-menu-hang-from (an override
|
|
267
|
+
hook, the contained width by default; a host whose contained layout is
|
|
268
|
+
wider than its full one's step sets it to that wider width), where a
|
|
269
|
+
full bar and a contained one draw the same, the menu does the same as a
|
|
270
|
+
contained bar's and spans the bar's content: the clamp below is a step,
|
|
271
|
+
zero up to that width and the pills' offset past it. Full comes from the
|
|
272
|
+
header's own width or, unset, from the width of the slot it sits in
|
|
273
|
+
(SiteLayout's header slot). */
|
|
274
|
+
.ds-site-header[data-ds-width='full'] .ds-site-header__panel,
|
|
275
|
+
:where([data-ds-width='full']) > .ds-site-header:not([data-ds-width]) .ds-site-header__panel {
|
|
276
|
+
/* --ds-site-header-nav-start is measured onto the header as the menu
|
|
277
|
+
opens, not a hook; the fallback covers the frame before it is. */
|
|
278
|
+
--_panel-start: calc(
|
|
279
|
+
var(--_bar-inset, 0px) +
|
|
280
|
+
clamp(
|
|
281
|
+
0px,
|
|
282
|
+
(100% - var(--ds-site-header-menu-hang-from, var(--ds-shell-contained-width, 100%))) * 1000,
|
|
283
|
+
var(--ds-site-header-nav-start, var(--_bar-inset, 0px)) - var(--_bar-inset, 0px)
|
|
284
|
+
)
|
|
285
|
+
);
|
|
286
|
+
inset-inline: var(--_panel-start) auto;
|
|
287
|
+
/* The contained-width cap holds only while the menu hangs from the
|
|
288
|
+
pills; up to the hang width the cap steps out of the way (the same
|
|
289
|
+
step, inverted), so the menu meets the bar's far edge as a contained
|
|
290
|
+
bar's does. */
|
|
291
|
+
width: min(
|
|
292
|
+
calc(
|
|
293
|
+
var(--ds-shell-contained-width, 100%) +
|
|
294
|
+
clamp(
|
|
295
|
+
0px,
|
|
296
|
+
(var(--ds-site-header-menu-hang-from, var(--ds-shell-contained-width, 100%)) - 100% + 1px) * 1000,
|
|
297
|
+
100vw
|
|
298
|
+
)
|
|
299
|
+
),
|
|
300
|
+
calc(100% - var(--_panel-start) - var(--_bar-inset, 0px))
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
|
|
211
304
|
/* Condensed: `condensedActions` take the place of `actions`. Whichever set
|
|
212
305
|
is not showing leaves the row but stays measurable (hidden, out of flow,
|
|
213
306
|
inert), as the folded pills do. */
|
|
@@ -362,6 +455,15 @@
|
|
|
362
455
|
width: 100%;
|
|
363
456
|
}
|
|
364
457
|
|
|
458
|
+
/* The list does the scrolling, as NavList's scrollable mode: no scrollbar
|
|
459
|
+
until it moves and its ends fading out, the sidebar's treatment, so the
|
|
460
|
+
drawer's body only gives it the height. */
|
|
461
|
+
.ds-site-header__drawer .ds-drawer__body {
|
|
462
|
+
display: flex;
|
|
463
|
+
flex-direction: column;
|
|
464
|
+
overflow: hidden;
|
|
465
|
+
}
|
|
466
|
+
|
|
365
467
|
/* Icon side padding, Button's rule: a section with a mega menu trails a
|
|
366
468
|
caret, whose box carries its own side bearing, so that pill's end takes
|
|
367
469
|
the step below the label side (16 → 12). */
|
|
@@ -76,9 +76,21 @@ type SiteHeaderOwnProps = {
|
|
|
76
76
|
* breakpoint (`tablet` or the wider `mid`) the bar starts folded by CSS
|
|
77
77
|
* alone, so a phone never sees the pills overflow; the measurement takes
|
|
78
78
|
* over once the script runs. Pick the step nearest where the pills stop
|
|
79
|
-
* fitting, or `never` for a bar that fits at every width.
|
|
79
|
+
* fitting, or `never` for a bar that fits at every width. Defaults to
|
|
80
|
+
* `foldBelow` when that is set, so a bar told to fold at a step starts
|
|
81
|
+
* folded there too and never shifts when its script runs.
|
|
82
|
+
* @default foldBelow ?? 'tablet'
|
|
80
83
|
*/
|
|
81
84
|
initialFold?: 'tablet' | 'mid' | 'never';
|
|
85
|
+
/**
|
|
86
|
+
* Fold the bar into its menu at or below this breakpoint even when the
|
|
87
|
+
* pills would fit (`tablet` is 959px and below, `mid` 1279px), for a site
|
|
88
|
+
* whose sidebar of pages leaves the page there: the menu then carries the
|
|
89
|
+
* pages (each section's `drawerItems`), so the reader always has one way
|
|
90
|
+
* in. Leave it out to fold only when the row runs out of room.
|
|
91
|
+
* @default undefined
|
|
92
|
+
*/
|
|
93
|
+
foldBelow?: 'tablet' | 'mid';
|
|
82
94
|
/**
|
|
83
95
|
* Whether the header sticks to the top of the viewport over a progressive
|
|
84
96
|
* blur. Off, it scrolls away with the page and draws no blur.
|
|
@@ -107,6 +119,17 @@ type SiteHeaderOwnProps = {
|
|
|
107
119
|
drawerTitle?: string;
|
|
108
120
|
/** The accessible name of the drawer's close button. */
|
|
109
121
|
drawerCloseLabel?: string;
|
|
122
|
+
/**
|
|
123
|
+
* How wide the bar's contents run, read from the shell recipe's width
|
|
124
|
+
* axis. `contained` centres them in the contained width (1440px, or the
|
|
125
|
+
* nearest `--ds-shell-contained-width`) with the side gutter, lining up
|
|
126
|
+
* with a contained page below; `full` runs them edge to edge, the gutter
|
|
127
|
+
* aside. Leave it out and the bar fills whatever box the host gives it,
|
|
128
|
+
* with no gutter of its own; inside a SiteLayout it follows the layout's
|
|
129
|
+
* `headerWidth` instead.
|
|
130
|
+
* @default undefined
|
|
131
|
+
*/
|
|
132
|
+
width?: 'contained' | 'full';
|
|
110
133
|
/** Additional CSS classes on the `<header>`. */
|
|
111
134
|
className?: string;
|
|
112
135
|
};
|
|
@@ -121,5 +144,5 @@ export interface SiteHeaderProps extends SiteHeaderOwnProps, Omit<React.Componen
|
|
|
121
144
|
* same sections. The forwarded ref and any unrecognised props target the
|
|
122
145
|
* `<header>`.
|
|
123
146
|
*/
|
|
124
|
-
export declare function SiteHeader({ brand, sections, currentHref, actions, condensedActions, wideActions, drawerFooter, drawerOpen: drawerOpenProp, defaultDrawerOpen, onDrawerOpenChange, initialFold, sticky, tintAfter, linkComponent, navLabel, drawerOpenLabel, drawerTitle, drawerCloseLabel, className, ref, ...rest }: SiteHeaderProps): React.JSX.Element;
|
|
147
|
+
export declare function SiteHeader({ brand, sections, currentHref, actions, condensedActions, wideActions, drawerFooter, drawerOpen: drawerOpenProp, defaultDrawerOpen, onDrawerOpenChange, foldBelow, initialFold, sticky, tintAfter, linkComponent, navLabel, drawerOpenLabel, drawerTitle, drawerCloseLabel, width, className, ref, ...rest }: SiteHeaderProps): React.JSX.Element;
|
|
125
148
|
export {};
|
|
@@ -4,12 +4,14 @@ import { useId, useRef, useState, useCallback, useLayoutEffect, useEffect } from
|
|
|
4
4
|
import { useLinkComponent } from "../../behaviors/LinkProvider.js";
|
|
5
5
|
import { useLayer } from "../../behaviors/useLayer.js";
|
|
6
6
|
import { isRtl } from "../../behaviors/direction.js";
|
|
7
|
+
import { mediaBelow, BREAKPOINT_MID_PX, BREAKPOINT_TABLET_PX } from "../../tokens/breakpoints.js";
|
|
7
8
|
import { MOTION_HOVER_HIDE_DELAY_MS } from "../../tokens/motion.js";
|
|
8
9
|
import { IconButton } from "../IconButton/IconButton.js";
|
|
9
10
|
import { Drawer } from "../Drawer/Drawer.js";
|
|
10
11
|
import { MegaMenu } from "../MegaMenu/MegaMenu.js";
|
|
11
12
|
import { NavList } from "../NavList/NavList.js";
|
|
12
13
|
import { ProgressiveBlur } from "../ProgressiveBlur/ProgressiveBlur.js";
|
|
14
|
+
import "../../behaviors/shell.css";
|
|
13
15
|
import "./SiteHeader.css";
|
|
14
16
|
import "../../fonts/material-symbols.css";
|
|
15
17
|
const isUnder = (href, currentHref) => currentHref != null && (currentHref === href || currentHref.startsWith(`${href}/`));
|
|
@@ -25,7 +27,8 @@ function SiteHeader({
|
|
|
25
27
|
drawerOpen: drawerOpenProp,
|
|
26
28
|
defaultDrawerOpen = false,
|
|
27
29
|
onDrawerOpenChange,
|
|
28
|
-
|
|
30
|
+
foldBelow,
|
|
31
|
+
initialFold = foldBelow ?? "tablet",
|
|
29
32
|
sticky = true,
|
|
30
33
|
tintAfter = 48,
|
|
31
34
|
linkComponent,
|
|
@@ -33,6 +36,7 @@ function SiteHeader({
|
|
|
33
36
|
drawerOpenLabel = "Open menu",
|
|
34
37
|
drawerTitle = "Menu",
|
|
35
38
|
drawerCloseLabel = "Close menu",
|
|
39
|
+
width,
|
|
36
40
|
className = "",
|
|
37
41
|
ref,
|
|
38
42
|
...rest
|
|
@@ -78,7 +82,9 @@ function SiteHeader({
|
|
|
78
82
|
const bar = barRef.current;
|
|
79
83
|
if (!bar) return;
|
|
80
84
|
const measure = () => {
|
|
81
|
-
const
|
|
85
|
+
const barStyle = getComputedStyle(bar);
|
|
86
|
+
const gap = parseFloat(barStyle.columnGap) || 0;
|
|
87
|
+
const padding = (parseFloat(barStyle.paddingInlineStart) || 0) + (parseFloat(barStyle.paddingInlineEnd) || 0);
|
|
82
88
|
const navStart = navRef.current ? parseFloat(getComputedStyle(navRef.current).marginInlineStart) || 0 : 0;
|
|
83
89
|
const rowWidth = (actionsEl) => {
|
|
84
90
|
const parts = [brandRef.current, navRef.current, wideRef.current, actionsEl];
|
|
@@ -86,11 +92,12 @@ function SiteHeader({
|
|
|
86
92
|
const present = widths.filter((w) => w > 0).length;
|
|
87
93
|
return widths.reduce((sum, w) => sum + w, 0) + navStart + gap * Math.max(present - 1, 0);
|
|
88
94
|
};
|
|
89
|
-
const room = bar.clientWidth - lockedGutter.current;
|
|
95
|
+
const room = bar.clientWidth - padding - lockedGutter.current;
|
|
90
96
|
const full = rowWidth(actionsRef.current);
|
|
91
97
|
const tight = condensedActionsRef.current ? rowWidth(condensedActionsRef.current) : full;
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
const forced = foldBelow !== void 0 && window.matchMedia(mediaBelow(foldBelow === "mid" ? BREAKPOINT_MID_PX : BREAKPOINT_TABLET_PX)).matches;
|
|
99
|
+
setCondensed(condensedActionsRef.current != null && (forced || full > room));
|
|
100
|
+
setFolded(forced || tight > room);
|
|
94
101
|
setMeasured(true);
|
|
95
102
|
};
|
|
96
103
|
measure();
|
|
@@ -104,7 +111,7 @@ function SiteHeader({
|
|
|
104
111
|
condensedActionsRef.current
|
|
105
112
|
].forEach((el) => el && observer.observe(el));
|
|
106
113
|
return () => observer.disconnect();
|
|
107
|
-
}, [sections, actions, condensedActions, wideActions, brand]);
|
|
114
|
+
}, [sections, actions, condensedActions, wideActions, brand, foldBelow]);
|
|
108
115
|
useEffect(() => {
|
|
109
116
|
if (!sticky) return;
|
|
110
117
|
let frame = 0;
|
|
@@ -129,10 +136,11 @@ function SiteHeader({
|
|
|
129
136
|
const rtl = isRtl(bar);
|
|
130
137
|
const start = (rect) => rtl ? document.documentElement.clientWidth - rect.right : rect.left;
|
|
131
138
|
const barRect = bar.getBoundingClientRect();
|
|
139
|
+
const inset = parseFloat(getComputedStyle(bar).paddingInlineStart) || 0;
|
|
132
140
|
const offsets = {
|
|
133
141
|
"--ds-site-header-height": `${bar.offsetHeight}px`,
|
|
134
142
|
"--ds-site-header-drawer-top": `${Math.max(barRect.top, 0)}px`,
|
|
135
|
-
"--ds-site-header-drawer-start": `${start(barRect)}px`
|
|
143
|
+
"--ds-site-header-drawer-start": `${start(barRect) + inset}px`
|
|
136
144
|
};
|
|
137
145
|
const button = menuButtonRef.current?.getBoundingClientRect();
|
|
138
146
|
if (button && button.width > 0) {
|
|
@@ -186,6 +194,26 @@ function SiteHeader({
|
|
|
186
194
|
}, [folded, measured, drawerOpen, setDrawerOpen]);
|
|
187
195
|
const panelOpen = openId != null && sections.some((s) => s.id === openId && s.mega);
|
|
188
196
|
const shown = sections.find((s) => s.id === shownId && s.mega) ?? null;
|
|
197
|
+
useLayoutEffect(() => {
|
|
198
|
+
const header = headerRef.current;
|
|
199
|
+
const panel = panelRef.current;
|
|
200
|
+
if (!header || !panel || !panelOpen) return;
|
|
201
|
+
const write = () => {
|
|
202
|
+
header.style.setProperty("--ds-site-header-menu-height", `${panel.offsetHeight}px`);
|
|
203
|
+
const bar = barRef.current;
|
|
204
|
+
const nav = navRef.current;
|
|
205
|
+
if (bar && nav) {
|
|
206
|
+
const barRect = bar.getBoundingClientRect();
|
|
207
|
+
const navRect = nav.getBoundingClientRect();
|
|
208
|
+
const start = isRtl(bar) ? barRect.right - navRect.right : navRect.left - barRect.left;
|
|
209
|
+
header.style.setProperty("--ds-site-header-nav-start", `${Math.round(start)}px`);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
write();
|
|
213
|
+
const observer = new ResizeObserver(write);
|
|
214
|
+
observer.observe(panel);
|
|
215
|
+
return () => observer.disconnect();
|
|
216
|
+
}, [panelOpen, shownId]);
|
|
189
217
|
const drawerItems = sections.map((section) => ({
|
|
190
218
|
id: section.id,
|
|
191
219
|
label: section.label,
|
|
@@ -197,13 +225,22 @@ function SiteHeader({
|
|
|
197
225
|
const classes = [
|
|
198
226
|
baseClass,
|
|
199
227
|
sticky && `${baseClass}--sticky`,
|
|
228
|
+
width && `${baseClass}--width`,
|
|
200
229
|
condensed && `${baseClass}--condensed`,
|
|
201
230
|
folded && `${baseClass}--folded`,
|
|
202
231
|
!measured && initialFold !== "never" && `${baseClass}--prefold-${initialFold}`,
|
|
203
232
|
className
|
|
204
233
|
].filter(Boolean).join(" ");
|
|
205
|
-
return /* @__PURE__ */ jsxs("header", { ...rest, ref: setRef, className: classes, children: [
|
|
234
|
+
return /* @__PURE__ */ jsxs("header", { ...rest, ref: setRef, className: classes, "data-ds-width": width, children: [
|
|
206
235
|
sticky && /* @__PURE__ */ jsx(ProgressiveBlur, { className: `${baseClass}__blur`, tinted }),
|
|
236
|
+
/* @__PURE__ */ jsx(
|
|
237
|
+
ProgressiveBlur,
|
|
238
|
+
{
|
|
239
|
+
className: `${baseClass}__menu-blur`,
|
|
240
|
+
tinted: true,
|
|
241
|
+
"data-open": panelOpen && !folded ? "" : void 0
|
|
242
|
+
}
|
|
243
|
+
),
|
|
207
244
|
/* @__PURE__ */ jsxs("div", { ref: barRef, className: `${baseClass}__bar`, children: [
|
|
208
245
|
brand && /* @__PURE__ */ jsx("div", { ref: brandRef, className: `${baseClass}__brand`, children: brand }),
|
|
209
246
|
/* @__PURE__ */ jsx("nav", { ref: navRef, "aria-label": navLabel, className: `${baseClass}__nav`, inert: folded, children: sections.map((section) => {
|
|
@@ -351,6 +388,7 @@ function SiteHeader({
|
|
|
351
388
|
currentHref,
|
|
352
389
|
defaultExpandedIds: currentSectionId ? [currentSectionId] : [],
|
|
353
390
|
linkComponent: Link,
|
|
391
|
+
scrollable: true,
|
|
354
392
|
onNavigate: () => setDrawerOpen(false)
|
|
355
393
|
},
|
|
356
394
|
drawerOpen ? "open" : "closed"
|