I need to join the name of some variables, here is an example:
file name: color-vars.less
First, some variables containing base and accent colors:
@red-base:#ff0000;
@red-accent:#FF1744;
@yellow-base:#FFCC00;
@yellow-accent:#FFEA00;
file name: color-mixin.less
A mixin that will allow me to combine colors
.add-color(@color-name){
.@{color-name}-bg {
background: ~"@{color-name}-base";
}
.@{color-name}-bg.accent {
background: ~"@{color-name}-accent";
}
}
file name: main.less
The main file that will call the mixin:
@import "color-vars.less";
@import "color-mixin.less";
.add-color(red);
.add-color(yellow);
This is the actual output:
.red-bg {
background: red-base;
}
.red-bg.accent {
background: red-accent;
}
.yellow-bg {
background: yellow-base;
}
.yellow-bg.accent {
background: yellow-accent;
}
What I was expecting is:
.red-bg {
background: #FF0000;
}
.red-bg.accent {
background: #FF1744;
}
.yellow-bg {
background: #FFCC00;
}
.yellow-bg.accent {
background: #FFEA00;
}
Keep in mind that I'm planning to use the lighten
and darken
functions, this is just an example, I need to get the value of a variable joining the name of the @color-name
and a string like "base" or "accent".