@apliteni/apliteni-ui 0.160.0 → 0.161.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/docs/components.md +32 -0
- package/package.json +1 -1
- package/react/dist/index.d.ts +8 -1
- package/react/dist/index.js +284 -140
- package/src/styles/button.css +79 -5
package/src/styles/button.css
CHANGED
|
@@ -3,8 +3,18 @@
|
|
|
3
3
|
* (sizes: xs / sm / md / lg, [icon], [disabled], [aria-busy])
|
|
4
4
|
* ========================================================================== */
|
|
5
5
|
|
|
6
|
+
:root {
|
|
7
|
+
/* The md padding and edge. The button and --btn-height-md both read them. */
|
|
8
|
+
--btn-pad-y-md: 9px;
|
|
9
|
+
--btn-edge-width: 1px;
|
|
10
|
+
/* The outer height of an md button: one line of --text-sm, the md padding and
|
|
11
|
+
the edge on each side. A part that takes a button's place uses it, so the
|
|
12
|
+
row keeps its height. */
|
|
13
|
+
--btn-height-md: calc(var(--text-sm) * var(--leading-tight) + 2 * var(--btn-pad-y-md) + 2 * var(--btn-edge-width));
|
|
14
|
+
}
|
|
15
|
+
|
|
6
16
|
.ui-btn {
|
|
7
|
-
--btn-pad-y:
|
|
17
|
+
--btn-pad-y: var(--btn-pad-y-md);
|
|
8
18
|
--btn-pad-x: 17px;
|
|
9
19
|
--btn-font: var(--text-sm);
|
|
10
20
|
|
|
@@ -18,10 +28,11 @@
|
|
|
18
28
|
line-height: var(--leading-tight);
|
|
19
29
|
border-radius: var(--radius-sm);
|
|
20
30
|
padding: var(--btn-pad-y) var(--btn-pad-x);
|
|
31
|
+
min-height: var(--btn-height-md);
|
|
21
32
|
cursor: pointer;
|
|
22
33
|
/* Light needs a stronger line here: --border on this fill measures 1.047:1.
|
|
23
34
|
why: docs/foundations.md#elevation */
|
|
24
|
-
border:
|
|
35
|
+
border: var(--btn-edge-width) solid var(--control-edge);
|
|
25
36
|
background: var(--surface); /* code-bg: inherit — control paint; the containing surface is the ground, for a chip and for a band alike. */
|
|
26
37
|
color: var(--text);
|
|
27
38
|
white-space: nowrap;
|
|
@@ -86,21 +97,23 @@
|
|
|
86
97
|
}
|
|
87
98
|
|
|
88
99
|
.ui-btn--danger { color: var(--text); }
|
|
89
|
-
.ui-btn--danger:hover, .ui-btn--danger:focus-visible {
|
|
100
|
+
.ui-btn--danger:hover, .ui-btn--danger:focus-visible, .ui-btn--danger[data-holding] {
|
|
90
101
|
color: var(--pink);
|
|
91
102
|
border-color: var(--pink);
|
|
92
103
|
background: color-mix(in srgb, var(--pink) 10%, transparent); /* code-bg: inherit — control paint; the containing surface is the ground, for a chip and for a band alike. */
|
|
93
104
|
}
|
|
105
|
+
/* A pointer hold is also a hover, so the held edge outranks the accent hover edge. */
|
|
106
|
+
.ui-btn.ui-btn--danger[data-holding]:hover { border-color: var(--pink); }
|
|
94
107
|
|
|
95
108
|
/* -- Sizes -------------------------------------------------------------- */
|
|
96
109
|
/* why: docs/components.md#extra-small-buttons */
|
|
97
110
|
.ui-btn--xs { --btn-pad-y: 4.5px; --btn-pad-x: 8px; --btn-font: var(--text-xs); min-width: 24px; min-height: 24px; }
|
|
98
111
|
.ui-btn--xs svg { width: 13px; height: 13px; stroke-width: 2.8; }
|
|
99
|
-
.ui-btn--sm { --btn-pad-y: 6px; --btn-pad-x: 12px; --btn-font: calc(var(--text-sm) - 0.5px); }
|
|
112
|
+
.ui-btn--sm { --btn-pad-y: 6px; --btn-pad-x: 12px; --btn-font: calc(var(--text-sm) - 0.5px); min-height: 0; }
|
|
100
113
|
.ui-btn--lg { --btn-pad-y: 13px; --btn-pad-x: 24px; --btn-font: var(--text-md); border-radius: var(--radius-md); }
|
|
101
114
|
|
|
102
115
|
/* Icon-only */
|
|
103
|
-
.ui-btn--icon { --btn-pad-y:
|
|
116
|
+
.ui-btn--icon { --btn-pad-y: var(--btn-pad-y-md); padding: var(--btn-pad-y-md); border-radius: var(--radius-sm); }
|
|
104
117
|
.ui-btn--icon.ui-btn--xs { --btn-pad-y: 4.5px; padding: 4.5px; }
|
|
105
118
|
.ui-btn--icon.ui-btn--sm { --btn-pad-y: 6px; padding: 6px; }
|
|
106
119
|
|
|
@@ -258,4 +271,65 @@
|
|
|
258
271
|
.ui-btn__dots i { animation: none; }
|
|
259
272
|
}
|
|
260
273
|
|
|
274
|
+
/* -- Hold to confirm ---------------------------------------------------- */
|
|
275
|
+
/* why: docs/components.md#hold-to-confirm */
|
|
276
|
+
.ui-btn[data-hold] {
|
|
277
|
+
touch-action: none;
|
|
278
|
+
user-select: none;
|
|
279
|
+
-webkit-user-select: none;
|
|
280
|
+
-webkit-touch-callout: none;
|
|
281
|
+
}
|
|
282
|
+
/* The fill is the press, so the button itself does not also sink. */
|
|
283
|
+
.ui-btn[data-hold]:active { transform: none; }
|
|
284
|
+
/* A copy of the content in the filled paint, cut from the start edge by --hold. */
|
|
285
|
+
.ui-btn__hold-fill {
|
|
286
|
+
position: absolute;
|
|
287
|
+
inset: 0;
|
|
288
|
+
display: flex;
|
|
289
|
+
align-items: center;
|
|
290
|
+
justify-content: center;
|
|
291
|
+
gap: inherit;
|
|
292
|
+
padding: inherit;
|
|
293
|
+
border-radius: inherit;
|
|
294
|
+
pointer-events: none;
|
|
295
|
+
clip-path: inset(0 calc(100% - var(--hold, 0) * 100%) 0 0);
|
|
296
|
+
transition: clip-path var(--dur-med) var(--ease-out);
|
|
297
|
+
}
|
|
298
|
+
[dir="rtl"] .ui-btn__hold-fill { clip-path: inset(0 0 0 calc(100% - var(--hold, 0) * 100%)); }
|
|
299
|
+
/* While held, the script moves the fill each frame or each step. */
|
|
300
|
+
.ui-btn[data-holding] .ui-btn__hold-fill { transition: none; }
|
|
301
|
+
.ui-btn--primary[data-holding] {
|
|
302
|
+
background: color-mix(in srgb, var(--accent) 14%, var(--surface)); /* code-bg: inherit — control paint; the containing surface is the ground, for a chip and for a band alike. */
|
|
303
|
+
border-color: var(--accent);
|
|
304
|
+
color: var(--strong);
|
|
305
|
+
filter: none;
|
|
306
|
+
}
|
|
307
|
+
/* In light --accent is --accent-strong, so the filled primary is its resting paint. */
|
|
308
|
+
.ui-btn--primary .ui-btn__hold-fill {
|
|
309
|
+
background: var(--accent); /* code-bg: inherit — control paint; the containing surface is the ground, for a chip and for a band alike. */
|
|
310
|
+
color: var(--accent-contrast);
|
|
311
|
+
}
|
|
312
|
+
/* White ink falls below the text floor on the lighter dark-theme accents. */
|
|
313
|
+
/* Dark is also the theme with no data-theme at all. */
|
|
314
|
+
:where(:root:not([data-theme="light"])) .ui-btn--primary .ui-btn__hold-fill { color: var(--signal-contrast); }
|
|
315
|
+
/* Quiet at rest: the pink fill shows only while the reader hovers, focuses, holds or lets it drain. */
|
|
316
|
+
.ui-btn--danger:is(:hover, :focus-visible, [data-holding], [data-hold-drain]) .ui-btn__hold-fill {
|
|
317
|
+
background: var(--pink); /* code-bg: inherit — control paint; the containing surface is the ground, for a chip and for a band alike. */
|
|
318
|
+
color: var(--danger-contrast);
|
|
319
|
+
}
|
|
320
|
+
/* Over the button, so a row of buttons keeps its height and the button does not move. */
|
|
321
|
+
.ui-btn__hold-hint {
|
|
322
|
+
position: absolute;
|
|
323
|
+
bottom: calc(100% + var(--space-2));
|
|
324
|
+
left: 50%;
|
|
325
|
+
translate: -50% 0;
|
|
326
|
+
font-size: var(--text-sm);
|
|
327
|
+
font-weight: var(--weight-normal);
|
|
328
|
+
line-height: var(--leading-tight);
|
|
329
|
+
color: var(--text);
|
|
330
|
+
pointer-events: none;
|
|
331
|
+
visibility: hidden;
|
|
332
|
+
}
|
|
333
|
+
.ui-btn[data-hold-hint] .ui-btn__hold-hint { visibility: visible; }
|
|
334
|
+
|
|
261
335
|
@keyframes ui-spin { to { transform: rotate(360deg); } }
|