@lanfermann/ui 0.3.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 (74) 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 +3 -3
  12. package/dist/components/code-block/code-block-live.js +5 -3
  13. package/dist/components/code-block/code-block.d.ts +7 -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-scroll.js +2 -1
  18. package/dist/components/code-block/code-tabs-frame.js +12 -5
  19. package/dist/components/code-block/code-tabs.d.ts +9 -4
  20. package/dist/components/code-block/code-tabs.js +9 -6
  21. package/dist/components/code-block/lines.js +23 -1
  22. package/dist/components/copy-page/copy-page.d.ts +4 -4
  23. package/dist/components/copy-page/copy-page.js +16 -28
  24. package/dist/components/docs-layout/docs-layout.d.ts +1 -1
  25. package/dist/components/docs-layout/docs-layout.js +3 -3
  26. package/dist/components/docs-layout/docs-nav.d.ts +51 -0
  27. package/dist/components/docs-layout/docs-nav.js +60 -0
  28. package/dist/components/grow/grow.d.ts +20 -0
  29. package/dist/components/grow/grow.js +98 -0
  30. package/dist/components/heading/heading.d.ts +4 -0
  31. package/dist/components/heading/heading.js +8 -4
  32. package/dist/components/hover-card/hover-card.d.ts +24 -0
  33. package/dist/components/hover-card/hover-card.js +51 -0
  34. package/dist/components/pager/pager.js +19 -24
  35. package/dist/components/scroll-fade/scroll-fade.d.ts +29 -0
  36. package/dist/components/scroll-fade/scroll-fade.js +40 -0
  37. package/dist/components/scroll-fade/use-scroll-edges.d.ts +13 -0
  38. package/dist/{internal/scroll-edges.js → components/scroll-fade/use-scroll-edges.js} +10 -7
  39. package/dist/components/section/section.d.ts +2 -1
  40. package/dist/components/section/section.js +2 -1
  41. package/dist/components/segmented-control/segmented-control.d.ts +7 -1
  42. package/dist/components/segmented-control/segmented-control.js +22 -11
  43. package/dist/components/select/select.d.ts +4 -1
  44. package/dist/components/select/select.js +15 -3
  45. package/dist/components/shimmer/shimmer.d.ts +21 -0
  46. package/dist/components/shimmer/shimmer.js +24 -0
  47. package/dist/components/side-nav/side-nav.js +11 -20
  48. package/dist/components/site-header/site-header.d.ts +1 -1
  49. package/dist/components/site-header/site-header.js +6 -3
  50. package/dist/components/slider/slider.d.ts +3 -1
  51. package/dist/components/slider/slider.js +45 -19
  52. package/dist/components/table/table.js +2 -1
  53. package/dist/components/tabs/tabs.js +3 -2
  54. package/dist/components/theme-switch/theme-switch.d.ts +47 -0
  55. package/dist/components/theme-switch/theme-switch.js +102 -0
  56. package/dist/components/trace/trace.d.ts +71 -0
  57. package/dist/components/trace/trace.js +201 -0
  58. package/dist/index.d.ts +11 -2
  59. package/dist/index.js +10 -2
  60. package/dist/internal/render-as.js +24 -0
  61. package/dist/internal/rule.js +5 -4
  62. package/package.json +1 -1
  63. package/src/styles/button-group.css +57 -0
  64. package/src/styles/code.css +13 -37
  65. package/src/styles/marks.css +10 -0
  66. package/src/styles/motion.css +4 -3
  67. package/src/styles/scroll-fade.css +26 -20
  68. package/src/styles/shimmer.css +68 -0
  69. package/src/styles/slider.css +57 -19
  70. package/src/styles.css +2 -1
  71. package/dist/components/page-header/page-header.d.ts +0 -30
  72. package/dist/components/page-header/page-header.js +0 -49
  73. package/dist/internal/scroll-fade.js +0 -24
  74. package/src/styles/tabs.css +0 -39
