@appartmint/css-mint 0.0.37 → 0.0.39

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/src/util.scss DELETED
@@ -1,715 +0,0 @@
1
- /// _util.scss - Variables, Functions, and Mixins to import elsewhere
2
- /// @author App Art Mint LLC
3
- ///
4
- /// @group Util
5
-
6
- /// Imports
7
- @use 'sass:color';
8
- @use 'sass:list';
9
- @use 'sass:map';
10
- @use 'sass:math';
11
- @use 'sass:meta';
12
- @use 'sass:string';
13
- @use 'sass:selector';
14
-
15
- /// Library name
16
- /// @group Variables
17
- /// @type String
18
- $lib: mint !default;
19
-
20
- /// Prefix added to selectors
21
- /// @group Variables
22
- /// @type String
23
- $pre: #{$lib}-;
24
-
25
- /// CSS-selector for disabled elements
26
- /// @group Variables
27
- /// @type String
28
- $disabled: #{'[disabled]'};
29
-
30
- /// CSS-selector for elements with an aria-controls attribute
31
- /// @group Variables
32
- /// @type String
33
- $has-controls: #{'[aria-controls]'};
34
-
35
- /// CSS-selector for elements with an aria-expanded attribute
36
- /// @group Variables
37
- /// @type String
38
- $has-expanded: #{'[aria-expanded]'};
39
-
40
- /// CSS-selector for elements with an aria-hidden attribute
41
- /// @group Variables
42
- /// @type String
43
- $has-hidden: #{'[aria-hidden]'};
44
-
45
- /// CSS-selector for elements with an href attribute
46
- /// @group Variables
47
- /// @type String
48
- $has-link: #{'[href]'};
49
-
50
- /// CSS-selector for elements with a routerLink attribute
51
- /// @group Variables
52
- /// @type String
53
- $has-router-link: #{'[routerLink]'};
54
-
55
- /// CSS-selector for elements with an id attribute
56
- /// @group Variables
57
- /// @type String
58
- $has-id: #{'[id]'};
59
-
60
- /// CSS-selector for elements that aren't tabbable (i.e. tabindex is negative)
61
- /// @group Variables
62
- /// @type String
63
- $not-tabbable: #{'[tabindex^="-"]'};
64
-
65
- /// CSS-selector for elements that are tabbable (i.e. tabindex isn't negative)
66
- /// @group Variables
67
- /// @type String
68
- $tabbable: #{'[tabindex]'}#{neg($not-tabbable)};
69
-
70
- /// CSS-selector for submenu buttons
71
- /// @group Variables
72
- /// @type String
73
- $sub-menu-buttons: #{'button'}#{$has-controls};
74
-
75
- /// CSS-selector for submenus
76
- /// @group Variables
77
- /// @type String
78
- $sub-menu: #{$sub-menu-buttons}#{' + ul'}#{$has-id};
79
-
80
- /// Value added to all time variables
81
- /// @group Variables
82
- /// @type Number
83
- $time-base: 0 !default;
84
-
85
- /// Value added to all time variables
86
- /// @group Variables
87
- /// @type Number
88
- $time-step: 100 !default;
89
-
90
- /// Time variables
91
- /// @group Maps
92
- /// @prop {Number} $time.instant [0] - Instant: the quickest time; close or equal to 0
93
- /// @prop {Number} $time.faster [100] - Faster: times that happen faster
94
- /// @prop {Number} $time.fast [200] - Fast: times that happen quickly
95
- /// @prop {Number} $time.default [300] - Default: times that are average
96
- /// @prop {Number} $time.slow [400] - Slow: times that happen slower
97
- /// @prop {Number} $time.slower [500] - Slower: times that happen slowly
98
- $time: (
99
- instant: $time-base + $time-step * 0,
100
- faster: $time-base + $time-step * 1,
101
- fast: $time-base + $time-step * 2,
102
- default: $time-base + $time-step * 3,
103
- slow: $time-base + $time-step * 4,
104
- slower: $time-base + $time-step * 5
105
- ) !default;
106
-
107
- /// Breakpoint variables
108
- /// @group Maps
109
- /// @prop {Number} $break.xs [480] - Extra-Small: mobile devices
110
- /// @prop {Number} $break.sm [768] - Small: small tablets, landscape mobiles
111
- /// @prop {Number} $break.md [1024] - Medium: small desktops, large tablets
112
- /// @prop {Number} $break.lg [1200] - Large: large desktops, landscape tablets
113
- /// @prop {Number} $break.xl [1440] - Extra-Large: larger desktops
114
- $break: (
115
- xs: 480,
116
- sm: 768,
117
- md: 1024,
118
- lg: 1200,
119
- xl: 1440
120
- ) !default;
121
-
122
- /// Prefixes the provided string with the library name if it isn't already
123
- /// @group Functions
124
- ///
125
- /// @param {String} $base - the string to be prefixed
126
- /// @return {String} - a prefixed string
127
- @function prefix ($base) {
128
- @if (meta.type-of($base) != 'string') {
129
- @error 'The prefix function requires a string value.';
130
- }
131
-
132
- $base: string.to-lower-case($base);
133
-
134
- @if (string.index($base, $pre) != 1) {
135
- $base: #{$pre}#{$base};
136
- }
137
-
138
- @return $base;
139
- }
140
-
141
- /// Prefixes the provided string with two dashes and the library name if it isn't already
142
- /// @group Functions
143
- ///
144
- /// @param {String} $base - the string to be prefixed
145
- /// @return {String} - a prefixed string
146
- @function css-prefix ($base) {
147
- @if (meta.type-of($base) != 'string') {
148
- @error 'The css-prefix function requires a string value.';
149
- }
150
-
151
- @while (string.index($base, '-') == 1) {
152
- $base: string.slice($base, 2);
153
- }
154
-
155
- @return '--#{prefix($base)}';
156
- }
157
-
158
- /// Creates a CSS-var call for the prefixed `$base`
159
- /// @group Functions
160
- ///
161
- /// @param {String} $base - the CSS-var to create a call for
162
- /// @return {String} - a CSS-var call
163
- @function css-var ($base) {
164
- @if (meta.type-of($base) != 'string') {
165
- @error 'The css-var function requires a string value.';
166
- }
167
-
168
- @if (string.index($base, '--') != 1) {
169
- $base: css-prefix($base);
170
- }
171
-
172
- @return var(#{$base});
173
- }
174
-
175
- /// Creates a class selector with the library prefix
176
- /// @group Functions
177
- ///
178
- /// @param {String} $base - the name of the class
179
- /// @return {String} - a class selector
180
- @function class($base) {
181
- @if (meta.type-of($base) != 'string') {
182
- @error 'The class function requires a string value.';
183
- }
184
-
185
- @return '.#{prefix($base)}';
186
- }
187
-
188
- /// Creates an id selector with the library prefix
189
- /// @group Functions
190
- ///
191
- /// @param {String} $base - the name of the id
192
- /// @param {String} $op - the comparison operator
193
- /// @return {String} - an id selector
194
- @function id ($base, $op: '=') {
195
- @if (meta.type-of($base) != 'string') {
196
- @error 'The id function requires a string value.';
197
- }
198
-
199
- @if (meta.type-of($op) != 'string') {
200
- @error 'The controls function requires a string value for param 2.';
201
- }
202
-
203
- @if not($op == '=' or $op == '~=' or $op == '|=' or $op == '^=' or $op == '$=' or $op == '*=') {
204
- @error 'The controls function requires a valid attribute comparison operator for param 2.';
205
- }
206
-
207
- @if ($op == '=') {
208
- @return '##{prefix($base)}';
209
- }
210
-
211
- @return '[id#{$op}#{prefix($base)}]';
212
- }
213
-
214
- /// Creates an aria-controls selector with the library prefix
215
- /// @group Functions
216
- ///
217
- /// @param {String} $id - the id of the controlled element
218
- /// @param {String} $op - the comparison operator
219
- /// @return {String} - an aria-controls selector
220
- @function controls ($id, $op: '=') {
221
- @if (meta.type-of($id) != 'string') {
222
- @error 'The controls function requires a string value for param 1.';
223
- }
224
-
225
- @if (meta.type-of($op) != 'string') {
226
- @error 'The controls function requires a string value for param 2.';
227
- }
228
-
229
- @if not($op == '=' or $op == '~=' or $op == '|=' or $op == '^=' or $op == '$=' or $op == '*=') {
230
- @error 'The controls function requires a valid attribute comparison operator for param 2.';
231
- }
232
-
233
- @return '[aria-controls#{$op}#{prefix($id)}]';
234
- }
235
-
236
- /// Creates an aria-expanded selector
237
- /// @group Functions
238
- ///
239
- /// @param {Bool} $bool - the value of the selector
240
- /// @return {String} - an aria-expanded selector
241
- @function expanded ($bool) {
242
- @if (meta.type-of($bool) == 'string') {
243
- $bool: string.to-lower-case($bool);
244
-
245
- @if not($bool == 'true' or $bool == 'false') {
246
- @error 'The expanded function requires a boolean value.';
247
- }
248
- }
249
-
250
- @else if (meta.type-of($bool) != 'bool') {
251
- @error 'The expanded function requires a boolean value.';
252
- }
253
-
254
- @return '[aria-expanded=#{$bool}]';
255
- }
256
-
257
- /// Creates an aria-hidden selector
258
- /// @group Functions
259
- ///
260
- /// @param {Bool} $bool - the value of the selector
261
- /// @return {String} - an aria-hidden selector
262
- @function hidden ($bool) {
263
- @if (meta.type-of($bool) == 'string') {
264
- $bool: string.to-lower-case($bool);
265
-
266
- @if not($bool == 'true' or $bool == 'false') {
267
- @error 'The hidden function requires a boolean value. Received: #{$bool}';
268
- }
269
- }
270
-
271
- @else if (meta.type-of($bool) !='bool') {
272
- @error 'The hidden function requires a boolean value. Received: #{$bool}';
273
- }
274
-
275
- @return '[aria-hidden=#{$bool}]';
276
- }
277
-
278
- /// Converts a number to ms
279
- /// @group Functions
280
- ///
281
- /// @param {Number} $val - the number of ms to return
282
- /// @return {Number} the number as ms
283
- @function ms ($val) {
284
- @if (meta.type-of($val) != 'number') {
285
- @error 'The ms function requires a number value.';
286
- }
287
-
288
- @return $val * 1ms;
289
- }
290
-
291
- /// Converts a number to px
292
- /// @group Functions
293
- ///
294
- /// @param {Number} $val - the number of px to return
295
- /// @return {Number} - the number as px
296
- @function px ($val) {
297
- @if (meta.type-of($val) != 'number') {
298
- @error 'The px function requires a number value.';
299
- }
300
-
301
- @return $val * 1px;
302
- }
303
-
304
- /// Removes the unit from the given value
305
- /// @group Functions
306
- ///
307
- /// @param {Number} $val - the value to strip
308
- /// @return {Number} - the number without units
309
- @function strip-unit($val) {
310
- @if (meta.type-of($val) != 'number') {
311
- @error 'The strip-unit function requires a number value.';
312
- }
313
-
314
- @return math.div($val, $val * 0 + 1);
315
- }
316
-
317
- /// Returns the percentage of the given values
318
- /// @group Functions
319
- ///
320
- /// @param {Number} $dividend - the value that will be devided
321
- /// @param {Number} $divisor - the value that will devided by
322
- /// @return {Number} - the percentage of the given values
323
- /// @throws {Error} - if the values are not numbers
324
- /// @throws {Error} - if the divisor is 0
325
- @function percent($dividend, $divisor, $padding: 0) {
326
- @if (meta.type-of($dividend) != 'number' or meta.type-of($divisor) != 'number' or meta.type-of($padding) != 'number') {
327
- @error 'The percent function requires number parameters.';
328
- }
329
-
330
- @if ($divisor == 0) {
331
- @error 'The percent function requires a non-zero value for param 2.';
332
- }
333
-
334
- @if (strip-unit($padding) != 0) {
335
- @return #{calc((($dividend * 100%) - $padding) / $divisor)}#{'%'};
336
- }
337
-
338
- @return math.div($dividend * 100%, $divisor);
339
- }
340
-
341
- /// Returns the requested time value as ms
342
- /// @group Functions
343
- ///
344
- /// @param {Number} $key - the key of the time to use
345
- /// @return {Number} - the time value as ms
346
- @function time($key) {
347
- @if not(map.has-key($time, $key)) {
348
- @error 'The time function requires one of the following values: #{map-keys($time)}';
349
- }
350
-
351
- @return ms(map.get($time, $key));
352
- }
353
-
354
- /// Returns the requested breakpoint value as px
355
- /// @group Functions
356
- ///
357
- /// @param {Number} $key - the key of the breakpoint to use
358
- /// @return {Number} - the breakpoint value as px
359
- @function break($key) {
360
- @if not(map.has-key($break, $key)) {
361
- @error 'The break function requires one of the following values: #{map-keys($break)}';
362
- }
363
-
364
- @return px(map.get($break, $key));
365
- }
366
-
367
- /// Creates a prefixed CSS var definition
368
- /// @group Mixins
369
- ///
370
- /// @param {String} $key - the key of the CSS var
371
- /// @param {Any} $val - the value of the CSS var
372
- /// @output a prefixed CSS var definition
373
- @mixin css-var ($key, $val) {
374
- @if (meta.type-of($key) != 'string') {
375
- @error 'The css-var mixin requires a string for the $key argument.';
376
- }
377
-
378
- @if (string.index($key, '--') != 1) {
379
- $key: css-prefix($key);
380
- }
381
-
382
- #{$key}: #{$val};
383
- }
384
-
385
- /// Creates a prefixed CSS var reference
386
- /// @group Mixins
387
- ///
388
- /// @param {String} $key1 - the key of the new CSS var to define
389
- /// @param {String} $key2 - the key of the referenced CSS var
390
- /// @output a prefixed CSS var reference
391
- @mixin css-var-ref ($key1, $key2) {
392
- @if (meta.type-of($key1) != 'string' or meta.type-of($key2) != 'string') {
393
- @error 'The css-var-ref mixin requires string values for both parameters.';
394
- }
395
-
396
- @include css-var($key1, css-var($key2));
397
- }
398
-
399
- /// Wraps the provided content in a media query
400
- /// @group Mixins
401
- ///
402
- /// @param {String} $min - the key of the breakpoint to use with min-width
403
- /// @param {String} $max - the key of the breakpoint to use with max-width
404
- /// @output the provided content wrapped in a media query
405
- @mixin break ($min, $max: null) {
406
- @if not(map.has-key($break, $min) and (meta.type-of($max) == 'null' or map.has-key($break, $max))) {
407
- @error 'The break mixin requires one or two of the following values: #{map-keys($break)}';
408
- }
409
-
410
- @if (map.has-key($break, $max)) {
411
- @media (min-width: break($min)) and (max-width: break($max)) {
412
- @content;
413
- }
414
- }
415
-
416
- @else {
417
- @media (min-width: break($min)) {
418
- @content;
419
- }
420
- }
421
- }
422
-
423
- @mixin break-max ($max, $min: null) {
424
- @if not(map.has-key($break, $max) and (meta.type-of($min) == 'null' or map.has-key($break, $min))) {
425
- @error 'The break-max mixin requires one or two of the following values: #{map-keys($break)}';
426
- }
427
-
428
- $break-max: break($max) - 1px;
429
- @if (map.has-key($break, $min)) {
430
- @media (min-width: break($min)) and (max-width: $break-max) {
431
- @content;
432
- }
433
- }
434
-
435
- @else {
436
- @media (max-width: $break-max) {
437
- @content;
438
- }
439
- }
440
- }
441
-
442
- /// Creates utility selectors for a given property at each breakpoint
443
- /// @group Mixins
444
- ///
445
- /// @param {String} $prop - the property to toggle
446
- /// @param {Any} $val - the active value of the property
447
- /// @param {Any} $none - the inactive value of the property
448
- /// @output utility selectors for the given property at each breakpoint
449
- @mixin break-util ($prop, $val, $none: "none") {
450
- @if (meta.type-of($prop) !='string') {
451
- @error 'The break-util mixin requires a string for the $prop argument.';
452
- }
453
-
454
- #{$prop}: #{$val};
455
-
456
- @each $key, $width in $break {
457
- &-#{$key} {
458
- #{$prop}: #{$none};
459
-
460
- @include break($key) {
461
- #{$prop}: #{$val};
462
- }
463
- }
464
-
465
- &-to-#{$key} {
466
- #{$prop}: #{$val};
467
-
468
- @include break($key) {
469
- #{$prop}: #{$none};
470
- }
471
- }
472
- }
473
- }
474
-
475
- /// Creates utility selectors for a box model property
476
- /// @group Mixins
477
- @mixin box-util ($prop, $val) {
478
- @if (meta.type-of($prop) != 'string') {
479
- @error 'The box-util mixin requires a string for the $prop argument.';
480
- }
481
-
482
- &-auto {
483
- #{$prop}-left: auto;
484
- #{$prop}-right: auto;
485
-
486
- &-v {
487
- #{$prop}: $val auto;
488
-
489
- @for $i from 0 through 6 {
490
- &#{$i} {
491
- #{$prop}: $val * $i auto;
492
- }
493
- }
494
- }
495
-
496
- &-t {
497
- #{$prop}-top: $val;
498
- #{$prop}-left: auto;
499
- #{$prop}-right: auto;
500
-
501
- @for $i from 0 through 6 {
502
- &#{$i} {
503
- #{$prop}-top: $val * $i;
504
- #{$prop}-left: auto;
505
- #{$prop}-right: auto;
506
- }
507
- }
508
- }
509
-
510
- &-b {
511
- #{$prop}-bottom: $val;
512
- #{$prop}-left: auto;
513
- #{$prop}-right: auto;
514
-
515
- @for $i from 0 through 6 {
516
- &#{$i} {
517
- #{$prop}-bottom: $val * $i;
518
- #{$prop}-left: auto;
519
- #{$prop}-right: auto;
520
- }
521
- }
522
- }
523
- }
524
-
525
- &-v {
526
- #{$prop}-top: $val;
527
- #{$prop}-bottom: $val;
528
-
529
- @for $i from 0 through 6 {
530
- &#{$i} {
531
- #{$prop}-top: $val * $i;
532
- #{$prop}-bottom: $val * $i;
533
- }
534
- }
535
- }
536
-
537
- &-t {
538
- #{$prop}-top: $val;
539
-
540
- @for $i from 0 through 6 {
541
- &#{$i} {
542
- #{$prop}-top: $val * $i;
543
- }
544
- }
545
-
546
- &#{50} {
547
- #{$prop}-top: 50vh;
548
- }
549
- }
550
-
551
- &-b {
552
- #{$prop}-bottom: $val;
553
-
554
- @for $i from 0 through 6 {
555
- &#{$i} {
556
- #{$prop}-bottom: $val * $i;
557
- }
558
- }
559
- }
560
-
561
- &-h {
562
- #{$prop}-left: $val;
563
- #{$prop}-right: $val;
564
-
565
- @for $i from 0 through 6 {
566
- &#{$i} {
567
- #{$prop}-left: $val * $i;
568
- #{$prop}-right: $val * $i;
569
- }
570
- }
571
- }
572
-
573
- &-l {
574
- #{$prop}-left: $val;
575
-
576
- @for $i from 0 through 6 {
577
- &#{$i} {
578
- #{$prop}-left: $val * $i;
579
- }
580
- }
581
- }
582
-
583
- &-r {
584
- #{$prop}-right: $val;
585
-
586
- @for $i from 0 through 6 {
587
- &#{$i} {
588
- #{$prop}-right: $val * $i;
589
- }
590
- }
591
- }
592
- }
593
-
594
- /// Generates css varibles for lighter, darker, or both variations
595
- /// @group Mixins
596
- ///
597
- /// @param {String} $name - the name of the color
598
- /// @param {Color} $color - the color to generate variations for
599
- /// @param {Number} $number - the number of variations to geerate
600
- /// @param {Boolean} $alpha - whether to generate alpha variations
601
- /// @output css variables for different shades of the source color
602
- @mixin shades ($name, $color, $number: 10, $alpha: false) {
603
- @error color.alpha($color);
604
- @if (meta.type-of($name) != 'string') {
605
- @error 'The shades mixin requires a string for the $name argument.';
606
- }
607
-
608
- @if (meta.type-of($color) != 'color') {
609
- @error 'The shades mixin requires a color for the $color argument.';
610
- }
611
-
612
- @if (meta.type-of($number) != 'number') {
613
- @error 'The shades mixin requires a number for the $number argument.';
614
- }
615
-
616
- @if (meta.type-of($alpha) == 'string') {
617
- $bool: string.to-lower-case($bool);
618
-
619
- @if not($bool == 'true' or $bool == 'false') {
620
- @error 'The shades mixin requires a boolean value for the $alpha argument. Received: #{$bool}';
621
- }
622
- }
623
-
624
- @else if (meta.type-of($alpha) != 'bool') {
625
- @error 'The shades mixin requires a boolean value for the $alpha argument. Received: #{$bool}';
626
- }
627
-
628
- @if ($alpha) {
629
- @for $i from 0 through $number - 1 {
630
- $amount: math.div($i, $number);
631
- @include css-var(#{$name}-#{$i}, color.change($color, $alpha: $amount));
632
- }
633
- } @else {
634
- @for $i from 0 through $number - 1 {
635
- $amount: math.div($i, $number);
636
- @include css-var(#{$name}-#{$i}, color.change($color, $lightness: $amount));
637
- }
638
- }
639
- }
640
-
641
- /// Wrap the content in given states
642
- /// @group Mixins
643
- ///
644
- /// @param {String[]} $states - a list of states
645
- @mixin states ($states...) {
646
- @if (list.length($states) == 0) {
647
- @error 'The states mixin requires at least one state parameter.';
648
- }
649
- @each $state in $states {
650
- @if (meta.type-of($state) != 'string') {
651
- @error 'The states mixin requires a string for each state parameter.';
652
- }
653
- }
654
-
655
- $selectors: ();
656
-
657
- @if (list.index($states, 'hover') != null) {
658
- $selectors: list.append($selectors, selector.append(&, ':hover'));
659
- }
660
-
661
- @if (list.index($states, 'focus') != null) {
662
- $selectors: list.append($selectors, selector.append(&, ':focus-visible'));
663
- }
664
-
665
- @if (list.index($states, 'active') != null) {
666
- $selectors: list.append($selectors, selector.append(&, ':active'));
667
- }
668
-
669
- @if (list.index($states, 'mint-active') != null) {
670
- $selectors: list.append($selectors, selector.append(&, class(active)));
671
- }
672
-
673
- @if (list.index($states, 'visited') != null) {
674
- $selectors: list.append($selectors, selector.append(&, ':visited'));
675
- }
676
-
677
- @if (list.index($states, 'disabled') != null) {
678
- $selectors: list.append($selectors, selector.append(&, ':disabled'));
679
- }
680
-
681
- @if (list.index($states, 'expanded') != null) {
682
- $selectors: list.append($selectors, selector.append(&, expanded(true)));
683
- }
684
-
685
- @at-root {
686
- #{$selectors} {
687
- @content;
688
- }
689
- }
690
- }
691
-
692
- /// Selector for all headers
693
- /// @group Mixins
694
- @mixin headers () {
695
- @for $i from 1 through 6 {
696
- h#{$i},
697
- #{class(h#{$i})} {
698
- @content;
699
- }
700
- }
701
- }
702
-
703
- /// Background clip text
704
- /// @group Mixins
705
- @mixin background-clip ($color) {
706
- color: $color;
707
-
708
- @supports (-webkit-background-clip: text) and (-webkit-text-fill-color: transparent) {
709
- background: $color;
710
- @content;
711
- background-clip: text;
712
- -webkit-background-clip: text;
713
- -webkit-text-fill-color: transparent;
714
- }
715
- }