Lilly
September 12, 2023, 12:37pm
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 Likes
RGJ
(Richard - Communiteq)
September 12, 2023, 12:43pm
2
This works for me?
$header_color: rgb(0,0,0);
$transparency: 0.5;
.d-header {
background: rgba($header_color, $transparency);
}
1 Like
Lilly
September 12, 2023, 12:57pm
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 Like
Canapin
(Coin-coin le Canapin)
September 12, 2023, 1:20pm
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 Likes
Don
September 12, 2023, 1:54pm
5
Hello Lilly
You have to create variables from these to make it workable in setting.
Here is a quick example:
5 Likes
Lilly
September 12, 2023, 1:58pm
6
That’s awesome, thank you @Don
3 Likes
Canapin
(Coin-coin le Canapin)
September 12, 2023, 1:59pm
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 Likes
system
(system)
Closed
October 12, 2023, 2:00pm
8
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.