I try to set different background color to namespaces, for that I use css variables and classes like this
CSS
body.workspace {
$backgroundColor: #f1f4fa !default;
&.admin {
$backgroundColor: #e4daec;
}
}
HTML
<body class="workspace #{namespace}">
...
</body>
And namespace is set to admin
if needed
But $backgroundColor
is all the time set to #e4daec independently of the class is admin or not
Maybe I have to use 2 différents variables ?
2
Answers
Yes but, I use to use my background variable in many different Classes so the best way is to set like this ?
In fact, it works well
You have at least two options. You can use two different varibles:
or you can use a @mixin with if statement something like this:
if body element has only workspace class like this:
The bg color should be #f1f4fa. But if tag has two classes like this:
The bg color should be #e4daec