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