Answer the question
In order to leave comments, you need to log in
What is the best way to organize styles on less to support different interface colors?
There is a task to organize support for various color solutions for the interface. All styles on less are grouped into components. Those. the markup is always the same, only the colors of the elements differ.
I see two ways:
1. For each element, define a personal variable with a color based on the context of the element (for example, @loginFormBg, @SerachButtonTextColor) and then simply specify the desired colors for these variables for each theme.
But there is a clear disadvantage in the form of a huge number of variables, which will often contain the same color values.
2. Put the theme identifier in the name of the variable, and inside each class, actually do an if, which, depending on the theme identifier, will use the desired value.
.sidebar {
width: 220px;
margin: 10px 0;
& when (@theme = default) {background: @black;}
& when (@theme = fireCat) {background: @fc_red;}
}
Answer the question
In order to leave comments, you need to log in
But what if you use one key theme color, and set all other colors relative to it?
Try changing your approach by using different methodologies, such as BEM from Yandex.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question