Skip to content

Commit cacab99

Browse files
committed
fix(core): cast color name to a string in Sass interpolation to remove warnings
1 parent 86fd06c commit cacab99

2 files changed

Lines changed: 20 additions & 17 deletions

File tree

core/src/css/ionic/core.ionic.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@include globals.generate-color-variables();
1313

1414
@each $color-name, $value in globals.$ionic-colors {
15-
.ion-color-#{$color-name} {
15+
.ion-color-#{"" + $color-name} {
1616
@include globals.generate-color($color-name);
1717
}
1818
}

core/src/themes/functions.color.scss

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
$color-variants: map.get($hue-colors, $hue);
143143

144144
$prefix: if($hue == "subtle", "-subtle", "");
145+
$name: "" + $color-name;
145146

146147
// TODO(FW-6417) this @if can be removed if we add subtle colors for ios and md
147148
// Only proceed if the color variants exist
@@ -156,21 +157,21 @@
156157
$foreground: map.get($color-variants, foreground);
157158

158159
// Generate CSS variables dynamically
159-
--ion-color#{$prefix}-base: var(--ion-color-#{$color-name}#{$prefix}, #{$base}) !important;
160-
--ion-color#{$prefix}-base-rgb: var(--ion-color-#{$color-name}#{$prefix}-rgb, #{$base-rgb}) !important;
161-
--ion-color#{$prefix}-contrast: var(--ion-color-#{$color-name}#{$prefix}-contrast, #{$contrast}) !important;
160+
--ion-color#{$prefix}-base: var(--ion-color-#{$name}#{$prefix}, #{$base}) !important;
161+
--ion-color#{$prefix}-base-rgb: var(--ion-color-#{$name}#{$prefix}-rgb, #{$base-rgb}) !important;
162+
--ion-color#{$prefix}-contrast: var(--ion-color-#{$name}#{$prefix}-contrast, #{$contrast}) !important;
162163
--ion-color#{$prefix}-contrast-rgb: var(
163-
--ion-color-#{$color-name}#{$prefix}-contrast-rgb,
164+
--ion-color-#{$name}#{$prefix}-contrast-rgb,
164165
#{$contrast-rgb}
165166
) !important;
166-
--ion-color#{$prefix}-shade: var(--ion-color-#{$color-name}#{$prefix}-shade, #{$shade}) !important;
167-
--ion-color#{$prefix}-tint: var(--ion-color-#{$color-name}#{$prefix}-tint, #{$tint}) !important;
167+
--ion-color#{$prefix}-shade: var(--ion-color-#{$name}#{$prefix}-shade, #{$shade}) !important;
168+
--ion-color#{$prefix}-tint: var(--ion-color-#{$name}#{$prefix}-tint, #{$tint}) !important;
168169
// TODO(FW-6417): remove the fallback variable when the foreground variable is
169170
// required by all palettes for all themes:
170-
// --ion-color#{$prefix}-foreground: var(--ion-color-#{$color-name}#{$prefix}-foreground, #{$foreground}) !important;
171+
// --ion-color#{$prefix}-foreground: var(--ion-color-#{$name}#{$prefix}-foreground, #{$foreground}) !important;
171172
--ion-color#{$prefix}-foreground: var(
172-
--ion-color-#{$color-name}#{$prefix}-foreground,
173-
var(--ion-color-#{$color-name}#{$prefix}, #{$foreground})
173+
--ion-color-#{$name}#{$prefix}-foreground,
174+
var(--ion-color-#{$name}#{$prefix}, #{$foreground})
174175
) !important;
175176
}
176177
}
@@ -229,24 +230,26 @@
229230
}
230231

231232
@each $color-name, $value in $theme-colors {
233+
$name: "" + $color-name;
234+
232235
@each $hue in (bold, subtle) {
233236
$colors: map.get($value, $hue);
234237

235238
@if $colors != null {
236239
$prefix: if($hue == subtle, "-subtle", "");
237240

238-
--ion-color-#{$color-name}#{$prefix}: #{map.get($colors, base)};
239-
--ion-color-#{$color-name}#{$prefix}-rgb: #{map.get($colors, base-rgb)};
240-
--ion-color-#{$color-name}#{$prefix}-contrast: #{map.get($colors, contrast)};
241-
--ion-color-#{$color-name}#{$prefix}-contrast-rgb: #{map.get($colors, contrast-rgb)};
242-
--ion-color-#{$color-name}#{$prefix}-shade: #{map.get($colors, shade)};
243-
--ion-color-#{$color-name}#{$prefix}-tint: #{map.get($colors, tint)};
241+
--ion-color-#{$name}#{$prefix}: #{map.get($colors, base)};
242+
--ion-color-#{$name}#{$prefix}-rgb: #{map.get($colors, base-rgb)};
243+
--ion-color-#{$name}#{$prefix}-contrast: #{map.get($colors, contrast)};
244+
--ion-color-#{$name}#{$prefix}-contrast-rgb: #{map.get($colors, contrast-rgb)};
245+
--ion-color-#{$name}#{$prefix}-shade: #{map.get($colors, shade)};
246+
--ion-color-#{$name}#{$prefix}-tint: #{map.get($colors, tint)};
244247
// TODO(FW-6417): this "if" can be removed when foreground is defined for ios/md
245248
// themes. It should not be added until we want foreground to be required for
246249
// ios and md because this will be a breaking change, requiring users to add
247250
// `--ion-color-{color}-foreground` in order to override the default colors
248251
@if (map.get($colors, foreground)) {
249-
--ion-color-#{$color-name}#{$prefix}-foreground: #{map.get($colors, foreground)};
252+
--ion-color-#{$name}#{$prefix}-foreground: #{map.get($colors, foreground)};
250253
}
251254
}
252255
}

0 commit comments

Comments
 (0)