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.
Files changed (124) hide show
  1. package/README.md +4 -4
  2. package/behaviors/chat-card.css +11 -6
  3. package/behaviors/clipboard.d.ts +7 -0
  4. package/behaviors/clipboard.js +35 -0
  5. package/behaviors/headingSlug.d.ts +8 -0
  6. package/behaviors/headingSlug.js +4 -0
  7. package/behaviors/shell.css +64 -0
  8. package/behaviors/syncedChoice.d.ts +2 -0
  9. package/behaviors/syncedChoice.js +48 -0
  10. package/behaviors/useLayer.d.ts +15 -2
  11. package/behaviors/useLayer.js +3 -2
  12. package/bin/templates/blocks/app/guide/PageFeedback.tsx +55 -0
  13. package/bin/templates/blocks/app/guide/page.module.css +94 -0
  14. package/bin/templates/blocks/app/guide/page.tsx +168 -0
  15. package/bin/templates/blocks/components/blocks/AppShell.module.css +3 -1
  16. package/bin/templates/blocks/components/blocks/AppShell.tsx +8 -0
  17. package/bin/templates/blocks/components/blocks/DocsShell.module.css +18 -0
  18. package/bin/templates/blocks/components/blocks/DocsShell.tsx +179 -0
  19. package/bin/templates/blocks/registry.json +13 -0
  20. package/chat/AssistantTurn.d.ts +2 -0
  21. package/chat/AssistantTurn.js +18 -7
  22. package/chat/ChatProvider.js +14 -0
  23. package/chat/ChatWidget.css +10 -0
  24. package/chat/ChatWidget.d.ts +7 -3
  25. package/chat/ChatWidget.js +6 -3
  26. package/chat/agentState.d.ts +2 -1
  27. package/chat/agentState.js +4 -1
  28. package/chat/awaiting.d.ts +19 -0
  29. package/chat/awaiting.js +21 -0
  30. package/chat/context.d.ts +4 -0
  31. package/chat/index.d.ts +1 -0
  32. package/chat/index.js +3 -1
  33. package/chat/server.d.ts +8 -3
  34. package/chat/server.js +1 -1
  35. package/code/highlight.d.ts +4 -0
  36. package/code/highlight.js +34 -0
  37. package/code/index.d.ts +16 -0
  38. package/code/index.js +23 -0
  39. package/components/ActionCard/ActionCard.css +3 -3
  40. package/components/AgentStatus/AgentStatus.css +114 -22
  41. package/components/AgentStatus/AgentStatus.d.ts +10 -7
  42. package/components/AgentStatus/AgentStatus.js +10 -0
  43. package/components/AiButton/AiButton.d.ts +3 -3
  44. package/components/AnchorNav/AnchorNav.d.ts +29 -3
  45. package/components/AnchorNav/AnchorNav.js +69 -5
  46. package/components/AppLayout/AppLayout.css +8 -4
  47. package/components/AppLayout/AppLayout.d.ts +13 -3
  48. package/components/AppLayout/AppLayout.js +2 -0
  49. package/components/ArtifactPanel/ArtifactPanel.css +46 -0
  50. package/components/ArtifactPanel/ArtifactPanel.d.ts +14 -4
  51. package/components/ArtifactPanel/ArtifactPanel.js +8 -5
  52. package/components/BackToTop/BackToTop.css +28 -0
  53. package/components/BackToTop/BackToTop.d.ts +28 -0
  54. package/components/BackToTop/BackToTop.js +47 -0
  55. package/components/BentoTile/BentoTile.css +3 -0
  56. package/components/CodeBlock/CodeBlock.css +63 -24
  57. package/components/CodeBlock/CodeBlock.d.ts +62 -6
  58. package/components/CodeBlock/CodeBlock.js +90 -48
  59. package/components/Composer/Composer.css +14 -9
  60. package/components/Composer/Composer.d.ts +10 -8
  61. package/components/Composer/Composer.js +2 -1
  62. package/components/CopyButton/CopyButton.d.ts +42 -0
  63. package/components/CopyButton/CopyButton.js +72 -0
  64. package/components/DescriptionList/DescriptionListCopy.d.ts +2 -2
  65. package/components/DescriptionList/DescriptionListCopy.js +7 -35
  66. package/components/Figure/Figure.css +26 -0
  67. package/components/Figure/Figure.d.ts +10 -1
  68. package/components/Figure/Figure.js +15 -3
  69. package/components/Heading/Heading.css +43 -0
  70. package/components/Heading/Heading.d.ts +14 -3
  71. package/components/Heading/Heading.js +22 -4
  72. package/components/HoverCard/HoverCard.js +1 -0
  73. package/components/Link/Link.css +38 -0
  74. package/components/Link/Link.d.ts +3 -3
  75. package/components/Link/Link.js +1 -1
  76. package/components/Menubar/Menubar.css +82 -0
  77. package/components/Menubar/Menubar.d.ts +40 -0
  78. package/components/Menubar/Menubar.js +97 -0
  79. package/components/MessageCard/MessageCard.css +1 -1
  80. package/components/NavList/NavList.css +197 -0
  81. package/components/NavList/NavList.d.ts +54 -6
  82. package/components/NavList/NavList.js +136 -8
  83. package/components/Pagination/Pagination.css +80 -0
  84. package/components/Pagination/Pagination.d.ts +29 -3
  85. package/components/Pagination/Pagination.js +49 -5
  86. package/components/Rating/Rating.css +26 -0
  87. package/components/Rating/Rating.d.ts +18 -5
  88. package/components/Rating/Rating.js +16 -7
  89. package/components/SectionTitle/SectionTitle.css +36 -0
  90. package/components/SectionTitle/SectionTitle.d.ts +10 -1
  91. package/components/SectionTitle/SectionTitle.js +7 -2
  92. package/components/ShaderScene/ShaderScene.d.ts +2 -1
  93. package/components/ShaderScene/ShaderScene.js +20 -2
  94. package/components/SiteFooter/SiteFooter.css +157 -0
  95. package/components/SiteFooter/SiteFooter.d.ts +53 -0
  96. package/components/SiteFooter/SiteFooter.js +61 -0
  97. package/components/SiteHeader/SiteHeader.css +106 -4
  98. package/components/SiteHeader/SiteHeader.d.ts +25 -2
  99. package/components/SiteHeader/SiteHeader.js +46 -8
  100. package/components/SiteLayout/SiteLayout.css +361 -0
  101. package/components/SiteLayout/SiteLayout.d.ts +103 -0
  102. package/components/SiteLayout/SiteLayout.js +68 -0
  103. package/components/SourceTrail/SourceTrail.css +1 -1
  104. package/components/Table/Table.css +14 -0
  105. package/components/Table/Table.d.ts +2 -0
  106. package/components/Table/Table.js +1 -1
  107. package/components/ToolCall/ToolCall.css +2 -2
  108. package/components/Tooltip/Tooltip.js +1 -0
  109. package/components/UsageCard/UsageCard.css +4 -3
  110. package/components/keyboard-patterns.json.d.ts +57 -0
  111. package/components/keyboard-patterns.json.js +1 -1
  112. package/components/registry.json +89 -19
  113. package/components/registry.json.d.ts +89 -19
  114. package/components/registry.json.js +1 -1
  115. package/index.d.ts +5 -0
  116. package/index.js +14 -1
  117. package/package.json +14 -2
  118. package/tokens/breakpoints.js +3 -3
  119. package/tokens/registry.json +5 -0
  120. package/tokens/registry.json.d.ts +5 -0
  121. package/tokens/registry.json.js +1 -1
  122. package/tokens/tokens-dark.css +12 -0
  123. package/tokens/tokens-light.css +12 -0
  124. package/tokens/values.json.js +1 -1
