@lanfermann/ui 0.3.0 → 0.5.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 (81) hide show
  1. package/dist/components/anchor-heading/anchor-heading.d.ts +1 -1
  2. package/dist/components/breadcrumbs/breadcrumbs.js +5 -10
  3. package/dist/components/button/button.d.ts +3 -0
  4. package/dist/components/button/button.js +14 -4
  5. package/dist/components/button-group/button-group-context.js +14 -0
  6. package/dist/components/button-group/button-group-variants.d.ts +14 -0
  7. package/dist/components/button-group/button-group-variants.js +93 -0
  8. package/dist/components/button-group/button-group.d.ts +36 -0
  9. package/dist/components/button-group/button-group.js +46 -0
  10. package/dist/components/code-block/code-block-frame.js +22 -6
  11. package/dist/components/code-block/code-block-live.d.ts +15 -3
  12. package/dist/components/code-block/code-block-live.js +14 -6
  13. package/dist/components/code-block/code-block.d.ts +8 -3
  14. package/dist/components/code-block/code-block.js +9 -3
  15. package/dist/components/code-block/code-keys.d.ts +24 -0
  16. package/dist/components/code-block/code-keys.js +107 -0
  17. package/dist/components/code-block/code-lines-live.d.ts +7 -0
  18. package/dist/components/code-block/code-lines-live.js +167 -0
  19. package/dist/components/code-block/code-lines-view.d.ts +1 -0
  20. package/dist/components/code-block/code-lines-view.js +50 -18
  21. package/dist/components/code-block/code-lines.d.ts +3 -0
  22. package/dist/components/code-block/code-scroll.js +2 -1
  23. package/dist/components/code-block/code-tabs-frame.js +12 -5
  24. package/dist/components/code-block/code-tabs.d.ts +10 -4
  25. package/dist/components/code-block/code-tabs.js +9 -6
  26. package/dist/components/code-block/highlight.d.ts +1 -0
  27. package/dist/components/code-block/line-diff.js +135 -0
  28. package/dist/components/code-block/lines.js +23 -1
  29. package/dist/components/copy-page/copy-page.d.ts +4 -4
  30. package/dist/components/copy-page/copy-page.js +16 -28
  31. package/dist/components/docs-layout/docs-layout.d.ts +1 -1
  32. package/dist/components/docs-layout/docs-layout.js +3 -3
  33. package/dist/components/docs-layout/docs-nav.d.ts +51 -0
  34. package/dist/components/docs-layout/docs-nav.js +60 -0
  35. package/dist/components/grow/grow.d.ts +20 -0
  36. package/dist/components/grow/grow.js +104 -0
  37. package/dist/components/heading/heading.d.ts +4 -0
  38. package/dist/components/heading/heading.js +8 -4
  39. package/dist/components/hover-card/hover-card.d.ts +24 -0
  40. package/dist/components/hover-card/hover-card.js +51 -0
  41. package/dist/components/pager/pager.js +19 -24
  42. package/dist/components/scroll-fade/scroll-fade.d.ts +29 -0
  43. package/dist/components/scroll-fade/scroll-fade.js +40 -0
  44. package/dist/components/scroll-fade/use-scroll-edges.d.ts +13 -0
  45. package/dist/{internal/scroll-edges.js → components/scroll-fade/use-scroll-edges.js} +10 -7
  46. package/dist/components/section/section.d.ts +2 -1
  47. package/dist/components/section/section.js +2 -1
  48. package/dist/components/segmented-control/segmented-control.d.ts +7 -1
  49. package/dist/components/segmented-control/segmented-control.js +22 -11
  50. package/dist/components/select/select.d.ts +4 -1
  51. package/dist/components/select/select.js +15 -3
  52. package/dist/components/shimmer/shimmer.d.ts +21 -0
  53. package/dist/components/shimmer/shimmer.js +24 -0
  54. package/dist/components/side-nav/side-nav.js +11 -20
  55. package/dist/components/site-header/site-header.d.ts +1 -1
  56. package/dist/components/site-header/site-header.js +6 -3
  57. package/dist/components/slider/slider.d.ts +3 -1
  58. package/dist/components/slider/slider.js +45 -19
  59. package/dist/components/table/table.js +2 -1
  60. package/dist/components/tabs/tabs.js +3 -2
  61. package/dist/components/theme-switch/theme-switch.d.ts +47 -0
  62. package/dist/components/theme-switch/theme-switch.js +102 -0
  63. package/dist/components/trace/trace.d.ts +71 -0
  64. package/dist/components/trace/trace.js +201 -0
  65. package/dist/index.d.ts +11 -2
  66. package/dist/index.js +10 -2
  67. package/dist/internal/render-as.js +24 -0
  68. package/dist/internal/rule.js +5 -4
  69. package/package.json +1 -1
  70. package/src/styles/button-group.css +57 -0
  71. package/src/styles/code.css +102 -38
  72. package/src/styles/marks.css +10 -0
  73. package/src/styles/motion.css +4 -3
  74. package/src/styles/scroll-fade.css +26 -20
  75. package/src/styles/shimmer.css +68 -0
  76. package/src/styles/slider.css +57 -19
  77. package/src/styles.css +2 -1
  78. package/dist/components/page-header/page-header.d.ts +0 -30
  79. package/dist/components/page-header/page-header.js +0 -49
  80. package/dist/internal/scroll-fade.js +0 -24
  81. package/src/styles/tabs.css +0 -39