@@ -0,0 +1,24 @@
1
+ import { mergeRefs } from "../lib/merge-refs.js";
2
+ import { cloneElement, createElement } from "react";
3
+ import { mergeProps } from "@base-ui/react/merge-props";
4
+ // src/internal/render-as.ts
5
+ /**
6
+ * Renders a part as its own element, or as the element its caller hands in as `render`: a
7
+ * router's link in place of an `<a>`. The part's props and the element's own are merged the way
8
+ * Base UI merges them (class names joined, styles and handlers merged, the element's own props
9
+ * winning otherwise).
10
+ *
11
+ * It is what Base UI's `useRender` does, as a plain function. `useRender` is a hook, which makes
12
+ * every part that calls it a client component; a part of plain markup (a link of the `SideNav`,
13
+ * of the `Breadcrumbs`, of the `Pager`) would then travel to the browser for nothing. With this
14
+ * it stays server-safe: no `"use client"`, and no script for a page of documentation.
15
+ */
16
+ function renderAs(tag, render, props) {
17
+ if (render === void 0) return createElement(tag, props);
18
+ if (typeof render === "function") return render(props, {});
19
+ const own = render.props;
20
+ const merged = mergeProps(props, own);
21
+ if (props.ref && own.ref) merged.ref = mergeRefs(props.ref, own.ref);
22
+ return cloneElement(render, merged);
23
+ }
24
+ export { renderAs };
@@ -1,9 +1,10 @@
1
1
  // src/internal/rule.ts
2
2
  /**
3
- * The 2px rule that opens a block (`Table`, `Accordion`, `ParameterList`, a `PageHeader` with
4
- * `rule`): a straight line with round ends. The box keeps a transparent 2px top border, so it is
5
- * laid out exactly as with `border-t-2`, and the line is drawn into that border as `::before`.
6
- * A border cannot round its own ends: with a radius it bends down at the corners instead.
3
+ * The 2px rule that opens a block (`Table`, `Accordion`, `ParameterList`): a straight line with
4
+ * round ends. The box keeps a transparent 2px top border, so it is laid out exactly as with
5
+ * `border-t-2`, and the line is drawn into that border as `::before`. A border cannot round its
6
+ * own ends: with a radius it bends down at the corners instead. Where the rule stands by itself,
7
+ * above a section's title, it is a `Separator` (`variant="rule"`).
7
8
  *
8
9
  * The box becomes positioned, and must not clip its top edge. Server-safe.
9
10
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lanfermann/ui",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Lanfermann design system components for Next.js + Tailwind CSS v4, built on Base UI.",
5
5
  "license": "MIT",
6
6
  "author": "Justin Lanfermann",
@@ -0,0 +1,57 @@
1
+ /*
2
+ * The keys of a ButtonGroup: where they meet and how they take the fitting's corners. A group is
3
+ * one fitting (one face, one edge, one shadow, on the group) with several keys in it, so the
4
+ * keys have no edge of their own. What divides two of them is a seam: the fitting's edge drawn
5
+ * once more, in its own colour, from one side of the face to the other.
6
+ *
7
+ * The first and the last key take the fitting's corners, so the wash under the pointer and the
8
+ * shade of a press fill the fitting right up to its edge instead of ending in a square inside
9
+ * it. With the keyboard on it a key rounds all four corners (button-group-variants.ts), so its
10
+ * ring closes around that key alone.
11
+ *
12
+ * A key is whatever carries `data-group-key` (a `Button` or a `SelectTrigger` inside a group),
13
+ * and it must be a child of the fitting: the corners are inherited from it.
14
+ */
15
+ @layer components {
16
+ [data-group-key] {
17
+ border: 0 solid var(--d-edge, var(--depth-surface-edge));
18
+ border-radius: 0;
19
+ }
20
+
21
+ /* In a row. */
22
+ :not([data-orientation="vertical"]) > [data-group-key] {
23
+ &:is([data-group-key] ~ *) {
24
+ border-inline-start-width: 1px;
25
+ }
26
+ &:not([data-group-key] ~ *) {
27
+ border-start-start-radius: inherit;
28
+ border-end-start-radius: inherit;
29
+ }
30
+ &:not(:has(~ [data-group-key])) {
31
+ border-start-end-radius: inherit;
32
+ border-end-end-radius: inherit;
33
+ }
34
+ }
35
+
36
+ /* One over the other. */
37
+ [data-orientation="vertical"] > [data-group-key] {
38
+ &:is([data-group-key] ~ *) {
39
+ border-block-start-width: 1px;
40
+ }
41
+ &:not([data-group-key] ~ *) {
42
+ border-start-start-radius: inherit;
43
+ border-start-end-radius: inherit;
44
+ }
45
+ &:not(:has(~ [data-group-key])) {
46
+ border-end-start-radius: inherit;
47
+ border-end-end-radius: inherit;
48
+ }
49
+ }
50
+
51
+ /* Forced colours drop the face and the washes: the seams stay as lines. */
52
+ @media (forced-colors: active) {
53
+ [data-group-key] {
54
+ border-color: ButtonBorder;
55
+ }
56
+ }
57
+ }
@@ -109,24 +109,8 @@
109
109
  }
