I have a variable on style-rtl.scss file : $language: var(--lang);
and that variable got defined in the root on style.css :
:root { --lang: 'selectedLang'; }
in the main.js file:
let language = localStorage.getItem("lang");// ar/fr
let r = document.querySelector(':root');
let rs = getComputedStyle(r);
r.style.setProperty('--lang', language);
let result = rs.getPropertyValue('--lang');
console.log(result); // fr
when i try to use this language variable on style-rtl.scss file it's read without problem :
.element {
content: $language;
}
But the problem is when I try to use it on if condition: The problem :
.element {
@if $language == 'ar' {
background-color: aqua;
}@else if $language == 'fr' {
background-color: red;
}
}
Any Help Please?
I try this but not working it's just going to the first condition
.element{
@if $language == 'var(#{--lang})' {
content: $langua;
background-color: aqua;
}@if $language == 'var(#{--lang})' {
content: $langua;
background-color: blueviolet;
}
}