@alulore/kumiko 0.14.1 → 0.15.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/LICENSE +21 -0
- package/README.md +32 -0
- package/dist/alert/alert.css +483 -0
- package/dist/alert/alert.d.ts +51 -0
- package/dist/alert/alert.js +40 -0
- package/dist/alert/index.d.ts +1 -0
- package/dist/alert/index.js +1 -0
- package/dist/card/card.css +727 -0
- package/dist/card/card.d.ts +62 -0
- package/dist/card/card.js +48 -0
- package/dist/card/index.d.ts +2 -0
- package/dist/card/index.js +2 -0
- package/dist/card/item-card.d.ts +84 -0
- package/dist/card/item-card.js +73 -0
- package/dist/list-row/index.d.ts +1 -0
- package/dist/list-row/index.js +1 -0
- package/dist/list-row/list-row-motion.d.ts +10 -0
- package/dist/list-row/list-row-motion.js +141 -0
- package/dist/list-row/list-row.css +403 -0
- package/dist/list-row/list-row.d.ts +64 -0
- package/dist/list-row/list-row.js +54 -0
- package/package.json +30 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alulore
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Kumiko
|
|
2
|
+
|
|
3
|
+
Polished, cozy React components with gentle motion, built on [ui-sdk](https://ui-sdk.dev). Every look and behaviour can be switched with props and CSS tokens.
|
|
4
|
+
|
|
5
|
+
Kumiko starts with UI and grows into the shared toolkit for Alulore's apps.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
bun add @alulore/kumiko @ui-sdk/react @ui-sdk/core react react-dom
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Install `@ui-sdk/*` at the exact version Kumiko lists as a peer.
|
|
14
|
+
|
|
15
|
+
## Use
|
|
16
|
+
|
|
17
|
+
Each component has its own entry point and stylesheet:
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { Button } from "@alulore/kumiko/button";
|
|
21
|
+
import "@alulore/kumiko/button.css";
|
|
22
|
+
|
|
23
|
+
export function Save() {
|
|
24
|
+
return <Button variant="solid">Save</Button>;
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Kumiko's styles sit in `@layer kumiko`. With Tailwind, name the layers first in your main stylesheet: `@layer theme, base, ui-sdk, kumiko, components, utilities;`
|
|
29
|
+
|
|
30
|
+
## License
|
|
31
|
+
|
|
32
|
+
MIT
|
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
@import "../motion/motion.css";
|
|
2
|
+
|
|
3
|
+
@layer kumiko {
|
|
4
|
+
:where(:root) {
|
|
5
|
+
--kumiko-alert-info-color: Highlight;
|
|
6
|
+
--kumiko-alert-success-color: oklch(0.58 0.14 150);
|
|
7
|
+
--kumiko-alert-warning-color: Mark;
|
|
8
|
+
--kumiko-alert-error-color: oklch(0.58 0.2 25);
|
|
9
|
+
--kumiko-alert-info-on: HighlightText;
|
|
10
|
+
--kumiko-alert-success-on: white;
|
|
11
|
+
--kumiko-alert-warning-on: MarkText;
|
|
12
|
+
--kumiko-alert-error-on: white;
|
|
13
|
+
--kumiko-alert-radius: 0.75rem;
|
|
14
|
+
--kumiko-alert-padding-block: 0.625rem;
|
|
15
|
+
--kumiko-alert-padding-inline: 0.875rem;
|
|
16
|
+
--kumiko-alert-gap: 0.625rem;
|
|
17
|
+
--kumiko-alert-font-size: 0.8125rem;
|
|
18
|
+
--kumiko-alert-line-height: 1.45;
|
|
19
|
+
--kumiko-alert-title-weight: 600;
|
|
20
|
+
--kumiko-alert-wash: 14%;
|
|
21
|
+
--kumiko-alert-text-tint: 55%;
|
|
22
|
+
--kumiko-alert-border-width: 1px;
|
|
23
|
+
--kumiko-alert-bar-width: 4px;
|
|
24
|
+
--kumiko-alert-icon-size: 1rem;
|
|
25
|
+
--kumiko-alert-lamp-size: 1.625rem;
|
|
26
|
+
--kumiko-alert-lamp-wash: 22%;
|
|
27
|
+
--kumiko-alert-nudge: 0.375rem;
|
|
28
|
+
--kumiko-alert-glow-size: 0.9rem;
|
|
29
|
+
--kumiko-alert-glow-strength: 55%;
|
|
30
|
+
--kumiko-alert-focus-ring: Highlight;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[data-slot="alert-frame"] {
|
|
34
|
+
display: grid;
|
|
35
|
+
grid-template-rows: 1fr;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
[data-slot="alert-clip"] {
|
|
39
|
+
min-block-size: 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
[data-slot="alert"] {
|
|
43
|
+
--_dir: 1;
|
|
44
|
+
--_c: var(--kumiko-alert-info-color);
|
|
45
|
+
--_on: var(--kumiko-alert-info-on);
|
|
46
|
+
--_bg: color-mix(in oklab, var(--_c) var(--kumiko-alert-wash), transparent);
|
|
47
|
+
--_fg: color-mix(in oklab, var(--_c) var(--kumiko-alert-text-tint), CanvasText);
|
|
48
|
+
--_plain-ic: currentColor;
|
|
49
|
+
--_lamp-ic: var(--_c);
|
|
50
|
+
--_lamp: color-mix(in oklab, var(--_c) var(--kumiko-alert-lamp-wash), transparent);
|
|
51
|
+
|
|
52
|
+
display: flex;
|
|
53
|
+
box-sizing: border-box;
|
|
54
|
+
gap: var(--kumiko-alert-gap);
|
|
55
|
+
align-items: flex-start;
|
|
56
|
+
padding: var(--kumiko-alert-padding-block) var(--kumiko-alert-padding-inline);
|
|
57
|
+
border: 0 solid var(--_c);
|
|
58
|
+
border-radius: var(--kumiko-alert-radius);
|
|
59
|
+
background: var(--_bg);
|
|
60
|
+
color: var(--_fg);
|
|
61
|
+
font-size: var(--kumiko-alert-font-size);
|
|
62
|
+
line-height: var(--kumiko-alert-line-height);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
[data-slot="alert"]:dir(rtl) {
|
|
66
|
+
--_dir: -1;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
[data-slot="alert"][data-tone="success"] {
|
|
70
|
+
--_c: var(--kumiko-alert-success-color);
|
|
71
|
+
--_on: var(--kumiko-alert-success-on);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
[data-slot="alert"][data-tone="warning"] {
|
|
75
|
+
--_c: var(--kumiko-alert-warning-color);
|
|
76
|
+
--_on: var(--kumiko-alert-warning-on);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
[data-slot="alert"][data-tone="error"] {
|
|
80
|
+
--_c: var(--kumiko-alert-error-color);
|
|
81
|
+
--_on: var(--kumiko-alert-error-on);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
[data-slot="alert-icon"] {
|
|
85
|
+
display: inline-grid;
|
|
86
|
+
flex: none;
|
|
87
|
+
place-items: center;
|
|
88
|
+
block-size: calc(1em * var(--kumiko-alert-line-height));
|
|
89
|
+
--_ic: var(--_plain-ic);
|
|
90
|
+
|
|
91
|
+
color: var(--_ic);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
[data-slot="alert-icon"] > svg {
|
|
95
|
+
inline-size: var(--kumiko-alert-icon-size);
|
|
96
|
+
block-size: var(--kumiko-alert-icon-size);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
[data-slot="alert-body"] {
|
|
100
|
+
flex: 1;
|
|
101
|
+
min-inline-size: 0;
|
|
102
|
+
overflow-wrap: anywhere;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
[data-slot="alert-title"] {
|
|
106
|
+
font-weight: var(--kumiko-alert-title-weight);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
[data-slot="alert-actions"] {
|
|
110
|
+
display: flex;
|
|
111
|
+
flex-wrap: wrap;
|
|
112
|
+
gap: 0.5rem;
|
|
113
|
+
align-items: center;
|
|
114
|
+
margin-block-start: 0.5rem;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
[data-slot="alert-dismiss"] {
|
|
118
|
+
position: relative;
|
|
119
|
+
display: inline-grid;
|
|
120
|
+
flex: none;
|
|
121
|
+
place-items: center;
|
|
122
|
+
box-sizing: border-box;
|
|
123
|
+
inline-size: calc(1em * var(--kumiko-alert-line-height));
|
|
124
|
+
block-size: calc(1em * var(--kumiko-alert-line-height));
|
|
125
|
+
margin: 0;
|
|
126
|
+
padding: 0;
|
|
127
|
+
border: 0;
|
|
128
|
+
border-radius: 999px;
|
|
129
|
+
background: transparent;
|
|
130
|
+
color: inherit;
|
|
131
|
+
cursor: var(--kumiko-press-cursor, pointer);
|
|
132
|
+
opacity: 0.7;
|
|
133
|
+
transition:
|
|
134
|
+
opacity var(--kumiko-fade-duration) var(--kumiko-fade-ease),
|
|
135
|
+
background-color var(--kumiko-fade-duration) var(--kumiko-fade-ease);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
[data-slot="alert-dismiss"] > svg {
|
|
139
|
+
inline-size: 0.875rem;
|
|
140
|
+
block-size: 0.875rem;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
[data-slot="alert-dismiss"]:focus-visible {
|
|
144
|
+
outline: 2px solid var(--kumiko-alert-focus-ring);
|
|
145
|
+
outline-offset: 1px;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@media (hover: hover) and (pointer: fine) {
|
|
149
|
+
[data-slot="alert-dismiss"]:hover {
|
|
150
|
+
background: color-mix(in oklab, currentColor 14%, transparent);
|
|
151
|
+
opacity: 1;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
@media (pointer: coarse) {
|
|
156
|
+
[data-slot="alert-dismiss"]::after {
|
|
157
|
+
position: absolute;
|
|
158
|
+
inset-block-start: 50%;
|
|
159
|
+
inset-inline-start: 50%;
|
|
160
|
+
inline-size: var(--kumiko-touch-target, 2.75rem);
|
|
161
|
+
block-size: var(--kumiko-touch-target, 2.75rem);
|
|
162
|
+
translate: -50% -50%;
|
|
163
|
+
content: "";
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
[data-slot="alert-dismiss"]:dir(rtl)::after {
|
|
167
|
+
translate: 50% -50%;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/*
|
|
172
|
+
* Options. Each is picked by a prop, which writes its own data attribute, or by a word in
|
|
173
|
+
* data-kumiko-alert on the alert or any container. A word only counts when the prop is absent,
|
|
174
|
+
* so a prop always wins. Every value has a word, so a container can opt out of a default.
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
/* Look: wash. The default, a tinted wash. */
|
|
178
|
+
[data-slot="alert"]:is(
|
|
179
|
+
[data-look="wash"],
|
|
180
|
+
:not([data-look]):is([data-kumiko-alert~="look-wash"], [data-kumiko-alert~="look-wash"] *)
|
|
181
|
+
) {
|
|
182
|
+
--_bg: color-mix(in oklab, var(--_c) var(--kumiko-alert-wash), transparent);
|
|
183
|
+
--_fg: color-mix(in oklab, var(--_c) var(--kumiko-alert-text-tint), CanvasText);
|
|
184
|
+
--_plain-ic: currentColor;
|
|
185
|
+
--_lamp-ic: var(--_c);
|
|
186
|
+
--_lamp: color-mix(in oklab, var(--_c) var(--kumiko-alert-lamp-wash), transparent);
|
|
187
|
+
|
|
188
|
+
border-width: 0;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/* Look: bar. A wash with an accent bar on the inline-start side, which mirrors in right-to-left. */
|
|
192
|
+
[data-slot="alert"]:is(
|
|
193
|
+
[data-look="bar"],
|
|
194
|
+
:not([data-look]):is([data-kumiko-alert~="look-bar"], [data-kumiko-alert~="look-bar"] *)
|
|
195
|
+
) {
|
|
196
|
+
--_bg: color-mix(in oklab, var(--_c) var(--kumiko-alert-wash), transparent);
|
|
197
|
+
--_fg: color-mix(in oklab, var(--_c) var(--kumiko-alert-text-tint), CanvasText);
|
|
198
|
+
--_plain-ic: currentColor;
|
|
199
|
+
--_lamp-ic: var(--_c);
|
|
200
|
+
--_lamp: color-mix(in oklab, var(--_c) var(--kumiko-alert-lamp-wash), transparent);
|
|
201
|
+
|
|
202
|
+
border-width: 0;
|
|
203
|
+
border-inline-start-width: var(--kumiko-alert-bar-width);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/* Look: outline. A tinted outline with no fill. */
|
|
207
|
+
[data-slot="alert"]:is(
|
|
208
|
+
[data-look="outline"],
|
|
209
|
+
:not([data-look]):is(
|
|
210
|
+
[data-kumiko-alert~="look-outline"],
|
|
211
|
+
[data-kumiko-alert~="look-outline"] *
|
|
212
|
+
)
|
|
213
|
+
) {
|
|
214
|
+
--_bg: transparent;
|
|
215
|
+
--_fg: CanvasText;
|
|
216
|
+
--_plain-ic: var(--_c);
|
|
217
|
+
--_lamp-ic: var(--_c);
|
|
218
|
+
--_lamp: color-mix(in oklab, var(--_c) var(--kumiko-alert-lamp-wash), transparent);
|
|
219
|
+
|
|
220
|
+
border-width: var(--kumiko-alert-border-width);
|
|
221
|
+
border-color: color-mix(in oklab, var(--_c) 65%, transparent);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/* Look: solid. A solid fill in the tone's colour. */
|
|
225
|
+
[data-slot="alert"]:is(
|
|
226
|
+
[data-look="solid"],
|
|
227
|
+
:not([data-look]):is([data-kumiko-alert~="look-solid"], [data-kumiko-alert~="look-solid"] *)
|
|
228
|
+
) {
|
|
229
|
+
--_bg: var(--_c);
|
|
230
|
+
--_fg: var(--_on);
|
|
231
|
+
--_plain-ic: currentColor;
|
|
232
|
+
--_lamp-ic: var(--_on);
|
|
233
|
+
--_lamp: color-mix(in oklab, var(--_on) 22%, transparent);
|
|
234
|
+
|
|
235
|
+
border-width: 0;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/* Icon: plain. The default, the tone's icon on its own. */
|
|
239
|
+
[data-slot="alert"]:is(
|
|
240
|
+
[data-icon-style="plain"],
|
|
241
|
+
:not([data-icon-style]):is(
|
|
242
|
+
[data-kumiko-alert~="icon-plain"],
|
|
243
|
+
[data-kumiko-alert~="icon-plain"] *
|
|
244
|
+
)
|
|
245
|
+
)
|
|
246
|
+
[data-slot="alert-icon"] {
|
|
247
|
+
--_ic: var(--_plain-ic);
|
|
248
|
+
|
|
249
|
+
display: inline-grid;
|
|
250
|
+
inline-size: auto;
|
|
251
|
+
block-size: calc(1em * var(--kumiko-alert-line-height));
|
|
252
|
+
margin-block: 0;
|
|
253
|
+
border-radius: 0;
|
|
254
|
+
background: transparent;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/* Icon: lamp. A small tinted round behind the icon. */
|
|
258
|
+
[data-slot="alert"]:is(
|
|
259
|
+
[data-icon-style="lamp"],
|
|
260
|
+
:not([data-icon-style]):is(
|
|
261
|
+
[data-kumiko-alert~="icon-lamp"],
|
|
262
|
+
[data-kumiko-alert~="icon-lamp"] *
|
|
263
|
+
)
|
|
264
|
+
)
|
|
265
|
+
[data-slot="alert-icon"] {
|
|
266
|
+
--_ic: var(--_lamp-ic);
|
|
267
|
+
|
|
268
|
+
display: inline-grid;
|
|
269
|
+
inline-size: var(--kumiko-alert-lamp-size);
|
|
270
|
+
block-size: var(--kumiko-alert-lamp-size);
|
|
271
|
+
margin-block: calc(
|
|
272
|
+
(1em * var(--kumiko-alert-line-height) - var(--kumiko-alert-lamp-size)) / 2
|
|
273
|
+
);
|
|
274
|
+
border-radius: 999px;
|
|
275
|
+
background: var(--_lamp);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/* Icon: none. The icon is hidden. */
|
|
279
|
+
[data-slot="alert"]:is(
|
|
280
|
+
[data-icon-style="none"],
|
|
281
|
+
:not([data-icon-style]):is(
|
|
282
|
+
[data-kumiko-alert~="icon-none"],
|
|
283
|
+
[data-kumiko-alert~="icon-none"] *
|
|
284
|
+
)
|
|
285
|
+
)
|
|
286
|
+
[data-slot="alert-icon"] {
|
|
287
|
+
display: none;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/*
|
|
291
|
+
* Appearing, on the frame. The frame fades in, and either rises, or grows its height so what
|
|
292
|
+
* is below slides down. Grow is the default.
|
|
293
|
+
*/
|
|
294
|
+
[data-slot="alert-frame"] {
|
|
295
|
+
--_fade: kumiko-alert-fade;
|
|
296
|
+
--_appear: kumiko-alert-grow;
|
|
297
|
+
|
|
298
|
+
animation:
|
|
299
|
+
var(--_fade) var(--kumiko-fade-duration) var(--kumiko-enter-ease) backwards,
|
|
300
|
+
var(--_appear) var(--kumiko-move-duration) var(--kumiko-move-ease) backwards;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
[data-slot="alert-frame"]:is(
|
|
304
|
+
[data-appear="grow"],
|
|
305
|
+
:not([data-appear]):is(
|
|
306
|
+
[data-kumiko-alert~="appear-grow"],
|
|
307
|
+
[data-kumiko-alert~="appear-grow"] *
|
|
308
|
+
)
|
|
309
|
+
) {
|
|
310
|
+
--_fade: kumiko-alert-fade;
|
|
311
|
+
--_appear: kumiko-alert-grow;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
[data-slot="alert-frame"]:is(
|
|
315
|
+
[data-appear="rise"],
|
|
316
|
+
:not([data-appear]):is(
|
|
317
|
+
[data-kumiko-alert~="appear-rise"],
|
|
318
|
+
[data-kumiko-alert~="appear-rise"] *
|
|
319
|
+
)
|
|
320
|
+
) {
|
|
321
|
+
--_fade: kumiko-alert-fade;
|
|
322
|
+
--_appear: kumiko-alert-rise;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
[data-slot="alert-frame"]:is(
|
|
326
|
+
[data-appear="none"],
|
|
327
|
+
:not([data-appear]):is(
|
|
328
|
+
[data-kumiko-alert~="appear-none"],
|
|
329
|
+
[data-kumiko-alert~="appear-none"] *
|
|
330
|
+
)
|
|
331
|
+
) {
|
|
332
|
+
--_fade: none;
|
|
333
|
+
--_appear: none;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
@keyframes kumiko-alert-fade {
|
|
337
|
+
from {
|
|
338
|
+
opacity: 0;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
@keyframes kumiko-alert-rise {
|
|
343
|
+
from {
|
|
344
|
+
translate: 0 0.5rem;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
@keyframes kumiko-alert-grow {
|
|
349
|
+
from {
|
|
350
|
+
overflow: hidden;
|
|
351
|
+
grid-template-rows: 0fr;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
to {
|
|
355
|
+
overflow: hidden;
|
|
356
|
+
grid-template-rows: 1fr;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/*
|
|
361
|
+
* Shown again, on the alert. A change of pulseKey sets data-run to a or b. Two sets of
|
|
362
|
+
* keyframes with the same steps restart the animation, because a new name starts it afresh.
|
|
363
|
+
* Glow is the default.
|
|
364
|
+
*/
|
|
365
|
+
[data-slot="alert"] {
|
|
366
|
+
--_again-a: kumiko-alert-glow-a;
|
|
367
|
+
--_again-b: kumiko-alert-glow-b;
|
|
368
|
+
--_again-duration: calc(var(--kumiko-settle-duration) * 3);
|
|
369
|
+
--_again-ease: var(--kumiko-settle-ease);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
[data-slot="alert"][data-run="a"] {
|
|
373
|
+
animation: var(--_again-a) var(--_again-duration) var(--_again-ease);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
[data-slot="alert"][data-run="b"] {
|
|
377
|
+
animation: var(--_again-b) var(--_again-duration) var(--_again-ease);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
[data-slot="alert"]:is(
|
|
381
|
+
[data-again="glow"],
|
|
382
|
+
:not([data-again]):is(
|
|
383
|
+
[data-kumiko-alert~="again-glow"],
|
|
384
|
+
[data-kumiko-alert~="again-glow"] *
|
|
385
|
+
)
|
|
386
|
+
) {
|
|
387
|
+
--_again-a: kumiko-alert-glow-a;
|
|
388
|
+
--_again-b: kumiko-alert-glow-b;
|
|
389
|
+
--_again-duration: calc(var(--kumiko-settle-duration) * 3);
|
|
390
|
+
--_again-ease: var(--kumiko-settle-ease);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
[data-slot="alert"]:is(
|
|
394
|
+
[data-again="nudge"],
|
|
395
|
+
:not([data-again]):is(
|
|
396
|
+
[data-kumiko-alert~="again-nudge"],
|
|
397
|
+
[data-kumiko-alert~="again-nudge"] *
|
|
398
|
+
)
|
|
399
|
+
) {
|
|
400
|
+
--_again-a: kumiko-alert-nudge-a;
|
|
401
|
+
--_again-b: kumiko-alert-nudge-b;
|
|
402
|
+
--_again-duration: calc(var(--kumiko-move-duration) * 2);
|
|
403
|
+
--_again-ease: var(--kumiko-move-ease);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
[data-slot="alert"]:is(
|
|
407
|
+
[data-again="none"],
|
|
408
|
+
:not([data-again]):is(
|
|
409
|
+
[data-kumiko-alert~="again-none"],
|
|
410
|
+
[data-kumiko-alert~="again-none"] *
|
|
411
|
+
)
|
|
412
|
+
) {
|
|
413
|
+
--_again-a: none;
|
|
414
|
+
--_again-b: none;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
@keyframes kumiko-alert-glow-a {
|
|
418
|
+
40% {
|
|
419
|
+
background-color: color-mix(
|
|
420
|
+
in oklab,
|
|
421
|
+
var(--_c) calc(var(--kumiko-alert-wash) * 2),
|
|
422
|
+
transparent
|
|
423
|
+
);
|
|
424
|
+
box-shadow: 0 0 var(--kumiko-alert-glow-size) 0.1rem
|
|
425
|
+
color-mix(in oklab, var(--_c) var(--kumiko-alert-glow-strength), transparent);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
@keyframes kumiko-alert-glow-b {
|
|
430
|
+
40% {
|
|
431
|
+
background-color: color-mix(
|
|
432
|
+
in oklab,
|
|
433
|
+
var(--_c) calc(var(--kumiko-alert-wash) * 2),
|
|
434
|
+
transparent
|
|
435
|
+
);
|
|
436
|
+
box-shadow: 0 0 var(--kumiko-alert-glow-size) 0.1rem
|
|
437
|
+
color-mix(in oklab, var(--_c) var(--kumiko-alert-glow-strength), transparent);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
@keyframes kumiko-alert-nudge-a {
|
|
442
|
+
20% {
|
|
443
|
+
translate: calc(var(--_dir) * var(--kumiko-alert-nudge)) 0;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
45% {
|
|
447
|
+
translate: calc(var(--_dir) * var(--kumiko-alert-nudge) * -0.8) 0;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
70% {
|
|
451
|
+
translate: calc(var(--_dir) * var(--kumiko-alert-nudge) * 0.4) 0;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
@keyframes kumiko-alert-nudge-b {
|
|
456
|
+
20% {
|
|
457
|
+
translate: calc(var(--_dir) * var(--kumiko-alert-nudge)) 0;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
45% {
|
|
461
|
+
translate: calc(var(--_dir) * var(--kumiko-alert-nudge) * -0.8) 0;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
70% {
|
|
465
|
+
translate: calc(var(--_dir) * var(--kumiko-alert-nudge) * 0.4) 0;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
@media (forced-colors: active) {
|
|
470
|
+
[data-slot="alert"] {
|
|
471
|
+
border-color: Highlight;
|
|
472
|
+
outline: 1px solid CanvasText;
|
|
473
|
+
outline-offset: -1px;
|
|
474
|
+
background: Canvas;
|
|
475
|
+
color: CanvasText;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
[data-slot="alert-icon"] {
|
|
479
|
+
background: transparent;
|
|
480
|
+
color: CanvasText;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** What an alert says: how serious it is. Error is announced at once, the rest politely. */
|
|
2
|
+
export type AlertTone = "info" | "success" | "warning" | "error";
|
|
3
|
+
/** How an alert is painted: a tinted wash, a wash with an accent bar, a tinted outline or a solid fill. */
|
|
4
|
+
export type AlertLook = "wash" | "bar" | "outline" | "solid";
|
|
5
|
+
/** How the icon is drawn: plain, inside a small tinted round lamp, or not at all. */
|
|
6
|
+
export type AlertIconStyle = "plain" | "lamp" | "none";
|
|
7
|
+
/** How an alert appears: with no motion, fading and rising, or fading while its height grows. */
|
|
8
|
+
export type AlertAppear = "none" | "rise" | "grow";
|
|
9
|
+
/** What happens when the same alert is raised again: nothing, a glow or a small nudge. */
|
|
10
|
+
export type AlertAgain = "none" | "glow" | "nudge";
|
|
11
|
+
export interface AlertProps extends Omit<React.ComponentPropsWithoutRef<"div">, "title"> {
|
|
12
|
+
/** @defaultValue "info" */
|
|
13
|
+
tone?: AlertTone;
|
|
14
|
+
/** A custom icon, or `false` for none. The default is a small icon for the tone. It is hidden from screen readers. */
|
|
15
|
+
icon?: React.ReactNode;
|
|
16
|
+
/** A bold first line. */
|
|
17
|
+
title?: React.ReactNode;
|
|
18
|
+
/** Buttons or links under the text. */
|
|
19
|
+
actions?: React.ReactNode;
|
|
20
|
+
/** Shows a close button that calls this. */
|
|
21
|
+
onDismiss?: () => void;
|
|
22
|
+
/** The close button's accessible name. @defaultValue "Dismiss" */
|
|
23
|
+
dismissLabel?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The paint. Without it, a word on any container picks: `data-kumiko-alert="look-bar"`, `look-wash`, `look-outline` or `look-solid`. A prop beats a word.
|
|
26
|
+
* @defaultValue "wash"
|
|
27
|
+
*/
|
|
28
|
+
look?: AlertLook;
|
|
29
|
+
/**
|
|
30
|
+
* The icon's style. Without it, `icon-plain`, `icon-lamp` or `icon-none` on any container picks.
|
|
31
|
+
* @defaultValue "plain"
|
|
32
|
+
*/
|
|
33
|
+
iconStyle?: AlertIconStyle;
|
|
34
|
+
/**
|
|
35
|
+
* How it appears: fading in and growing its height, so what is below slides down. Without it, `appear-none`, `appear-rise` or `appear-grow` on any container picks.
|
|
36
|
+
* @defaultValue "grow"
|
|
37
|
+
*/
|
|
38
|
+
appear?: AlertAppear;
|
|
39
|
+
/**
|
|
40
|
+
* What happens when `pulseKey` changes while mounted. Without it, `again-none`, `again-glow` or `again-nudge` on any container picks.
|
|
41
|
+
* @defaultValue "glow"
|
|
42
|
+
*/
|
|
43
|
+
again?: AlertAgain;
|
|
44
|
+
/** Change this while the alert stays mounted to show it again, for example a count of failed tries. */
|
|
45
|
+
pulseKey?: string | number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A message that stays in the page: info, success, warning or error, with an optional title, actions and close button.
|
|
49
|
+
* The looks and motion are props, or words on any container in `data-kumiko-alert`. A prop beats a word.
|
|
50
|
+
*/
|
|
51
|
+
export declare function Alert({ tone, icon, title, actions, onDismiss, dismissLabel, look, iconStyle, appear, again, pulseKey, children, ...rest }: AlertProps): React.JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
const paths = {
|
|
4
|
+
info: ["M8 7.2v4", "M8 4.9v.1"],
|
|
5
|
+
success: ["M5.2 8.3 7.2 10.3 10.9 6"],
|
|
6
|
+
warning: ["M8 5.6v3.2", "M8 11v.1"],
|
|
7
|
+
error: ["M8 4.9v3.9", "M8 11v.1"]
|
|
8
|
+
};
|
|
9
|
+
/** The small icon of each tone. */
|
|
10
|
+
function ToneIcon({ tone }) {
|
|
11
|
+
return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", children: [tone === "warning" ? (_jsx("path", { d: "M8 1.9 14.6 13.4H1.4Z" })) : (_jsx("circle", { cx: "8", cy: "8", r: "6.4" })), paths[tone].map((d) => (_jsx("path", { d: d }, d)))] }));
|
|
12
|
+
}
|
|
13
|
+
function Cross() {
|
|
14
|
+
return (_jsx("svg", { viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "m4.5 4.5 7 7m0-7-7 7" }) }));
|
|
15
|
+
}
|
|
16
|
+
/** The close button. */
|
|
17
|
+
function Dismiss({ label, onDismiss }) {
|
|
18
|
+
return (_jsx("button", { type: "button", "data-slot": "alert-dismiss", "aria-label": label, onClick: onDismiss, children: _jsx(Cross, {}) }));
|
|
19
|
+
}
|
|
20
|
+
/** Counts how often `pulseKey` changed, so the glow and nudge can restart. Alternating two names restarts a CSS animation. */
|
|
21
|
+
function useRuns(pulseKey) {
|
|
22
|
+
const [seen, setSeen] = useState(pulseKey);
|
|
23
|
+
const [runs, setRuns] = useState(0);
|
|
24
|
+
if (seen !== pulseKey) {
|
|
25
|
+
setSeen(pulseKey);
|
|
26
|
+
setRuns(runs + 1);
|
|
27
|
+
}
|
|
28
|
+
if (runs === 0) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
return runs % 2 === 1 ? "a" : "b";
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A message that stays in the page: info, success, warning or error, with an optional title, actions and close button.
|
|
35
|
+
* The looks and motion are props, or words on any container in `data-kumiko-alert`. A prop beats a word.
|
|
36
|
+
*/
|
|
37
|
+
export function Alert({ tone = "info", icon, title, actions, onDismiss, dismissLabel = "Dismiss", look, iconStyle, appear, again, pulseKey, children, ...rest }) {
|
|
38
|
+
const run = useRuns(pulseKey);
|
|
39
|
+
return (_jsx("div", { "data-slot": "alert-frame", "data-appear": appear, children: _jsx("div", { "data-slot": "alert-clip", children: _jsxs("div", { role: tone === "error" ? "alert" : "status", ...rest, "data-slot": "alert", "data-tone": tone, "data-look": look, "data-icon-style": iconStyle, "data-again": again, "data-run": run, children: [icon === false ? null : (_jsx("span", { "data-slot": "alert-icon", "aria-hidden": "true", children: icon ?? _jsx(ToneIcon, { tone: tone }) })), _jsxs("div", { "data-slot": "alert-body", children: [title ? _jsx("div", { "data-slot": "alert-title", children: title }) : null, children, actions ? _jsx("div", { "data-slot": "alert-actions", children: actions }) : null] }), onDismiss ? _jsx(Dismiss, { label: dismissLabel, onDismiss: onDismiss }) : null] }) }) }));
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Alert, type AlertAgain, type AlertAppear, type AlertIconStyle, type AlertLook, type AlertProps, type AlertTone } from "./alert";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Alert } from "./alert";
|