swage 0.1.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.
@@ -0,0 +1,580 @@
1
+ /**
2
+ * TailwindCSS v4.0 compatible replacement for `tailwindcss-animate`.
3
+ *
4
+ * @author Luca Bosin <https://github.com/Wombosvideo>
5
+ * @license MIT
6
+ */
7
+
8
+ /* @property declarations for animation variables, to prevent inheritance */
9
+ @property --tw-animation-delay {
10
+ syntax: "*";
11
+ inherits: false;
12
+ initial-value: 0s;
13
+ }
14
+
15
+ @property --tw-animation-direction {
16
+ syntax: "*";
17
+ inherits: false;
18
+ initial-value: normal;
19
+ }
20
+
21
+ @property --tw-animation-duration {
22
+ syntax: "*";
23
+ inherits: false;
24
+ /* does not have an initial value in order for the `--tw-duration` variable to work */
25
+ }
26
+
27
+ @property --tw-animation-fill-mode {
28
+ syntax: "*";
29
+ inherits: false;
30
+ initial-value: none;
31
+ }
32
+
33
+ @property --tw-animation-iteration-count {
34
+ syntax: "*";
35
+ inherits: false;
36
+ initial-value: 1;
37
+ }
38
+
39
+ @property --tw-enter-blur {
40
+ syntax: "*";
41
+ inherits: false;
42
+ initial-value: 0;
43
+ }
44
+
45
+ @property --tw-enter-opacity {
46
+ syntax: "*";
47
+ inherits: false;
48
+ initial-value: 1;
49
+ }
50
+
51
+ @property --tw-enter-rotate {
52
+ syntax: "*";
53
+ inherits: false;
54
+ initial-value: 0;
55
+ }
56
+
57
+ @property --tw-enter-scale {
58
+ syntax: "*";
59
+ inherits: false;
60
+ initial-value: 1;
61
+ }
62
+
63
+ @property --tw-enter-translate-x {
64
+ syntax: "*";
65
+ inherits: false;
66
+ initial-value: 0;
67
+ }
68
+
69
+ @property --tw-enter-translate-y {
70
+ syntax: "*";
71
+ inherits: false;
72
+ initial-value: 0;
73
+ }
74
+
75
+ @property --tw-exit-blur {
76
+ syntax: "*";
77
+ inherits: false;
78
+ initial-value: 0;
79
+ }
80
+
81
+ @property --tw-exit-opacity {
82
+ syntax: "*";
83
+ inherits: false;
84
+ initial-value: 1;
85
+ }
86
+
87
+ @property --tw-exit-rotate {
88
+ syntax: "*";
89
+ inherits: false;
90
+ initial-value: 0;
91
+ }
92
+
93
+ @property --tw-exit-scale {
94
+ syntax: "*";
95
+ inherits: false;
96
+ initial-value: 1;
97
+ }
98
+
99
+ @property --tw-exit-translate-x {
100
+ syntax: "*";
101
+ inherits: false;
102
+ initial-value: 0;
103
+ }
104
+
105
+ @property --tw-exit-translate-y {
106
+ syntax: "*";
107
+ inherits: false;
108
+ initial-value: 0;
109
+ }
110
+
111
+ @theme inline {
112
+ /* Predefined values */
113
+
114
+ --animation-delay-0: 0s;
115
+ --animation-delay-75: 75ms;
116
+ --animation-delay-100: 0.1s;
117
+ --animation-delay-150: 0.15s;
118
+ --animation-delay-200: 0.2s;
119
+ --animation-delay-300: 0.3s;
120
+ --animation-delay-500: 0.5s;
121
+ --animation-delay-700: 0.7s;
122
+ --animation-delay-1000: 1s;
123
+
124
+ --animation-repeat-0: 0;
125
+ --animation-repeat-1: 1;
126
+ --animation-repeat-infinite: infinite;
127
+
128
+ --animation-direction-normal: normal;
129
+ --animation-direction-reverse: reverse;
130
+ --animation-direction-alternate: alternate;
131
+ --animation-direction-alternate-reverse: alternate-reverse;
132
+
133
+ --animation-fill-mode-none: none;
134
+ --animation-fill-mode-forwards: forwards;
135
+ --animation-fill-mode-backwards: backwards;
136
+ --animation-fill-mode-both: both;
137
+
138
+ --percentage-0: 0;
139
+ --percentage-5: 0.05;
140
+ --percentage-10: 0.1;
141
+ --percentage-15: 0.15;
142
+ --percentage-20: 0.2;
143
+ --percentage-25: 0.25;
144
+ --percentage-30: 0.3;
145
+ --percentage-35: 0.35;
146
+ --percentage-40: 0.4;
147
+ --percentage-45: 0.45;
148
+ --percentage-50: 0.5;
149
+ --percentage-55: 0.55;
150
+ --percentage-60: 0.6;
151
+ --percentage-65: 0.65;
152
+ --percentage-70: 0.7;
153
+ --percentage-75: 0.75;
154
+ --percentage-80: 0.8;
155
+ --percentage-85: 0.85;
156
+ --percentage-90: 0.9;
157
+ --percentage-95: 0.95;
158
+ --percentage-100: 1;
159
+ --percentage-translate-full: 1;
160
+
161
+ /* Animations and keyframes */
162
+
163
+ --animate-in: enter var(--tw-animation-duration, var(--tw-duration, 150ms)) var(--tw-ease, ease)
164
+ var(--tw-animation-delay, 0s) var(--tw-animation-iteration-count, 1)
165
+ var(--tw-animation-direction, normal) var(--tw-animation-fill-mode, none);
166
+ --animate-out: exit var(--tw-animation-duration, var(--tw-duration, 150ms)) var(--tw-ease, ease)
167
+ var(--tw-animation-delay, 0s) var(--tw-animation-iteration-count, 1)
168
+ var(--tw-animation-direction, normal) var(--tw-animation-fill-mode, none);
169
+
170
+ @keyframes enter {
171
+ from {
172
+ opacity: var(--tw-enter-opacity, 1);
173
+ transform: translate3d(var(--tw-enter-translate-x, 0), var(--tw-enter-translate-y, 0), 0)
174
+ scale3d(var(--tw-enter-scale, 1), var(--tw-enter-scale, 1), var(--tw-enter-scale, 1))
175
+ rotate(var(--tw-enter-rotate, 0));
176
+ filter: blur(var(--tw-enter-blur, 0));
177
+ }
178
+ }
179
+
180
+ @keyframes exit {
181
+ to {
182
+ opacity: var(--tw-exit-opacity, 1);
183
+ transform: translate3d(var(--tw-exit-translate-x, 0), var(--tw-exit-translate-y, 0), 0)
184
+ scale3d(var(--tw-exit-scale, 1), var(--tw-exit-scale, 1), var(--tw-exit-scale, 1))
185
+ rotate(var(--tw-exit-rotate, 0));
186
+ filter: blur(var(--tw-exit-blur, 0));
187
+ }
188
+ }
189
+
190
+ --animate-accordion-down: accordion-down var(--tw-animation-duration, var(--tw-duration, 200ms))
191
+ var(--tw-ease, ease-out) var(--tw-animation-delay, 0s) var(--tw-animation-iteration-count, 1)
192
+ var(--tw-animation-direction, normal) var(--tw-animation-fill-mode, none);
193
+ --animate-accordion-up: accordion-up var(--tw-animation-duration, var(--tw-duration, 200ms))
194
+ var(--tw-ease, ease-out) var(--tw-animation-delay, 0s) var(--tw-animation-iteration-count, 1)
195
+ var(--tw-animation-direction, normal) var(--tw-animation-fill-mode, none);
196
+ --animate-collapsible-down: collapsible-down
197
+ var(--tw-animation-duration, var(--tw-duration, 200ms)) var(--tw-ease, ease-out)
198
+ var(--tw-animation-delay, 0s) var(--tw-animation-iteration-count, 1)
199
+ var(--tw-animation-direction, normal) var(--tw-animation-fill-mode, none);
200
+ --animate-collapsible-up: collapsible-up var(--tw-animation-duration, var(--tw-duration, 200ms))
201
+ var(--tw-ease, ease-out) var(--tw-animation-delay, 0s) var(--tw-animation-iteration-count, 1)
202
+ var(--tw-animation-direction, normal) var(--tw-animation-fill-mode, none);
203
+
204
+ @keyframes accordion-down {
205
+ from {
206
+ height: 0;
207
+ }
208
+ to {
209
+ height: var(
210
+ --radix-accordion-content-height,
211
+ var(
212
+ --bits-accordion-content-height,
213
+ var(
214
+ --reka-accordion-content-height,
215
+ var(--kb-accordion-content-height, var(--ngp-accordion-content-height, auto))
216
+ )
217
+ )
218
+ );
219
+ }
220
+ }
221
+
222
+ @keyframes accordion-up {
223
+ from {
224
+ height: var(
225
+ --radix-accordion-content-height,
226
+ var(
227
+ --bits-accordion-content-height,
228
+ var(
229
+ --reka-accordion-content-height,
230
+ var(--kb-accordion-content-height, var(--ngp-accordion-content-height, auto))
231
+ )
232
+ )
233
+ );
234
+ }
235
+ to {
236
+ height: 0;
237
+ }
238
+ }
239
+
240
+ @keyframes collapsible-down {
241
+ from {
242
+ height: 0;
243
+ }
244
+ to {
245
+ height: var(
246
+ --radix-collapsible-content-height,
247
+ var(
248
+ --bits-collapsible-content-height,
249
+ var(--reka-collapsible-content-height, var(--kb-collapsible-content-height, auto))
250
+ )
251
+ );
252
+ }
253
+ }
254
+
255
+ @keyframes collapsible-up {
256
+ from {
257
+ height: var(
258
+ --radix-collapsible-content-height,
259
+ var(
260
+ --bits-collapsible-content-height,
261
+ var(--reka-collapsible-content-height, var(--kb-collapsible-content-height, auto))
262
+ )
263
+ );
264
+ }
265
+ to {
266
+ height: 0;
267
+ }
268
+ }
269
+
270
+ --animate-caret-blink: caret-blink 1.25s ease-out infinite;
271
+
272
+ @keyframes caret-blink {
273
+ 0%,
274
+ 70%,
275
+ 100% {
276
+ opacity: 1;
277
+ }
278
+ 20%,
279
+ 50% {
280
+ opacity: 0;
281
+ }
282
+ }
283
+ }
284
+
285
+ /* Utility classes */
286
+
287
+ @utility animation-duration-* {
288
+ --tw-animation-duration: calc(--value(number) * 1ms);
289
+ --tw-animation-duration: --value(--animation-duration-*, [duration], "initial", [*]);
290
+ animation-duration: calc(--value(number) * 1ms);
291
+ animation-duration: --value(--animation-duration-*, [duration], "initial", [*]);
292
+ }
293
+
294
+ @utility delay-* {
295
+ animation-delay: calc(--value(number) * 1ms);
296
+ animation-delay: --value(--animation-delay-*, [duration], "initial", [*]);
297
+ --tw-animation-delay: calc(--value(number) * 1ms);
298
+ --tw-animation-delay: --value(--animation-delay-*, [duration], "initial", [*]);
299
+ }
300
+
301
+ @utility repeat-* {
302
+ animation-iteration-count: --value(--animation-repeat-*, number, "initial", [*]);
303
+ --tw-animation-iteration-count: --value(--animation-repeat-*, number, "initial", [*]);
304
+ }
305
+
306
+ @utility direction-* {
307
+ animation-direction: --value(--animation-direction-*, "initial", [*]);
308
+ --tw-animation-direction: --value(--animation-direction-*, "initial", [*]);
309
+ }
310
+
311
+ @utility fill-mode-* {
312
+ animation-fill-mode: --value(--animation-fill-mode-*, "initial", [*]);
313
+ --tw-animation-fill-mode: --value(--animation-fill-mode-*, "initial", [*]);
314
+ }
315
+
316
+ @utility running {
317
+ animation-play-state: running;
318
+ }
319
+ @utility paused {
320
+ animation-play-state: paused;
321
+ }
322
+ @utility play-state-* {
323
+ animation-play-state: --value("initial", [*]);
324
+ }
325
+
326
+ @utility blur-in {
327
+ --tw-enter-blur: 20px;
328
+ }
329
+ @utility blur-in-* {
330
+ --tw-enter-blur: calc(--value(number) * 1px);
331
+ --tw-enter-blur: --value(--blur-*, [*]);
332
+ }
333
+
334
+ @utility blur-out {
335
+ --tw-exit-blur: 20px;
336
+ }
337
+ @utility blur-out-* {
338
+ --tw-exit-blur: calc(--value(number) * 1px);
339
+ --tw-exit-blur: --value(--blur-*, [*]);
340
+ }
341
+
342
+ @utility fade-in {
343
+ --tw-enter-opacity: 0;
344
+ }
345
+ @utility fade-in-* {
346
+ --tw-enter-opacity: calc(--value(number) / 100);
347
+ --tw-enter-opacity: --value(--percentage-*, [*]);
348
+ }
349
+
350
+ @utility fade-out {
351
+ --tw-exit-opacity: 0;
352
+ }
353
+ @utility fade-out-* {
354
+ --tw-exit-opacity: calc(--value(number) / 100);
355
+ --tw-exit-opacity: --value(--percentage-*, [*]);
356
+ }
357
+
358
+ @utility zoom-in {
359
+ --tw-enter-scale: 0;
360
+ }
361
+ @utility zoom-in-* {
362
+ --tw-enter-scale: calc(--value(number) * 1%);
363
+ --tw-enter-scale: calc(--value(ratio));
364
+ --tw-enter-scale: --value(--percentage-*, [*]);
365
+ }
366
+ @utility -zoom-in-* {
367
+ --tw-enter-scale: calc(--value(number) * -1%);
368
+ --tw-enter-scale: calc(--value(ratio) * -1);
369
+ --tw-enter-scale: --value(--percentage-*, [*]);
370
+ }
371
+
372
+ @utility zoom-out {
373
+ --tw-exit-scale: 0;
374
+ }
375
+ @utility zoom-out-* {
376
+ --tw-exit-scale: calc(--value(number) * 1%);
377
+ --tw-exit-scale: calc(--value(ratio));
378
+ --tw-exit-scale: --value(--percentage-*, [*]);
379
+ }
380
+ @utility -zoom-out-* {
381
+ --tw-exit-scale: calc(--value(number) * -1%);
382
+ --tw-exit-scale: calc(--value(ratio) * -1);
383
+ --tw-exit-scale: --value(--percentage-*, [*]);
384
+ }
385
+
386
+ @utility spin-in {
387
+ --tw-enter-rotate: 30deg;
388
+ }
389
+ @utility spin-in-* {
390
+ --tw-enter-rotate: calc(--value(number) * 1deg);
391
+ --tw-enter-rotate: calc(--value(ratio) * 360deg);
392
+ --tw-enter-rotate: --value(--rotate-*, [*]);
393
+ }
394
+ @utility -spin-in {
395
+ --tw-enter-rotate: -30deg;
396
+ }
397
+ @utility -spin-in-* {
398
+ --tw-enter-rotate: calc(--value(number) * -1deg);
399
+ --tw-enter-rotate: calc(--value(ratio) * -360deg);
400
+ --tw-enter-rotate: --value(--rotate-*, [*]);
401
+ }
402
+
403
+ @utility spin-out {
404
+ --tw-exit-rotate: 30deg;
405
+ }
406
+ @utility spin-out-* {
407
+ --tw-exit-rotate: calc(--value(number) * 1deg);
408
+ --tw-exit-rotate: calc(--value(ratio) * 360deg);
409
+ --tw-exit-rotate: --value(--rotate-*, [*]);
410
+ }
411
+ @utility -spin-out {
412
+ --tw-exit-rotate: -30deg;
413
+ }
414
+ @utility -spin-out-* {
415
+ --tw-exit-rotate: calc(--value(number) * -1deg);
416
+ --tw-exit-rotate: calc(--value(ratio) * -360deg);
417
+ --tw-exit-rotate: --value(--rotate-*, [*]);
418
+ }
419
+
420
+ @utility slide-in-from-top {
421
+ --tw-enter-translate-y: -100%;
422
+ }
423
+ @utility slide-in-from-top-* {
424
+ --tw-enter-translate-y: calc(--value(integer) * var(--spacing) * -1);
425
+ --tw-enter-translate-y: calc(--value(--percentage-*, --percentage-translate-*) * -100%);
426
+ --tw-enter-translate-y: calc(--value(ratio) * -100%);
427
+ --tw-enter-translate-y: calc(--value(--translate-*, [percentage], [length]) * -1);
428
+ }
429
+ @utility slide-in-from-bottom {
430
+ --tw-enter-translate-y: 100%;
431
+ }
432
+ @utility slide-in-from-bottom-* {
433
+ --tw-enter-translate-y: calc(--value(integer) * var(--spacing));
434
+ --tw-enter-translate-y: calc(--value(--percentage-*, --percentage-translate-*) * 100%);
435
+ --tw-enter-translate-y: calc(--value(ratio) * 100%);
436
+ --tw-enter-translate-y: --value(--translate-*, [percentage], [length]);
437
+ }
438
+ @utility slide-in-from-left {
439
+ --tw-enter-translate-x: -100%;
440
+ }
441
+ @utility slide-in-from-left-* {
442
+ --tw-enter-translate-x: calc(--value(integer) * var(--spacing) * -1);
443
+ --tw-enter-translate-x: calc(--value(--percentage-*, --percentage-translate-*) * -100%);
444
+ --tw-enter-translate-x: calc(--value(ratio) * -100%);
445
+ --tw-enter-translate-x: calc(--value(--translate-*, [percentage], [length]) * -1);
446
+ }
447
+ @utility slide-in-from-right {
448
+ --tw-enter-translate-x: 100%;
449
+ }
450
+ @utility slide-in-from-right-* {
451
+ --tw-enter-translate-x: calc(--value(integer) * var(--spacing));
452
+ --tw-enter-translate-x: calc(--value(--percentage-*, --percentage-translate-*) * 100%);
453
+ --tw-enter-translate-x: calc(--value(ratio) * 100%);
454
+ --tw-enter-translate-x: --value(--translate-*, [percentage], [length]);
455
+ }
456
+ @utility slide-in-from-start {
457
+ &:dir(ltr) {
458
+ --tw-enter-translate-x: -100%;
459
+ }
460
+ &:dir(rtl) {
461
+ --tw-enter-translate-x: 100%;
462
+ }
463
+ }
464
+ @utility slide-in-from-start-* {
465
+ &:where(:dir(ltr), [dir="ltr"], [dir="ltr"] *) {
466
+ --tw-enter-translate-x: calc(--value(integer) * var(--spacing) * -1);
467
+ --tw-enter-translate-x: calc(--value(--percentage-*, --percentage-translate-*) * -100%);
468
+ --tw-enter-translate-x: calc(--value(ratio) * -100%);
469
+ --tw-enter-translate-x: calc(--value(--translate-*, [percentage], [length]) * -1);
470
+ }
471
+ &:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *) {
472
+ --tw-enter-translate-x: calc(--value(integer) * var(--spacing));
473
+ --tw-enter-translate-x: calc(--value(--percentage-*, --percentage-translate-*) * 100%);
474
+ --tw-enter-translate-x: calc(--value(ratio) * 100%);
475
+ --tw-enter-translate-x: --value(--translate-*, [percentage], [length]);
476
+ }
477
+ }
478
+ @utility slide-in-from-end {
479
+ &:dir(ltr) {
480
+ --tw-enter-translate-x: 100%;
481
+ }
482
+ &:dir(rtl) {
483
+ --tw-enter-translate-x: -100%;
484
+ }
485
+ }
486
+ @utility slide-in-from-end-* {
487
+ &:where(:dir(ltr), [dir="ltr"], [dir="ltr"] *) {
488
+ --tw-enter-translate-x: calc(--value(integer) * var(--spacing));
489
+ --tw-enter-translate-x: calc(--value(--percentage-*, --percentage-translate-*) * 100%);
490
+ --tw-enter-translate-x: calc(--value(ratio) * 100%);
491
+ --tw-enter-translate-x: --value(--translate-*, [percentage], [length]);
492
+ }
493
+ &:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *) {
494
+ --tw-enter-translate-x: calc(--value(integer) * var(--spacing) * -1);
495
+ --tw-enter-translate-x: calc(--value(--percentage-*, --percentage-translate-*) * -100%);
496
+ --tw-enter-translate-x: calc(--value(ratio) * -100%);
497
+ --tw-enter-translate-x: calc(--value(--translate-*, [percentage], [length]) * -1);
498
+ }
499
+ }
500
+
501
+ @utility slide-out-to-top {
502
+ --tw-exit-translate-y: -100%;
503
+ }
504
+ @utility slide-out-to-top-* {
505
+ --tw-exit-translate-y: calc(--value(integer) * var(--spacing) * -1);
506
+ --tw-exit-translate-y: calc(--value(--percentage-*, --percentage-translate-*) * -100%);
507
+ --tw-exit-translate-y: calc(--value(ratio) * -100%);
508
+ --tw-exit-translate-y: calc(--value(--translate-*, [percentage], [length]) * -1);
509
+ }
510
+ @utility slide-out-to-bottom {
511
+ --tw-exit-translate-y: 100%;
512
+ }
513
+ @utility slide-out-to-bottom-* {
514
+ --tw-exit-translate-y: calc(--value(integer) * var(--spacing));
515
+ --tw-exit-translate-y: calc(--value(--percentage-*, --percentage-translate-*) * 100%);
516
+ --tw-exit-translate-y: calc(--value(ratio) * 100%);
517
+ --tw-exit-translate-y: --value(--translate-*, [percentage], [length]);
518
+ }
519
+ @utility slide-out-to-left {
520
+ --tw-exit-translate-x: -100%;
521
+ }
522
+ @utility slide-out-to-left-* {
523
+ --tw-exit-translate-x: calc(--value(integer) * var(--spacing) * -1);
524
+ --tw-exit-translate-x: calc(--value(--percentage-*, --percentage-translate-*) * -100%);
525
+ --tw-exit-translate-x: calc(--value(ratio) * -100%);
526
+ --tw-exit-translate-x: calc(--value(--translate-*, [percentage], [length]) * -1);
527
+ }
528
+ @utility slide-out-to-right {
529
+ --tw-exit-translate-x: 100%;
530
+ }
531
+ @utility slide-out-to-right-* {
532
+ --tw-exit-translate-x: calc(--value(integer) * var(--spacing));
533
+ --tw-exit-translate-x: calc(--value(--percentage-*, --percentage-translate-*) * 100%);
534
+ --tw-exit-translate-x: calc(--value(ratio) * 100%);
535
+ --tw-exit-translate-x: --value(--translate-*, [percentage], [length]);
536
+ }
537
+ @utility slide-out-to-start {
538
+ &:dir(ltr) {
539
+ --tw-exit-translate-x: -100%;
540
+ }
541
+ &:dir(rtl) {
542
+ --tw-exit-translate-x: 100%;
543
+ }
544
+ }
545
+ @utility slide-out-to-start-* {
546
+ &:where(:dir(ltr), [dir="ltr"], [dir="ltr"] *) {
547
+ --tw-exit-translate-x: calc(--value(integer) * var(--spacing) * -1);
548
+ --tw-exit-translate-x: calc(--value(--percentage-*, --percentage-translate-*) * -100%);
549
+ --tw-exit-translate-x: calc(--value(ratio) * -100%);
550
+ --tw-exit-translate-x: calc(--value(--translate-*, [percentage], [length]) * -1);
551
+ }
552
+ &:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *) {
553
+ --tw-exit-translate-x: calc(--value(integer) * var(--spacing));
554
+ --tw-exit-translate-x: calc(--value(--percentage-*, --percentage-translate-*) * 100%);
555
+ --tw-exit-translate-x: calc(--value(ratio) * 100%);
556
+ --tw-exit-translate-x: --value(--translate-*, [percentage], [length]);
557
+ }
558
+ }
559
+ @utility slide-out-to-end {
560
+ &:dir(ltr) {
561
+ --tw-exit-translate-x: 100%;
562
+ }
563
+ &:dir(rtl) {
564
+ --tw-exit-translate-x: -100%;
565
+ }
566
+ }
567
+ @utility slide-out-to-end-* {
568
+ &:where(:dir(ltr), [dir="ltr"], [dir="ltr"] *) {
569
+ --tw-exit-translate-x: calc(--value(integer) * var(--spacing));
570
+ --tw-exit-translate-x: calc(--value(--percentage-*, --percentage-translate-*) * 100%);
571
+ --tw-exit-translate-x: calc(--value(ratio) * 100%);
572
+ --tw-exit-translate-x: --value(--translate-*, [percentage], [length]);
573
+ }
574
+ &:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *) {
575
+ --tw-exit-translate-x: calc(--value(integer) * var(--spacing) * -1);
576
+ --tw-exit-translate-x: calc(--value(--percentage-*, --percentage-translate-*) * -100%);
577
+ --tw-exit-translate-x: calc(--value(ratio) * -100%);
578
+ --tw-exit-translate-x: calc(--value(--translate-*, [percentage], [length]) * -1);
579
+ }
580
+ }
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../base_generator"
4
+
5
+ module Swage::Generators
6
+ class ScaffoldGenerator < BaseGenerator
7
+ source_root File.expand_path("templates", __dir__)
8
+
9
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
10
+
11
+ class_option :orm, type: :string, default: "active_record"
12
+
13
+ # add json templates as necessary
14
+
15
+ def create_view_files
16
+ actions = %w[index show new edit form partial]
17
+
18
+ actions.each do |action|
19
+ template "#{action}.rb.tt", File.join("app/views", controller_file_path, "#{action}.rb")
20
+ end
21
+ end
22
+
23
+ def create_controller_files
24
+ template "controller.rb.tt", File.join("app/controllers", "#{controller_file_path}_controller.rb")
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,59 @@
1
+ <% if namespaced? -%>
2
+ require_dependency "<%= namespaced_path %>/application_controller"
3
+
4
+ <% end -%>
5
+ <% module_namespacing do -%>
6
+ class <%= controller_class_name %>Controller < ApplicationController
7
+ before_action :set_<%= singular_table_name %>, only: %i[ show edit update destroy ]
8
+
9
+ # GET <%= route_url %>
10
+ def index
11
+ @<%= plural_table_name %> = <%= orm_class.all(class_name) %>
12
+ end
13
+
14
+ # GET <%= route_url %>/1
15
+ def show
16
+ end
17
+
18
+ # GET <%= route_url %>/new
19
+ def new
20
+ @<%= singular_table_name %> = <%= orm_class.build(class_name) %>
21
+ end
22
+
23
+ # GET <%= route_url %>/1/edit
24
+ def edit
25
+ end
26
+
27
+ # POST <%= route_url %>
28
+ def create
29
+ @<%= singular_table_name %> = <%= orm_class.build(class_name) %>
30
+
31
+ if save Views::<%= controller_class_name %>::Form.new(@<%= singular_table_name %>)
32
+ redirect_to @<%= singular_table_name %>, notice: <%= "\"#{human_name} was successfully created.\"" %>
33
+ else
34
+ render Views::<%= controller_class_name %>::New, status: :unprocessable_entity
35
+ end
36
+ end
37
+
38
+ # PATCH/PUT <%= route_url %>/1
39
+ def update
40
+ if save! Views::<%= controller_class_name %>::Form.new(@<%= singular_table_name %>)
41
+ redirect_to @<%= singular_table_name %>, notice: <%= "\"#{human_name} was successfully updated.\"" %>, status: :see_other
42
+ else
43
+ render Views::<%= controller_class_name %>::Edit, status: :unprocessable_entity
44
+ end
45
+ end
46
+
47
+ # DELETE <%= route_url %>/1
48
+ def destroy
49
+ @<%= singular_table_name %>.destroy!
50
+ redirect_to <%= index_helper %>_url, notice: <%= "\"#{human_name} was successfully destroyed.\"" %>, status: :see_other
51
+ end
52
+
53
+ private
54
+ # Use callbacks to share common setup or constraints between actions.
55
+ def set_<%= singular_table_name %>
56
+ @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
57
+ end
58
+ end
59
+ <% end -%>
@@ -0,0 +1,27 @@
1
+ module Views
2
+ module <%= controller_class_name %>
3
+ class Edit < Views::Base
4
+ include Phlexible::Rails::AutoLayout
5
+
6
+ def initialize(<%= singular_table_name %>: nil)
7
+ @<%= singular_table_name %> = <%= singular_table_name %>
8
+ end
9
+
10
+ controller_variable :<%= singular_table_name %>
11
+
12
+ def view_template
13
+ div(class: "mx-auto md:w-2/3 w-full px-8") do
14
+ Heading(level: 1) { "Editing <%= human_name.downcase %>" }
15
+
16
+ render Form.new(@<%= singular_table_name %>)
17
+
18
+ div(class: "mt-6 flex gap-4") do
19
+ Link(href: <%= singular_table_name %>_path(@<%= singular_table_name %>)) { "Show this <%= human_name.downcase %>" }
20
+ span(class: "text-gray-300") { "|" }
21
+ Link(href: <%= plural_table_name %>_path) { "Back to <%= human_name.pluralize.downcase %>" }
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end