@@ -1,6 +1,31 @@
1
1
  import { default as React } from 'react';
2
+ import { LinkComponent } from '../../behaviors/LinkProvider';
3
+ /** A neighbouring page the `adjacent` form links to. */
4
+ export interface PaginationLink {
5
+ /** Where the link goes. */
6
+ href: string;
7
+ /** The page's title, shown under the Previous or Next eyebrow. */
8
+ label: string;
9
+ }
2
10
  /** Props owned by Pagination itself — everything else falls through to the nav landmark. */
3
11
  type PaginationOwnProps = {
12
+ /**
13
+ * The pager's form. `numbered` (the default) steps through numbered pages
14
+ * of one list. `adjacent` links to the page before and after this one in
15
+ * a sequence (a guide's chapters, a set of articles) as two cards naming
16
+ * them, and takes `previous` and `next` instead of page numbers.
17
+ */
18
+ variant?: 'numbered' | 'adjacent';
19
+ /** The page before this one, for the `adjacent` form. Leave it out on the first page. */
20
+ previous?: PaginationLink;
21
+ /** The page after this one, for the `adjacent` form. Leave it out on the last page. */
22
+ next?: PaginationLink;
23
+ /** The eyebrow over the previous page's title in the `adjacent` form. */
24
+ previousText?: string;
25
+ /** The eyebrow over the next page's title in the `adjacent` form. */
26
+ nextText?: string;
27
+ /** The component that renders the `adjacent` form's links, such as Next.js's `Link`. Defaults to the nearest LinkProvider's, else a plain `<a>`. */
28
+ linkComponent?: LinkComponent;
4
29
  /**
5
30
  * Current page (1-based), for a controlled pager. Leave it undefined to let
6
31
  * the component keep its own page, seeded from `defaultPage`.
@@ -8,8 +33,8 @@ type PaginationOwnProps = {
8
33
  page?: number;
9
34
  /** Page shown on first render when the pager is uncontrolled (1-based) */
10
35
  defaultPage?: number;
11
- /** Total number of pages */
12
- pageCount: number;
36
+ /** Total number of pages. Required for the `numbered` form; the `adjacent` form ignores it. */
37
+ pageCount?: number;
13
38
  /** Called with the page the user requests */
14
39
  onPageChange?: (page: number) => void;
15
40
  /** Pages shown on each side of the current page */
@@ -40,7 +65,8 @@ export interface PaginationProps extends PaginationOwnProps, Omit<React.Componen
40
65
  /**
41
66
  * Pagination component — page navigation for long datasets.
42
67
  * Numbered pages with ellipses for large ranges, or a compact
43
- * prev/next readout. Pairs with Table.
68
+ * prev/next readout. Pairs with Table. The `adjacent` form instead links
69
+ * to the previous and next page of a sequence, as two titled cards.
44
70
  *
45
71
  * Forwards a ref to the `<nav>` landmark and spreads unrecognised props onto
46
72
  * it. The landmark is named "Pagination" unless a native `aria-label` or
@@ -5,6 +5,8 @@ import "./Pagination.css";
5
5
  import "../../fonts/material-symbols.css";
6
6
  import { useLocale } from "../../behaviors/LocaleProvider.js";
7
7
  import { formatNumber } from "../../behaviors/locale.js";
8
+ import { useLinkComponent } from "../../behaviors/LinkProvider.js";
9
+ import { warnOnce } from "../../behaviors/devWarning.js";
8
10
  const defaultPageLabel = (page) => `Page ${page}`;
9
11
  const defaultReadoutLabel = (page, pageCount) => `Page ${page} of ${pageCount}`;
10
12
  const range = (start, end) => Array.from({ length: end - start + 1 }, (_, i) => start + i);
@@ -27,9 +29,15 @@ const getPageItems = (page, pageCount, siblingCount) => {
27
29
  };
28
30
  const Pagination = React.forwardRef(
29
31
  ({
32
+ variant = "numbered",
33
+ previous,
34
+ next,
35
+ previousText = "Previous",
36
+ nextText = "Next",
37
+ linkComponent,
30
38
  page,
31
39
  defaultPage = 1,
32
- pageCount,
40
+ pageCount: pageCountProp,
33
41
  onPageChange,
34
42
  siblingCount = 1,
35
43
  size = "default",
@@ -43,7 +51,12 @@ const Pagination = React.forwardRef(
43
51
  ...rest
44
52
  }, ref) => {
45
53
  const locale = useLocale(localeProp);
54
+ const Link = useLinkComponent(linkComponent);
46
55
  const baseClass = "ds-pagination";
56
+ if (variant === "numbered" && pageCountProp === void 0) {
57
+ warnOnce("Pagination: the numbered form needs `pageCount`; without it, it draws one page.");
58
+ }
59
+ const pageCount = pageCountProp ?? 1;
47
60
  const compact = size === "compact";
48
61
  const isControlled = page !== void 0;
49
62
  const [internalPage, setInternalPage] = useState(defaultPage);
@@ -52,12 +65,43 @@ const Pagination = React.forwardRef(
52
65
  const isFirst = clampedPage <= 1;
53
66
  const isLast = clampedPage >= pageCount;
54
67
  const goTo = (target) => {
55
- const next = Math.min(Math.max(target, 1), pageCount);
56
- if (next === clampedPage) return;
57
- if (!isControlled) setInternalPage(next);
58
- onPageChange?.(next);
68
+ const next2 = Math.min(Math.max(target, 1), pageCount);
69
+ if (next2 === clampedPage) return;
70
+ if (!isControlled) setInternalPage(next2);
71
+ onPageChange?.(next2);
59
72
  };
60
73
  const classes = [baseClass, compact ? `${baseClass}--compact` : "", className].filter(Boolean).join(" ");
74
+ if (variant === "adjacent") {
75
+ const card = (direction, link) => /* @__PURE__ */ jsxs(
76
+ Link,
77
+ {
78
+ href: link.href,
79
+ className: `${baseClass}__adjacent ${baseClass}__adjacent--${direction}`,
80
+ rel: direction === "previous" ? "prev" : "next",
81
+ children: [
82
+ /* @__PURE__ */ jsxs("span", { className: `${baseClass}__adjacent-eyebrow`, children: [
83
+ direction === "previous" && /* @__PURE__ */ jsx("span", { className: `${baseClass}__icon material-symbols-rounded ds-mirror-rtl`, "aria-hidden": "true", children: "chevron_left" }),
84
+ direction === "previous" ? previousText : nextText,
85
+ direction === "next" && /* @__PURE__ */ jsx("span", { className: `${baseClass}__icon material-symbols-rounded ds-mirror-rtl`, "aria-hidden": "true", children: "chevron_right" })
86
+ ] }),
87
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}__adjacent-title`, children: link.label })
88
+ ]
89
+ }
90
+ );
91
+ return /* @__PURE__ */ jsxs(
92
+ "nav",
93
+ {
94
+ "aria-label": ariaLabel ?? "Pagination",
95
+ ...rest,
96
+ ref,
97
+ className: [baseClass, `${baseClass}--adjacent`, className].filter(Boolean).join(" "),
98
+ children: [
99
+ previous ? card("previous", previous) : /* @__PURE__ */ jsx("span", { "aria-hidden": "true" }),
100
+ next ? card("next", next) : /* @__PURE__ */ jsx("span", { "aria-hidden": "true" })
101
+ ]
102
+ }
103
+ );
104
+ }
61
105
  const arrowButton = (direction) => {
62
106
  const disabled = direction === "previous" ? isFirst : isLast;
63
107
  return /* @__PURE__ */ jsx(
@@ -72,3 +72,29 @@
72
72
  .ds-rating--disabled .ds-rating__step:hover {
73
73
  transform: none;
74
74
  }
75
+
76
+ /* ============================================
77
+ THUMBS (variant="thumbs")
78
+ A two-way verdict: the chosen thumb fills in the primary
79
+ icon colour (a verdict, not a score, so not the star gold),
80
+ and each thumb sits in a tertiary icon button's round hover.
81
+ ============================================ */
82
+
83
+ .ds-rating--thumbs {
84
+ gap: var(--gap-100);
85
+ }
86
+
87
+ .ds-rating--thumbs .ds-rating__step {
88
+ justify-content: center;
89
+ width: var(--control-height-compact);
90
+ height: var(--control-height-compact);
91
+ border-radius: var(--radius-pill);
92
+ }
93
+
94
+ .ds-rating--thumbs .ds-rating__step:not(:disabled):hover {
95
+ background-color: var(--color-action-passive-bg-hover);
96
+ }
97
+
98
+ .ds-rating--thumbs .ds-rating__step--filled {
99
+ color: var(--color-icon-primary);
100
+ }
@@ -22,7 +22,7 @@ type RatingOwnProps = {
22
22
  icon?: string | React.ReactNode;
23
23
  /** Component size */
24
24
  size?: 'default' | 'compact';
25
- /** Accessible name for the group, and the base of each step's label */
25
+ /** Accessible name for the group, and the base of each step's label (in the `thumbs` form the group's name only; each thumb is named by `upLabel` or `downLabel`) */
26
26
  label?: string;
27
27
  /**
28
28
  * The spoken value, given a step (or, in `readOnly` mode, the current
@@ -32,14 +32,27 @@ type RatingOwnProps = {
32
32
  valueLabel?: (value: number, max: number) => string;
33
33
  /** Additional CSS classes */
34
34
  className?: string;
35
+ /**
36
+ * The scale's form. `stars` (the default) is a row of `max` steps that
37
+ * fill up to the value. `thumbs` is a two-way verdict, a thumb up and a
38
+ * thumb down, for a quick "Was this helpful?": value 1 is up, 2 is down,
39
+ * 0 is no answer yet, and `max`, `icon` and `valueLabel` are ignored.
40
+ */
41
+ variant?: 'stars' | 'thumbs';
42
+ /** Accessible name of the thumb up in the `thumbs` form. */
43
+ upLabel?: string;
44
+ /** Accessible name of the thumb down in the `thumbs` form. */
45
+ downLabel?: string;
35
46
  };
36
47
  export interface RatingProps extends RatingOwnProps, Omit<React.ComponentPropsWithoutRef<'div'>, keyof RatingOwnProps> {
37
48
  }
38
49
  /**
39
- * Star-scale rating control. Behaves as a radio group: each step is a
40
- * `role="radio"` button, arrow keys move the selection, and the current
41
- * step holds the roving tab stop. `readOnly` renders the same row as a
42
- * static image with a spoken "N out of M" label.
50
+ * Rating control: a star scale, or with `variant="thumbs"` a thumb up and a
51
+ * thumb down for a quick "Was this helpful?". Behaves as a radio group:
52
+ * each step is a `role="radio"` button, arrow keys move the selection, and
53
+ * the current step holds the roving tab stop. `readOnly` renders the same
54
+ * row as a static image with a spoken label ("N out of M", or the thumb's
55
+ * label).
43
56
  *
44
57
  * Forwards a ref to the root element and spreads unrecognised props onto it.
45
58
  */
@@ -7,9 +7,12 @@ import { mirrorClass, logicalArrowKey } from "../../behaviors/direction.js";
7
7
  const defaultValueLabel = (value, max) => `${value} out of ${max}`;
8
8
  const Rating = React.forwardRef(
9
9
  ({
10
+ variant = "stars",
11
+ upLabel = "Yes",
12
+ downLabel = "No",
10
13
  value,
11
14
  defaultValue = 0,
12
- max = 5,
15
+ max: maxProp = 5,
13
16
  onValueChange,
14
17
  readOnly = false,
15
18
  disabled = false,
@@ -21,6 +24,8 @@ const Rating = React.forwardRef(
21
24
  className = "",
22
25
  ...rest
23
26
  }, ref) => {
27
+ const thumbs = variant === "thumbs";
28
+ const max = thumbs ? 2 : maxProp;
24
29
  const [internalValue, setInternalValue] = useState(defaultValue);
25
30
  const [hoverValue, setHoverValue] = useState(0);
26
31
  const baseClass = "ds-rating";
@@ -29,6 +34,7 @@ const Rating = React.forwardRef(
29
34
  const classes = [
30
35
  baseClass,
31
36
  `${baseClass}--${size}`,
37
+ thumbs ? `${baseClass}--thumbs` : "",
32
38
  readOnly ? `${baseClass}--read-only` : "",
33
39
  disabled ? `${baseClass}--disabled` : "",
34
40
  className
@@ -65,6 +71,9 @@ const Rating = React.forwardRef(
65
71
  }
66
72
  };
67
73
  const steps = Array.from({ length: max }, (_, i) => i + 1);
74
+ const isFilled = (step) => thumbs ? step === displayValue : step <= displayValue;
75
+ const iconFor = (step) => thumbs ? step === 1 ? "thumb_up" : "thumb_down" : icon;
76
+ const stepLabel = (step) => thumbs ? step === 1 ? upLabel : downLabel : valueLabel(step, max);
68
77
  if (readOnly) {
69
78
  return /* @__PURE__ */ jsx(
70
79
  "div",
@@ -73,13 +82,13 @@ const Rating = React.forwardRef(
73
82
  ref,
74
83
  className: classes,
75
84
  role: "img",
76
- "aria-label": rest["aria-label"] ?? `${label}: ${valueLabel(currentValue, max)}`,
85
+ "aria-label": rest["aria-label"] ?? (thumbs ? currentValue ? `${label}: ${stepLabel(currentValue)}` : label : `${label}: ${valueLabel(currentValue, max)}`),
77
86
  children: steps.map((step) => /* @__PURE__ */ jsx(
78
87
  "span",
79
88
  {
80
- className: `${baseClass}__step ${step <= displayValue ? `${baseClass}__step--filled` : ""}`,
89
+ className: `${baseClass}__step ${isFilled(step) ? `${baseClass}__step--filled` : ""}`,
81
90
  "aria-hidden": "true",
82
- children: /* @__PURE__ */ jsx("span", { className: `${baseClass}__icon${typeof icon === "string" ? ` material-symbols-rounded ${mirrorClass(icon)}` : ""}`, children: icon })
91
+ children: /* @__PURE__ */ jsx("span", { className: `${baseClass}__icon${typeof iconFor(step) === "string" ? ` material-symbols-rounded ${mirrorClass(iconFor(step))}` : ""}`, children: iconFor(step) })
83
92
  },
84
93
  step
85
94
  ))
@@ -106,13 +115,13 @@ const Rating = React.forwardRef(
106
115
  type: "button",
107
116
  role: "radio",
108
117
  "aria-checked": checked,
109
- "aria-label": label ? `${label}: ${valueLabel(step, max)}` : valueLabel(step, max),
118
+ "aria-label": thumbs ? stepLabel(step) : label ? `${label}: ${stepLabel(step)}` : stepLabel(step),
110
119
  tabIndex: tabStop ? 0 : -1,
111
120
  disabled,
112
- className: `${baseClass}__step ${step <= displayValue ? `${baseClass}__step--filled` : ""}`,
121
+ className: `${baseClass}__step ${isFilled(step) ? `${baseClass}__step--filled` : ""}`,
113
122
  onClick: () => setValue(step),
114
123
  onMouseEnter: () => setHoverValue(step),
115
- children: /* @__PURE__ */ jsx("span", { className: `${baseClass}__icon${typeof icon === "string" ? ` material-symbols-rounded ${mirrorClass(icon)}` : ""}`, "aria-hidden": "true", children: icon })
124
+ children: /* @__PURE__ */ jsx("span", { className: `${baseClass}__icon${typeof iconFor(step) === "string" ? ` material-symbols-rounded ${mirrorClass(iconFor(step))}` : ""}`, "aria-hidden": "true", children: iconFor(step) })
116
125
  },
117
126
  step
118
127
  );
@@ -43,3 +43,39 @@
43
43
  line-height: var(--font-paragraph-line-height);
44
44
  color: var(--color-text-tertiary);
45
45
  }
46
+
47
+ /* Anchor: Heading's "#" link to the section, quiet until the heading is
48
+ hovered or the link focused, and a scroll margin so a jump clears a
49
+ sticky header (--ds-heading-scroll-margin, as on Heading). */
50
+ .ds-section-title__heading--anchored {
51
+ scroll-margin-block-start: var(--ds-heading-scroll-margin, var(--gap-500));
52
+ }
53
+
54
+ .ds-section-title__anchor {
55
+ margin-inline-start: 0.3em; /* ds-allow(typography): a word-space after the title at any tier, as on Heading */
56
+ color: var(--color-text-tertiary);
57
+ text-decoration: none;
58
+ opacity: 0;
59
+ transition: opacity var(--motion-duration-base) var(--motion-ease-standard), color var(--motion-duration-base) var(--motion-ease-standard);
60
+ }
61
+
62
+ .ds-section-title__heading:hover .ds-section-title__anchor,
63
+ .ds-section-title__anchor:focus-visible {
64
+ opacity: 1;
65
+ }
66
+
67
+ .ds-section-title__anchor:hover {
68
+ color: var(--color-text-secondary);
69
+ }
70
+
71
+ .ds-section-title__anchor:focus-visible {
72
+ outline: 2px solid var(--color-action-primary-bg);
73
+ outline-offset: 2px;
74
+ border-radius: var(--radius-100);
75
+ }
76
+
77
+ @media (hover: none) {
78
+ .ds-section-title__anchor {
79
+ opacity: 1;
80
+ }
81
+ }
@@ -10,6 +10,15 @@ type SectionTitleOwnProps = {
10
10
  trailing?: React.ReactNode;
11
11
  /** Whether to draw the bottom divider line. Set false above content that draws its own lines (bordered tables, calendars), so the section separates by whitespace alone. */
12
12
  divider?: boolean;
13
+ /**
14
+ * Give the heading an id and a "#" link to itself, shown on hover and
15
+ * focus, as Heading's `anchor` does. `true` makes the id from the title;
16
+ * a string sets it. The id lands on the heading, not the root, so an
17
+ * `id` passed through goes to the root and the link targets the anchor.
18
+ */
19
+ anchor?: boolean | string;
20
+ /** Accessible name of the anchor link, given the title. Defaults to "Link to <title>". */
21
+ anchorLabel?: (title: string) => string;
13
22
  /** Additional CSS classes */
14
23
  className?: string;
15
24
  };
@@ -17,7 +26,7 @@ export interface SectionTitleProps extends SectionTitleOwnProps, Omit<React.Comp
17
26
  }
18
27
  /**
19
28
  * SectionTitle — an `<h2>` section heading with optional trailing content
20
- * and a bottom divider. Forwards a ref to the root div and spreads native
29
+ * and a bottom divider, and with `anchor` a link to itself. Forwards a ref to the root div and spreads native
21
30
  * attributes onto it.
22
31
  */
23
32
  export declare const SectionTitle: React.ForwardRefExoticComponent<SectionTitleProps & React.RefAttributes<HTMLDivElement>>;
@@ -1,15 +1,20 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import React from "react";
3
+ import { headingSlug } from "../../behaviors/headingSlug.js";
3
4
  import "./SectionTitle.css";
4
5
  const SectionTitle = React.forwardRef(
5
- ({ title, trailing, divider = true, className, ...rest }, ref) => {
6
+ ({ title, trailing, divider = true, anchor, anchorLabel = (text) => `Link to ${text}`, className, ...rest }, ref) => {
7
+ const id = typeof anchor === "string" ? anchor : anchor ? headingSlug(title) || void 0 : void 0;
6
8
  const classes = [
7
9
  "ds-section-title",
8
10
  !divider && "ds-section-title--no-divider",
9
11
  className
10
12
  ].filter(Boolean).join(" ");
11
13
  return /* @__PURE__ */ jsxs("div", { ...rest, ref, className: classes, children: [
12
- /* @__PURE__ */ jsx("h2", { className: "ds-section-title__heading", children: title }),
14
+ /* @__PURE__ */ jsxs("h2", { className: `ds-section-title__heading${id ? " ds-section-title__heading--anchored" : ""}`, id, children: [
15
+ title,
16
+ id && /* @__PURE__ */ jsx("a", { className: "ds-section-title__anchor", href: `#${id}`, "aria-label": anchorLabel(title), children: "#" })
17
+ ] }),
13
18
  trailing !== void 0 && trailing !== null && /* @__PURE__ */ jsx("span", { className: "ds-section-title__trailing", children: trailing })
