|
89 | 89 | @return eccgui-color-mix($color 100% * $alpha, transparent); |
90 | 90 | } |
91 | 91 |
|
| 92 | +$debug-rgba-values: "yes"; |
| 93 | + |
| 94 | +/** |
| 95 | + * Split between rgba(red, green, blue, alpha) and rgba(color, alpha). |
| 96 | + */ |
| 97 | +@function rgba($r, $g, $b: "undefined", $a: 1) { |
| 98 | + // check if old notation is used |
| 99 | + @if meta.variable-exists("r") && meta.variable-exists("g") && $b == "undefined" { |
| 100 | + // rgba(color, alpha) was used |
| 101 | + // forward to our color check splitter |
| 102 | + // @debug ("rgba input: #{$r} #{$g}"); // looks like the signature r,g,b,a always get transformed to color,alpha |
| 103 | + @return rgba-extended($r, $g); |
| 104 | + } @else { |
| 105 | + // rgba(r, g, b, a) is used |
| 106 | + // should never trigger because of the magical transformation |
| 107 | + $color-new-notation: rgb(#{$r} #{$g} #{$b} / #{$a}); |
| 108 | + |
| 109 | + @error "Old color notation found -> use #{$color-new-notation}"; |
| 110 | + @return $color-new-notation; |
| 111 | + } |
| 112 | +} |
| 113 | + |
92 | 114 | /** |
93 | 115 | * Overwrite SCSS built-in rgba function to support colors by custom properties and CSS color methods. |
94 | 116 | * TODO: we need to check if this is future proof, maybe this bahaviour is not planned by Dart Sass library. |
95 | 117 | */ |
96 | | -@function rgba($color, $alpha) { |
| 118 | +@function rgba-extended($color, $alpha) { |
97 | 119 | @if meta.type-of($color) == "color" { |
98 | 120 | // value is SASS color value, we use SASS color functionality |
99 | 121 | $alphacolor: color.change($color, $alpha: $alpha); |
|
102 | 124 | $alphacolor: transparent; |
103 | 125 | } |
104 | 126 |
|
105 | | - @debug "Color value $color is not defined by CSS custom property: rgba(#{$color}, #{$alpha}) -> #{$alphacolor}"; |
| 127 | + @if $debug-rgba-values == "yes" { |
| 128 | + @warn "Color value $color is not defined by CSS custom property: rgba(#{$color}, #{$alpha}) -> #{$alphacolor}"; |
| 129 | + } |
| 130 | + |
106 | 131 | @return $alphacolor; |
107 | 132 | } @else { |
108 | 133 | // value is not a SASS color value, we use CSS color method |
|
0 commit comments