sugarcss 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1224 @@
1
+ //
2
+ // Loaders specific
3
+ //
4
+
5
+ @mixin s-loader-grid(
6
+ $props : (),
7
+ $animation : ()
8
+ ) {
9
+ $props : _sugar-parse-properties($props, (
10
+ shape : circle rect,
11
+ color : color,
12
+ colors : list,
13
+ cols : integer,
14
+ rows : integer,
15
+ size : number,
16
+ gap : number,
17
+ offset : number,
18
+ rotate : degree
19
+ ));
20
+ $animation : _sugar-parse-properties($animation, (
21
+ shape : circle rect,
22
+ steps : integer,
23
+ spread : number,
24
+ rotate : number,
25
+ scale : number,
26
+ opacity : number,
27
+ duration : second,
28
+ delay : second,
29
+ ease : string
30
+ ));
31
+
32
+ $color : map-get-or($props, color, red);
33
+ $colors : map-get($props, colors);
34
+ $cols : map-get-or($props, cols, 5);
35
+ $rows : map-get-or($props, rows, 5);
36
+ $size : map-get-or($props, size, 10px);
37
+ $gap : map-get-or($props, gap, 5px);
38
+ $shape : map-get-or($props, shape, rect);
39
+ $offset : map-get-or($props, offset, 200px);
40
+ $rotate : map-get-or($props, rotate, 0);
41
+
42
+ $a-steps : map-get-or($animation, steps, 5);
43
+ $a-spread : map-get($animation, spread);
44
+ $a-rotate : map-get($animation, rotate);
45
+ $a-scale : map-get($animation, scale);
46
+ $a-opacity : map-get($animation, opacity);
47
+ $a-duration : map-get-or($animation, duration, 1s);
48
+ $a-delay : map-get-or($animation, delay, 0s);
49
+ $a-shape : map-get($animation, shape);
50
+ $a-ease : map-get-or($animation, ease, ease-in-out);
51
+
52
+ // manage duration :
53
+ $a-duration : $a-duration + $a-delay;
54
+
55
+ width : $size;
56
+ height : $size;
57
+ @if $shape == circle {
58
+ border-radius: 50%;
59
+ }
60
+
61
+ // position grid
62
+ $width : $size * $cols + $gap * ($cols - 1);
63
+ $height : $size * $rows + $gap * ($rows - 1);
64
+
65
+ // @include s-translate((-$width / 2 - $size - $gap - $offset) (-$height / 2 - $size - $gap - $offset));
66
+ @include s-transform(
67
+ -translateX (-$width / 2 - $size - $gap - $offset)
68
+ -translateY (-$height / 2 - $size - $gap - $offset)
69
+ -rotate $rotate);
70
+ transform-origin: ($offset + $width / 2 + $gap + $size) ($offset + $height / 2 + $gap + $size);
71
+
72
+ $a-name : unquote("grid-#{unique-id()}");
73
+
74
+ // calculate box shadows
75
+ $shadows : ();
76
+ $color-idx : 1;
77
+ @for $i from 0 through $cols - 1 {
78
+ @for $j from 0 through $rows - 1 {
79
+ $x : ($size * $i + $gap * $i) + $size + $gap + $offset;
80
+ $y : ($size * $j + $gap * $j) + $size + $gap + $offset;
81
+ $c : $color;
82
+ @if $colors and length($colors) == $cols * $rows {
83
+ $c : nth($colors, $color-idx);
84
+ $color-idx : $color-idx + 1;
85
+ } @else if length($colors) == 2 {
86
+ @if $j % 2 == 0 {
87
+ $color-idx : $color-idx - 1;
88
+ }
89
+ $c : nth($colors, $color-idx % 2 + 1);
90
+ }
91
+ $shadows : append($shadows, $c $x $y 0 0, comma);
92
+ }
93
+ }
94
+
95
+ &:before {
96
+ @if $shape == circle {
97
+ border-radius: 50%;
98
+ }
99
+ position: relative;
100
+ z-index:1;
101
+ content:'';
102
+ display: block;
103
+ width: $size;
104
+ height: $size;
105
+ animation : $a-name $a-duration $a-ease 0s infinite;
106
+ box-shadow : $shadows;
107
+ transform-origin: ($offset + $width / 2 + $gap + $size) ($offset + $height / 2 + $gap + $size);
108
+ @content;
109
+ }
110
+
111
+ // calculate percentage of delay
112
+ $p-delay : 1 / $a-duration * $a-delay;
113
+ // animation
114
+ @keyframes #{$a-name} {
115
+ @for $i from 1 through $a-steps {
116
+ $percentage : percentage((1 - $p-delay) / $a-steps * $i);
117
+ #{$percentage} {
118
+ // loop on each box shadows
119
+ $shadows : ();
120
+ $color-idx : 1;
121
+ @for $j from 0 through $cols - 1 {
122
+ @for $k from 0 through $rows - 1 {
123
+ $x : ($size * $j + $gap * $j) + $size + $gap + $offset;
124
+ $y : ($size * $k + $gap * $k) + $size + $gap + $offset;
125
+ $s-spread : 0;
126
+ $blur : 0;
127
+ $c : $color;
128
+ @if $colors and length($colors) == $cols * $rows {
129
+ $c : nth($colors, $color-idx);
130
+ $color-idx : $color-idx + 1;
131
+ } @else if length($colors) == 2 {
132
+ @if $j % 2 != 0 {
133
+ $color-idx : $color-idx - 1;
134
+ }
135
+ $c : nth($colors, $color-idx % 2 + 1);
136
+ }
137
+ $transparentize : 0;
138
+ @if $a-opacity and $i < $a-steps {
139
+ $transparentize : 1 - $a-opacity;
140
+ $transparentize : $transparentize * 10;
141
+ $t-rand : random($transparentize);
142
+ $transparentize : $t-rand / 10;
143
+ $c : transparentize($c, $transparentize);
144
+ }
145
+ @if $a-scale {
146
+ @if $i >= $a-steps {
147
+ $s-spread : 0;
148
+ } @else {
149
+ $s-spread : s-rem(random($a-scale - $size) + 0px);
150
+ }
151
+ }
152
+ @if $a-spread and $i < $a-steps {
153
+ $randX : random($a-spread / 2);
154
+ $randY : random($a-spread / 2);
155
+ @if random(10) < 5 {
156
+ $randX : $randX * -1;
157
+ }
158
+ @if random(10) < 5 {
159
+ $randY : $randY * -1;
160
+ }
161
+ $x : $x + $randX;
162
+ $y : $y + $randY;
163
+ }
164
+ @if $i >= $a-steps {
165
+ $shadows : append($shadows, $c $x $y 0 0, comma);
166
+ } @else {
167
+ $shadows : append($shadows, $c $x $y $blur $s-spread, comma);
168
+ }
169
+ }
170
+ }
171
+ @if $a-rotate and $i < $a-steps {
172
+
173
+ $randX : random($a-rotate / 2);
174
+ @if random(10) < 5 {
175
+ $randX : $randX * -1;
176
+ }
177
+ transform : rotateZ($randX + 0deg);
178
+ } @else {
179
+ transform : rotateZ(0);
180
+ }
181
+ @if $i < $a-steps - 1 {
182
+ @if $a-shape == circle {
183
+ @include s-corner(50%);
184
+ } @else if $a-shape == rect {
185
+ @include s-corner(0);
186
+ }
187
+ }
188
+ // apply shadows
189
+ box-shadow: $shadows;
190
+ }
191
+ }
192
+ }
193
+ }
194
+
195
+ @mixin s-loader-spinner(
196
+ $spinner : (),
197
+ $animation : ()
198
+ ) {
199
+ $spinner : _sugar-parse-properties($spinner, (
200
+ type : elastic linear fade-in fade-out fade-in-out,
201
+ size : number,
202
+ width : number,
203
+ color : color,
204
+ bgcolor : color,
205
+ length : number
206
+ ));
207
+ $animation : _sugar-parse-properties($animation, (
208
+ duration : second,
209
+ ease : string
210
+ ));
211
+
212
+
213
+ $type : map-get-or($spinner, type, linear);
214
+ $size : map-get-or($spinner, size, 1em);
215
+ $width : map-get-or($spinner, width, 0.3em);
216
+ $color : map-get-or($spinner, color, red);
217
+ $bgcolor : map-get-or($spinner, bgcolor, inherit);
218
+ $length : map-get-or($animation, length, 3/4);
219
+
220
+ $a-duration : map-get-or($animation, duration, 1s);
221
+ $a-ease : ease;
222
+ @if $type == elastic {
223
+ $a-ease : map-get-or($animation, ease, ease);
224
+ } @else {
225
+ $a-ease : map-get-or($animation, ease, linear);
226
+ }
227
+
228
+
229
+ $a-name : unquote("spinner-#{unique-id()}");
230
+ $p-step : 1 / $a-duration;
231
+
232
+ @if $type == linear {
233
+ & {
234
+ font-size:$size;
235
+ position:relative;
236
+ text-indent:-9999em;
237
+ border-top:$width solid transparentize($color,.8);
238
+ border-right:$width solid transparentize($color,.8);
239
+ border-bottom:$width solid transparentize($color,.8);
240
+ border-left:$width solid transparentize($color,0);
241
+ transform: translateZ(0);
242
+ animation: $a-name $a-duration $a-ease 0s infinite;
243
+ }
244
+ &,&:after {
245
+ border-radius:50%;
246
+ width:1em;
247
+ height:1em;
248
+ }
249
+ @keyframes #{$a-name} {
250
+ 0% {
251
+ transform:rotate(0deg);
252
+ }
253
+ 100% {
254
+ transform:rotate(360deg);
255
+ }
256
+ }
257
+ } @else if $type == elastic {
258
+ background: inherit;
259
+ &,&:before,&:after {
260
+ border-radius:50%;
261
+ }
262
+ &:before,&:after {
263
+ position:absolute;
264
+ content:'';
265
+ }
266
+ &:before {
267
+ width:5.2em;
268
+ height:10.2em;
269
+ background: $bgcolor;
270
+ border-radius: 10.2em 0 0 10.2em;
271
+ top:-0.1em;
272
+ left:-0.1em;
273
+ transform-origin:5.2em 5.1em;
274
+ animation:$a-name $a-duration infinite $a-ease $a-duration * $length;
275
+ }
276
+ & {
277
+ font-size:$size / 10;
278
+ text-indent:-99999em;
279
+ position:relative;
280
+ width:10em;
281
+ height:10em;
282
+ box-shadow: inset 0 0 0 $width $color;
283
+ transform: translateZ(0);
284
+ }
285
+ &:after {
286
+ width:5.2em;
287
+ height:10.2em;
288
+ background: $bgcolor;
289
+ border-radius: 0 10.2em 10.2em 0;
290
+ top:-0.1em;
291
+ left:5.1em;
292
+ transform-origin:0px 5.1em;
293
+ animation:$a-name $a-duration infinite ease;
294
+ }
295
+ @keyframes #{$a-name} {
296
+ 0% {
297
+ transform:rotate(0deg);
298
+ }
299
+ 100% {
300
+ transform:rotate(360deg);
301
+ }
302
+ }
303
+ } @else if $type == fade-out {
304
+ & {
305
+ font-size:$size;
306
+ text-indent:-9999em;
307
+ width:1em;
308
+ height:1em;
309
+ border-radius:50%;
310
+ background: $color;
311
+ background: linear-gradient(to right, transparentize($color,0) 10%, transparentize($color,1) 42%);
312
+ position: relative;
313
+ animation: $a-name $a-duration $a-ease 0s infinite;
314
+ transform: translateZ(0);
315
+ }
316
+ &:before {
317
+ width:50%;
318
+ height:50%;
319
+ background: $color;
320
+ border-radius: 100% 0 0 0;
321
+ position:absolute;
322
+ top:0;
323
+ left:0;
324
+ content:'';
325
+ }
326
+ $width : $size - $width * 2;
327
+ &:after {
328
+ background:$bgcolor;
329
+ width: $width;
330
+ height: $width;
331
+ border-radius:50%;
332
+ content:'';
333
+ margin:auto;
334
+ position: absolute;
335
+ top: 0; left: 0; bottom: 0; right: 0;
336
+ }
337
+ @keyframes #{$a-name} {
338
+ 0% {
339
+ transform:rotate(0deg);
340
+ }
341
+ 100% {
342
+ transform:rotate(360deg);
343
+ }
344
+ }
345
+ } @else if $type == fade-in {
346
+ & {
347
+ font-size:$size;
348
+ text-indent:-9999em;
349
+ width:1em;
350
+ height:1em;
351
+ border-radius:50%;
352
+ background: $color;
353
+ background: linear-gradient(to left, transparentize($color,1) 52%, transparentize($color,0) 90%);
354
+ position: relative;
355
+ animation: $a-name $a-duration $a-ease 0s infinite;
356
+ transform: translateZ(0);
357
+ }
358
+ &:before {
359
+ width:50%;
360
+ height:50%;
361
+ background: $color;
362
+ border-radius: 0 0 0 100%;
363
+ position:absolute;
364
+ bottom:0;
365
+ left:0;
366
+ content:'';
367
+ }
368
+ $width : $size - $width * 2;
369
+ &:after {
370
+ background:$bgcolor;
371
+ width: $width;
372
+ height: $width;
373
+ border-radius:50%;
374
+ content:'';
375
+ margin:auto;
376
+ position: absolute;
377
+ top: 0; left: 0; bottom: 0; right: 0;
378
+ }
379
+ @keyframes #{$a-name} {
380
+ 0% {
381
+ transform:rotate(0deg);
382
+ }
383
+ 100% {
384
+ transform:rotate(360deg);
385
+ }
386
+ }
387
+ } @else if $type == fade-in-out {
388
+ font-size: $size;
389
+ width: 1em;
390
+ height: 1em;
391
+ border-radius: 50%;
392
+ //overflow: hidden;
393
+ &:before {
394
+ content: "";
395
+ position: absolute;
396
+ width: 100%;
397
+ height: 100%;
398
+ border-radius: 50%;
399
+ background: linear-gradient($color, transparentize($color,1) 60%);
400
+ animation: $a-name $a-duration infinite linear;
401
+ }
402
+ $width : $size - $width * 2;
403
+ &:after {
404
+ background:$bgcolor;
405
+ width: $width;
406
+ height: $width;
407
+ border-radius:50%;
408
+ content:'';
409
+ margin:auto;
410
+ position: absolute;
411
+ top: 0; left: 0; bottom: 0; right: 0;
412
+ }
413
+ @keyframes #{$a-name} {
414
+ to {
415
+ transform: rotate(360deg);
416
+ }
417
+ }
418
+ }
419
+ }
420
+
421
+ @mixin s-loader-circle(
422
+ $props : (),
423
+ $animation : ()
424
+ ) {
425
+ $props : _sugar-parse-properties($props, (
426
+ color : color,
427
+ colors : list,
428
+ size : number,
429
+ radius : number,
430
+ count : integer,
431
+ opacity : number
432
+ ));
433
+ $animation : _sugar-parse-properties($animation, (
434
+ shape : circle rect,
435
+ spread : number,
436
+ rotate : number,
437
+ scale : number,
438
+ opacity : number,
439
+ near : integer,
440
+ ease : string,
441
+ duration : second,
442
+ delay : second
443
+ ));
444
+ $color : map-get-or($props, color, red);
445
+ $colors : map-get($props, colors);
446
+ $size : map-get-or($props, size, 10px);
447
+ $radius : map-get-or($props, radius, 30px);
448
+ $count : map-get-or($props, count, 8);
449
+ $opacity : map-get-or($props, opacity, 1);
450
+
451
+ $a-name : unquote("circle-#{unique-id()}");
452
+ $a-spread : map-get-or($animation, spread, null);
453
+ $a-rotate : map-get-or($animation, rotate, null);
454
+ $a-scale : map-get-or($animation, scale, null);
455
+ $a-opacity : map-get-or($animation, opacity, null);
456
+ $a-near : map-get-or($animation, near, round($count / 2));
457
+ $a-ease : map-get-or($animation, ease, ease-in-out);
458
+ $a-duration : map-get-or($animation, duration, 1s);
459
+ $a-delay : map-get-or($animation, delay, 0s);
460
+
461
+ // manage duration
462
+ $a-duration : $a-duration + $a-delay;
463
+
464
+ $base-shadows : ();
465
+ @for $i from 0 through $count {
466
+ $x : $radius * s-cos(360deg / $count * $i);
467
+ $y : $radius * s-sin(360deg / $count * $i);
468
+ $c : $color;
469
+ @if $colors {
470
+ $c : nth($colors, $i + 1);
471
+ }
472
+ @if $opacity {
473
+ $c : transparentize($c, 1 - $opacity);
474
+ }
475
+ $base-shadows : append($base-shadows, $c $x $y 0 0, comma);
476
+ }
477
+
478
+ $spread-map : ();
479
+ // calculate percentage of delay
480
+ $p-delay : 0;
481
+ $p-step : 1 / $count;
482
+ @if $a-delay > 0 {
483
+ $p-delay : 1 / $a-duration * $a-delay;
484
+ $p-step : (1 - $p-delay) / ($count + 1);
485
+ }
486
+ // animation
487
+ @keyframes #{$a-name} {
488
+ @for $step-idx from 0 through $count {
489
+ $p : percentage($step-idx * $p-step);
490
+ @if $a-delay > 0 {
491
+ $p : percentage($step-idx * $p-step) + percentage($p-step);
492
+ }
493
+ #{$p} {
494
+ $shadows : ();
495
+ @for $count-idx from 0 through $count {
496
+ $x : $radius * s-cos(360deg / $count * $count-idx);
497
+ $y : $radius * s-sin(360deg / $count * $count-idx);
498
+
499
+ $diff : abs($step-idx - $count-idx);
500
+ @if $step-idx + $a-near > $count and $count-idx - $a-near < 0 {
501
+ $diff : abs($count-idx - ($step-idx - $count));
502
+ } @else if $step-idx - $a-near < 0 and $count-idx + $a-near > $count {
503
+ $diff : abs($step-idx + ($count - $count-idx));
504
+ }
505
+
506
+ $c : $color;
507
+ @if $colors {
508
+ $c : nth($colors, $count-idx + 1);
509
+ }
510
+ $_opacity : 1;
511
+ @if $a-opacity {
512
+ @if $diff < $a-near {
513
+ $_opacity : ($a-opacity - $opacity) / $a-near * ($a-near - $diff);
514
+ $o : $opacity + $_opacity;
515
+ // $transparentize : $_opacity;
516
+ $c : transparentize($c, 1 - $o);
517
+ } @else if $opacity {
518
+ $c : transparentize($c, 1 - $opacity);
519
+ }
520
+ } @else if $opacity {
521
+ $c : transparentize($c, 1 - $opacity);
522
+ }
523
+ $scale : $size;
524
+ @if $a-scale {
525
+ @if $diff == 0 {
526
+ $scale : $a-scale;
527
+ } @else if $diff <= $a-near {
528
+ $s : $a-scale - $size;
529
+ $scale : $size + $s - $s / $a-near * $diff;
530
+ }
531
+ }
532
+ @if $a-spread and $diff < $a-near {
533
+ $randX : random(round($a-spread / 2));
534
+ $randY : random(round($a-spread / 2));
535
+ @if random(10) < 5 {
536
+ $randX : $randX * -1;
537
+ }
538
+ @if random(10) < 5 {
539
+ $randY : $randY * -1;
540
+ }
541
+ @if $step-idx == 0 {
542
+ $s : (
543
+ x : $randX,
544
+ y : $randY
545
+ );
546
+ $spread-map : map-set($spread-map, $count-idx, $s);
547
+ }
548
+ @if $step-idx == $count {
549
+ $map : map-get($spread-map, $count-idx);
550
+ @if $map {
551
+ $randX : map-get($map, x);
552
+ $randY : map-get($map, y);
553
+ } @else {
554
+ $randX : 0;
555
+ $randY : 0;
556
+ }
557
+ }
558
+ $x : $x + $randX;
559
+ $y : $y + $randY;
560
+ }
561
+ @if $count-idx < $count {
562
+ $shadows : append($shadows, $x $y 0 ($scale - $size) $c, comma);
563
+ }
564
+ }
565
+ box-shadow : $shadows;
566
+ }
567
+ }
568
+ @if $a-delay > 0 and percentage($count * $p-step) + percentage($p-step) < 100 {
569
+ #{percentage($count * $p-step) + percentage($p-step) * 2} {
570
+ box-shadow: $base-shadows;
571
+ }
572
+ }
573
+ }
574
+ &:after {
575
+ border-radius:50%;
576
+ width : $size;
577
+ height : $size;
578
+ display : block;
579
+ content : '';
580
+ box-shadow: $base-shadows;
581
+ animation : $a-name $a-duration $a-ease 0s infinite;
582
+ }
583
+ // @include s-translate(-50% -50%);
584
+ // transform: rotate(- 360deg / $count / 2);
585
+ @include s-transform(-translateX -50% -translateY -50% -rotate -90deg);
586
+ }
587
+
588
+ @mixin s-loader-radial(
589
+ $props : (),
590
+ $animation : ()
591
+ ) {
592
+ $props : _sugar-parse-properties($props, (
593
+ shape : circle rect,
594
+ size : number,
595
+ width : number,
596
+ style : dotted dashed solid double groove ridge inset outset initial inherit,
597
+ color : color,
598
+ colors : list
599
+ ));
600
+ $animation : _sugar-parse-properties($animation, (
601
+ duration : second,
602
+ delay : second,
603
+ count : integer,
604
+ spread : number,
605
+ ease : string
606
+ ));
607
+ $shape : map-get-or($props, shape, circle);
608
+ $size : map-get-or($props, size, 1em);
609
+ $width : map-get-or($props, width, 0.2em);
610
+ $style : map-get-or($props, style, solid);
611
+ $color : map-get-or($props, color, red);
612
+ $colors : map-get($props, colors);
613
+
614
+ $a-ease : map-get-or($animation, ease, linear);
615
+ $a-count : map-get-or($animation, count, 2);
616
+ $a-duration : map-get-or($animation, duration, 2s);
617
+ $a-delay : map-get-or($animation, delay, 0s);
618
+ $a-spread : map-get-or($animation, spread, 0);
619
+
620
+ // manage duration
621
+ $a-duration : $a-duration + $a-delay;
622
+
623
+ // calculate percentage of delay
624
+ $p-delay : 1;
625
+ @if $a-delay > 0 {
626
+ $p-delay : 1 - 1 / $a-duration * $a-delay;
627
+ }
628
+
629
+ $a-name : unquote("radial-#{unique-id()}");
630
+ $step : percentage($p-delay / $a-count);
631
+ $current : 0%;
632
+ $current-idx : 1;
633
+ @keyframes #{$a-name}-b {
634
+ @for $i from 0 through $a-count - 1 {
635
+ @if $current < 100 {
636
+ #{$current} {
637
+ @include s-transform(-translateX -50% -translateY -50% -scaleX 0 -scaleY 0);
638
+ opacity:0;
639
+ top : 0;
640
+ left : 0;
641
+ @if $colors and length($colors) == $a-count * 2 {
642
+ $c : nth($colors, $current-idx);
643
+ border-color: $c;
644
+ // background: radial-gradient(transparentize($c, 1) 30%, $c 50%, transparentize($c, 1) 70%);
645
+ }
646
+ }
647
+ #{$current + $step / 2 - 0.0001%} {
648
+ @include s-transform(-translateX -50% -translateY -50% -scaleX 0.5 -scaleY 0.5);
649
+ opacity:1;
650
+ @if $colors and length($colors) == $a-count * 2 {
651
+ $c : nth($colors, $current-idx);
652
+ border-color: $c;
653
+ // background: radial-gradient(transparentize($c, 1) 30%, $c 50%, transparentize($c, 1) 70%);
654
+ }
655
+ }
656
+ #{$current + $step - 0.0001%} {
657
+ @include s-transform(-translateX -50% -translateY -50% -scaleX 1 -scaleY 1);
658
+ opacity:0;
659
+ @if $a-spread > 0 {
660
+ $randX : random(round($a-spread));
661
+ @if random(10) < 5 {
662
+ $randX : $randX * -1;
663
+ }
664
+ $randY : random(round($a-spread));
665
+ @if random(10) < 5 {
666
+ $randY : $randY * -1;
667
+ }
668
+ top : $randY + unquote(unit($a-spread));
669
+ left : $randX + unquote(unit($a-spread));
670
+ }
671
+ @if $colors and length($colors) == $a-count * 2 {
672
+ $c : nth($colors, $current-idx);
673
+ border-color: $c;
674
+ // background: radial-gradient(transparentize($c, 1) 30%, $c 50%, transparentize($c, 1) 70%);
675
+ }
676
+ }
677
+ #{$current + $step} {
678
+ @include s-transform(-translateX -50% -translateY -50% -scaleX 0 -scaleY 0);
679
+ top: 0;
680
+ left: 0;
681
+ }
682
+ }
683
+ $current : $current + $step;
684
+ $current-idx : $current-idx + 2;
685
+ }
686
+ }
687
+ $current : 0%;
688
+ $current-idx : 2;
689
+ @keyframes #{$a-name}-a {
690
+ @for $i from 0 through $a-count - 1 {
691
+ @if $current < 100 {
692
+ #{$current} {
693
+ @include s-transform(-translateX -50% -translateY -50% -scaleX 0 -scaleY 0);
694
+ opacity:0;
695
+ top : 0;
696
+ left : 0;
697
+ @if $colors and length($colors) == $a-count * 2 {
698
+ $c : nth($colors, $current-idx);
699
+ border-color: $c;
700
+ //background: radial-gradient(transparentize($c, 1) 30%, $c 50%, transparentize($c, 1) 70%);
701
+ }
702
+ }
703
+ #{$current + $step / 2 - 0.0001%} {
704
+ @include s-transform(-translateX -50% -translateY -50% -scaleX 0.5 -scaleY 0.5);
705
+ opacity:1;
706
+ @if $colors and length($colors) == $a-count * 2 {
707
+ $c : nth($colors, $current-idx);
708
+ border-color: $c;
709
+ // background: radial-gradient(transparentize($c, 1) 30%, $c 50%, transparentize($c, 1) 70%);
710
+ }
711
+ }
712
+ #{$current + $step - 0.0001%} {
713
+ @include s-transform(-translateX -50% -translateY -50% -scaleX 1 -scaleY 1);
714
+ opacity:0;
715
+ @if $a-spread > 0 {
716
+ $randX : random(round($a-spread));
717
+ @if random(10) < 5 {
718
+ $randX : $randX * -1;
719
+ }
720
+ $randY : random(round($a-spread));
721
+ @if random(10) < 5 {
722
+ $randY : $randY * -1;
723
+ }
724
+ top : $randY + unquote(unit($a-spread));
725
+ left : $randX + unquote(unit($a-spread));
726
+ }
727
+ @if $colors and length($colors) == $a-count * 2 {
728
+ $c : nth($colors, $current-idx);
729
+ // background: radial-gradient(transparentize($c, 1) 30%, $c 50%, transparentize($c, 1) 70%);
730
+ border-color : $c;
731
+ }
732
+ }
733
+ #{$current + $step} {
734
+ @include s-transform(-translateX -50% -translateY -50% -scaleX 0 -scaleY 0);
735
+ top: 0;
736
+ left: 0;
737
+ }
738
+ }
739
+ $current : $current + $step;
740
+ $current-idx : $current-idx + 2;
741
+ }
742
+ }
743
+
744
+ position: relative;
745
+ &:before,
746
+ &:after {
747
+ content:'';
748
+ display: block;
749
+ width:$size;
750
+ height:$size;
751
+ position: absolute;
752
+ top:0; left:0;
753
+ @include s-translate(-50% -50%);
754
+ opacity:0;
755
+ @if $shape == circle {
756
+ border-radius:50%;
757
+ }
758
+ @content;
759
+ }
760
+ // cubic-bezier(1,.01,0,1)
761
+ $c : $color;
762
+ @if $colors and length($colors) == 2 {
763
+ $c : nth($colors, 1);
764
+ }
765
+ &:before {
766
+ border:$width $style $c;
767
+ // background: radial-gradient(transparentize($c, 1) 30%, $c 50%, transparentize($c, 1) 70%);
768
+ animation: #{$a-name}-b $a-duration $a-ease 0s infinite;
769
+ }
770
+ @if $colors and length($colors) == 2 {
771
+ $c : nth($colors, 2);
772
+ }
773
+ &:after {
774
+ border: $width $style $c;
775
+ // background: radial-gradient(transparentize($c, 1) 30%, $c 50%, transparentize($c, 1) 70%);
776
+ animation: #{$a-name}-a $a-duration $a-ease ($a-duration - $a-delay) / $a-count / 2 infinite;
777
+ }
778
+ }
779
+
780
+ @mixin s-loader-bars(
781
+ $props : (),
782
+ $animation : ()
783
+ ) {
784
+ $props : _sugar-parse-properties($props, (
785
+ shape : circle rect,
786
+ color : color,
787
+ colors : list,
788
+ width : number,
789
+ height : number,
790
+ count : integer,
791
+ gap : number,
792
+ opacity : number
793
+ ));
794
+ $animation : _sugar-parse-properties($animation, (
795
+ direction : up down both,
796
+ opacity : number,
797
+ duration : second,
798
+ delay : second,
799
+ near : integer,
800
+ ease : string,
801
+ spread : number,
802
+ continuous : true
803
+ ));
804
+
805
+ $shape : map-get-or($props, shape, rect);
806
+ $color : map-get-or($props, color, red);
807
+ $colors : map-get($props, colors);
808
+ $count : map-get-or($props, count, 5);
809
+ $width : map-get-or($props, width, 0.5em);
810
+ $height : map-get-or($props, height, 2em);
811
+ $gap : map-get-or($props, gap, 0.5em);
812
+ $opacity : map-get-or($props, opacity, 1);
813
+
814
+ $a-opacity : map-get($animation, opacity);
815
+ $a-duration : map-get-or($animation, duration, 1s);
816
+ $a-delay : map-get-or($animation, delay, 0s);
817
+ $a-near : map-get-or($animation, near, 1);
818
+ $a-ease : map-get-or($animation, ease, ease-in-out);
819
+ $a-spread : map-get-or($animation, spread, null);
820
+ $a-direction : map-get-or($animation, direction, both);
821
+ $a-continuous : map-get-or($animation, continuous, true);
822
+
823
+ // manage duration
824
+ $a-duration : $a-duration + $a-delay;
825
+ @if $a-delay > 0 {
826
+ $a-continuous : false;
827
+ }
828
+
829
+ // manage direction
830
+ @if not $a-spread or $a-spread <= 0 {
831
+ $a-direction : up;
832
+ }
833
+
834
+ $offset : $width;
835
+
836
+ // position grid
837
+ $_width : $width * ($count - 1) + $gap * ($count - 1);
838
+
839
+ $a-name : unquote("bars-#{unique-id()}");
840
+
841
+ // calculate box shadows
842
+ $shadows : ();
843
+
844
+ @if $a-direction == both or $a-direction == up {
845
+ @for $i from 0 through $count - 1 {
846
+ $x : ($width * $i + $gap * $i) + $width + $gap + $offset;
847
+ $y : $height / 2 + $offset;
848
+ $c : $color;
849
+ @if $colors {
850
+ $c : nth($colors, $i + 1);
851
+ }
852
+ @if $a-opacity {
853
+ $c : transparentize($color, 1 - $opacity);
854
+ }
855
+ $shadows : append($shadows, $c $x $y 0 0, comma);
856
+ }
857
+ }
858
+ @if $a-direction == both or $a-direction == down {
859
+ @for $i from 0 through $count - 1 {
860
+ $x : ($width * $i + $gap * $i) + $width + $gap + $offset;
861
+ $y : $height / 2 + $offset;
862
+ $c : $color;
863
+ @if $colors {
864
+ $c : nth($colors, $i + 1);
865
+ }
866
+ @if $a-opacity {
867
+ $c : transparentize($color, 1 - $opacity);
868
+ }
869
+ $shadows : append($shadows, $c $x $y 0 0, comma);
870
+ }
871
+ }
872
+ $base-shadows : $shadows;
873
+
874
+ &:before {
875
+ @if $shape == circle {
876
+ border-radius: 50%;
877
+ }
878
+ width: $width;
879
+ height: $height;
880
+ content: '';
881
+ display: block;
882
+ animation : $a-name $a-duration $a-ease 0s infinite;
883
+ box-shadow : $shadows;
884
+ @include s-translate((-$_width / 2 - $width - $gap - $offset) (-$height / 2 - $offset));
885
+ transform-origin: ($offset + $_width / 2 + $gap + $width) ($offset + $height / 2);
886
+ @content;
887
+ }
888
+
889
+ // calculate percentage of delay
890
+ $p-delay : 0;
891
+ $p-step : 1 / $count;
892
+ @if $a-delay > 0 {
893
+ $p-delay : 1 / $a-duration * $a-delay;
894
+ $p-step : (1 - $p-delay) / ($count + 1);
895
+ }
896
+ // animation
897
+ $step : 1 / $count;
898
+ @keyframes #{$a-name} {
899
+ @for $j from 0 through $count {
900
+ $p : percentage($j * $p-step);
901
+ @if $a-delay > 0 {
902
+ $p : percentage($j * $p-step) + percentage($p-step);
903
+ }
904
+ #{$p} {
905
+ // loop on each box shadows
906
+ $shadows : ();
907
+
908
+ @if $a-direction == both or $a-direction == up {
909
+ @for $i from 0 through $count - 1 {
910
+ $x : ($width * $i + $gap * $i) + $width + $gap + $offset;
911
+ $y : $height / 2 + $offset;
912
+
913
+ $diff : abs($j - $i);
914
+
915
+ @if $a-continuous {
916
+ @if $j + $a-near > $count and $i - $a-near < 0 {
917
+ $diff : abs($i - ($j - $count));
918
+ } @else if $j - $a-near < 0 and $i + $a-near > $count {
919
+ $diff : abs($j + ($count - $i));
920
+ }
921
+ }
922
+
923
+ @if $a-spread {
924
+ @if $diff < $a-near {
925
+ $y : $y - ($a-spread - ($a-spread / $a-near * $diff));
926
+ } @else if $i == $j {
927
+ $y : $y - $a-spread;
928
+ }
929
+ }
930
+
931
+ $c : $color;
932
+ @if $colors {
933
+ $c : nth($colors, $i + 1);
934
+ }
935
+ $_opacity : 1;
936
+ @if $a-opacity {
937
+ @if $diff < $a-near {
938
+ $_opacity : ($a-opacity - $opacity) / $a-near * ($a-near - $diff);
939
+ $o : $opacity + $_opacity;
940
+ // $transparentize : $_opacity;
941
+ $c : transparentize($c, 1 - $o);
942
+ } @else if $opacity {
943
+ $c : transparentize($c, 1 - $opacity);
944
+ }
945
+ } @else if $opacity {
946
+ $c : transparentize($c, 1 - $opacity);
947
+ }
948
+ $shadows : append($shadows, $c $x $y 0 0, comma);
949
+ }
950
+ }
951
+
952
+ @if $a-direction == both or $a-direction == down {
953
+ @for $i from 0 through $count - 1 {
954
+ $x : ($width * $i + $gap * $i) + $width + $gap + $offset;
955
+ $y : $height / 2 + $offset;
956
+
957
+ $diff : abs($j - $i);
958
+ @if $a-continuous {
959
+ @if $j + $a-near > $count and $i - $a-near < 0 {
960
+ $diff : abs($i - ($j - $count));
961
+ } @else if $j - $a-near < 0 and $i + $a-near > $count {
962
+ $diff : abs($j + ($count - $i));
963
+ }
964
+ }
965
+
966
+ @if $diff < $a-near {
967
+ $y : $y + ($a-spread - ($a-spread / $a-near * $diff));
968
+ } @else if $i == $j {
969
+ $y : $y + $a-spread;
970
+ }
971
+ $c : $color;
972
+ @if $colors {
973
+ $c : nth($colors, $i + 1);
974
+ }
975
+ $_opacity : 1;
976
+ @if $a-opacity {
977
+ @if $diff < $a-near {
978
+ $_opacity : ($a-opacity - $opacity) / $a-near * ($a-near - $diff);
979
+ $o : $opacity + $_opacity;
980
+ // $transparentize : $_opacity;
981
+ $c : transparentize($c, 1 - $o);
982
+ } @else if $opacity {
983
+ $c : transparentize($c, 1 - $opacity);
984
+ }
985
+ } @else if $opacity {
986
+ $c : transparentize($c, 1 - $opacity);
987
+ }
988
+ $shadows : append($shadows, $c $x $y 0 0, comma);
989
+ }
990
+ }
991
+
992
+ // apply shadows
993
+ box-shadow: $shadows;
994
+ }
995
+ }
996
+ @if $a-delay > 0 and percentage($count * $p-step) + percentage($p-step) < 100 {
997
+ #{percentage($count * $p-step) + percentage($p-step) * 2} {
998
+ box-shadow: $base-shadows;
999
+ }
1000
+ }
1001
+ }
1002
+ }
1003
+
1004
+ @mixin s-loader-couch-potato(
1005
+ $props : (),
1006
+ $animation : ()
1007
+ ) {
1008
+ $props : _sugar-parse-properties($props, (
1009
+ size : number,
1010
+ color : color,
1011
+ colors : list
1012
+ ));
1013
+
1014
+ $animation : _sugar-parse-properties($animation, (
1015
+ duration : second,
1016
+ delay : second,
1017
+ ease : string,
1018
+ rotate : degree,
1019
+ scale : number
1020
+ ));
1021
+
1022
+ $size : map-get-or($props, size, 1em);
1023
+ $color : map-get-or($props, color, red);
1024
+ $colors : map-get($props, colors);
1025
+
1026
+ $a-duration : map-get-or($animation, duration, 1s);
1027
+ $a-delay : map-get-or($animation, delay, 0s);
1028
+ $a-ease : map-get-or($animation, ease, ease-in-out);
1029
+ $a-rotate : map-get-or($animation, rotate, 360deg);
1030
+ $a-scale : map-get-or($animation, scale, 0.7);
1031
+
1032
+ $a-duration : $a-duration + $a-delay;
1033
+
1034
+ $a-name : unquote("couch-potato-#{unique-id()}");
1035
+
1036
+ $c : $color;
1037
+ @if $colors and length($colors) == 2 {
1038
+ $c : nth($colors, 1);
1039
+ }
1040
+ &:before {
1041
+ display: block;
1042
+ width : $size;
1043
+ height: $size;
1044
+ content:'';
1045
+ @include s-translate(-50% -50%);
1046
+ background: $c;
1047
+ transform-origin: $size/2 $size/2;
1048
+ animation: $a-name $a-duration $a-ease 0s infinite;
1049
+ }
1050
+
1051
+ $p-delay : 0;
1052
+ @if $a-delay > 0 {
1053
+ $p-delay : 1 / $a-duration * $a-delay;
1054
+ }
1055
+ @keyframes #{$a-name} {
1056
+ 0% {
1057
+ border-radius:0;
1058
+ @include s-transform(-rotate 0deg -scale 1);
1059
+ }
1060
+ #{(100% - percentage($p-delay)) / 2} {
1061
+ border-radius:50%;
1062
+ @include s-transform(-rotate $a-rotate / 2 -scale $a-scale);
1063
+ @if $colors and length($colors) == 2 {
1064
+ $c : nth($colors, 2);
1065
+ }
1066
+ background: $c;
1067
+ }
1068
+ #{100% - percentage($p-delay)} {
1069
+ border-radius:0;
1070
+ @include s-transform(-rotate $a-rotate -scale 1);
1071
+ @if $colors and length($colors) == 2 {
1072
+ $c : nth($colors, 1);
1073
+ }
1074
+ background: $c;
1075
+ }
1076
+ 100% {
1077
+ border-radius:0;
1078
+ @include s-transform(-rotate $a-rotate -scale 1);
1079
+ }
1080
+ }
1081
+ }
1082
+
1083
+ @mixin s-loader-flip-ball(
1084
+ $props : (),
1085
+ $animation : ()
1086
+ ) {
1087
+ $props : _sugar-parse-properties($props, (
1088
+ shape : circle rect,
1089
+ size : number,
1090
+ color : color,
1091
+ colors : list
1092
+ ));
1093
+
1094
+ $animation : _sugar-parse-properties($animation, (
1095
+ duration : second,
1096
+ delay : second,
1097
+ ease : string
1098
+ ));
1099
+
1100
+ $shape : map-get-or($props, shape, circle);
1101
+ $size : map-get-or($props, size, 1em);
1102
+ $color : map-get-or($props, color, red);
1103
+ $colors : map-get($props, colors);
1104
+
1105
+ $a-duration : map-get-or($animation, duration, 1s);
1106
+ $a-delay : map-get-or($animation, delay, 0s);
1107
+ $a-ease : map-get-or($animation, ease, ease-in-out);
1108
+
1109
+ $a-duration : $a-duration + $a-delay;
1110
+
1111
+ $a-name : unquote("google-ball-#{unique-id()}");
1112
+
1113
+ $c : $color;
1114
+ @if $colors {
1115
+ $c : nth($colors, length($colors));
1116
+ }
1117
+
1118
+ display: inline-block;
1119
+ background: $c;
1120
+ width: $size;
1121
+ height: $size;
1122
+ @if $shape == circle {
1123
+ border-radius: 50%;
1124
+ }
1125
+ animation: #{$a-name}-rotate $a-duration $a-ease 0s infinite;
1126
+ position: relative;
1127
+
1128
+ &:after,
1129
+ &:before {
1130
+ display: block;
1131
+ width : $size;
1132
+ height: $size/2;
1133
+ @if $shape == circle {
1134
+ border-radius: $size $size 0 0;
1135
+ }
1136
+ content:'';
1137
+ background: $c;
1138
+ transform-origin: $size / 2 $size / 2;
1139
+ position: absolute;
1140
+ top: 0; left:0;
1141
+ }
1142
+ &:after {
1143
+ animation: #{$a-name}-after $a-duration $a-ease 0s infinite;
1144
+ // display: none;
1145
+ }
1146
+ &:before {
1147
+ animation: #{$a-name}-before $a-duration $a-ease 0s infinite;
1148
+ // background : white;
1149
+ }
1150
+
1151
+ $p-delay : 0;
1152
+ @if $a-delay > 0 {
1153
+ $p-delay : 1 / $a-duration * $a-delay;
1154
+ }
1155
+ $steps : 2;
1156
+ @if $colors {
1157
+ $steps : length($colors);
1158
+ }
1159
+
1160
+ @keyframes #{$a-name}-after {
1161
+ @for $i from 1 through $steps {
1162
+ #{percentage(1 / $steps * $i) - 0.0001%} {
1163
+ @include s-transform(-rotateX 180deg);
1164
+ }
1165
+ #{percentage(1 / $steps * $i)} {
1166
+ background: nth($colors, $i);
1167
+ @include s-transform(-rotateX 0deg);
1168
+ }
1169
+ #{percentage(1 / $steps * $i) - percentage(1 / $steps) / 2} {
1170
+ $c : null;
1171
+ @if $i - 1 <= 0 {
1172
+ $c : nth($colors, length($colors));
1173
+ } @else {
1174
+ $c : nth($colors, $i - 1);
1175
+ }
1176
+ background: s-color($c, -darken 10%);
1177
+ }
1178
+ #{(percentage(1 / $steps * $i) - percentage(1 / $steps) / 2 + 0.0001%)} {
1179
+ $c : null;
1180
+ @if $i + 1 > length($colors) {
1181
+ $c : nth($colors, 1);
1182
+ } @else {
1183
+ $c : nth($colors, $i + 1);
1184
+ }
1185
+ background: s-color(nth($colors, $i), -lighten 8%);
1186
+ }
1187
+ }
1188
+ }
1189
+ @keyframes #{$a-name}-before {
1190
+ @for $i from 1 through $steps {
1191
+ #{percentage(1 / $steps * $i) - 0.0001%} {
1192
+ background: nth($colors, $i);
1193
+ }
1194
+ #{percentage(1 / $steps * $i)} {
1195
+ $c : null;
1196
+ @if $i + 1 > length($colors) {
1197
+ $c : nth($colors, 1);
1198
+ } @else {
1199
+ $c : nth($colors, $i + 1);
1200
+ }
1201
+ background: $c;
1202
+ }
1203
+ }
1204
+ }
1205
+ @keyframes #{$a-name}-rotate {
1206
+ @for $i from 1 through $steps {
1207
+ #{percentage(1 / $steps * $i) - 0.0001%} {
1208
+ @include s-transform(-rotate ($i - 1) * 90deg);
1209
+ $c : null;
1210
+ @if $i - 1 <= 0 {
1211
+ $c : nth($colors, length($colors));
1212
+ background: $c;
1213
+ } @else {
1214
+ $c : nth($colors, $i - 1);
1215
+ background: $c;
1216
+ }
1217
+ }
1218
+ #{percentage(1 / $steps * $i)} {
1219
+ @include s-transform(-rotate $i * 90deg);
1220
+ background: nth($colors, $i);
1221
+ }
1222
+ }
1223
+ }
1224
+ }