@appartmint/css-mint 0.0.34 → 0.0.36

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@appartmint/css-mint",
3
3
  "author": "App Art Mint LLC",
4
- "version": "0.0.34",
4
+ "version": "0.0.36",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "description": "Styles by App Art Mint",
@@ -1,26 +1,42 @@
1
1
  @use 'sass:color';
2
2
  @use '../util' as *;
3
3
 
4
+ @function get-luminance($color) {
5
+ @if (color.space($color) == 'rgb') {
6
+ @return math.sqrt(
7
+ 0.299 * color.red($color) * color.red($color)
8
+ + 0.587 * color.green($color) * color.green($color)
9
+ + 0.114 * color.blue($color) * color.blue($color));
10
+ }
11
+ @else if (color.space($color) == 'hsl') {
12
+ @return color.lightness($color);
13
+ }
14
+
15
+ @error 'Invalid color space: #{color.space($color)}';
16
+ }
17
+
4
18
  :root {
5
- @include shades(glow, rgba(255, 255, 255, 0), darken, 7, 10%, true);
6
- @include shades(shadow, rgba(0, 0, 0, 0), darken, 7, 10%, true);
19
+ /// Black and White Shades
20
+ /*@include shades(c-bw, black);
21
+ @include shades(glow, rgba(255, 255, 255, 0), 10, true);
22
+ @include shades(shadow, rgba(0, 0, 0, 0), 10, true);
7
23
 
8
24
  /// Brand Colors
9
- @include shades(c-brand, #C55);
10
- @include shades(c-accent, #483d8b);
11
- @include shades(c-success, #208a20);
12
- @include shades(c-danger, #ff4d4d);
13
- @include shades(c-warning, #ffaa22);
14
- @include shades(c-info, #238cc4);
25
+ @include shades(c-brand, hsl(0, 54%, 50%));
26
+ @include shades(c-accent, hsl(248, 39%, 50%));
27
+ @include shades(c-success, hsl(120, 62%, 50%));
28
+ @include shades(c-danger, hsl(0, 100%, 50%));
29
+ @include shades(c-warning, hsl(37, 100%, 50%));
30
+ @include shades(c-info, hsl(201, 70%, 50%));
15
31
 
16
32
  /// App Colors
17
- @include shades(c-fg, color.adjust(black, $lightness: 10%), lighten);
18
- @include shades(c-bg, color.adjust(white, $lightness: -10%), darken);
33
+ @include css-var-ref(c-fg, c-bw-8);
34
+ @include css-var-ref(c-bg, c-bw-1);*/
19
35
  }
20
36
 
21
37
  #{class(theme)} {
22
38
  &-dark {
23
- @include shades(c-fg, color.adjust(white, $lightness: -10%), darken);
24
- @include shades(c-bg, color.adjust(black, $lightness: 10%), lighten);
39
+ @include css-var-ref(c-fg, c-bw-1);
40
+ @include css-var-ref(c-bg, c-bw-8);
25
41
  }
26
42
  }
package/src/util.scss CHANGED
@@ -596,12 +596,11 @@ $break: (
596
596
  ///
597
597
  /// @param {String} $name - the name of the color
598
598
  /// @param {Color} $color - the color to generate variations for
599
- /// @param {String} $type - the type of variation to generate
600
599
  /// @param {Number} $number - the number of variations to geerate
601
- /// @param {String} $amount - the amount to vary the color by
602
600
  /// @param {Boolean} $alpha - whether to generate alpha variations
603
601
  /// @output css variables for different shades of the source color
604
- @mixin shades ($name, $color, $type: both, $number: 7, $amount: 10%, $alpha: false) {
602
+ @mixin shades ($name, $color, $number: 10, $alpha: false) {
603
+ @error color.space($color);
605
604
  @if (meta.type-of($name) != 'string') {
606
605
  @error 'The shades mixin requires a string for the $name argument.';
607
606
  }
@@ -610,10 +609,6 @@ $break: (
610
609
  @error 'The shades mixin requires a color for the $color argument.';
611
610
  }
612
611
 
613
- @if not($type == lighten or $type == darken or $type == both) {
614
- @error 'The shades mixin requires a string of "lighten", "darken", or "both" for the $type argument.';
615
- }
616
-
617
612
  @if (meta.type-of($number) != 'number') {
618
613
  @error 'The shades mixin requires a number for the $number argument.';
619
614
  }
@@ -630,61 +625,15 @@ $break: (
630
625
  @error 'The shades mixin requires a boolean value for the $alpha argument. Received: #{$bool}';
631
626
  }
632
627
 
633
- @include css-var(#{$name}, $color);
634
-
635
628
  @if ($alpha) {
636
- @if ($type == lighten) {
637
- @for $i from 0 through $number - 1 {
638
- @include css-var(#{$name}-#{$i}, color.adjust($color, $alpha: -$i * math.div($amount, 100%)));
639
- }
640
- }
641
-
642
- @else if ($type == darken) {
643
- @for $i from 0 through $number - 1 {
644
- @include css-var(#{$name}-#{$i}, color.adjust($color, $alpha: $i * math.div($amount, 100%)));
645
- }
646
- }
647
-
648
- @else if ($type == both) {
649
- $num-light: floor(math.div($number, 2));
650
-
651
- @for $i from 0 through $num-light - 1 {
652
- @include css-var(#{$name}-#{$i}, color.adjust($color, $alpha: -$i * math.div($amount, 100%)));
653
- }
654
-
655
- @include css-var(#{$name}-#{$num-light}, $color);
656
-
657
- @for $i from $num-light + 1 through $number - 1 {
658
- @include css-var(#{$name}-#{$i}, color.adjust($color, $alpha: ($num-light - $i) * math.div($amount, 100%)));
659
- }
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));
660
632
  }
661
- }
662
-
663
- @else {
664
- @if ($type == lighten) {
665
- @for $i from 0 through $number - 1 {
666
- @include css-var(#{$name}-#{$i}, color.adjust($color, $lightness: $i * $amount));
667
- }
668
- }
669
-
670
- @else if ($type == darken) {
671
- @for $i from 0 through $number - 1 {
672
- @include css-var(#{$name}-#{$i}, color.adjust($color, $lightness: $i * -$amount));
673
- }
674
- }
675
-
676
- @else if ($type == both) {
677
- $num-light: math.floor(math.div($number, 2));
678
-
679
- @for $i from 0 through $num-light - 1 {
680
- @include css-var(#{$name}-#{$i}, color.adjust($color, $lightness: ($num-light - $i) * $amount));
681
- }
682
-
683
- @include css-var(#{$name}-#{$num-light}, $color);
684
-
685
- @for $i from $num-light + 1 through $number - 1 {
686
- @include css-var(#{$name}-#{$i}, color.adjust($color, $lightness: ($i - $num-light) * -$amount));
687
- }
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));
688
637
  }
689
638
  }
690
639
  }