@@ -1,4 +1,6 @@
1
1
  "use client";
2
+ import { Button } from "../button/button.js";
3
+ import { ButtonGroup } from "../button-group/button-group.js";
2
4
  import { Icon } from "../icon/icon.js";
3
5
  import { MenuContent, MenuItem, MenuLinkItem } from "../menu/menu.js";
4
6
  import { ActionArrow } from "../../internal/arrow.js";
@@ -14,10 +16,10 @@ const CONFIRM_MS = 1600;
14
16
  /**
15
17
  * Hands a docs page on as Markdown: one raised fitting split in two, the copy and the menu. The
16
18
  * copy fetches the page's Markdown and puts it on the clipboard, for a model or an agent; the
17
- * menu repeats it with a line on what it is, and opens the Markdown in a new tab. Put it in the
18
- * page header, at the end of the row above the title.
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.
19
21
  *
20
- * It is one part with two keys, so it moves as one: under the pointer the whole fitting lifts,
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,
21
23
  * and the key under it takes the hover wash. Pressed, the fitting goes down and drops its
22
24
  * ambient shadow, and only the pressed key takes the inner shade, so it rocks on that key and the
23
25
  * other keeps its gloss. A copy is confirmed in the key, as in a code block: the copy symbol
@@ -71,9 +73,11 @@ function CopyPage({ href, label, description, viewLabel, viewDescription, moreLa
71
73
  }
72
74
  }
73
75
  const isCopied = state === "copied";
74
- return /* @__PURE__ */ jsxs("div", {
76
+ return /* @__PURE__ */ jsxs(ButtonGroup, {
77
+ size: "sm",
78
+ "aria-label": label,
75
79
  "data-slot": "copy-page",
76
- className: cn("relative inline-flex h-(--control-sm) shrink-0 items-stretch rounded-md bg-raised depth-raised text-sm font-medium text-fg", "transition-[box-shadow,scale] spring-seat", "has-[button:hover]:spring-snap has-[button:hover:not(:active)]:depth-raised-hover", "has-[button:active]:scale-(--motion-press-scale) has-[button:active]:shadow-pressed has-[button:active]:spring-snap", className),
80
+ className: cn("rounded-md", className),
77
81
  onPointerEnter: (event) => {
78
82
  load().catch(() => {});
79
83
  onPointerEnter?.(event);
@@ -84,12 +88,11 @@ function CopyPage({ href, label, description, viewLabel, viewDescription, moreLa
84
88
  },
85
89
  ...props,
86
90
  children: [
87
- /* @__PURE__ */ jsxs("button", {
88
- type: "button",
91
+ /* @__PURE__ */ jsxs(Button, {
89
92
  "data-slot": "copy-page-copy",
90
93
  "data-copied": isCopied ? "" : void 0,
91
94
  onClick: () => void copy(),
92
- className: cn(key, "gap-1.5 rounded-l-md pr-2.5 pl-(--control-pad-sm)"),
95
+ className: "pr-2.5",
93
96
  children: [/* @__PURE__ */ jsxs("span", {
94
97
  className: "relative flex size-4 shrink-0 items-center justify-center",
95
98
  children: [/* @__PURE__ */ jsx(Icon, {
@@ -106,18 +109,15 @@ function CopyPage({ href, label, description, viewLabel, viewDescription, moreLa
106
109
  })]
107
110
  }), label]
108
111
  }),
109
- /* @__PURE__ */ jsx("span", {
110
- "aria-hidden": true,
111
- "data-slot": "copy-page-divider",
112
- className: "w-px bg-hairline"
113
- }),
114
112
  /* @__PURE__ */ jsxs(Menu.Root, {
115
113
  modal: false,
116
114
  defaultOpen,
117
115
  children: [/* @__PURE__ */ jsx(Menu.Trigger, {
118
- "data-slot": "copy-page-more",
119
- "aria-label": moreLabel,
120
- className: cn(key, "group/more justify-center rounded-r-md px-1.5 data-popup-open:bg-hover pointer-coarse:px-2.5"),
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
121
  children: /* @__PURE__ */ jsx(ChevronDownGlyph, {
122
122
  width: 12,
123
123
  height: 12,
@@ -160,18 +160,6 @@ function CopyPage({ href, label, description, viewLabel, viewDescription, moreLa
160
160
  ]
161
161
  });
162
162
  }
163
- /**
164
- * One key of the fitting. It has no face of its own: the fitting's gloss shows through, a wash
165
- * marks the key under the pointer, and a press shades only this key. On a touch screen its target
166
- * grows to 44px up and down, never sideways, so the two keys never take each other's taps.
167
- */
168
- const key = [
169
- "relative inline-flex items-center outline-offset-2 select-none",
170
- "transition-[background-color,box-shadow] spring-seat hover:bg-hover hover:spring-snap",
171
- "active:bg-raised-pressed active:inset-shadow-pressed active:spring-snap",
172
- "focus-visible:z-1 focus-visible:rounded-md focus-visible:outline-2 focus-visible:outline-accent",
173
- "pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:top-1/2 pointer-coarse:after:h-11 pointer-coarse:after:-translate-y-1/2 pointer-coarse:after:content-['']"
174
- ].join(" ");
175
163
  /** A row of the menu: a tile, then two lines. It keeps the list's instant highlight. */
176
164
  const row = "group/row items-center gap-3 px-2 py-2";
177
165
  function Tile({ children }) {
@@ -5,7 +5,7 @@ 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). A side column
8
+ * `--docs-top` (3.5rem: the `SiteHeader`'s bar, 8px off the top and 48px tall). A side column
9
9
  * longer than the window scrolls inside itself, and fades at the end that has more. The pages
10
10
  * column shows from `lg`, the sections column from `xl`; below that, the pages go into the
11
11
  * site's menu and the sections fold above the text.
@@ -1,5 +1,5 @@
1
1
  import { containerVariants } from "../container/container.js";
2
- import { ScrollFade } from "../../internal/scroll-fade.js";
2
+ import { ScrollFade } from "../scroll-fade/scroll-fade.js";
3
3
  import { cn } from "../../lib/cn.js";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  // src/components/docs-layout/docs-layout.tsx
@@ -9,7 +9,7 @@ import { jsx } from "react/jsx-runtime";
9
9
  * in the middle, the page's sections on the right.
10
10
  *
11
11
  * The side columns stay in view while the text scrolls, below a sticky bar of the height in
12
- * `--docs-top` (4rem: the `SiteHeader`'s bar, 8px off the top and 56px tall). A side column
12
+ * `--docs-top` (3.5rem: the `SiteHeader`'s bar, 8px off the top and 48px tall). A side column
13
13
  * longer than the window scrolls inside itself, and fades at the end that has more. The pages
14
14
  * column shows from `lg`, the sections column from `xl`; below that, the pages go into the
15
15
  * site's menu and the sections fold above the text.
@@ -17,7 +17,7 @@ import { jsx } from "react/jsx-runtime";
17
17
  function DocsLayout({ className, ...props }) {
18
18
  return /* @__PURE__ */ jsx("div", {
19
19
  "data-slot": "docs-layout",
20
- 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),
21
21
  ...props
22
22
  });
23
23
  }
@@ -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;
@@ -0,0 +1,104 @@
1
+ "use client";
2
+ import { cn } from "../../lib/cn.js";
3
+ import { mergeRefs } from "../../lib/merge-refs.js";
4
+ import { jsx } from "react/jsx-runtime";
5
+ import { useLayoutEffect, useRef } from "react";
6
+ // src/components/grow/grow.tsx
7
+ /** The transitions of a part inside that already move the content's height by themselves. */
8
+ const heightProperties = /* @__PURE__ */ new Set([
9
+ "height",
10
+ "max-height",
11
+ "grid-template-rows"
12
+ ]);
13
+ /** Whether something inside is moving its own height: a panel opening, another `Grow`. */
14
+ function movingInside(content) {
15
+ return content.getAnimations({ subtree: true }).some((animation) => animation instanceof CSSTransition && heightProperties.has(animation.transitionProperty) && animation.playState !== "finished");
16
+ }
17
+ /** Whether the box itself is on its way to a height. */
18
+ function heightMoving(box) {
19
+ return box.getAnimations().some((animation) => animation instanceof CSSTransition && animation.transitionProperty === "height" && animation.playState === "running");
20
+ }
21
+ /**
22
+ * A block whose height follows what it holds. When something joins it (a step of a `Trace`, a
23
+ * paragraph that arrives, the next tab's panel), it eases to its new height on `settle`, and
24
+ * what stands below moves down with it instead of jumping. It shrinks the same way.
25
+ *
26
+ * Put it around the part that changes, not around the page: what stands inside below the change
27
+ * still moves at once. Give each part that grows on its own a `Grow` of its own, side by side;
28
+ * one inside another sets its height in the middle of the other's measuring, and the outer one
29
+ * then learns of it a frame late.
30
+ *
31
+ * At rest it is a plain block of the content's height that clips nothing. It clips only while
32
+ * it moves, so a line that joins at its foot is uncovered as the block opens. From rest it does
33
+ * not animate the first height, a resize of the window, or a height that something inside is
34
+ * already animating (an opening `Collapsible`): then it simply follows.
35
+ * Already on its way, it takes a new height as its goal from where it stands. Under reduced
36
+ * motion it always follows.
37
+ */
38
+ function Grow({ className, children, ref, ...props }) {
39
+ const box = useRef(null);
40
+ const content = useRef(null);
41
+ useLayoutEffect(() => {
42
+ const outer = box.current;
43
+ const inner = content.current;
44
+ if (!outer || !inner) return;
45
+ const reduced = window.matchMedia("(prefers-reduced-motion: reduce)");
46
+ /** The content's height when it was last measured, and the window's width then. */
47
+ let height = inner.offsetHeight;
48
+ let width = window.innerWidth;
49
+ const rest = () => {
50
+ delete outer.dataset.moving;
51
+ outer.style.height = "";
52
+ };
53
+ const observer = new ResizeObserver(() => {
54
+ const nextHeight = inner.offsetHeight;
55
+ const nextWidth = window.innerWidth;
56
+ const moving = outer.dataset.moving !== void 0;
57
+ const from = moving ? outer.getBoundingClientRect().height : height;
58
+ const follow = reduced.matches || nextWidth !== width || movingInside(inner);
59
+ height = nextHeight;
60
+ width = nextWidth;
61
+ if (Math.abs(nextHeight - from) < .5) {
62
+ if (moving) rest();
63
+ return;
64
+ }
65
+ if (follow && (!moving || reduced.matches)) {
66
+ if (moving) rest();
67
+ return;
68
+ }
69
+ outer.dataset.moving = "";
70
+ outer.style.transition = "none";
71
+ outer.style.height = `${from}px`;
72
+ outer.offsetHeight;
73
+ outer.style.transition = "";
74
+ outer.style.height = `${nextHeight}px`;
75
+ });
76
+ observer.observe(inner);
77
+ const arrived = (event) => {
78
+ if (event.target !== outer || event.propertyName !== "height") return;
79
+ if (event.type === "transitioncancel" && heightMoving(outer)) return;
80
+ rest();
81
+ };
82
+ outer.addEventListener("transitionend", arrived);
83
+ outer.addEventListener("transitioncancel", arrived);
84
+ return () => {
85
+ observer.disconnect();
86
+ outer.removeEventListener("transitionend", arrived);
87
+ outer.removeEventListener("transitioncancel", arrived);
88
+ rest();
89
+ };
90
+ }, []);
91
+ return /* @__PURE__ */ jsx("div", {
92
+ ref: mergeRefs(box, ref),
93
+ "data-slot": "grow",
94
+ className: cn("transition-[height] spring-settle data-moving:overflow-clip", className),
95
+ ...props,
96
+ children: /* @__PURE__ */ jsx("div", {
97
+ ref: content,
98
+ "data-slot": "grow-content",
99
+ className: "flow-root",
100
+ children
101
+ })
102
+ });
103
+ }
104
+ export { Grow };
@@ -11,6 +11,10 @@ export type HeadingProps = ComponentProps<"h2"> & VariantProps<typeof headingVar
11
11
  * A title on the type scale. Write it as a sentence with a full stop ("Bei Lanfermann
12
12
  * anmelden."), in sentence case. Pick `level` for the document outline and `size` for the look:
13
13
  * they are independent.
14
+ *
15
+ * What opens a page or a section is this and a `Text` under it, set left, with nothing above the
16
+ * title: `size="display"` once, for the page's opening, `size="title"` for every section. Give
17
+ * the title a measure (`max-w-[44rem]`) and the lead a shorter one (`max-w-[34rem]`).
14
18
  */
15
19
  export declare function Heading({ level, size, className, ...props }: HeadingProps): import("react").JSX.Element;
16
20
  export {};
@@ -3,10 +3,10 @@ import { jsx } from "react/jsx-runtime";
3
3
  import { cva } from "class-variance-authority";
4
4
  // src/components/heading/heading.tsx
5
5
  const headingVariants = cva("text-balance text-fg", { variants: { size: {
6
- /** 54px: one per page at most, on a landing view. */
7
- display: "text-3xl font-medium",
8
- /** 36px: the title of a page. */
9
- title: "text-2xl font-medium",
6
+ /** 54px: one per page at most, on a landing view. 36px on a phone. */
7
+ display: "text-3xl font-medium max-sm:text-2xl",
8
+ /** 36px: the title of a page. 24px on a phone. */
9
+ title: "text-2xl font-medium max-sm:text-xl",
10
10
  /** 24px: a section, usually under a rule. */
11
11
  section: "text-xl font-semibold",
12
12
  /** 20px: a card, a dialog, a group. */
@@ -24,6 +24,10 @@ const sizeForLevel = {
24
24
  * A title on the type scale. Write it as a sentence with a full stop ("Bei Lanfermann
25
25
  * anmelden."), in sentence case. Pick `level` for the document outline and `size` for the look:
26
26
  * they are independent.
27
+ *
28
+ * What opens a page or a section is this and a `Text` under it, set left, with nothing above the
29
+ * title: `size="display"` once, for the page's opening, `size="title"` for every section. Give
30
+ * the title a measure (`max-w-[44rem]`) and the lead a shorter one (`max-w-[34rem]`).
27
31
  */
28
32
  function Heading({ level = 2, size, className, ...props }) {
29
33
  const Tag = `h${level}`;
@@ -0,0 +1,24 @@
1
+ import { LinkVariants } from "../link/link-variants.js";
2
+ import { PreviewCard } from "@base-ui/react/preview-card";
3
+ /**
4
+ * A look at what stands behind a link, before following it: the page a term leads to, the
5
+ * customer behind a name. It opens while the link is pointed at (after a moment, so a pointer
6
+ * passing over does not open it) or has the keyboard, and never on a touch screen.
7
+ *
8
+ * It is a preview and nothing more. Everything in it must also stand where the link leads,
9
+ * because assistive tech does not go through it: there, the link is the whole interface. For
10
+ * something a person has to read or operate, use a `Popover`.
11
+ */
12
+ export declare const HoverCard: <Payload>(props: PreviewCard.Root.Props<Payload>) => React.JSX.Element;
13
+ export type HoverCardTriggerProps = PreviewCard.Trigger.Props & LinkVariants;
14
+ /**
15
+ * The link. It stays a link, with a link's look and its `href`; pass a router's link as `render`.
16
+ * `delay` and `closeDelay` (ms) say how long it waits before the card opens and closes.
17
+ */
18
+ export declare function HoverCardTrigger({ className, variant, ...props }: HoverCardTriggerProps): import("react").JSX.Element;
19
+ export type HoverCardContentProps = PreviewCard.Popup.Props & Pick<PreviewCard.Positioner.Props, "side" | "align" | "sideOffset" | "alignOffset">;
20
+ /**
21
+ * The card: a sheet that grows out of the link and hangs from the start of it, like everything
22
+ * that is set left. A title, a line or two, perhaps a picture; nothing to press.
23
+ */
24
+ export declare function HoverCardContent({ className, side, align, sideOffset, alignOffset, ...props }: HoverCardContentProps): import("react").JSX.Element;
@@ -0,0 +1,51 @@
1
+ "use client";
2
+ import { useGround } from "../ground/ground.js";
3
+ import { linkVariants } from "../link/link-variants.js";
4
+ import { popupMotion } from "../../internal/popup.js";
5
+ import { mergeClassName } from "../../lib/cn.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ import { PreviewCard } from "@base-ui/react/preview-card";
8
+ // src/components/hover-card/hover-card.tsx
9
+ /**
10
+ * A look at what stands behind a link, before following it: the page a term leads to, the
11
+ * customer behind a name. It opens while the link is pointed at (after a moment, so a pointer
12
+ * passing over does not open it) or has the keyboard, and never on a touch screen.
13
+ *
14
+ * It is a preview and nothing more. Everything in it must also stand where the link leads,
15
+ * because assistive tech does not go through it: there, the link is the whole interface. For
16
+ * something a person has to read or operate, use a `Popover`.
17
+ */
18
+ const HoverCard = PreviewCard.Root;
19
+ /**
20
+ * The link. It stays a link, with a link's look and its `href`; pass a router's link as `render`.
21
+ * `delay` and `closeDelay` (ms) say how long it waits before the card opens and closes.
22
+ */
23
+ function HoverCardTrigger({ className, variant, ...props }) {
24
+ return /* @__PURE__ */ jsx(PreviewCard.Trigger, {
25
+ "data-slot": "hover-card-trigger",
26
+ className: mergeClassName(linkVariants({ variant }), className),
27
+ ...props
28
+ });
29
+ }
30
+ /**
31
+ * The card: a sheet that grows out of the link and hangs from the start of it, like everything
32
+ * that is set left. A title, a line or two, perhaps a picture; nothing to press.
33
+ */
34
+ function HoverCardContent({ className, side = "bottom", align = "start", sideOffset = 8, alignOffset, ...props }) {
35
+ const ground = useGround();
36
+ return /* @__PURE__ */ jsx(PreviewCard.Portal, { children: /* @__PURE__ */ jsx(PreviewCard.Positioner, {
37
+ "data-slot": "hover-card-positioner",
38
+ side,
39
+ align,
40
+ sideOffset,
41
+ alignOffset,
42
+ className: "z-50 max-w-(--available-width)",
43
+ children: /* @__PURE__ */ jsx(PreviewCard.Popup, {
44
+ "data-slot": "hover-card-content",
45
+ "data-theme": ground,
46
+ className: mergeClassName(["flex w-72 flex-col gap-2 rounded-xl bg-sheet p-4 text-control text-fg-body depth-floating", popupMotion], className),
47
+ ...props
48
+ })
49
+ }) });
50
+ }
51
+ export { HoverCard, HoverCardContent, HoverCardTrigger };
@@ -1,8 +1,7 @@
1
- "use client";
2
1
  import { ActionArrow } from "../../internal/arrow.js";
2
+ import { renderAs } from "../../internal/render-as.js";
3
3
  import { cn } from "../../lib/cn.js";
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
- import { useRender } from "@base-ui/react/use-render";
6
5
  // src/components/pager/pager.tsx
7
6
  /**
8
7
  * The way on at the end of a page that is one of a sequence: the page before and the page after,
@@ -24,28 +23,24 @@ function Pager({ label = "Weitere Seiten", className, children, ...props }) {
24
23
  */
25
24
  function PagerLink({ direction, title, label = direction === "next" ? "Nächste Seite" : "Vorherige Seite", render, className, ...props }) {
26
25
  const next = direction === "next";
27
- return useRender({
28
- defaultTagName: "a",
29
- render,
30
- props: {
31
- ...props,
32
- "data-slot": "pager-link",
33
- "data-direction": direction,
34
- rel: next ? "next" : "prev",
35
- className: cn("group/pager -mx-3 flex min-w-0 flex-col gap-1 rounded-lg px-3 py-3 transition-colors duration-150 ease-out hover:bg-hover", "focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-accent", next && "sm:col-start-2 sm:items-end sm:text-right", className),
36
- children: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("span", {
37
- "data-slot": "pager-label",
38
- className: cn("flex items-center gap-1.5 text-sm text-fg-muted", next && "sm:flex-row-reverse"),
39
- children: [/* @__PURE__ */ jsx(ActionArrow, {
40
- direction: next ? "right" : "left",
41
- size: 14
42
- }), label]
43
- }), /* @__PURE__ */ jsx("span", {
44
- "data-slot": "pager-title",
45
- className: "max-w-full text-lg font-medium text-pretty text-fg",
46
- children: title
47
- })] })
48
- }
26
+ return renderAs("a", render, {
27
+ ...props,
28
+ "data-slot": "pager-link",
29
+ "data-direction": direction,
30
+ rel: next ? "next" : "prev",
31
+ className: cn("group/pager -mx-3 flex min-w-0 flex-col gap-1 rounded-lg px-3 py-3 transition-colors duration-150 ease-out hover:bg-hover", "focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-accent", next && "sm:col-start-2 sm:items-end sm:text-right", className),
32
+ children: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("span", {
33
+ "data-slot": "pager-label",
34
+ className: cn("flex items-center gap-1.5 text-sm text-fg-muted", next && "sm:flex-row-reverse"),
35
+ children: [/* @__PURE__ */ jsx(ActionArrow, {
36
+ direction: next ? "right" : "left",
37
+ size: 14
38
+ }), label]
39
+ }), /* @__PURE__ */ jsx("span", {
40
+ "data-slot": "pager-title",
41
+ className: "max-w-full text-lg font-medium text-pretty text-fg",
42
+ children: title
43
+ })] })
49
44
  });
50
45
  }
51
46
  export { Pager, PagerLink };
@@ -0,0 +1,29 @@
1
+ import { ComponentProps } from "react";
2
+ export type ScrollFadeProps = ComponentProps<"div"> & {
3
+ /** The direction the box scrolls in, and so the edges that fade. */
4
+ axis?: "x" | "y";
5
+ /**
6
+ * The edges that may fade: both (the default), or only the one where the content starts or
7
+ * ends. A list under a heading that stays put needs no fade at its start.
8
+ */
9
+ edges?: "both" | "start" | "end";
10
+ /** How deep the fade is, as a CSS length. 40px unless set. */
11
+ size?: string;
12
+ };
13
+ /**
14
+ * A box that scrolls inside itself and fades at the edge where more waits, instead of being cut
15
+ * hard: a long list in a sheet, a row of chips, the side column of a page. An edge fades only
16
+ * while there is something beyond it, so a box whose content fits looks like any other, and the
17
+ * fade moves in and out on `settle`. It is a mask, not a tinted overlay: it works on every
18
+ * ground and over a picture.
19
+ *
20
+ * Give the box its size (`max-h-64`, `h-full`); it sets its own `overflow`. Its background and
21
+ * border belong on a box around it, since the mask fades everything the box paints, and so does
22
+ * a focus outline. What takes the keyboard focus inside is scrolled clear of the fade. A box
23
+ * that holds nothing focusable must be reachable itself: give it `tabIndex={0}`, a `role` and a
24
+ * name, as a `Table` does.
25
+ *
26
+ * Where the scrolling element belongs to another part, use `useScrollEdges` on it and set
27
+ * `data-scroll-fade` to the axis.
28
+ */
29
+ export declare function ScrollFade({ axis, edges, size, className, style, ref, ...props }: ScrollFadeProps): import("react").JSX.Element;
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ import { cn } from "../../lib/cn.js";
3
+ import { mergeRefs } from "../../lib/merge-refs.js";
4
+ import { useScrollEdges } from "./use-scroll-edges.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import { useRef } from "react";
7
+ // src/components/scroll-fade/scroll-fade.tsx
8
+ /**
9
+ * A box that scrolls inside itself and fades at the edge where more waits, instead of being cut
10
+ * hard: a long list in a sheet, a row of chips, the side column of a page. An edge fades only
11
+ * while there is something beyond it, so a box whose content fits looks like any other, and the
12
+ * fade moves in and out on `settle`. It is a mask, not a tinted overlay: it works on every
13
+ * ground and over a picture.
14
+ *
15
+ * Give the box its size (`max-h-64`, `h-full`); it sets its own `overflow`. Its background and
16
+ * border belong on a box around it, since the mask fades everything the box paints, and so does
17
+ * a focus outline. What takes the keyboard focus inside is scrolled clear of the fade. A box
18
+ * that holds nothing focusable must be reachable itself: give it `tabIndex={0}`, a `role` and a
19
+ * name, as a `Table` does.
20
+ *
21
+ * Where the scrolling element belongs to another part, use `useScrollEdges` on it and set
22
+ * `data-scroll-fade` to the axis.
23
+ */
24
+ function ScrollFade({ axis = "y", edges = "both", size, className, style, ref, ...props }) {
25
+ const box = useRef(null);
26
+ useScrollEdges(box, axis);
27
+ return /* @__PURE__ */ jsx("div", {
28
+ ref: mergeRefs(box, ref),
29
+ "data-slot": "scroll-fade",
30
+ "data-scroll-fade": axis,
31
+ "data-fade-edges": edges === "both" ? void 0 : edges,
32
+ className: cn(axis === "x" ? "overflow-x-auto" : "overflow-y-auto", className),
33
+ style: size ? {
34
+ "--scroll-fade-size": size,
35
+ ...style
36
+ } : style,
37
+ ...props
38
+ });
39
+ }
40
+ export { ScrollFade };
@@ -0,0 +1,13 @@
1
+ import { RefObject } from "react";
2
+ /**
3
+ * Says on a box that scrolls which of its ends has more to show: `data-overflow` holds `start`,
4
+ * `end`, both, or is absent. The stylesheet fades those edges (scroll-fade.css) once the box
5
+ * also carries `data-scroll-fade="x"` or `"y"`. The state is written straight onto the element,
6
+ * so scrolling never renders.
7
+ *
8
+ * Use it where the scrolling box is another part's element and cannot be a `ScrollFade` (a list
9
+ * of tabs, the popup of a menu). `axis` is the direction the box scrolls in. For a box that
10
+ * mounts later than the component (a popup), pass something that changes when it does as
11
+ * `mounted`, so the edges are watched from then on.
12
+ */
13
+ export declare function useScrollEdges(ref: RefObject<HTMLElement | null>, axis?: "x" | "y", mounted?: unknown): void;