Lilly
(Lillian Louis)
12 Septiembre, 2023 12:37
1
Can some knowledgeable code guru explain why this seems to always throw an error (regardless of the settings.yaml file contents):
.d-header {
background: rgba($header_color, $transparency);
}
but this does not?
.d-header {
background: rgba(darkslategrey, 0.5);
}
Even if I switch the code to use $header_color in the rgb(47, 79, 79)
format, it always give me an error related to a $color element.
2 Me gusta
RGJ
(Richard - Communiteq)
12 Septiembre, 2023 12:43
2
This works for me?
$header_color: rgb(0,0,0);
$transparency: 0.5;
.d-header {
background: rgba($header_color, $transparency);
}
1 me gusta
Lilly
(Lillian Louis)
12 Septiembre, 2023 12:57
3
Yes but as soon as I put the variables into a settings.yml like this, it does not work for me. I get an error saying $color is not a color
even though I am not using a $color variable here. So I assume it may be related to an interpolation thing that I don’t understand.
header_color:
type: string
default: ""
description:
en: "..."
transparency:
type: string
default: ""
description:
en: "..."
In my mind, it seems like this is about how the CSS is compiled. the variables work when declared at the CSS run time, but not dynamically via separate settings.yml file.
this doesn’t work either:
.d-header {
background: rgba(#{$header_color}, #{$transparency});
}
1 me gusta
Canapin
(Coin-coin le Canapin)
12 Septiembre, 2023 13:20
4
Hi Lilly!
I stumble upon the same issue not so long ago.
Short answer: Themes and CSS variables are considered strings and, while you can use them in attributes such as color
, background
, border
and so on, they can’t be used in SCSS color functions.
The issue is not related to Discourse:
opened 04:47PM - 22 Jan 21 UTC
closed 10:28PM - 27 Jan 21 UTC
I am passing in variables to sass using gulp-sass-variables, which will always i… nject a string.
Unquote doesn't seem to have any effect on my string.
```
$primary: "#ffffff"; // <- Passed in via gulp-sass-variables
$anchor: scale-color(unquote($primary), $lightness: -14%); // Error: $color: #ffffff is not a color.
```
Am I using unquote in the wrong way?
There’s an overcomplicated way to circumvent this I didn’t try: Unquote not working on colour string · Issue #3006 · sass/sass · GitHub
4 Me gusta
Don
12 Septiembre, 2023 13:54
5
Hello Lilly
You have to create variables from these to make it workable in setting.
Here is a quick example:
5 Me gusta
Lilly
(Lillian Louis)
12 Septiembre, 2023 13:58
6
That’s awesome, thank you @Don
3 Me gusta
Canapin
(Coin-coin le Canapin)
12 Septiembre, 2023 13:59
7
It’s not the first time I say “it’s not possible” and you come like “yes it is”, Don
probably not the last time as well
8 Me gusta
system
(system)
Cerrado
12 Octubre, 2023 14:00
8
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.