I want to know if I could improve my LESS-Snippet. I have a lot of variables with colornames/my own color captions and associated colors for fore- and background. And I define classes namend after my colors.
@logocolorgreen: #40FF01; @logocolorgreenname: green; @logocolorgreenitem: #404040;
@logocolormidblue: #01C0FF; @logocolormidbluename: midblue; @logocolormidblueitem: #404040;
@logocolorpurple: #C00031; @logocolorpurplename: purple; @logocolorpurpleitem: white;
@logocoloryellow: #FFC000; @logocoloryellowname: yellow; @logocoloryellowitem: #404040;
// ... more Colors
div {
.mixedin(@colorname) {
@bgvarname: "logocolor@{colorname}";
background-color: @@bgvarname;
@fgvarname: "logocolor@{colorname}item";
color: @@fgvarname;
}
&.@{logocolorgreenname} {
.mixedin(@logocolorgreenname);
}
&.@{logocolormidbluename} {
.mixedin(@logocolormidbluename);
}
&.@{logocolorpurplename} {
.mixedin(@logocolorpurplename);
}
&.@{logocoloryellowname} {
.mixedin(@logocoloryellowname);
}
// ... more Colors
}
compiles to
div.green {
background-color: #40ff01;
color: #404040;
}
div.midblue {
background-color: #01c0ff;
color: #404040;
}
div.purple {
background-color: #c00031;
color: white;
}
div.yellow {
background-color: #ffc000;
color: #404040;
}
I want to know, if I can
- Avoid the excessive repeat of the Mixedin?
- Avoid the double c&p for classname and mixedin-parameter in each mixedin-usage?
Thanks!