sileo 0.0.1

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/index.ts ADDED
@@ -0,0 +1,9 @@
1
+ export type { SileoButton, SileoState, SileoStyles } from "./sileo";
2
+ export type {
3
+ ToastButton,
4
+ ToastOptions,
5
+ ToastPosition,
6
+ ToastPromiseOptions,
7
+ ToastStyles,
8
+ } from "./toast";
9
+ export { sileo, Toaster } from "./toast";
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "sileo",
3
+ "version": "0.0.1",
4
+ "description": "A lightweight toast notification library for React",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/hiaaryan/sileo.git"
9
+ },
10
+ "main": "./index.ts",
11
+ "types": "./index.ts",
12
+ "sideEffects": [
13
+ "./sileo.css"
14
+ ],
15
+ "exports": {
16
+ ".": "./index.ts",
17
+ "./sileo": "./sileo.tsx",
18
+ "./sileo.css": "./sileo.css",
19
+ "./toast": "./toast.tsx"
20
+ },
21
+ "files": [
22
+ "sileo.tsx",
23
+ "toast.tsx",
24
+ "index.ts",
25
+ "sileo.css"
26
+ ]
27
+ }
package/sileo.css ADDED
@@ -0,0 +1,483 @@
1
+ /* -------------------------------- Variables ------------------------------- */
2
+
3
+ :root {
4
+ --sileo-spring-easing: linear(
5
+ 0,
6
+ 0.002 0.6%,
7
+ 0.007 1.2%,
8
+ 0.015 1.8%,
9
+ 0.025 2.4%,
10
+ 0.057 3.7%,
11
+ 0.104 5.2%,
12
+ 0.151 6.5%,
13
+ 0.208 7.9%,
14
+ 0.455 13.6%,
15
+ 0.566 16.3%,
16
+ 0.619 17.7%,
17
+ 0.669 19.1%,
18
+ 0.715 20.5%,
19
+ 0.755 21.8%,
20
+ 0.794 23.2%,
21
+ 0.829 24.6%,
22
+ 0.861 26%,
23
+ 0.889 27.4%,
24
+ 0.914 28.8%,
25
+ 0.937 30.3%,
26
+ 0.956 31.8%,
27
+ 0.974 33.4%,
28
+ 0.987 34.8%,
29
+ 0.997 36.2%,
30
+ 1.014 39.2%,
31
+ 1.024 42.5%,
32
+ 1.028 46.3%,
33
+ 1.026 51.9%,
34
+ 1.01 66.1%,
35
+ 1.003 74.9%,
36
+ 1 85.2%,
37
+ 1
38
+ );
39
+
40
+ --sileo-duration: 600ms;
41
+ --sileo-height: 40px;
42
+ --sileo-width: 350px;
43
+
44
+ --sileo-state-success: oklch(0.723 0.219 142.136);
45
+ --sileo-state-loading: oklch(0.556 0 0);
46
+ --sileo-state-error: oklch(0.637 0.237 25.331);
47
+ --sileo-state-warning: oklch(0.795 0.184 86.047);
48
+ --sileo-state-info: oklch(0.685 0.169 237.323);
49
+ --sileo-state-action: oklch(0.623 0.214 259.815);
50
+ }
51
+
52
+ /* ---------------------------------- Toast --------------------------------- */
53
+
54
+ [data-sileo-toast] {
55
+ position: relative;
56
+ cursor: pointer;
57
+ pointer-events: auto;
58
+ border: 0;
59
+ background: transparent;
60
+ padding: 0;
61
+ width: var(--sileo-width);
62
+ height: var(--sileo-button-height, var(--sileo-height));
63
+ opacity: 0;
64
+ transform: translateZ(0) scale(0.95);
65
+ transform-origin: center;
66
+ filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.05));
67
+ contain: layout style;
68
+ overflow: visible;
69
+ }
70
+
71
+ [data-sileo-toast][data-state="loading"] {
72
+ cursor: default;
73
+ }
74
+
75
+ [data-sileo-toast][data-ready="true"] {
76
+ opacity: 1;
77
+ transform: translateZ(0) scale(1);
78
+ transition:
79
+ transform calc(var(--sileo-duration) * 0.66) var(--sileo-spring-easing),
80
+ opacity calc(var(--sileo-duration) * 0.66) var(--sileo-spring-easing),
81
+ margin-bottom calc(var(--sileo-duration) * 0.66) var(--sileo-spring-easing),
82
+ margin-top calc(var(--sileo-duration) * 0.66) var(--sileo-spring-easing),
83
+ height var(--sileo-duration) var(--sileo-spring-easing);
84
+ }
85
+
86
+ /* Entry animation direction */
87
+ [data-sileo-viewport][data-position^="top"]
88
+ [data-sileo-toast]:not([data-ready="true"]) {
89
+ transform: translateY(-6px) scale(0.95);
90
+ }
91
+
92
+ [data-sileo-viewport][data-position^="bottom"]
93
+ [data-sileo-toast]:not([data-ready="true"]) {
94
+ transform: translateY(6px) scale(0.95);
95
+ }
96
+
97
+ /* Exit */
98
+ [data-sileo-toast][data-ready="true"][data-exiting="true"] {
99
+ opacity: 0;
100
+ pointer-events: none;
101
+ }
102
+
103
+ [data-sileo-viewport][data-position^="top"]
104
+ [data-sileo-toast][data-ready="true"][data-exiting="true"] {
105
+ transform: translateY(-6px) scale(0.95);
106
+ }
107
+
108
+ [data-sileo-viewport][data-position^="bottom"]
109
+ [data-sileo-toast][data-ready="true"][data-exiting="true"] {
110
+ transform: translateY(6px) scale(0.95);
111
+ }
112
+
113
+ /* ------------------------------- SVG Canvas ------------------------------- */
114
+
115
+ [data-sileo-canvas] {
116
+ position: absolute;
117
+ left: 0;
118
+ right: 0;
119
+ pointer-events: none;
120
+ transform: translateZ(0);
121
+ contain: layout style;
122
+ overflow: visible;
123
+ }
124
+
125
+ [data-sileo-canvas][data-edge="top"] {
126
+ bottom: 0;
127
+ transform: scaleY(-1) translateZ(0);
128
+ }
129
+
130
+ [data-sileo-canvas][data-edge="bottom"] {
131
+ top: 0;
132
+ }
133
+
134
+ [data-sileo-svg] {
135
+ overflow: visible;
136
+ }
137
+
138
+ /* --------------------------------- Shapes --------------------------------- */
139
+
140
+ [data-sileo-pill],
141
+ [data-sileo-body] {
142
+ transform-box: fill-box;
143
+ transform-origin: 50% 0%;
144
+ }
145
+
146
+ [data-sileo-toast][data-ready="true"] [data-sileo-pill] {
147
+ transition:
148
+ transform var(--sileo-duration) var(--sileo-spring-easing),
149
+ width var(--sileo-duration) var(--sileo-spring-easing),
150
+ height var(--sileo-duration) var(--sileo-spring-easing),
151
+ x var(--sileo-duration) var(--sileo-spring-easing),
152
+ fill var(--sileo-duration) var(--sileo-spring-easing);
153
+ }
154
+
155
+ [data-sileo-toast][data-ready="true"][data-expanded="true"] [data-sileo-pill] {
156
+ transition-delay: calc(var(--sileo-duration) * 0.08);
157
+ }
158
+
159
+ [data-sileo-toast][data-ready="true"] [data-sileo-body] {
160
+ transition:
161
+ transform var(--sileo-duration) var(--sileo-spring-easing),
162
+ opacity var(--sileo-duration) var(--sileo-spring-easing),
163
+ fill var(--sileo-duration) var(--sileo-spring-easing);
164
+ }
165
+
166
+ /* --------------------------------- Header --------------------------------- */
167
+
168
+ [data-sileo-header] {
169
+ position: absolute;
170
+ z-index: 20;
171
+ display: flex;
172
+ align-items: center;
173
+ padding: 0.5rem;
174
+ height: var(--sileo-height);
175
+ overflow: hidden;
176
+ }
177
+
178
+ [data-sileo-toast][data-ready="true"] [data-sileo-header] {
179
+ max-width: var(--sileo-pill-width);
180
+ transition:
181
+ transform var(--sileo-duration) var(--sileo-spring-easing),
182
+ left var(--sileo-duration) var(--sileo-spring-easing),
183
+ max-width var(--sileo-duration) var(--sileo-spring-easing);
184
+ }
185
+
186
+ [data-sileo-header][data-edge="top"] {
187
+ bottom: 0;
188
+ }
189
+
190
+ [data-sileo-header][data-edge="bottom"] {
191
+ top: 0;
192
+ }
193
+
194
+ /* Header inner morphing */
195
+ [data-sileo-header-stack] {
196
+ position: relative;
197
+ display: inline-flex;
198
+ align-items: center;
199
+ height: 100%;
200
+ }
201
+
202
+ [data-sileo-header-inner] {
203
+ display: flex;
204
+ align-items: center;
205
+ gap: 0.5rem;
206
+ white-space: nowrap;
207
+ opacity: 1;
208
+ filter: blur(0px);
209
+ }
210
+
211
+ [data-sileo-header-inner][data-layer="current"] {
212
+ animation: sileo-header-enter 1s var(--sileo-spring-easing) both;
213
+ }
214
+
215
+ [data-sileo-header-inner][data-layer="prev"] {
216
+ position: absolute;
217
+ left: 0;
218
+ top: 0;
219
+ pointer-events: none;
220
+ }
221
+
222
+ [data-sileo-header-inner][data-exiting="true"] {
223
+ animation: sileo-header-exit 150ms ease forwards;
224
+ }
225
+
226
+ /* ---------------------------------- Badge --------------------------------- */
227
+
228
+ [data-sileo-badge] {
229
+ display: flex;
230
+ height: 24px;
231
+ width: 24px;
232
+ flex-shrink: 0;
233
+ align-items: center;
234
+ justify-content: center;
235
+ border-radius: 9999px;
236
+ color: var(--sileo-tone, currentColor);
237
+ background-color: var(--sileo-tone-bg, transparent);
238
+ }
239
+
240
+ /* ---------------------------------- Title --------------------------------- */
241
+
242
+ [data-sileo-title] {
243
+ font-size: 0.825rem;
244
+ line-height: 1rem;
245
+ font-weight: 500;
246
+ text-transform: capitalize;
247
+ color: var(--sileo-tone, currentColor);
248
+ }
249
+
250
+ /* ------------------------------ State Colors ------------------------------ */
251
+
252
+ :is([data-sileo-badge], [data-sileo-title])[data-state] {
253
+ --_c: var(--sileo-state-success);
254
+ --sileo-tone: var(--_c);
255
+ --sileo-tone-bg: color-mix(in oklch, var(--_c) 20%, transparent);
256
+ }
257
+
258
+ :is([data-sileo-badge], [data-sileo-title])[data-state="loading"] {
259
+ --_c: var(--sileo-state-loading);
260
+ }
261
+
262
+ :is([data-sileo-badge], [data-sileo-title])[data-state="error"] {
263
+ --_c: var(--sileo-state-error);
264
+ }
265
+
266
+ :is([data-sileo-badge], [data-sileo-title])[data-state="warning"] {
267
+ --_c: var(--sileo-state-warning);
268
+ }
269
+
270
+ :is([data-sileo-badge], [data-sileo-title])[data-state="info"] {
271
+ --_c: var(--sileo-state-info);
272
+ }
273
+
274
+ :is([data-sileo-badge], [data-sileo-title])[data-state="action"] {
275
+ --_c: var(--sileo-state-action);
276
+ }
277
+
278
+ /* --------------------------------- Content -------------------------------- */
279
+
280
+ [data-sileo-content] {
281
+ position: absolute;
282
+ left: 0;
283
+ z-index: 10;
284
+ width: 100%;
285
+ pointer-events: none;
286
+ }
287
+
288
+ [data-sileo-toast][data-ready="true"] [data-sileo-content] {
289
+ transition: opacity calc(var(--sileo-duration) * 0.08)
290
+ var(--sileo-spring-easing) calc(var(--sileo-duration) * 0.04);
291
+ }
292
+
293
+ [data-sileo-content][data-edge="top"] {
294
+ top: 0;
295
+ }
296
+
297
+ [data-sileo-content][data-edge="bottom"] {
298
+ top: var(--sileo-height);
299
+ }
300
+
301
+ [data-sileo-content][data-visible="true"] {
302
+ pointer-events: auto;
303
+ }
304
+
305
+ [data-sileo-toast][data-ready="true"]
306
+ [data-sileo-content][data-visible="true"] {
307
+ transition: opacity var(--sileo-duration) var(--sileo-spring-easing)
308
+ calc(var(--sileo-duration) * 0.25);
309
+ }
310
+
311
+ [data-sileo-description] {
312
+ width: 100%;
313
+ text-align: left;
314
+ padding: 1rem;
315
+ font-size: 0.875rem;
316
+ line-height: 1.25rem;
317
+ contain: layout style;
318
+ content-visibility: auto;
319
+ }
320
+
321
+ /* --------------------------------- Button --------------------------------- */
322
+
323
+ [data-sileo-button] {
324
+ display: flex;
325
+ align-items: center;
326
+ justify-content: center;
327
+ height: 1.75rem;
328
+ padding: 0 0.625rem;
329
+ margin-top: 0.75rem;
330
+ border-radius: 9999px;
331
+ border: 0;
332
+ font-size: 0.75rem;
333
+ font-weight: 500;
334
+ cursor: pointer;
335
+ color: var(--sileo-btn-color, currentColor);
336
+ background-color: var(--sileo-btn-bg, transparent);
337
+ transition: background-color 150ms ease;
338
+ }
339
+
340
+ [data-sileo-button]:hover {
341
+ background-color: var(--sileo-btn-bg-hover, transparent);
342
+ }
343
+
344
+ [data-sileo-button][data-state] {
345
+ --_c: var(--sileo-state-success);
346
+ --sileo-btn-color: var(--_c);
347
+ --sileo-btn-bg: color-mix(in oklch, var(--_c) 15%, transparent);
348
+ --sileo-btn-bg-hover: color-mix(in oklch, var(--_c) 25%, transparent);
349
+ }
350
+
351
+ [data-sileo-button][data-state="loading"] {
352
+ --_c: var(--sileo-state-loading);
353
+ }
354
+
355
+ [data-sileo-button][data-state="error"] {
356
+ --_c: var(--sileo-state-error);
357
+ }
358
+
359
+ [data-sileo-button][data-state="warning"] {
360
+ --_c: var(--sileo-state-warning);
361
+ }
362
+
363
+ [data-sileo-button][data-state="info"] {
364
+ --_c: var(--sileo-state-info);
365
+ }
366
+
367
+ [data-sileo-button][data-state="action"] {
368
+ --_c: var(--sileo-state-action);
369
+ }
370
+
371
+ /* -------------------------------- Animations ------------------------------ */
372
+
373
+ [data-sileo-icon="spin"] {
374
+ animation: sileo-spin 1s linear infinite;
375
+ }
376
+
377
+ @keyframes sileo-spin {
378
+ to {
379
+ rotate: 360deg;
380
+ }
381
+ }
382
+
383
+ @keyframes sileo-header-enter {
384
+ from {
385
+ opacity: 0;
386
+ filter: blur(6px);
387
+ }
388
+ to {
389
+ opacity: 1;
390
+ filter: blur(0px);
391
+ }
392
+ }
393
+
394
+ @keyframes sileo-header-exit {
395
+ from {
396
+ opacity: 1;
397
+ filter: blur(0px);
398
+ }
399
+ to {
400
+ opacity: 0;
401
+ filter: blur(6px);
402
+ }
403
+ }
404
+
405
+ /* -------------------------------- Viewports ------------------------------- */
406
+
407
+ [data-sileo-viewport] {
408
+ position: fixed;
409
+ z-index: 50;
410
+ display: flex;
411
+ gap: 0.75rem;
412
+ padding: 0.75rem;
413
+ pointer-events: none;
414
+ max-width: calc(100vw - 1.5rem);
415
+ contain: layout style;
416
+ }
417
+
418
+ [data-sileo-viewport][data-position^="top"]
419
+ [data-sileo-toast]:not([data-ready="true"]) {
420
+ margin-bottom: calc(-1 * (var(--sileo-height) + 0.75rem));
421
+ }
422
+
423
+ [data-sileo-viewport][data-position^="bottom"]
424
+ [data-sileo-toast]:not([data-ready="true"]) {
425
+ margin-top: calc(-1 * (var(--sileo-height) + 0.75rem));
426
+ }
427
+
428
+ /* Vertical edge */
429
+ [data-sileo-viewport][data-position^="top"] {
430
+ top: 0;
431
+ flex-direction: column-reverse;
432
+ }
433
+
434
+ [data-sileo-viewport][data-position^="bottom"] {
435
+ bottom: 0;
436
+ flex-direction: column;
437
+ }
438
+
439
+ /* Horizontal alignment */
440
+ [data-sileo-viewport][data-position$="left"] {
441
+ left: 0;
442
+ align-items: flex-start;
443
+ }
444
+
445
+ [data-sileo-viewport][data-position$="right"] {
446
+ right: 0;
447
+ align-items: flex-end;
448
+ }
449
+
450
+ [data-sileo-viewport][data-position$="center"] {
451
+ left: 50%;
452
+ transform: translateX(-50%);
453
+ align-items: center;
454
+ }
455
+
456
+ @media (prefers-reduced-motion: no-preference) {
457
+ [data-sileo-toast][data-ready="true"] {
458
+ will-change: transform, opacity;
459
+ }
460
+
461
+ [data-sileo-toast][data-ready="true"][data-expanded="true"] {
462
+ will-change: transform, opacity, height;
463
+ }
464
+
465
+ [data-sileo-pill],
466
+ [data-sileo-body] {
467
+ will-change: transform;
468
+ }
469
+
470
+ [data-sileo-canvas] {
471
+ will-change: filter;
472
+ }
473
+ }
474
+
475
+ @media (prefers-reduced-motion: reduce) {
476
+ *,
477
+ *::before,
478
+ *::after {
479
+ animation-duration: 0.01ms;
480
+ animation-iteration-count: 1;
481
+ transition-duration: 0.01ms;
482
+ }
483
+ }