@lanfermann/ui 0.2.0 → 0.4.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 (80) hide show
  1. package/dist/components/accordion/accordion.js +2 -1
  2. package/dist/components/anchor-heading/anchor-heading.d.ts +1 -1
  3. package/dist/components/breadcrumbs/breadcrumbs.js +5 -10
  4. package/dist/components/button/button.d.ts +3 -0
  5. package/dist/components/button/button.js +14 -4
  6. package/dist/components/button-group/button-group-context.js +14 -0
  7. package/dist/components/button-group/button-group-variants.d.ts +14 -0
  8. package/dist/components/button-group/button-group-variants.js +93 -0
  9. package/dist/components/button-group/button-group.d.ts +36 -0
  10. package/dist/components/button-group/button-group.js +46 -0
  11. package/dist/components/code-block/code-block-frame.js +22 -6
  12. package/dist/components/code-block/code-block-live.d.ts +3 -3
  13. package/dist/components/code-block/code-block-live.js +5 -3
  14. package/dist/components/code-block/code-block.d.ts +7 -3
  15. package/dist/components/code-block/code-block.js +9 -3
  16. package/dist/components/code-block/code-keys.d.ts +24 -0
  17. package/dist/components/code-block/code-keys.js +107 -0
  18. package/dist/components/code-block/code-scroll.js +2 -1
  19. package/dist/components/code-block/code-tabs-frame.js +12 -5
  20. package/dist/components/code-block/code-tabs.d.ts +9 -4
  21. package/dist/components/code-block/code-tabs.js +9 -6
  22. package/dist/components/code-block/lines.js +23 -1
  23. package/dist/components/copy-page/copy-page.d.ts +46 -0
  24. package/dist/components/copy-page/copy-page.js +211 -0
  25. package/dist/components/docs-layout/docs-layout.d.ts +4 -2
  26. package/dist/components/docs-layout/docs-layout.js +11 -6
  27. package/dist/components/docs-layout/docs-nav.d.ts +51 -0
  28. package/dist/components/docs-layout/docs-nav.js +60 -0
  29. package/dist/components/grow/grow.d.ts +20 -0
  30. package/dist/components/grow/grow.js +98 -0
  31. package/dist/components/heading/heading.d.ts +4 -0
  32. package/dist/components/heading/heading.js +8 -4
  33. package/dist/components/hover-card/hover-card.d.ts +24 -0
  34. package/dist/components/hover-card/hover-card.js +51 -0
  35. package/dist/components/pager/pager.js +19 -24
  36. package/dist/components/parameter-list/parameter-list.js +2 -1
  37. package/dist/components/scroll-fade/scroll-fade.d.ts +29 -0
  38. package/dist/components/scroll-fade/scroll-fade.js +40 -0
  39. package/dist/components/scroll-fade/use-scroll-edges.d.ts +13 -0
  40. package/dist/{internal/scroll-edges.js → components/scroll-fade/use-scroll-edges.js} +10 -7
  41. package/dist/components/section/section.d.ts +2 -1
  42. package/dist/components/section/section.js +2 -1
  43. package/dist/components/segmented-control/segmented-control.d.ts +7 -1
  44. package/dist/components/segmented-control/segmented-control.js +22 -11
  45. package/dist/components/select/select.d.ts +4 -1
  46. package/dist/components/select/select.js +15 -3
  47. package/dist/components/separator/separator.js +2 -2
  48. package/dist/components/shimmer/shimmer.d.ts +21 -0
  49. package/dist/components/shimmer/shimmer.js +24 -0
  50. package/dist/components/side-nav/side-nav.js +11 -20
  51. package/dist/components/site-header/site-header.d.ts +1 -1
  52. package/dist/components/site-header/site-header.js +6 -3
  53. package/dist/components/slider/slider.d.ts +3 -1
  54. package/dist/components/slider/slider.js +45 -19
  55. package/dist/components/table/table.d.ts +6 -6
  56. package/dist/components/table/table.js +24 -17
  57. package/dist/components/table-of-contents/table-of-contents.js +11 -6
  58. package/dist/components/tabs/tabs.js +4 -8
  59. package/dist/components/theme-switch/theme-switch.d.ts +47 -0
  60. package/dist/components/theme-switch/theme-switch.js +102 -0
  61. package/dist/components/trace/trace.d.ts +71 -0
  62. package/dist/components/trace/trace.js +201 -0
  63. package/dist/index.d.ts +12 -2
  64. package/dist/index.js +11 -2
  65. package/dist/internal/render-as.js +24 -0
  66. package/dist/internal/rule.js +16 -0
  67. package/dist/lib/merge-refs.js +9 -0
  68. package/package.json +1 -1
  69. package/src/styles/button-group.css +57 -0
  70. package/src/styles/code.css +14 -68
  71. package/src/styles/copy.css +46 -0
  72. package/src/styles/marks.css +10 -0
  73. package/src/styles/motion.css +4 -3
  74. package/src/styles/scroll-fade.css +58 -0
  75. package/src/styles/shimmer.css +68 -0
  76. package/src/styles/slider.css +57 -19
  77. package/src/styles.css +4 -1
  78. package/dist/components/page-header/page-header.d.ts +0 -30
  79. package/dist/components/page-header/page-header.js +0 -48
  80. package/src/styles/tabs.css +0 -39
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { cn } from "../../lib/cn.js";
3
- import { CodeCopy } from "./code-copy.js";
3
+ import { CodeKeys } from "./code-keys.js";
4
4
  import { CodeScroll } from "./code-scroll.js";