110
110
 
111
111
  /*
112
- * The edges of a block that scrolls sideways fade where more code waits. The two lengths are
113
- * registered so the mask can move between them on a spring; the scroller sets them from
114
- * `data-overflow` (code-block-frame.tsx).
115
- */
116
- @property --code-fade-start {
117
- syntax: "<length>";
118
- inherits: false;
119
- initial-value: 0px;
120
- }
121
- @property --code-fade-end {
122
- syntax: "<length>";
123
- inherits: false;
124
- initial-value: 0px;
125
- }
126
-
127
- /*
128
- * The parts of a block that Tailwind classes cannot say well: counters, generated signs and the
129
- * mask. Measures come from the block (code-block-frame.tsx):
112
+ * The parts of a block that Tailwind classes cannot say well: counters and generated signs.
113
+ * Measures come from the block (code-block-frame.tsx):
130
114
  * --code-pad-x the inset of the code from the block's edge
131
115
  * --code-gutter the room before the code: line numbers and the sign of a change
132
116
  * --code-digits the width of the widest line number
@@ -142,11 +126,19 @@
142
126
  font-variant-ligatures: none;
143
127
  tab-size: 2;
144
128
  }
145
- [data-slot="code-block-code"][data-wrap] {
129
+ /* Long lines break: because the code was rendered so, or because the wrap key of the block is on. */
130
+ [data-slot="code-block-code"][data-wrap],
131
+ [data-wrap="on"] [data-slot="code-block-code"] {
146
132
  width: auto;
147
133
  white-space: pre-wrap;
148
134
  overflow-wrap: anywhere;
149
135
  }
136
+ /* The key is off: lines run on and scroll, whatever the code was rendered with. */
137
+ [data-wrap="off"] [data-slot="code-block-code"] {
138
+ width: max-content;
139
+ white-space: pre;
140
+ overflow-wrap: normal;
141
+ }
150
142
 
151
143
  [data-slot="code-block-line"] {
152
144
  position: relative;
@@ -195,28 +187,12 @@
195
187
  color: var(--lf-danger);
196
188
  }
197
189
 
198
- /* The edges fade where more code waits to the side; the mask moves on `settle`. The focus
199
- outline is drawn by the block around it, since a mask would cut it off. */
190
+ /* The edges fade where more code waits to the side (scroll-fade.css). The focus outline is
191
+ drawn by the block around it, since the mask would cut it off. */
200
192
  [data-slot="code-block-scroll"] {
201
- mask-image: linear-gradient(
202
- to right,
203
- transparent,
204
- #000 var(--code-fade-start),
205
- #000 calc(100% - var(--code-fade-end)),
206
- transparent
207
- );
208
- transition:
209
- --code-fade-start var(--transition-duration-spring-settle) var(--ease-spring-settle),
210
- --code-fade-end var(--transition-duration-spring-settle) var(--ease-spring-settle);
211
193
  scrollbar-width: thin;
212
194
  scrollbar-color: var(--lf-line) transparent;
213
195
  }
214
- [data-slot="code-block-scroll"][data-overflow~="start"] {
215
- --code-fade-start: 2.5rem;
216
- }
217
- [data-slot="code-block-scroll"][data-overflow~="end"] {
218
- --code-fade-end: 2.5rem;
219
- }
220
196
 
221
197
  /* The copy key's confirmation is shared with every control that copies: see copy.css. */
222
198
  }
@@ -28,6 +28,16 @@
28
28
  transition-timing-function: var(--ease-spring-seat);
29
29
  }
30
30
 
31
+ /*
32
+ * A disc that appears already closed starts as the ring and closes where it stands: the step of
33
+ * a `Trace` that has just finished, whose mark was the spinner a moment ago. Beside `mark-on`.
34
+ */
35
+ @utility mark-closes {
36
+ @starting-style {
37
+ box-shadow: inset 0 0 0 1.5px var(--mark-ring, var(--lf-line));
38
+ }
39
+ }
40
+
31
41
  /* Forced colours drop box-shadows: draw the ring as an outline and the disc as a fill. */
