-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphysics-toast.css
More file actions
375 lines (320 loc) · 9.36 KB
/
physics-toast.css
File metadata and controls
375 lines (320 loc) · 9.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
/* ================================ Variables ================================ */
:root {
--sileo-spring-easing: linear(0, 0.002 0.6%, 0.007 1.2%, 0.015 1.8%, 0.026 2.4%, 0.041 3.1%,
0.06 3.8%, 0.108 5.3%, 0.157 6.6%, 0.214 8%, 0.467 13.7%,
0.577 16.3%, 0.631 17.7%, 0.682 19.1%, 0.73 20.5%, 0.771 21.8%,
0.808 23.1%, 0.844 24.5%, 0.874 25.8%, 0.903 27.2%, 0.928 28.6%,
0.952 30.1%, 0.972 31.6%, 0.988 33.1%, 1.01 35.7%, 1.025 38.5%,
1.034 41.6%, 1.038 45%, 1.035 50.1%, 1.012 64.2%, 1.003 73%,
0.999 83.7%, 1);
--sileo-duration: 550ms;
--sileo-height: 40px;
--sileo-width: 350px;
--sileo-state-success: oklch(0.723 0.219 142.136);
--sileo-state-loading: oklch(0.556 0 0);
--sileo-state-error: oklch(0.637 0.237 25.331);
--sileo-state-warning: oklch(0.795 0.184 86.047);
--sileo-state-info: oklch(0.685 0.169 237.323);
--sileo-state-action: oklch(0.623 0.214 259.815);
}
/* ================================== Toast ================================== */
[data-sileo-toast] {
position: relative;
box-sizing: border-box;
cursor: pointer;
pointer-events: auto;
touch-action: none;
border: 0;
background: transparent;
padding: 0;
font: inherit;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
color: inherit;
text-align: left;
outline: none;
width: var(--sileo-width);
height: var(--_h, var(--sileo-height));
opacity: 0;
transform: translateZ(0) scale(0.95);
transform-origin: center;
contain: layout style;
overflow: visible;
}
[data-sileo-toast][data-state="loading"] {
cursor: default;
}
[data-sileo-toast][data-ready="true"] {
opacity: 1;
transform: translateZ(0) scale(1);
transition:
transform calc(var(--sileo-duration) * 0.66) var(--sileo-spring-easing),
opacity calc(var(--sileo-duration) * 0.66) var(--sileo-spring-easing),
margin-bottom calc(var(--sileo-duration) * 0.66) var(--sileo-spring-easing),
margin-top calc(var(--sileo-duration) * 0.66) var(--sileo-spring-easing),
height var(--sileo-duration) var(--sileo-spring-easing);
}
/* Entry direction */
[data-sileo-viewport][data-position^="top"] [data-sileo-toast]:not([data-ready="true"]) {
transform: translateY(-6px) scale(0.95);
}
[data-sileo-viewport][data-position^="bottom"] [data-sileo-toast]:not([data-ready="true"]) {
transform: translateY(6px) scale(0.95);
}
/* Exit */
[data-sileo-toast][data-ready="true"][data-exiting="true"] {
opacity: 0;
pointer-events: none;
}
[data-sileo-viewport][data-position^="top"] [data-sileo-toast][data-ready="true"][data-exiting="true"] {
transform: translateY(-6px) scale(0.95);
}
[data-sileo-viewport][data-position^="bottom"] [data-sileo-toast][data-ready="true"][data-exiting="true"] {
transform: translateY(6px) scale(0.95);
}
/* ============================== State Colors =============================== */
[data-sileo-toast][data-state] { --_c: var(--sileo-state-success); }
[data-sileo-toast][data-state="loading"] { --_c: var(--sileo-state-loading); }
[data-sileo-toast][data-state="error"] { --_c: var(--sileo-state-error); }
[data-sileo-toast][data-state="warning"] { --_c: var(--sileo-state-warning); }
[data-sileo-toast][data-state="info"] { --_c: var(--sileo-state-info); }
[data-sileo-toast][data-state="action"] { --_c: var(--sileo-state-action); }
/* ================================ SVG Canvas =============================== */
[data-sileo-canvas] {
position: absolute;
left: 0;
right: 0;
pointer-events: none;
transform: translateZ(0);
contain: layout style;
overflow: visible;
}
[data-sileo-canvas][data-edge="top"] {
bottom: 0;
transform: scaleY(-1) translateZ(0);
}
[data-sileo-canvas][data-edge="bottom"] {
top: 0;
}
[data-sileo-svg] {
overflow: visible;
}
/* ================================= Header ================================= */
[data-sileo-header] {
position: absolute;
z-index: 20;
display: flex;
align-items: center;
padding: 0.5rem;
height: var(--sileo-height);
overflow: hidden;
left: var(--_px, 0px);
transform: var(--_ht);
max-width: var(--_pw);
}
[data-sileo-toast][data-ready="true"] [data-sileo-header] {
transition:
transform var(--sileo-duration) var(--sileo-spring-easing),
left var(--sileo-duration) var(--sileo-spring-easing),
max-width var(--sileo-duration) var(--sileo-spring-easing);
}
[data-sileo-header][data-edge="top"] {
bottom: 0;
}
[data-sileo-header][data-edge="bottom"] {
top: 0;
}
/* Header inner morphing */
[data-sileo-header-stack] {
position: relative;
display: inline-flex;
align-items: center;
height: 100%;
}
[data-sileo-header-inner] {
display: flex;
align-items: center;
gap: 0.5rem;
white-space: nowrap;
}
[data-sileo-header-inner][data-layer="current"],
[data-sileo-header-inner][data-exiting="true"] {
will-change: opacity, filter;
}
[data-sileo-header-inner][data-layer="current"] {
animation: sileo-header-enter var(--sileo-duration) var(--sileo-spring-easing) both;
}
[data-sileo-header-inner][data-layer="prev"] {
position: absolute;
left: 0;
top: 0;
pointer-events: none;
}
[data-sileo-header-inner][data-exiting="true"] {
animation: sileo-header-exit 300ms ease forwards;
}
/* ================================== Badge ================================== */
[data-sileo-badge] {
display: flex;
height: 24px;
width: 24px;
flex-shrink: 0;
align-items: center;
justify-content: center;
padding: 2px;
border-radius: 9999px;
color: var(--_c);
background-color: color-mix(in oklch, var(--_c) 20%, transparent);
}
[data-sileo-badge] svg {
width: 16px;
height: 16px;
}
/* ================================== Title ================================== */
[data-sileo-title] {
font-size: 0.825rem;
line-height: 1rem;
font-weight: 500;
text-transform: capitalize;
color: var(--_c);
}
/* ================================= Content ================================= */
[data-sileo-content] {
position: absolute;
left: 0;
z-index: 10;
width: 100%;
pointer-events: none;
opacity: var(--_co, 0);
}
[data-sileo-content]:not([data-visible="true"]) {
content-visibility: hidden;
}
[data-sileo-toast][data-ready="true"] [data-sileo-content] {
transition: opacity calc(var(--sileo-duration) * 0.08) ease calc(var(--sileo-duration) * 0.04);
}
[data-sileo-content][data-edge="top"] {
top: 0;
}
[data-sileo-content][data-edge="bottom"] {
top: var(--sileo-height);
}
[data-sileo-content][data-visible="true"] {
pointer-events: auto;
}
[data-sileo-toast][data-ready="true"] [data-sileo-content][data-visible="true"] {
transition: opacity calc(var(--sileo-duration) * 0.5) ease calc(var(--sileo-duration) * 0.25);
}
[data-sileo-description] {
padding: 1rem;
font-size: 0.875rem;
line-height: 1.25rem;
color: #6e6e73;
content-visibility: auto;
}
/* ================================== Button ================================= */
[data-sileo-button] {
display: flex;
align-items: center;
justify-content: center;
height: 1.75rem;
padding: 0 0.625rem;
margin-top: 0.75rem;
border-radius: 9999px;
border: 0;
font-size: 0.75rem;
font-weight: 500;
cursor: pointer;
text-decoration: none;
color: var(--_c);
background-color: color-mix(in oklch, var(--_c) 15%, transparent);
transition: background-color 150ms ease;
}
[data-sileo-button]:hover {
background-color: color-mix(in oklch, var(--_c) 25%, transparent);
}
/* ================================ Animations =============================== */
[data-sileo-icon="spin"] {
animation: sileo-spin 1s linear infinite;
}
@keyframes sileo-spin {
to {
rotate: 360deg;
}
}
@keyframes sileo-header-enter {
from {
opacity: 0;
filter: blur(6px);
}
to {
opacity: 1;
filter: blur(0px);
}
}
@keyframes sileo-header-exit {
from {
opacity: 1;
filter: blur(0px);
}
to {
opacity: 0;
filter: blur(6px);
}
}
/* ================================ Viewports ================================ */
[data-sileo-viewport] {
position: fixed;
z-index: 50;
display: flex;
gap: 0.75rem;
padding: 0.75rem;
pointer-events: none;
max-width: calc(100vw - 1.5rem);
contain: layout style;
}
/* Stacking: new toast collapses in with negative margin */
[data-sileo-viewport][data-position^="top"] [data-sileo-toast]:not([data-ready="true"]) {
margin-bottom: calc(-1 * (var(--sileo-height) + 0.75rem));
}
[data-sileo-viewport][data-position^="bottom"] [data-sileo-toast]:not([data-ready="true"]) {
margin-top: calc(-1 * (var(--sileo-height) + 0.75rem));
}
/* Vertical edge */
[data-sileo-viewport][data-position^="top"] {
top: 0;
flex-direction: column-reverse;
}
[data-sileo-viewport][data-position^="bottom"] {
bottom: 0;
flex-direction: column;
}
/* Horizontal alignment */
[data-sileo-viewport][data-position$="left"] {
left: 0;
align-items: flex-start;
}
[data-sileo-viewport][data-position$="right"] {
right: 0;
align-items: flex-end;
}
[data-sileo-viewport][data-position$="center"] {
left: 50%;
transform: translateX(-50%);
align-items: center;
}
@media (prefers-reduced-motion: no-preference) {
[data-sileo-toast][data-ready="true"]:hover,
[data-sileo-toast][data-ready="true"][data-exiting="true"] {
will-change: transform, opacity, height;
}
}
@media (prefers-reduced-motion: reduce) {
[data-sileo-toast],
[data-sileo-toast] *,
[data-sileo-toast] *::before,
[data-sileo-toast] *::after {
animation-duration: 0.01ms;
animation-iteration-count: 1;
transition-duration: 0.01ms;
}
}