473,403 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Changing scss variable in runtime

Hi 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';

}

and 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:

.element {

u/if $language == 'ar' {

background-color: aqua;

}@else if $language == 'fr' {

background-color: red;

}

}
Nov 14 '22 #1
0 5278

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: munish | last post by:
I m using pull model to retrieve records in crystal reports. Is there any way that i can change login information, database and table at runtime(in .Net).
1
by: Tom Rahav | last post by:
Hello. I use visual basic .net 2003 and Crystal Reports for creating win-reports. My question is if there is any possibility to set font properties (type, color and size) of a text control or...
1
by: Steve | last post by:
Can you change the TableStyle of a DataGrid at runtime? I have set up two table styles in visual studio, then depending on the value of a user controlled combo box, I wish to apply one of the 2...
4
by: Kasper Heftholm Kristensen | last post by:
Hi. I want to change the used namespace at runtime depending on another variable, but I'm not sure how to does this, if possible. The code below will not compile, but I hope it gives you an...
1
by: O.A.Haugum | last post by:
Hi I want to use a lot of icons in panels in a status bar. The icons shall show the current status of operations and has to be changed programmatically. Is it possible to store the icons...
1
by: Roby Eisenbraun Martins | last post by:
Hi, I'm Roby Eisenbraun Martins. I'm C++, VB, C# and ASP .NET developer. I'm Trying to hide objects in the crystal reports with C# code (runtime). I can hide the TextObject, but I really can't...
6
by: aidy | last post by:
Hi, This is a snippet of my XSLT <xsl:for-each select = "SAFS_LOG/LOG_MESSAGE"> <xsl:choose> <xsl:when test="@type = 'FAILED'"> <xsl:variable name="isFailed" select="@type" /> <BR>...
2
by: tfsimes | last post by:
Hi, I am a long time ASP developer learning .NET, so please bear with me. I am trying to find an article or such that will help me understand how to change control properties at runtime based on...
2
by: Lado.Leskovec | last post by:
Hi, I have while loop running, that ends when a certain boolean variable is set (ClosingProgram). Obviousely I can change that variable by cliclking a custom button or something, but i would like...
2
by: John Allen | last post by:
I need to change the "Browsable" attribute for one of my class' properties at runtime (from "true" to "false"). The only way I can see how to do it is via "ICustomTypeDescriptor.GetProperties()"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.