How use maps in less mixins

34 views Asked by At

From the documentation: enter image description here

I wrote:

#colors() {
    backgroundDarkPrimary: '#0747A6';
    backgroundMedium: '#dfe1e6';
    backgroundLight: '#ebecf0';
    backgroundLightest: '#F4F5F7';
    backgroundLightPrimary: '#D2E5FE';
    backgroundLightSuccess: '#E4FCEF';
}

But when I use it in a mixin I get an error:

enter image description here

enter image description here

heed help

1

There are 1 answers

3
imhvost On

Why do you wrap colors in ''?

/* less */

#colors() {
  background: #0747A6;
}

.mixin( @height: 40px, @background: #colors[background] ) {
  height: @height;
  background: @background;
}

div {
  .mixin;
}

codepen