32
42
  @media (forced-colors: active) {
33
43
  .mark {
@@ -24,9 +24,10 @@
24
24
  }
25
25
 
26
26
  /*
27
- * The three keyframe animations in the system. All show ongoing work nobody triggered a state
28
- * change for: the spinner turns, a progress bar without a known end runs through its trough, and
29
- * under reduced motion both breathe instead.
27
+ * Three of the four keyframe animations in the system (the fourth is the shimmer of a line of
28
+ * text, shimmer.css). All show ongoing work nobody triggered a state change for: the spinner
29
+ * turns, a progress bar without a known end runs through its trough, and under reduced motion
30
+ * all of them breathe instead.
30
31
  */
31
32
  @theme {
32
33
  --animate-spinner: spinner 0.75s linear infinite;
@@ -1,12 +1,16 @@
1
1
  /*
2
- * A box that scrolls (`ScrollFade`: a wide table, the side columns of a docs page) fades at the
3
- * edges where more waits, as a code block's long lines (code.css) and a long row of tabs
4
- * (tabs.css) do: what the edge cuts says that it goes on, instead of looking cut off.
5
- * `useScrollEdges` sets `data-overflow` from the scroll position; the two lengths are
6
- * registered so the mask moves on `settle`. A box that fits has no mask.
2
+ * A box that scrolls fades at the edges where more waits: what the edge cuts says that it goes
3
+ * on, instead of looking cut off. It is the one fade of the library: a `ScrollFade`, a wide
4
+ * table, the side columns of a docs page, a code block's long lines and a long row of tabs all
5
+ * carry `data-scroll-fade` with their axis, and `useScrollEdges` sets `data-overflow` on them
6
+ * from the scroll position. A box that fits has no mask.
7
+ *
8
+ * `--scroll-fade-size` is how deep the fade is (40px). The two lengths the mask is drawn from
9
+ * are registered, so they can move between nothing and that depth on `settle`.
7
10
  *
8
11
  * The mask cuts everything the box paints, its outline too: a box that takes the keyboard
9
- * focus has its outline drawn by a box around it (`Table`).
12
+ * focus has its outline drawn by a box around it (`Table`). What takes the focus inside is
13
+ * scrolled clear of the fade.
10
14
  */
11
15
  @property --scroll-fade-start {
12
16
  syntax: "<length>";
@@ -25,28 +29,30 @@
25
29
  --scroll-fade-start var(--transition-duration-spring-settle) var(--ease-spring-settle),
26
30
  --scroll-fade-end var(--transition-duration-spring-settle) var(--ease-spring-settle);
27
31
  }
28
- [data-scroll-fade="x"][data-overflow] {
29
- mask-image: linear-gradient(
30
- to right,
31
- transparent,
32
- #000 var(--scroll-fade-start),
33
- #000 calc(100% - var(--scroll-fade-end)),
34
- transparent
35
- );
32
+ [data-scroll-fade="x"] {
33
+ --scroll-fade-to: right;
34
+ scroll-padding-inline: var(--scroll-fade-size, 2.5rem);
35
+ &:dir(rtl) {
36
+ --scroll-fade-to: left;
37
+ }
38
+ }
39
+ [data-scroll-fade="y"] {
40
+ --scroll-fade-to: bottom;
41
+ scroll-padding-block: var(--scroll-fade-size, 2.5rem);
36
42
  }
37
- [data-scroll-fade="y"][data-overflow] {
43
+ [data-scroll-fade][data-overflow] {
38
44
  mask-image: linear-gradient(
39
- to bottom,
45
+ to var(--scroll-fade-to),
40
46
  transparent,
41
47
  #000 var(--scroll-fade-start),
42
48
  #000 calc(100% - var(--scroll-fade-end)),
43
49
  transparent
44
50
  );
45
51
  }
46
- [data-scroll-fade][data-overflow~="start"] {
47
- --scroll-fade-start: 2.5rem;
52
+ [data-scroll-fade][data-overflow~="start"]:not([data-fade-edges="end"]) {
53
+ --scroll-fade-start: var(--scroll-fade-size, 2.5rem);
48
54
  }
49
- [data-scroll-fade][data-overflow~="end"] {
50
- --scroll-fade-end: 2.5rem;
55
+ [data-scroll-fade][data-overflow~="end"]:not([data-fade-edges="start"]) {
56
+ --scroll-fade-end: var(--scroll-fade-size, 2.5rem);
51
57
  }
52
58
  }
@@ -0,0 +1,68 @@
1
+ /*
2
+ * Shimmer: a soft light that passes through a line of text while the work it names is going on
3
+ * ("Zahlungen werden abgeglichen"). The text stands in the muted colour and the light is the
4
+ * ground's strongest text colour, so nothing is brighter than what stands beside it: it is a
5
+ * sign of life, not a glare. Both come from the ground the line stands on.
6
+ *
7
+ * It is one of the system's four keyframe animations (motion.css): work that goes on by itself,
8
+ * which nobody triggered a state change for.
9
+ *
10
+ * How it is drawn: the text is filled with a gradient three times its width, with one narrow
11
+ * band of light in its middle, and the gradient is pushed through from one side to the other.
12
+ * For half of the way the band is on the text; before and after, it is outside it. That is the
13
+ * rest between two passes, which keeps the line calm.
14
+ *
15
+ * --shimmer-duration one pass and its rest (2.4s)
16
+ * --shimmer-band half the width of the light (3em: it grows with the type)
17
+ * --shimmer-from, --shimmer-to the text's colour and the light's
18
+ *
19
+ * It is a paint, not a transform: a browser redraws the line on every frame. That is fine for a
20
+ * line of text and wrong for a block of it. Under reduced motion nothing passes and the line
21
+ * breathes like the spinner; in forced colours and where text cannot clip a background it is
22
+ * plain text.
23
+ */
24
+ @keyframes shimmer {
25
+ from {
26
+ background-position: 100% 0;
27
+ }
28
+ to {
29
+ background-position: 0 0;
30
+ }
31
+ }
32
+
33
+ @utility shimmer {
34
+ --shimmer-from: var(--lf-text-muted);
35
+ --shimmer-to: var(--lf-text);
36
+ color: var(--shimmer-from);
37
+
38
+ @supports ((background-clip: text) or (-webkit-background-clip: text)) {
39
+ @media (prefers-reduced-motion: no-preference) and (forced-colors: none) {
40
+ background-image: linear-gradient(
41
+ 100deg,
42
+ var(--shimmer-from) calc(50% - var(--shimmer-band, 3em)),
43
+ var(--shimmer-to) 50%,
44
+ var(--shimmer-from) calc(50% + var(--shimmer-band, 3em))
45
+ );
46
+ background-size: 300% 100%;
47
+ background-repeat: no-repeat;
48
+ -webkit-background-clip: text;
49
+ background-clip: text;
50
+ -webkit-text-fill-color: transparent;
51
+ animation: shimmer var(--shimmer-duration, 2.4s) linear infinite;
52
+
53
+ /* Read from the right, the light passes from the right. */
54
+ &:dir(rtl) {
55
+ animation-direction: reverse;
56
+ }
57
+ /* Selected, the text is filled again: a transparent fill would leave the selection empty. */
58
+ &::selection,
59
+ & ::selection {
60
+ -webkit-text-fill-color: currentColor;
61
+ }
62
+ }
63
+ }
64
+
65
+ @media (prefers-reduced-motion: reduce) {
66
+ animation: var(--animate-breathe);
67
+ }
68
+ }
@@ -6,8 +6,16 @@
6
6
  * phone), where anything that needs layout is redone on the main thread, at half that or less.
7
7
  *
8
8
  * Places are worked out in CSS from one number per thumb, `--p` (0 at the lowest value, 1 at the
9
- * highest), and the width of the control (`100cqw`: the control is a size container). Nothing is
10
- * measured in JavaScript, so the first frame is already right.
9
+ * highest). A part rides in a lane: a box as wide as the way a thumb can go, moved by `--p`
10
+ * times its own width. That is a percentage, and a percentage stays a percentage in the
11
+ * computed style: it changes when the value changes and at no other time. So nothing is
12
+ * measured in JavaScript, the first frame is already right, and a slider that changes its
13
+ * width does not glide to its new place.
14
+ *
15
+ * (The places were lengths first, from the width of the control as `100cqw`. Firefox works such
16
+ * a length out against the window before it knows the container, then corrects it, and the
17
+ * correction is a change of the computed style like any other: on load, the thumb of a full
18
+ * slider glided in from a window's width away. Justin's Firefox, 2026-11-16.)
11
19
  *
12
20
  * What follows a finger eases on `--slider-chase`: the `snap` spring written as a plain bezier
13
21
  * (within 0.02 of it; a test compares the two). Safari's compositor takes a bezier whose values
@@ -17,10 +25,7 @@
17
25
 
18
26
  /* On the control: the lengths the parts below share. */
19
27
  @utility slider-geometry {
20
- container-type: inline-size;
21
28
  --slider-thumb: calc(var(--switch-h) - 4px);
22
- /* How far a thumb's centre can go: it stops inside the trough, 2px from its wall. */
23
- --slider-travel: calc(100cqw - var(--slider-thumb));
24
29
  --slider-chase: cubic-bezier(0.3, 0.95, 0.25, 1);
25
30
  --slider-dir: 1;
26
31
  &:dir(rtl) {
@@ -28,12 +33,39 @@
28
33
  }
29
34
  }
30
35
 
31
- /* A part that rides with a thumb. Set `--p` on it; its box starts where the travel starts. */
36
+ /*
37
+ * A lane: as wide as the way a thumb's centre can go, which is the control less one thumb (it
38
+ * stops inside the trough, 2px from its wall). Set `--p` on it. The trough is wider than the
39
+ * control by its two walls: a lane inside it takes them off again (`--slider-walls`).
40
+ *
41
+ * A lane ENDS where the way has got to, and what rides in it stands at its end. At the lowest
42
+ * value the whole lane lies before the control, at the highest it lies in it. It is an empty
43
+ * box, but a box that reached past the control's end would make a page scroll sideways to it;
44
+ * before the start of a line there is nowhere to scroll to.
45
+ */
46
+ @utility slider-lane {
47
+ position: absolute;
48
+ inset-block: 0;
49
+ inset-inline-start: 0;
50
+ width: calc(100% - var(--slider-thumb) - var(--slider-walls, 0px));
51
+ translate: calc(var(--slider-dir) * (var(--p, 0) - 1) * 100%);
52
+ }
53
+
54
+ /* A lane for a part that rides with a thumb, centred on the trough's line. Give it a height. */
32
55
  @utility slider-at {
33
56
  position: absolute;
34
57
  top: 50%;
35
58
  inset-inline-start: 0;
36
- translate: calc(var(--slider-dir) * var(--p, 0) * var(--slider-travel)) -50%;
59
+ width: calc(100% - var(--slider-thumb) - var(--slider-walls, 0px));
60
+ translate: calc(var(--slider-dir) * (var(--p, 0) - 1) * 100%) -50%;
61
+ }
62
+
63
+ /* The place of the part in its lane: a box of the part's own size, from the lane's end on. */
64
+ @utility slider-seat {
65
+ position: absolute;
66
+ inset-block: 0;
67
+ inset-inline-start: 100%;
68
+ aspect-ratio: 1;
37
69
  }
38
70
 
39
71
  /*
@@ -54,7 +86,7 @@
54
86
 
55
87
  /*
56
88
  * The part that deforms: the thumb's face, and the cap of the fill that holds it. It is centred
57
- * in its rider. Set `--size` (its length at rest), `--s` (how stretched: 1 at rest) and `--d`
89
+ * in its seat. Set `--size` (its length at rest), `--s` (how stretched: 1 at rest) and `--d`
58
90
  * (the way it travels on screen: 1 to the right, -1 to the left).
59
91
  *
60
92
  * Stretched, it is longer and a little thinner, and it moves back by half of what it gained:
@@ -91,20 +123,26 @@
91
123
  }
92
124
 
93
125
  /*
94
- * The fill is a bar as long as the trough that is pushed out of it at the start, so only its end
95
- * shows: `--fill-end` is where it ends, from the start of the trough. In a range a window with
96
- * the same trick cuts its beginning: `--fill-start`.
126
+ * The fill is a bar as long as the trough that hangs from a lane, so its end is where the lane
127
+ * ends and its beginning lies outside the trough, which cuts it round. `--fill-lead` is how far
128
+ * past the lane's end it reaches: half a cap, the middle of the thumb it runs up to.
129
+ *
130
+ * In a range the bar must begin at the first thumb. A lane takes a window there (`--p` of the
131
+ * first thumb), which cuts everything before its edge, and the bar's lane inside it goes on by
132
+ * the way between the two thumbs. Both lanes ease alike, so the end stands where the second
133
+ * thumb is at every moment. The window reaches past the trough's end, where the trough cuts it.
97
134
  */
98
- @utility slider-fill-window {
135
+ @utility slider-fill-bar {
99
136
  position: absolute;
100
137
  inset-block: 0;
101
- inset-inline-start: 0;
102
- width: 100%;
103
- overflow: hidden;
104
- translate: calc(var(--slider-dir) * var(--fill-start, 0px));
138
+ inset-inline-end: calc(var(--fill-lead, 0px) * -1);
139
+ /* The lane, a thumb and the two walls: the trough. */
140
+ width: calc(100% + var(--slider-thumb) + var(--slider-walls, 0px));
105
141
  }
106
- @utility slider-fill-bar {
142
+ @utility slider-fill-window {
107
143
  position: absolute;
108
- inset: 0;
109
- translate: calc(var(--slider-dir) * (var(--fill-end, 0px) - var(--fill-start, 0px) - 100%));
144
+ inset-block: 0;
145
+ inset-inline-start: calc(100% + var(--switch-h) / 2);
146
+ width: calc(100% + var(--slider-thumb) + var(--slider-walls, 0px));
147
+ overflow: hidden;
110
148
  }
package/src/styles.css CHANGED
@@ -27,8 +27,9 @@
27
27
  @import "./styles/toast.css";
28
28
  @import "./styles/slider.css";
29
29
  @import "./styles/segmented.css";
30
- @import "./styles/tabs.css";
30
+ @import "./styles/button-group.css";
31
31
  @import "./styles/scroll-fade.css";
32
+ @import "./styles/shimmer.css";
32
33
  @import "./styles/calendar.css";
33
34
  @import "./styles/prose.css";
34
35
  @import "./styles/base.css";
@@ -1,30 +0,0 @@
1
- import { HeadingProps } from "../heading/heading.js";
2
- import { TextProps } from "../text/text.js";
3
- import { ComponentProps } from "react";
4
- export type PageHeaderProps = ComponentProps<"div"> & {
5
- /**
6
- * Opens the block with the 2px rule. Every section of a page has one; its opening has none, and
7
- * neither has a section that a `Seam` opens.
8
- */
9
- rule?: boolean;
10
- };
11
- /**
12
- * What opens a page or one of its sections: a title, then a lead, then what the reader can do.
13
- * Nothing stands above the title, no label and no number. Everything is set left.
14
- */
15
- export declare function PageHeader({ rule, className, ...props }: PageHeaderProps): import("react").JSX.Element;
16
- declare const titleOnAPhone: {
17
- readonly display: "max-sm:text-2xl";
18
- readonly title: "max-sm:text-xl";
19
- };
20
- export type PageHeaderTitleProps = Omit<HeadingProps, "size"> & {
21
- /** `display` (54px) once on a page, for its opening. `title` (36px) for every section. */
22
- size?: keyof typeof titleOnAPhone;
23
- };
24
- /** A sentence with a full stop, in sentence case. It states the thing, not a topic. */
25
- export declare function PageHeaderTitle({ level, size, className, ...props }: PageHeaderTitleProps): import("react").JSX.Element;
26
- /** One or two sentences under the title, at lines of about 55 characters. */
27
- export declare function PageHeaderLead({ className, ...props }: TextProps): import("react").JSX.Element;
28
- /** The next step: one button, and at most one quiet way beside it. */
29
- export declare function PageHeaderActions({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
30
- export {};
@@ -1,49 +0,0 @@
1
- import { Heading } from "../heading/heading.js";
2
- import { Text } from "../text/text.js";
3
- import { ruleTop } from "../../internal/rule.js";
4
- import { cn } from "../../lib/cn.js";
5
- import { jsx } from "react/jsx-runtime";
6
- // src/components/page-header/page-header.tsx
7
- /**
8
- * What opens a page or one of its sections: a title, then a lead, then what the reader can do.
9
- * Nothing stands above the title, no label and no number. Everything is set left.
10
- */
11
- function PageHeader({ rule = false, className, ...props }) {
12
- return /* @__PURE__ */ jsx("div", {
13
- "data-slot": "page-header",
14
- className: cn("flex flex-col items-start gap-4", rule && [ruleTop, "pt-6"], className),
15
- ...props
16
- });
17
- }
18
- const titleOnAPhone = {
19
- display: "max-sm:text-2xl",
20
- title: "max-sm:text-xl"
21
- };
22
- /** A sentence with a full stop, in sentence case. It states the thing, not a topic. */
23
- function PageHeaderTitle({ level = 2, size = "title", className, ...props }) {
24
- return /* @__PURE__ */ jsx(Heading, {
25
- "data-slot": "page-header-title",
26
- level,
27
- size,
28
- className: cn("max-w-[44rem]", titleOnAPhone[size], className),
29
- ...props
30
- });
31
- }
32
- /** One or two sentences under the title, at lines of about 55 characters. */
33
- function PageHeaderLead({ className, ...props }) {
34
- return /* @__PURE__ */ jsx(Text, {
35
- "data-slot": "page-header-lead",
36
- size: "lg",
37
- className: cn("max-w-[34rem] text-pretty", className),
38
- ...props
39
- });
40
- }
41
- /** The next step: one button, and at most one quiet way beside it. */
42
- function PageHeaderActions({ className, ...props }) {
43
- return /* @__PURE__ */ jsx("div", {
44
- "data-slot": "page-header-actions",
45
- className: cn("flex flex-wrap items-center gap-x-5 gap-y-3 pt-2", className),
46
- ...props
47
- });
48
- }
49
- export { PageHeader, PageHeaderActions, PageHeaderLead, PageHeaderTitle };
@@ -1,24 +0,0 @@
1
- "use client";
2
- import { useScrollEdges } from "./scroll-edges.js";
3
- import { mergeRefs } from "../lib/merge-refs.js";
4
- import { jsx } from "react/jsx-runtime";
5
- import { useRef } from "react";
6
- // src/internal/scroll-fade.tsx
7
- /**
8
- * A box that scrolls and fades its edges where more waits (scroll-fade.css), as a code block's
9
- * long lines and a long row of tabs do. The box itself still needs its `overflow-*`.
10
- *
11
- * It is the client part of components that stay server-safe (`Table`, `DocsLayout`): they render
12
- * this one box, and everything inside it stays theirs. The mask also cuts what is drawn outside
13
- * the box, so a focus outline belongs on a box around it.
14
- */
15
- function ScrollFade({ axis = "x", ref, ...props }) {
16
- const box = useRef(null);
17
- useScrollEdges(box, axis);
18
- return /* @__PURE__ */ jsx("div", {
19
- ref: mergeRefs(box, ref),
20
- "data-scroll-fade": axis,
21
- ...props
22
- });
23
- }
24
- export { ScrollFade };
@@ -1,39 +0,0 @@
1
- /*
2
- * A row of tabs wider than its place scrolls sideways inside itself (tabs.tsx), and its edges
3
- * fade where more tabs wait, as a code block's long lines do (code.css): a tab cut by the edge
4
- * says that the row goes on. The two lengths are registered so the mask moves on a spring;
5
- * `useScrollEdges` sets `data-overflow` from the scroll position. A row that fits has no mask.
6
- */
7
- @property --tabs-fade-start {
8
- syntax: "<length>";
9
- inherits: false;
10
- initial-value: 0px;
11
- }
12
- @property --tabs-fade-end {
13
- syntax: "<length>";
14
- inherits: false;
15
- initial-value: 0px;
16
- }
17
-
18
- @layer components {
19
- [data-slot="tabs-list"] {
20
- transition:
21
- --tabs-fade-start var(--transition-duration-spring-settle) var(--ease-spring-settle),
22
- --tabs-fade-end var(--transition-duration-spring-settle) var(--ease-spring-settle);
23
- }
24
- [data-slot="tabs-list"][data-overflow] {
25
- mask-image: linear-gradient(
26
- to right,
27
- transparent,
28
- #000 var(--tabs-fade-start),
29
- #000 calc(100% - var(--tabs-fade-end)),
30
- transparent
31
- );
32
- }
33
- [data-slot="tabs-list"][data-overflow~="start"] {
34
- --tabs-fade-start: 2.5rem;
35
- }
36
- [data-slot="tabs-list"][data-overflow~="end"] {
37
- --tabs-fade-end: 2.5rem;
38
- }
39
- }