14
19
  ] });
15
20
  }
@@ -7,7 +7,8 @@ export type ShaderSceneId = 'horizon' | 'rift' | 'glyphs' | 'prism' | 'meteors'
7
7
  * `pending` while the GL context comes up (bounded by a watchdog), `active`
8
8
  * once a frame has painted, `unavailable` when it is disabled, WebGL2
9
9
  * cannot run it or its context is lost (it returns to `active` when the
10
- * context comes back).
10
+ * context comes back, or after it rebuilds on a fresh canvas once it is
11
+ * near the screen, passing through `pending`).
11
12
  */
12
13
  export type ShaderSceneStatus = 'pending' | 'active' | 'unavailable';
13
14
  /** One finishing pass's setting: whether it runs, and its own settings. */
@@ -80,6 +80,7 @@ function ShaderScene({
80
80
  const [gl, setGl] = React.useState("pending");
81
81
  const [gaveUp, setGaveUp] = React.useState(false);
82
82
  const [restored, setRestored] = React.useState(0);
83
+ const rebuildsWithoutPaint = React.useRef(0);
83
84
  React.useEffect(() => {
84
85
  if (!enabled || gl !== "pending") return;
85
86
  const timer = window.setTimeout(() => setGaveUp(true), MOTION_RENDERER_WATCHDOG_MS);
@@ -116,10 +117,19 @@ function ShaderScene({
116
117
  reportError.current?.(log);
117
118
  }) : null;
118
119
  let lost = false;
120
+ let near = false;
121
+ let rebuildFrame = 0;
122
+ const rebuild = () => {
123
+ if (rebuildsWithoutPaint.current >= 2) return;
124
+ rebuildsWithoutPaint.current += 1;
125
+ setGl("pending");
126
+ setRestored((count) => count + 1);
127
+ };
119
128
  const onContextLost = (event) => {
120
129
  event.preventDefault();
121
130
  lost = true;
122
131
  setGl("failed");
132
+ if (near) rebuildFrame = requestAnimationFrame(rebuild);
123
133
  };
124
134
  const onContextRestored = () => {
125
135
  setGl("pending");
@@ -128,6 +138,7 @@ function ShaderScene({
128
138
  canvas?.addEventListener("webglcontextlost", onContextLost);
129
139
  canvas?.addEventListener("webglcontextrestored", onContextRestored);
130
140
  const unlisten = () => {
141
+ cancelAnimationFrame(rebuildFrame);
131
142
  canvas?.removeEventListener("webglcontextlost", onContextLost);
132
143
  canvas?.removeEventListener("webglcontextrestored", onContextRestored);
133
144
  };
@@ -183,6 +194,7 @@ function ShaderScene({
183
194
  renderer.draw(values, time, canvas.width, canvas.height, ratio);
184
195
  if (!painted) {
185
196
  painted = true;
197
+ rebuildsWithoutPaint.current = 0;
186
198
  setGl("painted");
187
199
  }
188
200
  };
@@ -206,10 +218,16 @@ function ShaderScene({
206
218
  });
207
219
  }
208
220
  const visibilityObserver = typeof IntersectionObserver === "undefined" ? null : new IntersectionObserver(
209
- (entries) => entries[entries.length - 1].isIntersecting ? start() : stop(),
221
+ (entries) => {
222
+ near = entries[entries.length - 1].isIntersecting;
223
+ if (!near) stop();
224
+ else if (lost) rebuild();
225
+ else start();
226
+ },
210
227
  { rootMargin: "200px 0px" }
211
228
  );
212
229
  visibilityObserver?.observe(host);
230
+ if (!visibilityObserver) near = true;
213
231
  const sizeObserver = new ResizeObserver(() => {
214
232
  if (frame || lost) return;
215
233
  fit();
@@ -237,7 +255,7 @@ function ShaderScene({
237
255
  };
238
256
  }, [definition, custom, liveRef, enabled, restored]);
239
257
  const classes = ["ds-shader-scene", className].filter(Boolean).join(" ");
240
- return /* @__PURE__ */ jsx("div", { ...rest, ref: setRef, className: classes, "data-status": status, "aria-hidden": "true", children: enabled && /* @__PURE__ */ jsx("canvas", { ref: canvasRef, className: "ds-shader-scene__canvas" }) });
258
+ return /* @__PURE__ */ jsx("div", { ...rest, ref: setRef, className: classes, "data-status": status, "aria-hidden": "true", children: enabled && /* @__PURE__ */ jsx("canvas", { ref: canvasRef, className: "ds-shader-scene__canvas" }, restored) });
241
259
  }
242
260
  export {
243
261
  PASSES as SHADER_PASSES,
@@ -0,0 +1,157 @@
1
+ /* ============================================
2
+ SITE FOOTER COMPONENT
3
+ The bottom of a site: brand and a line about it,
4
+ a sitemap of link columns, and a row of small print.
5
+ The floor of the page, so it carries no surface of
6
+ its own: a hairline fading at both ends above the
7
+ small print separates the two rows, and the host
8
+ decides the width.
9
+ ============================================ */
10
+
11
+ .ds-site-footer {
12
+ display: flex;
13
+ flex-direction: column;
14
+ gap: var(--gap-1000);
15
+ width: 100%;
16
+ padding-block: var(--padding-1000) var(--padding-500);
17
+ box-sizing: border-box;
18
+ container-type: inline-size;
19
+ }
20
+
21
+ /* ============================================
22
+ TOP — about, then the columns
23
+ ============================================ */
24
+
25
+ .ds-site-footer__top {
26
+ display: flex;
27
+ flex-wrap: wrap;
28
+ gap: var(--gap-500);
29
+ justify-content: space-between;
30
+ }
31
+
32
+ .ds-site-footer__about {
33
+ display: flex;
34
+ flex: 1 1 calc(10 * var(--control-height-default));
35
+ flex-direction: column;
36
+ gap: var(--gap-300);
37
+ max-width: calc(10 * var(--control-height-default));
38
+ }
39
+
40
+ .ds-site-footer__brand {
41
+ display: flex;
42
+ align-items: center;
43
+ gap: var(--gap-200);
44
+ font-family: var(--font-title-body-family);
45
+ font-size: var(--font-title-body-size);
46
+ font-weight: var(--font-title-body-weight);
47
+ line-height: var(--font-title-body-line-height);
48
+ color: var(--color-text-primary);
49
+ }
50
+
51
+ .ds-site-footer__description {
52
+ margin: 0;
53
+ font-family: var(--font-paragraph-sm-family);
54
+ font-size: var(--font-paragraph-sm-size);
55
+ line-height: var(--font-paragraph-sm-line-height);
56
+ color: var(--color-text-secondary);
57
+ }
58
+
59
+ .ds-site-footer__columns {
60
+ display: grid;
61
+ flex: 2 1 auto;
62
+ grid-template-columns: repeat(auto-fit, minmax(calc(4 * var(--control-height-default)), 1fr));
63
+ gap: var(--gap-500);
64
+ }
65
+
66
+ .ds-site-footer__title {
67
+ margin: 0 0 var(--gap-300);
68
+ font-family: var(--font-paragraph-sm-emphasis-family);
69
+ font-size: var(--font-paragraph-sm-emphasis-size);
70
+ font-weight: var(--font-paragraph-sm-emphasis-weight);
71
+ line-height: var(--font-paragraph-sm-emphasis-line-height);
72
+ color: var(--color-text-primary);
73
+ }
74
+
75
+ .ds-site-footer__links {
76
+ display: flex;
77
+ flex-direction: column;
78
+ gap: var(--gap-200);
79
+ margin: 0;
80
+ padding: 0;
81
+ list-style: none;
82
+ }
83
+
84
+ /* Quiet links: secondary text that lifts to primary on hover, the way the
85
+ rails' rows do, with no underline until hover. */
86
+ .ds-site-footer__link {
87
+ display: inline-flex;
88
+ align-items: center;
89
+ gap: var(--gap-050);
90
+ font-family: var(--font-paragraph-sm-family);
91
+ font-size: var(--font-paragraph-sm-size);
92
+ line-height: var(--font-paragraph-sm-line-height);
93
+ color: var(--color-text-secondary);
94
+ text-decoration: none;
95
+ border-radius: var(--radius-100);
96
+ transition: color var(--motion-duration-base) var(--motion-ease-standard);
97
+ }
98
+
99
+ .ds-site-footer__link:hover {
100
+ color: var(--color-text-primary);
101
+ text-decoration: underline;
102
+ }
103
+
104
+ .ds-site-footer__link:focus-visible {
105
+ outline: 2px solid var(--color-action-primary-bg);
106
+ outline-offset: 2px;
107
+ }
108
+
109
+ .ds-site-footer__external {
110
+ --icon-size: var(--icon-size-500);
111
+ line-height: 1;
112
+ }
113
+
114
+ /* ============================================
115
+ BOTTOM — small print and social
116
+ ============================================ */
117
+
118
+ .ds-site-footer__bottom {
119
+ display: flex;
120
+ flex-wrap: wrap;
121
+ align-items: center;
122
+ justify-content: space-between;
123
+ gap: var(--gap-300);
124
+ position: relative;
125
+ padding-block-start: var(--padding-500);
126
+ }
127
+
128
+ /* The rule above the small print fades out at both ends, so it reads as a
129
+ pause in the footer rather than a box edge. */
130
+ .ds-site-footer__bottom::before {
131
+ content: '';
132
+ position: absolute;
133
+ inset-block-start: 0;
134
+ inset-inline: 0;
135
+ height: var(--border-025);
136
+ background: linear-gradient(
137
+ to right, /* ds-allow(physical): a symmetric fade, the same at both ends in either reading direction */
138
+ transparent,
139
+ var(--color-divider) var(--gap-1500),
140
+ var(--color-divider) calc(100% - var(--gap-1500)),
141
+ transparent
142
+ );
143
+ pointer-events: none;
144
+ }
145
+
146
+ .ds-site-footer__legal {
147
+ font-family: var(--font-caption-family);
148
+ font-size: var(--font-caption-size);
149
+ line-height: var(--font-caption-line-height);
150
+ color: var(--color-text-tertiary);
151
+ }
152
+
153
+ .ds-site-footer__social {
154
+ display: flex;
155
+ align-items: center;
156
+ gap: var(--gap-100);
157
+ }
@@ -0,0 +1,53 @@
1
+ import { default as React } from 'react';
2
+ import { LinkComponent } from '../../behaviors/LinkProvider';
3
+ /** One link in a footer column. */
4
+ export interface SiteFooterLink {
5
+ /** Link text. */
6
+ label: string;
7
+ /** Where it goes. */
8
+ href: string;
9
+ /** The link leaves the site: it opens in a new tab and says so. */
10
+ external?: boolean;
11
+ }
12
+ /** A labelled column of footer links. */
13
+ export interface SiteFooterColumn {
14
+ /** The column's heading, e.g. "Docs". */
15
+ label: string;
16
+ /** Its links, in order. */
17
+ links: SiteFooterLink[];
18
+ }
19
+ /** Props owned by SiteFooter itself. */
20
+ type SiteFooterOwnProps = {
21
+ /** The sitemap columns, in order along the row. Leave it out for a footer of small print alone. */
22
+ columns?: SiteFooterColumn[];
23
+ /** The brand at the start of the footer: a logo, a name, or both. */
24
+ brand?: React.ReactNode;
25
+ /** A line about the site under the brand. */
26
+ description?: React.ReactNode;
27
+ /** Social or utility controls for the bottom row's end, such as IconButtons. */
28
+ social?: React.ReactNode;
29
+ /** The bottom row's small print: a copyright, a licence, a privacy link. */
30
+ legal?: React.ReactNode;
31
+ /** Accessible name of the navigation landmark that holds the columns. */
32
+ navLabel?: string;
33
+ /** Text read after an external link's name, for a screen reader. */
34
+ externalLabel?: string;
35
+ /**
36
+ * The component its links render with, such as Next.js's `Link`. A plain
37
+ * `<a>` when unset. Server-renderable, so it reads no LinkProvider: pass
38
+ * it here.
39
+ */
40
+ linkComponent?: LinkComponent;
41
+ /** Additional CSS classes */
42
+ className?: string;
43
+ };
44
+ export interface SiteFooterProps extends SiteFooterOwnProps, Omit<React.ComponentPropsWithRef<'footer'>, keyof SiteFooterOwnProps | 'children'> {
45
+ }
46
+ /**
47
+ * SiteFooter: the bottom of a site, the pair to SiteHeader. The brand and a
48
+ * line about the site, then columns of links (a sitemap), then a row of
49
+ * small print with social links at its end. The columns fold from a row to
50
+ * a grid to a single stack as the footer narrows. Server-renderable.
51
+ */
52
+ export declare function SiteFooter({ columns, brand, description, social, legal, navLabel, externalLabel, linkComponent, className, ref, ...rest }: SiteFooterProps): React.JSX.Element;
53
+ export {};