5
5
  import { codeHead, codeRoot } from "./code-surface.js";
6
6
  import { readChoice, subscribeChoices, writeChoice } from "./code-tabs-store.js";
@@ -11,9 +11,10 @@ import { Tabs } from "@base-ui/react/tabs";
11
11
  /**
12
12
  * The client half of CodeTabs: a row of tabs in the header, each with its mark, and one soft
13
13
  * highlight that glides to the chosen tab (`glide`, placed by Base UI's measure and moved by
14
- * `translate`). The copy button takes the code that is shown.
14
+ * `translate`). The keys at the end of the header take the code that is shown.
15
15
  */
16
- function CodeTabsFrame({ children, tabs, group, defaultValue, label, className, ...labels }) {
16
+ function CodeTabsFrame({ children, tabs, group, defaultValue, label, download, wrap = false, wrapToggle = false, className, ...keyOptions }) {
17
+ const [wrapped, setWrapped] = useState(wrap);
17
18
  const names = tabs.map((tab) => tab.label);
18
19
  const [own, setOwn] = useState(defaultValue ?? names[0]);
19
20
  const shared = useSyncExternalStore(subscribeChoices, () => group ? readChoice(group) : void 0, () => void 0);
@@ -36,6 +37,7 @@ function CodeTabsFrame({ children, tabs, group, defaultValue, label, className,
36
37
  setOwn(next);
37
38
  if (group) writeChoice(group, next);
38
39
  },
40
+ "data-wrap": wrapToggle ? wrapped ? "on" : "off" : void 0,
39
41
  className: cn(codeRoot, className),
40
42
  children: [/* @__PURE__ */ jsxs("div", {
41
43
  "data-slot": "code-tabs-header",
@@ -56,10 +58,15 @@ function CodeTabsFrame({ children, tabs, group, defaultValue, label, className,
56
58
  "data-slot": "code-tabs-indicator",
57
59
  className: cn("absolute top-(--active-tab-top) left-0 -z-10 h-(--active-tab-height) w-(--active-tab-width) translate-x-(--active-tab-left) rounded-sm bg-hover", "forced-colors:outline forced-colors:-outline-offset-1", placed && "transition-[translate,width] spring-glide")
58
60
  })]
59
- }), /* @__PURE__ */ jsx(CodeCopy, {
61
+ }), /* @__PURE__ */ jsx(CodeKeys, {
60
62
  text: tabs[index]?.copyText ?? "",
61
63
  codeRef: activeCode,
62
- ...labels
64
+ fileName: tabs[index]?.fileName,
65
+ download,
66
+ wrapToggle,
67
+ wrapped,
68
+ onWrappedChange: setWrapped,
69
+ ...keyOptions
63
70
  })]
64
71
  }), panels.map((panel, at) => /* @__PURE__ */ jsx(Tabs.Panel, {
65
72
  value: names[at],
@@ -1,4 +1,4 @@
1
- import { CodeCopyLabels } from "./code-copy.js";
1
+ import { CodeKeyOptions } from "./code-keys.js";
2
2
  import { CodeLinesOptions } from "./code-lines-view.js";
3
3
  import { CodeLanguage } from "./highlight.js";
4
4
  export type CodeTab = CodeLinesOptions & {
@@ -6,8 +6,10 @@ export type CodeTab = CodeLinesOptions & {
6
6
  label: string;
7
7
  code: string;
8
8
  language?: CodeLanguage;
9
+ /** The file this version is saved as when the block has a download key. */
10
+ fileName?: string;
9
11
  };
10
- export type CodeTabsProps = CodeCopyLabels & {
12
+ export type CodeTabsProps = Omit<CodeKeyOptions, "download"> & {
11
13
  items: CodeTab[];
12
14
  /**
13
15
  * Blocks with the same group share the reader's choice: picking „bun“ in one shows bun in all
@@ -18,11 +20,14 @@ export type CodeTabsProps = CodeCopyLabels & {
18
20
  defaultValue?: string;
19
21
  /** The name of the tab row, and of each code region after it. */
20
22
  label?: string;
23
+ /** Adds a key that saves the version that is shown, as its tab's `fileName`. */
24
+ download?: boolean;
21
25
  className?: string;
22
26
  };
23
27
  /**
24
28
  * One block, several versions of the same code: the install command for each package manager,
25
29
  * or a component and its stylesheet. The tabs sit in the header with their marks; the copy
26
- * button copies the version that is shown.
30
+ * button copies the version that is shown, and so do the download and the line wrap when the
31
+ * block has them (see `CodeBlock`).
27
32
  */
28
- export declare function CodeTabs({ items, group, defaultValue, label, className, ...copyLabels }: CodeTabsProps): import("react").JSX.Element;
33
+ export declare function CodeTabs({ items, group, defaultValue, label, className, ...keyOptions }: CodeTabsProps): import("react").JSX.Element;
@@ -1,25 +1,28 @@
1
1
  import { CodeLines } from "./code-lines.js";
2
2
  import { CodeTabsFrame } from "./code-tabs-frame.js";
3
- import { copyText } from "./lines.js";
3
+ import { codeFileName, copyText } from "./lines.js";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  // src/components/code-block/code-tabs.tsx
6
6
  /**
7
7
  * One block, several versions of the same code: the install command for each package manager,
8
8
  * or a component and its stylesheet. The tabs sit in the header with their marks; the copy
9
- * button copies the version that is shown.
9
+ * button copies the version that is shown, and so do the download and the line wrap when the
10
+ * block has them (see `CodeBlock`).
10
11
  */
11
- function CodeTabs({ items, group, defaultValue, label = "Code", className, ...copyLabels }) {
12
+ function CodeTabs({ items, group, defaultValue, label = "Code", className, ...keyOptions }) {
12
13
  return /* @__PURE__ */ jsx(CodeTabsFrame, {
13
14
  tabs: items.map((item) => ({
14
15
  label: item.label,
15
- copyText: copyText(item.code, item.removed)
16
+ copyText: copyText(item.code, item.removed),
17
+ fileName: item.fileName ?? codeFileName(void 0, item.language)
16
18
  })),
17
19
  group,
18
20
  defaultValue,
19
21
  label,
22
+ wrap: items.every((item) => item.wrap),
20
23
  className,
21
- ...copyLabels,
22
- children: items.map(({ label: name, code, language = "text", ...lines }) => /* @__PURE__ */ jsx(CodeLines, {
24
+ ...keyOptions,
25
+ children: items.map(({ label: name, code, language = "text", fileName: _, ...lines }) => /* @__PURE__ */ jsx(CodeLines, {
23
26
  code,
24
27
  language,
25
28
  ...lines
@@ -37,4 +37,26 @@ function lineKinds(count, { marked, added, removed }) {
37
37
  ];
38
38
  return Array.from({ length: count }, (_, i) => r.has(i + 1) ? "removed" : a.has(i + 1) ? "added" : m.has(i + 1) ? "marked" : void 0);
39
39
  }
40
- export { copyText, lineKinds, parseLines, trimCode };
40
+ /**
41
+ * The file a block of code is saved as when nothing names it: the last part of its title if that
42
+ * is a file's name ("app/api/route.ts" gives "route.ts"), or `code` with the ending of its
43
+ * language.
44
+ */
45
+ function codeFileName(title, language = "text") {
46
+ const name = title?.split(/[/\\]/).pop();
47
+ if (name && /^\S*\.[A-Za-z0-9]+$/.test(name)) return name;
48
+ return `code.${{
49
+ text: "txt",
50
+ shell: "sh",
51
+ bash: "sh",
52
+ zsh: "sh",
53
+ typescript: "ts",
54
+ javascript: "js",
55
+ markdown: "md",
56
+ python: "py",
57
+ powershell: "ps1",
58
+ dotenv: "env",
59
+ yml: "yaml"
60
+ }[language] ?? language}`;
61
+ }
62
+ export { codeFileName, copyText, lineKinds, parseLines, trimCode };
@@ -0,0 +1,46 @@
1
+ import { ComponentProps } from "react";
2
+ export type CopyPageProps = Omit<ComponentProps<"div">, "children" | "aria-label" | "aria-labelledby"> & {
3
+ /** The page as Markdown, on this site: what is copied, and what "view" opens. */
4
+ href: string;
5
+ /** The button, and the first entry of the menu: the thing, then the action ("Seite kopieren"). */
6
+ label: string;
7
+ /** Under it in the menu: what the copy is, and for whom ("Als Markdown, für eine KI"). */
8
+ description: string;
9
+ /** The second entry: "Als Markdown ansehen". */
10
+ viewLabel: string;
11
+ /** Under it: "Die Seite als reiner Text". */
12
+ viewDescription: string;
13
+ /** The name of the button that opens the menu ("Weitere Möglichkeiten"). */
14
+ moreLabel: string;
15
+ /** Read out once the page is on the clipboard: a full sentence ("Die Seite ist kopiert."). */
16
+ copied: string;
17
+ /** Read out when the clipboard refused or the page could not be loaded. */
18
+ failed: string;
19
+ /** Called once the page has reached the clipboard. */
20
+ onCopied?: () => void;
21
+ /** Opens the menu on the first render: for stories and screenshots. */
22
+ defaultOpen?: boolean;
23
+ };
24
+ /**
25
+ * Hands a docs page on as Markdown: one raised fitting split in two, the copy and the menu. The
26
+ * copy fetches the page's Markdown and puts it on the clipboard, for a model or an agent; the
27
+ * menu repeats it with a line on what it is, and opens the Markdown in a new tab. Put it at the
28
+ * end of the row above the page's title.
29
+ *
30
+ * It is a `ButtonGroup`, named by its `label`: one part with two keys, so it moves as one: under the pointer the whole fitting lifts,
31
+ * and the key under it takes the hover wash. Pressed, the fitting goes down and drops its
32
+ * ambient shadow, and only the pressed key takes the inner shade, so it rocks on that key and the
33
+ * other keeps its gloss. A copy is confirmed in the key, as in a code block: the copy symbol
34
+ * shrinks away and the tick draws itself, short leg first, then fades where it stands while the
35
+ * symbol seats back. There is no toast; a screen reader hears one sentence.
36
+ *
37
+ * The chevron turns over while the menu is open, settling with a small bounce; the sheet grows
38
+ * out of it and leaves by fading, as every sheet does. The menu's rows carry a tile with their
39
+ * symbol, and the row under the pointer or the keyboard highlights at once. Copying from the
40
+ * menu closes it and confirms in the key, where the eye goes back to.
41
+ *
42
+ * The Markdown is fetched as soon as a pointer or the keyboard reaches the fitting, so the copy
43
+ * that follows is immediate; where the browser takes a promise for the clipboard (Safari, Chrome)
44
+ * the fetch can finish inside the press. Word the labels as the thing, then the action.
45
+ */
46
+ export declare function CopyPage({ href, label, description, viewLabel, viewDescription, moreLabel, copied: copiedSentence, failed: failedSentence, onCopied, defaultOpen, className, onPointerEnter, onFocus, ...props }: CopyPageProps): import("react").JSX.Element;
@@ -0,0 +1,211 @@
1
+ "use client";
2
+ import { Button } from "../button/button.js";
3
+ import { ButtonGroup } from "../button-group/button-group.js";
4
+ import { Icon } from "../icon/icon.js";
5
+ import { MenuContent, MenuItem, MenuLinkItem } from "../menu/menu.js";
6
+ import { ActionArrow } from "../../internal/arrow.js";
7
+ import { ChevronDownGlyph, TickGlyph } from "../../internal/glyphs.js";
8
+ import { cn } from "../../lib/cn.js";
9
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
+ import { Copy01Icon } from "@hugeicons/core-free-icons";
11
+ import { useEffect, useRef, useState } from "react";
12
+ import { Menu } from "@base-ui/react/menu";
13
+ // src/components/copy-page/copy-page.tsx
14
+ /** How long a copy stays confirmed before the symbol comes back, in ms (as in a code block). */
15
+ const CONFIRM_MS = 1600;
16
+ /**
17
+ * Hands a docs page on as Markdown: one raised fitting split in two, the copy and the menu. The
18
+ * copy fetches the page's Markdown and puts it on the clipboard, for a model or an agent; the
19
+ * menu repeats it with a line on what it is, and opens the Markdown in a new tab. Put it at the
20
+ * end of the row above the page's title.
21
+ *
22
+ * It is a `ButtonGroup`, named by its `label`: one part with two keys, so it moves as one: under the pointer the whole fitting lifts,
23
+ * and the key under it takes the hover wash. Pressed, the fitting goes down and drops its
24
+ * ambient shadow, and only the pressed key takes the inner shade, so it rocks on that key and the
25
+ * other keeps its gloss. A copy is confirmed in the key, as in a code block: the copy symbol
26
+ * shrinks away and the tick draws itself, short leg first, then fades where it stands while the
27
+ * symbol seats back. There is no toast; a screen reader hears one sentence.
28
+ *
29
+ * The chevron turns over while the menu is open, settling with a small bounce; the sheet grows
30
+ * out of it and leaves by fading, as every sheet does. The menu's rows carry a tile with their
31
+ * symbol, and the row under the pointer or the keyboard highlights at once. Copying from the
32
+ * menu closes it and confirms in the key, where the eye goes back to.
33
+ *
34
+ * The Markdown is fetched as soon as a pointer or the keyboard reaches the fitting, so the copy
35
+ * that follows is immediate; where the browser takes a promise for the clipboard (Safari, Chrome)
36
+ * the fetch can finish inside the press. Word the labels as the thing, then the action.
37
+ */
38
+ function CopyPage({ href, label, description, viewLabel, viewDescription, moreLabel, copied: copiedSentence, failed: failedSentence, onCopied, defaultOpen, className, onPointerEnter, onFocus, ...props }) {
39
+ const [state, setState] = useState("idle");
40
+ const timer = useRef(void 0);
41
+ useEffect(() => () => clearTimeout(timer.current), []);
42
+ const markdown = useRef(void 0);
43
+ const load = () => {
44
+ markdown.current ??= fetch(href).then((response) => {
45
+ if (!response.ok) throw new Error(`${response.status}`);
46
+ return response.text();
47
+ });
48
+ return markdown.current;
49
+ };
50
+ const settle = (next) => {
51
+ clearTimeout(timer.current);
52
+ setState(next);
53
+ timer.current = setTimeout(() => setState("idle"), CONFIRM_MS);
54
+ };
55
+ async function copy() {
56
+ const text = load();
57
+ try {
58
+ if (typeof ClipboardItem !== "undefined" && navigator.clipboard?.write) {
59
+ const blob = text.then((body) => new Blob([body], { type: "text/plain" }));
60
+ await navigator.clipboard.write([new ClipboardItem({ "text/plain": blob })]);
61
+ } else await navigator.clipboard.writeText(await text);
62
+ settle("copied");
63
+ onCopied?.();
64
+ } catch {
65
+ try {
66
+ await navigator.clipboard.writeText(await text);
67
+ settle("copied");
68
+ onCopied?.();
69
+ } catch {
70
+ markdown.current = void 0;
71
+ settle("failed");
72
+ }
73
+ }
74
+ }
75
+ const isCopied = state === "copied";
76
+ return /* @__PURE__ */ jsxs(ButtonGroup, {
77
+ size: "sm",
78
+ "aria-label": label,
79
+ "data-slot": "copy-page",
80
+ className: cn("rounded-md", className),
81
+ onPointerEnter: (event) => {
82
+ load().catch(() => {});
83
+ onPointerEnter?.(event);
84
+ },
85
+ onFocus: (event) => {
86
+ load().catch(() => {});
87
+ onFocus?.(event);
88
+ },
89
+ ...props,
90
+ children: [
91
+ /* @__PURE__ */ jsxs(Button, {
92
+ "data-slot": "copy-page-copy",
93
+ "data-copied": isCopied ? "" : void 0,
94
+ onClick: () => void copy(),
95
+ className: "pr-2.5",
96
+ children: [/* @__PURE__ */ jsxs("span", {
97
+ className: "relative flex size-4 shrink-0 items-center justify-center",
98
+ children: [/* @__PURE__ */ jsx(Icon, {
99
+ "data-slot": "copy-page-symbol",
100
+ icon: Copy01Icon,
101
+ size: 16,
102
+ className: "absolute"
103
+ }), /* @__PURE__ */ jsx(TickGlyph, {
104
+ "data-slot": "copy-page-tick",
105
+ width: 20,
106
+ height: 20,
107
+ strokeWidth: 21 / 20,
108
+ className: "absolute"
109
+ })]
110
+ }), label]
111
+ }),
112
+ /* @__PURE__ */ jsxs(Menu.Root, {
113
+ modal: false,
114
+ defaultOpen,
115
+ children: [/* @__PURE__ */ jsx(Menu.Trigger, {
116
+ render: /* @__PURE__ */ jsx(Button, {
117
+ "data-slot": "copy-page-more",
118
+ "aria-label": moreLabel,
119
+ className: "group/more px-1.5 pointer-coarse:px-2.5"
120
+ }),
121
+ children: /* @__PURE__ */ jsx(ChevronDownGlyph, {
122
+ width: 12,
123
+ height: 12,
124
+ className: "text-fg-muted transition-[rotate,color] spring-seat group-hover/more:text-fg group-data-popup-open/more:rotate-180 group-data-popup-open/more:text-fg motion-reduce:transition-none"
125
+ })
126
+ }), /* @__PURE__ */ jsxs(MenuContent, {
127
+ align: "end",
128
+ className: "w-76 p-1.5",
129
+ children: [/* @__PURE__ */ jsxs(MenuItem, {
130
+ onClick: () => void copy(),
131
+ className: row,
132
+ children: [/* @__PURE__ */ jsx(Tile, { children: /* @__PURE__ */ jsx(Icon, {
133
+ icon: Copy01Icon,
134
+ size: 16
135
+ }) }), /* @__PURE__ */ jsx(RowText, {
136
+ title: label,
137
+ description
138
+ })]
139
+ }), /* @__PURE__ */ jsxs(MenuLinkItem, {
140
+ href,
141
+ target: "_blank",
142
+ rel: "noopener",
143
+ className: row,
144
+ children: [/* @__PURE__ */ jsx(Tile, { children: /* @__PURE__ */ jsx(MarkdownGlyph, {}) }), /* @__PURE__ */ jsx(RowText, {
145
+ title: /* @__PURE__ */ jsxs(Fragment, { children: [viewLabel, /* @__PURE__ */ jsx(ActionArrow, {
146
+ direction: "out",
147
+ size: 12,
148
+ className: "text-fg-muted"
149
+ })] }),
150
+ description: viewDescription
151
+ })]
152
+ })]
153
+ })]
154
+ }),
155
+ /* @__PURE__ */ jsx("span", {
156
+ role: "status",
157
+ className: "sr-only",
158
+ children: state === "copied" ? copiedSentence : state === "failed" ? failedSentence : ""
159
+ })
160
+ ]
161
+ });
162
+ }
163
+ /** A row of the menu: a tile, then two lines. It keeps the list's instant highlight. */
164
+ const row = "group/row items-center gap-3 px-2 py-2";
165
+ function Tile({ children }) {
166
+ return /* @__PURE__ */ jsx("span", {
167
+ "aria-hidden": true,
168
+ "data-slot": "copy-page-tile",
169
+ className: "flex size-8 shrink-0 items-center justify-center rounded-md bg-surface text-fg-muted inset-ring inset-ring-hairline group-data-highlighted/row:text-fg forced-colors:inset-ring-[CanvasText]",
170
+ children
171
+ });
172
+ }
173
+ function RowText({ title, description }) {
174
+ return /* @__PURE__ */ jsxs("span", {
175
+ className: "flex min-w-0 flex-col gap-0.5",
176
+ children: [/* @__PURE__ */ jsx("span", {
177
+ className: "flex items-center gap-1 text-control leading-tight text-fg",
178
+ children: title
179
+ }), /* @__PURE__ */ jsx("span", {
180
+ className: "text-sm leading-snug text-fg-muted",
181
+ children: description
182
+ })]
183
+ });
184
+ }
185
+ /** The Markdown mark (an M and a down arrow in a frame), drawn at the icons' weight. */
186
+ function MarkdownGlyph(props) {
187
+ return /* @__PURE__ */ jsxs("svg", {
188
+ "aria-hidden": true,
189
+ width: 16,
190
+ height: 16,
191
+ viewBox: "0 0 24 24",
192
+ fill: "none",
193
+ stroke: "currentColor",
194
+ strokeWidth: 1.5,
195
+ strokeLinecap: "round",
196
+ strokeLinejoin: "round",
197
+ ...props,
198
+ children: [
199
+ /* @__PURE__ */ jsx("rect", {
200
+ x: "2",
201
+ y: "5",
202
+ width: "20",
203
+ height: "14",
204
+ rx: "3"
205
+ }),
206
+ /* @__PURE__ */ jsx("path", { d: "M6 15V9l2.5 3L11 9v6" }),
207
+ /* @__PURE__ */ jsx("path", { d: "M16.5 9v6m-2.5-2.5 2.5 2.5 2.5-2.5" })
208
+ ]
209
+ });
210
+ }
211
+ export { CopyPage };
@@ -5,8 +5,10 @@ import { ComponentProps } from "react";
5
5
  * in the middle, the page's sections on the right.
6
6
  *
7
7
  * The side columns stay in view while the text scrolls, below a sticky bar of the height in
8
- * `--docs-top` (4rem: the `SiteHeader`'s bar, 8px off the top and 56px tall). The pages column shows from `lg`, the sections column
9
- * from `xl`; below that, the pages go into the site's menu and the sections fold above the text.
8
+ * `--docs-top` (3.5rem: the `SiteHeader`'s bar, 8px off the top and 48px tall). A side column
9
+ * longer than the window scrolls inside itself, and fades at the end that has more. The pages
10
+ * column shows from `lg`, the sections column from `xl`; below that, the pages go into the
11
+ * site's menu and the sections fold above the text.
10
12
  */
11
13
  export declare function DocsLayout({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
12
14
  /** The pages of the set: a `SideNav`. Hidden below `lg`. */
@@ -1,4 +1,5 @@
1
1
  import { containerVariants } from "../container/container.js";
2
+ import { ScrollFade } from "../scroll-fade/scroll-fade.js";
2
3
  import { cn } from "../../lib/cn.js";
3
4
  import { jsx } from "react/jsx-runtime";
4
5
  // src/components/docs-layout/docs-layout.tsx
@@ -8,20 +9,23 @@ import { jsx } from "react/jsx-runtime";
8
9
  * in the middle, the page's sections on the right.
9
10
  *
10
11
  * The side columns stay in view while the text scrolls, below a sticky bar of the height in
11
- * `--docs-top` (4rem: the `SiteHeader`'s bar, 8px off the top and 56px tall). The pages column shows from `lg`, the sections column
12
- * from `xl`; below that, the pages go into the site's menu and the sections fold above the text.
12
+ * `--docs-top` (3.5rem: the `SiteHeader`'s bar, 8px off the top and 48px tall). A side column
13
+ * longer than the window scrolls inside itself, and fades at the end that has more. The pages
14
+ * column shows from `lg`, the sections column from `xl`; below that, the pages go into the
15
+ * site's menu and the sections fold above the text.
13
16
  */
14
17
  function DocsLayout({ className, ...props }) {
15
18
  return /* @__PURE__ */ jsx("div", {
16
19
  "data-slot": "docs-layout",
17
- className: cn(containerVariants(), "grid [--docs-top:4rem] lg:grid-cols-[13.5rem_minmax(0,1fr)] lg:gap-x-10 xl:grid-cols-[13.5rem_minmax(0,1fr)_12rem]", className),
20
+ className: cn(containerVariants(), "grid [--docs-top:3.5rem] lg:grid-cols-[13.5rem_minmax(0,1fr)] lg:gap-x-10 xl:grid-cols-[13.5rem_minmax(0,1fr)_12rem]", className),
18
21
  ...props
19
22
  });
20
23
  }
21
- const sticky = "sticky top-(--docs-top) max-h-[calc(100dvh-var(--docs-top))] self-start overflow-y-auto overscroll-contain [scrollbar-width:thin]";
24
+ const sticky = "sticky top-(--docs-top) max-h-[calc(100dvh-var(--docs-top))] scroll-py-10 self-start overflow-y-auto overscroll-contain [scrollbar-width:thin]";
22
25
  /** The pages of the set: a `SideNav`. Hidden below `lg`. */
23
26
  function DocsLayoutNav({ className, ...props }) {
24
- return /* @__PURE__ */ jsx("div", {
27
+ return /* @__PURE__ */ jsx(ScrollFade, {
28
+ axis: "y",
25
29
  "data-slot": "docs-layout-nav",
26
30
  className: cn(sticky, "-ml-2.5 hidden pt-10 pr-1 pb-10 pl-2.5 lg:block", className),
27
31
  ...props
@@ -37,7 +41,8 @@ function DocsLayoutMain({ className, ...props }) {
37
41
  }
38
42
  /** The sections of the page: a `TableOfContents`. Hidden below `xl`. */
39
43
  function DocsLayoutAside({ className, ...props }) {
40
- return /* @__PURE__ */ jsx("div", {
44
+ return /* @__PURE__ */ jsx(ScrollFade, {
45
+ axis: "y",
41
46
  "data-slot": "docs-layout-aside",
42
47
  className: cn(sticky, "hidden pt-10 pb-10 pl-1 xl:block", className),
43
48
  ...props
@@ -0,0 +1,51 @@
1
+ /** One page of the set. A page may have subpages, which are read after it. */
2
+ export type DocsPage = {
3
+ /** The page's name, as it stands in the navigation and above the page. */
4
+ title: string;
5
+ /** Where it is, as the site's router knows it ("/doku/schnellstart"). */
6
+ href: string;
7
+ /** Pages under this one. They show in the navigation while the reader is on it or on them. */
8
+ pages?: readonly DocsPage[];
9
+ };
10
+ /** A part of the set: a noun ("Anleitungen") and the pages under it. */
11
+ export type DocsGroup = {
12
+ title: string;
13
+ pages: readonly DocsPage[];
14
+ };
15
+ /** The whole set, in the order it is read. */
16
+ export type DocsNav = readonly DocsGroup[];
17
+ /** A step of the trail above a page's title. A group is no page and has no `href`. */
18
+ export type DocsCrumb = {
19
+ title: string;
20
+ href?: string;
21
+ };
22
+ /** Where a page stands in its set. */
23
+ export type DocsPlace = {
24
+ page: DocsPage;
25
+ /** The part of the set it belongs to. */
26
+ group: DocsGroup;
27
+ /** The page it lies under, if it is a subpage. */
28
+ parent?: DocsPage;
29
+ /** The page read before it and the one read after it, across groups. None at either end. */
30
+ previous?: DocsPage;
31
+ next?: DocsPage;
32
+ /** What stands above it, from the outside in: its group, then its parent. Not the page. */
33
+ trail: DocsCrumb[];
34
+ };
35
+ /** Whether two addresses lead to the same page ("/doku/start/" and "/doku/start#bevor"). */
36
+ export declare function sameDocsPage(a: string, b: string): boolean;
37
+ /** Every page of the set in reading order: each page, then its subpages, group after group. */
38
+ export declare function docsPages(nav: DocsNav): DocsPage[];
39
+ /**
40
+ * Where the page at `href` stands: its group, its parent, the trail above it and the pages
41
+ * before and after it. `undefined` when the set has no such page.
42
+ */
43
+ export declare function findDocsPage(nav: DocsNav, href: string): DocsPlace | undefined;
44
+ /**
45
+ * Whether a page of the navigation is the one being read, or lies above it: the first wears
46
+ * `current`, the second is `open` so its subpages show.
47
+ */
48
+ export declare function docsPageState(page: DocsPage, href: string): {
49
+ current: boolean;
50
+ open: boolean;
51
+ };
@@ -0,0 +1,60 @@
1
+ // src/components/docs-layout/docs-nav.ts
2
+ /** An address without what does not name a page: its query, its fragment, a closing slash. */
3
+ function pathOf(href) {
4
+ const path = href.replace(/[?#].*$/, "");
5
+ return path.length > 1 ? path.replace(/\/+$/, "") : path;
6
+ }
7
+ /** Whether two addresses lead to the same page ("/doku/start/" and "/doku/start#bevor"). */
8
+ function sameDocsPage(a, b) {
9
+ return pathOf(a) === pathOf(b);
10
+ }
11
+ /** Every page of the set in reading order: each page, then its subpages, group after group. */
12
+ function docsPages(nav) {
13
+ const walk = (pages) => pages.flatMap((page) => [page, ...walk(page.pages ?? [])]);
14
+ return nav.flatMap((group) => walk(group.pages));
15
+ }
16
+ /**
17
+ * Where the page at `href` stands: its group, its parent, the trail above it and the pages
18
+ * before and after it. `undefined` when the set has no such page.
19
+ */
20
+ function findDocsPage(nav, href) {
21
+ const order = docsPages(nav);
22
+ const at = order.findIndex((page) => sameDocsPage(page.href, href));
23
+ const page = order[at];
24
+ if (!page) return void 0;
25
+ const within = (pages, above) => {
26
+ for (const candidate of pages) {
27
+ if (candidate === page) return above;
28
+ const deeper = within(candidate.pages ?? [], [...above, candidate]);
29
+ if (deeper) return deeper;
30
+ }
31
+ };
32
+ for (const group of nav) {
33
+ const above = within(group.pages, []);
34
+ if (!above) continue;
35
+ return {
36
+ page,
37
+ group,
38
+ parent: above[above.length - 1],
39
+ previous: order[at - 1],
40
+ next: order[at + 1],
41
+ trail: [{ title: group.title }, ...above.map((parent) => ({
42
+ title: parent.title,
43
+ href: parent.href
44
+ }))]
45
+ };
46
+ }
47
+ }
48
+ /**
49
+ * Whether a page of the navigation is the one being read, or lies above it: the first wears
50
+ * `current`, the second is `open` so its subpages show.
51
+ */
52
+ function docsPageState(page, href) {
53
+ const current = sameDocsPage(page.href, href);
54
+ const holds = (pages) => pages.some((sub) => sameDocsPage(sub.href, href) || holds(sub.pages ?? []));
55
+ return {
56
+ current,
57
+ open: !current && holds(page.pages ?? [])
58
+ };
59
+ }
60
+ export { docsPageState, docsPages, findDocsPage, sameDocsPage };
@@ -0,0 +1,20 @@
1
+ import { ComponentProps } from "react";
2
+ export type GrowProps = ComponentProps<"div">;
3
+ /**
4
+ * A block whose height follows what it holds. When something joins it (a step of a `Trace`, a
5
+ * paragraph that arrives, the next tab's panel), it eases to its new height on `settle`, and
6
+ * what stands below moves down with it instead of jumping. It shrinks the same way.
7
+ *
8
+ * Put it around the part that changes, not around the page: what stands inside below the change
9
+ * still moves at once. Give each part that grows on its own a `Grow` of its own, side by side;
10
+ * one inside another sets its height in the middle of the other's measuring, and the outer one
11
+ * then learns of it a frame late.
12
+ *
13
+ * At rest it is a plain block of the content's height that clips nothing. It clips only while
14
+ * it moves, so a line that joins at its foot is uncovered as the block opens. From rest it does
15
+ * not animate the first height, a resize of the window, or a height that something inside is
16
+ * already animating (an opening `Collapsible`): then it simply follows.
17
+ * Already on its way, it takes a new height as its goal from where it stands. Under reduced
18
+ * motion it always follows.
19
+ */
20
+ export declare function Grow({ className, children, ref, ...props }: GrowProps): import("react").JSX.Element;