Skip to content

Commit a835086

Browse files
authored
fix: resolve sass warnings (#179)
Co-authored-by: Daniel Kimmich <[email protected]>
1 parent e58d948 commit a835086

File tree

6 files changed

+24
-16
lines changed

6 files changed

+24
-16
lines changed

projects/material-css-vars/src/lib/_internal-helper.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@use "sass:meta";
2+
13
// used to circumvent node sass issue: https://github.com/sass/node-sass/issues/2251
24
@function rgb($r, $g: null, $b: null) {
35
@if ($g == null) {
@@ -42,7 +44,7 @@
4244
@mixin root($varMap: null) {
4345
@at-root :root {
4446
@each $varName, $varValue in $varMap {
45-
@if (type_of($varValue) ==string) {
47+
@if (meta.type-of($varValue) == string) {
4648
#{$varName}: $varValue; // to prevent quotes interpolation
4749
} @else {
4850
#{$varName}: #{$varValue};

projects/material-css-vars/src/lib/_public-color-util.scss

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
@function hex-to-rgb($color) {
1+
@use "sass:color";
2+
3+
@function hex-to-rgb($color) {
24
@if ($color == null) {
35
@return null;
46
}
5-
@return red($color), green($color), blue($color);
7+
@return color.channel($color, "red"), color.channel($color, "green"),
8+
color.channel($color, "blue");
69
}
710

811
@function hex-to-rgba($color) {

projects/material-css-vars/src/lib/_public-util.scss

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@use "sass:map";
2+
@use "sass:meta";
13
@use "public-color-util";
24
@use "variables";
35

@@ -39,9 +41,9 @@
3941
}
4042
}
4143

42-
$color: map_get($palette_, $hue);
44+
$color: map.get($palette_, $hue);
4345

44-
@if (type-of($opacity) == number) {
46+
@if (meta.type-of($opacity) == number) {
4547
@return rgba($color, $opacity);
4648
} @else {
4749
@return $color;
@@ -76,7 +78,7 @@
7678
@error "Invalid palette";
7779
}
7880
}
79-
$var: map_get($palette_, $hue);
81+
$var: map.get($palette_, $hue);
8082
@return #{rgba($var, $opacity)};
8183
}
8284

@@ -179,7 +181,7 @@
179181
@if ($var != "contrast") {
180182
$colorVal: public-color-util.hex-to-rgb($defaultVal);
181183
@if $colorVal != null {
182-
$new-map: map_merge(
184+
$new-map: map.merge(
183185
$new-map,
184186
(--palette-#{$paletteType}-#{$var}: #{$colorVal})
185187
);

projects/material-css-vars/src/lib/_variables.scss

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@use "@angular/material" as mat;
22
@use "public-color-util";
3+
@use "sass:map";
34

45
$dark-theme-selector: ".isDarkTheme" !default;
56
$light-theme-selector: ".isLightTheme" !default;
@@ -507,15 +508,15 @@ $palette-warn-no-rgb: (
507508
),
508509
) !default;
509510

510-
$contrast-palette: map_get($palette-primary, "contrast") !default;
511-
$contrast-palette-no-rgb: map_get($palette-primary-no-rgb, "contrast") !default;
512-
$contrast-palette-accent: map_get($palette-accent, "contrast") !default;
513-
$contrast-palette-accent-no-rgb: map_get(
511+
$contrast-palette: map.get($palette-primary, "contrast") !default;
512+
$contrast-palette-no-rgb: map.get($palette-primary-no-rgb, "contrast") !default;
513+
$contrast-palette-accent: map.get($palette-accent, "contrast") !default;
514+
$contrast-palette-accent-no-rgb: map.get(
514515
$palette-accent-no-rgb,
515516
"contrast"
516517
) !default;
517-
$contrast-palette-warn: map_get($palette-warn, "contrast") !default;
518-
$contrast-palette-warn-no-rgb: map_get(
518+
$contrast-palette-warn: map.get($palette-warn, "contrast") !default;
519+
$contrast-palette-warn-no-rgb: map.get(
519520
$palette-warn-no-rgb,
520521
"contrast"
521522
) !default;

src/app/_app.theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@use "sass:map";
22
@use "@angular/material" as mat;
33

4-
@mixin app-theme($theme) {
4+
@mixin theme($theme) {
55
// Extract the palettes you need from the theme definition.
66
$color: mat.m2-get-color-config($theme);
77
$primary: map.get($color, primary);

src/styles.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@use "../projects/material-css-vars" as mat-css-vars;
22
@use "@angular/material" as mat;
33

4-
@import "./app/app.theme";
4+
@use "./app/app.theme" as app;
55

66
$custom-typography: mat.m2-define-typography-config(
77
$font-family: "Roboto, monospace",
@@ -13,7 +13,7 @@ $custom-typography: mat.m2-define-typography-config(
1313
$typography-config: $custom-typography
1414
)
1515
using($mat-css-theme) {
16-
@include app-theme($mat-css-theme);
16+
@include app.theme($mat-css-theme);
1717
}
1818

1919
@include mat-css-vars.mat-css-set-palette-defaults(

0 commit comments

Comments
 (0)