C
C
Cat Anton2014-10-26 22:43:57
css
Cat Anton, 2014-10-26 22:43:57

How to write a mixin in LESS?

How to write .icon-before() with less to:

.icon-before("post", "file", "book", "check", "image", "globe", /* ... */ "data" );

turned into:
.icon-post:before { content: '\e800'; }
.icon-file:before { content: '\e801'; }
.icon-book:before { content: '\e802'; }
.icon-check:before { content: '\e803'; }
.icon-image:before { content: '\e804'; }
.icon-globe:before { content: '\e805'; }
// ...
.icon-data:before { content: '\e80f'; }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
neolink, 2014-10-26
@27cm

.icon-before(@list...) {
    .do(@index, @list) when (@index <= length(@list)) {
            @name: extract(@list, @index);           
            [email protected]{name}:before {
                content: replace(%("\%a", rgb(0, 232, @index)), "#00", '') 
            }               
           .do(@index + 1, @list);
    }
    .do(1, @list);
}
.icon-before(post, file, book, check, image, globe, data, a1, a2, a3, a4);

jsfiddle.net/jwdrb6m6

V
Vitaly Kirenkov, 2014-10-26
@DeLaVega

As far as I know, there are no cycles in loess, they are in sass.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question