@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.
- package/dist/components/anchor-heading/anchor-heading.d.ts +1 -1
- package/dist/components/breadcrumbs/breadcrumbs.js +5 -10
- package/dist/components/button/button.d.ts +3 -0
- package/dist/components/button/button.js +14 -4
- package/dist/components/button-group/button-group-context.js +14 -0
- package/dist/components/button-group/button-group-variants.d.ts +14 -0
- package/dist/components/button-group/button-group-variants.js +93 -0
- package/dist/components/button-group/button-group.d.ts +36 -0
- package/dist/components/button-group/button-group.js +46 -0
- package/dist/components/code-block/code-block-frame.js +22 -6
- package/dist/components/code-block/code-block-live.d.ts +15 -3
- package/dist/components/code-block/code-block-live.js +14 -6
- package/dist/components/code-block/code-block.d.ts +8 -3
- package/dist/components/code-block/code-block.js +9 -3
- package/dist/components/code-block/code-keys.d.ts +24 -0
- package/dist/components/code-block/code-keys.js +107 -0
- package/dist/components/code-block/code-lines-live.d.ts +7 -0
- package/dist/components/code-block/code-lines-live.js +167 -0
- package/dist/components/code-block/code-lines-view.d.ts +1 -0
- package/dist/components/code-block/code-lines-view.js +50 -18
- package/dist/components/code-block/code-lines.d.ts +3 -0
- package/dist/components/code-block/code-scroll.js +2 -1
- package/dist/components/code-block/code-tabs-frame.js +12 -5
- package/dist/components/code-block/code-tabs.d.ts +10 -4
- package/dist/components/code-block/code-tabs.js +9 -6
- package/dist/components/code-block/highlight.d.ts +1 -0
- package/dist/components/code-block/line-diff.js +135 -0
- package/dist/components/code-block/lines.js +23 -1
- package/dist/components/copy-page/copy-page.d.ts +4 -4
- package/dist/components/copy-page/copy-page.js +16 -28
- package/dist/components/docs-layout/docs-layout.d.ts +1 -1
- package/dist/components/docs-layout/docs-layout.js +3 -3
- package/dist/components/docs-layout/docs-nav.d.ts +51 -0
- package/dist/components/docs-layout/docs-nav.js +60 -0
- package/dist/components/grow/grow.d.ts +20 -0
- package/dist/components/grow/grow.js +104 -0
- package/dist/components/heading/heading.d.ts +4 -0
- package/dist/components/heading/heading.js +8 -4
- package/dist/components/hover-card/hover-card.d.ts +24 -0
- package/dist/components/hover-card/hover-card.js +51 -0
- package/dist/components/pager/pager.js +19 -24
- package/dist/components/scroll-fade/scroll-fade.d.ts +29 -0
- package/dist/components/scroll-fade/scroll-fade.js +40 -0
- package/dist/components/scroll-fade/use-scroll-edges.d.ts +13 -0
- package/dist/{internal/scroll-edges.js → components/scroll-fade/use-scroll-edges.js} +10 -7
- package/dist/components/section/section.d.ts +2 -1
- package/dist/components/section/section.js +2 -1
- package/dist/components/segmented-control/segmented-control.d.ts +7 -1
- package/dist/components/segmented-control/segmented-control.js +22 -11
- package/dist/components/select/select.d.ts +4 -1
- package/dist/components/select/select.js +15 -3
- package/dist/components/shimmer/shimmer.d.ts +21 -0
- package/dist/components/shimmer/shimmer.js +24 -0
- package/dist/components/side-nav/side-nav.js +11 -20
- package/dist/components/site-header/site-header.d.ts +1 -1
- package/dist/components/site-header/site-header.js +6 -3
- package/dist/components/slider/slider.d.ts +3 -1
- package/dist/components/slider/slider.js +45 -19
- package/dist/components/table/table.js +2 -1
- package/dist/components/tabs/tabs.js +3 -2
- package/dist/components/theme-switch/theme-switch.d.ts +47 -0
- package/dist/components/theme-switch/theme-switch.js +102 -0
- package/dist/components/trace/trace.d.ts +71 -0
- package/dist/components/trace/trace.js +201 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.js +10 -2
- package/dist/internal/render-as.js +24 -0
- package/dist/internal/rule.js +5 -4
- package/package.json +1 -1
- package/src/styles/button-group.css +57 -0
- package/src/styles/code.css +102 -38
- package/src/styles/marks.css +10 -0
- package/src/styles/motion.css +4 -3
- package/src/styles/scroll-fade.css +26 -20
- package/src/styles/shimmer.css +68 -0
- package/src/styles/slider.css +57 -19
- package/src/styles.css +2 -1
- package/dist/components/page-header/page-header.d.ts +0 -30
- package/dist/components/page-header/page-header.js +0 -49
- package/dist/internal/scroll-fade.js +0 -24
- package/src/styles/tabs.css +0 -39
|
@@ -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
|
+
}
|
package/src/styles/code.css
CHANGED
|
@@ -109,24 +109,8 @@
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
/*
|
|
112
|
-
* The
|
|
113
|
-
*
|
|
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,19 +126,40 @@
|
|
|
142
126
|
font-variant-ligatures: none;
|
|
143
127
|
tab-size: 2;
|
|
144
128
|
}
|
|
145
|
-
|
|
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
|
|
|
143
|
+
/*
|
|
144
|
+
* A line is a grid of one row around its body, so a live block can open the row from nothing
|
|
145
|
+
* and close it again (below). It clips only up and down: an italic's overhang stays.
|
|
146
|
+
*/
|
|
151
147
|
[data-slot="code-block-line"] {
|
|
152
148
|
position: relative;
|
|
153
|
-
|
|
149
|
+
display: grid;
|
|
150
|
+
grid-template-rows: 1fr;
|
|
151
|
+
overflow-y: clip;
|
|
154
152
|
padding-inline: var(--code-pad-x) var(--code-pad-x);
|
|
155
153
|
padding-left: calc(var(--code-pad-x) + var(--code-gutter, 0px));
|
|
156
154
|
counter-increment: line;
|
|
157
155
|
}
|
|
156
|
+
[data-slot="code-block-line-body"] {
|
|
157
|
+
min-height: 0;
|
|
158
|
+
}
|
|
159
|
+
/* An empty line still holds one line of room: a zero-width space, which is never copied. */
|
|
160
|
+
[data-slot="code-block-line-body"]:empty::before {
|
|
161
|
+
content: "\200b";
|
|
162
|
+
}
|
|
158
163
|
|
|
159
164
|
/* Numbers are read past, not read out, and never copied with the code. */
|
|
160
165
|
[data-line-numbers] > [data-slot="code-block-line"]::before {
|
|
@@ -195,27 +200,86 @@
|
|
|
195
200
|
color: var(--lf-danger);
|
|
196
201
|
}
|
|
197
202
|
|
|
198
|
-
/*
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
203
|
+
/*
|
|
204
|
+
* Lines that change (CodeBlockLive, code-lines-live.tsx). Only once the block stands
|
|
205
|
+
* (`data-live`): what is there when it first shows does not move.
|
|
206
|
+
*
|
|
207
|
+
* A line that joins opens like a fold: its row opens from nothing on `settle` and pushes the
|
|
208
|
+
* lines below down, while its text fades in and drops into place from just above
|
|
209
|
+
* (`--motion-enter-offset`). Chosen by Justin over a flap and a drawer (DESIGN.md). The row is
|
|
210
|
+
* the one height that moves here, because the lines below have to make room (motion.md); a
|
|
211
|
+
* `Grow` around the block sees it moving and follows. A line that goes fades on `leave` while
|
|
212
|
+
* its row closes, is not counted and has no number. Every state is a transition, so a line that
|
|
213
|
+
* comes back mid-way turns round.
|
|
214
|
+
*
|
|
215
|
+
* Part way, a row of `f fr` is narrower than the line around it (f times f, against f, of the
|
|
216
|
+
* line's height: fractions under 1 share out only part of the room). The line's own height is
|
|
217
|
+
* what makes room and what is seen, as it clips; the text overflows its row into it.
|
|
218
|
+
*/
|
|
219
|
+
[data-live] > [data-slot="code-block-line"] {
|
|
220
|
+
transition: grid-template-rows var(--transition-duration-spring-settle)
|
|
221
|
+
var(--ease-spring-settle);
|
|
222
|
+
@starting-style {
|
|
223
|
+
grid-template-rows: 0fr;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
[data-live] > [data-slot="code-block-line"] > [data-slot="code-block-line-body"] {
|
|
208
227
|
transition:
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
228
|
+
opacity var(--transition-duration-spring-settle) var(--ease-spring-settle),
|
|
229
|
+
translate var(--transition-duration-spring-settle) var(--ease-spring-settle);
|
|
230
|
+
@starting-style {
|
|
231
|
+
opacity: 0;
|
|
232
|
+
translate: 0 calc(-1 * var(--motion-enter-offset));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
[data-slot="code-block-line"][data-motion="leave"] {
|
|
236
|
+
grid-template-rows: 0fr;
|
|
237
|
+
counter-increment: none;
|
|
238
|
+
user-select: none;
|
|
239
|
+
&::before {
|
|
240
|
+
content: none;
|
|
241
|
+
}
|
|
242
|
+
& > [data-slot="code-block-line-body"] {
|
|
243
|
+
opacity: 0;
|
|
244
|
+
transition-duration: var(--transition-duration-spring-leave);
|
|
245
|
+
transition-timing-function: var(--ease-spring-leave);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/*
|
|
250
|
+
* What a change put into a line that stays (a value, a comma) arrives as new. Two styles, both
|
|
251
|
+
* kept (DESIGN.md): it fades in (`fade`, Einblenden), or also lights up in the accent and lets
|
|
252
|
+
* the light go (`glow`, Aufleuchten).
|
|
253
|
+
*/
|
|
254
|
+
[data-live] [data-slot="code-block-fresh"] {
|
|
255
|
+
transition:
|
|
256
|
+
opacity var(--transition-duration-spring-settle) var(--ease-spring-settle),
|
|
257
|
+
background-color 900ms ease-out;
|
|
258
|
+
@starting-style {
|
|
259
|
+
opacity: 0;
|
|
260
|
+
}
|
|
213
261
|
}
|
|
214
|
-
[data-
|
|
215
|
-
|
|
262
|
+
[data-live][data-change-motion="glow"] [data-slot="code-block-fresh"] {
|
|
263
|
+
border-radius: 2px;
|
|
264
|
+
box-decoration-break: clone;
|
|
265
|
+
@starting-style {
|
|
266
|
+
background-color: color-mix(in oklab, var(--lf-accent) 28%, transparent);
|
|
267
|
+
}
|
|
216
268
|
}
|
|
217
|
-
|
|
218
|
-
|
|
269
|
+
|
|
270
|
+
/* Under reduced motion rows do not open or close, and the text does not travel (the offset is
|
|
271
|
+
zero, motion.css): it only fades. */
|
|
272
|
+
@media (prefers-reduced-motion: reduce) {
|
|
273
|
+
[data-live] > [data-slot="code-block-line"] {
|
|
274
|
+
transition: none;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/* The edges fade where more code waits to the side (scroll-fade.css). The focus outline is
|
|
279
|
+
drawn by the block around it, since the mask would cut it off. */
|
|
280
|
+
[data-slot="code-block-scroll"] {
|
|
281
|
+
scrollbar-width: thin;
|
|
282
|
+
scrollbar-color: var(--lf-line) transparent;
|
|
219
283
|
}
|
|
220
284
|
|
|
221
285
|
/* The copy key's confirmation is shared with every control that copies: see copy.css. */
|
package/src/styles/marks.css
CHANGED
|
@@ -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 {
|
package/src/styles/motion.css
CHANGED
|
@@ -24,9 +24,10 @@
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* under reduced motion
|
|
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
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* `useScrollEdges` sets `data-overflow`
|
|
6
|
-
*
|
|
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"]
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
|
43
|
+
[data-scroll-fade][data-overflow] {
|
|
38
44
|
mask-image: linear-gradient(
|
|
39
|
-
to
|
|
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
|
+
}
|
package/src/styles/slider.css
CHANGED
|
@@ -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)
|
|
10
|
-
*
|
|
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
|
-
/*
|
|
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
|
-
|
|
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
|
|
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
|
|
95
|
-
*
|
|
96
|
-
* the
|
|
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-
|
|
135
|
+
@utility slider-fill-bar {
|
|
99
136
|
position: absolute;
|
|
100
137
|
inset-block: 0;
|
|
101
|
-
inset-inline-
|
|
102
|
-
|
|
103
|
-
|
|
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-
|
|
142
|
+
@utility slider-fill-window {
|
|
107
143
|
position: absolute;
|
|
108
|
-
inset: 0;
|
|
109
|
-
|
|
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/
|
|
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 };
|