Skip to content

Commit

Permalink
Insertion parameter in mixins, fixes #14
Browse files Browse the repository at this point in the history
  • Loading branch information
backflip committed Mar 23, 2014
1 parent d103aa3 commit 9d41226
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
9 changes: 5 additions & 4 deletions templates/_icons.less
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
url('<%= fontPath %><%= fontName %>.svg#<%= fontName %>') format('svg');
}

.icon-base:before {
.icon-base-pseudo {
font-family: "<%= fontName %>";
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
Expand All @@ -25,10 +25,11 @@
content: @@filename;
}

.icon(@filename) {
.icon(@filename, @insert: before) {
@pseudo-selector: ~":@{insert}";

&:before {
&:extend(.icon-base:before);
&@{pseudo-selector} {
&:extend(.icon-base-pseudo);
.icon-char(@filename);
}
}
Expand Down
4 changes: 2 additions & 2 deletions templates/_icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
@return $char;
}

@mixin icon($filename) {
&:before {
@mixin icon($filename, $insert: before) {
&:#{$insert} {
@extend %icon;
content: icon-char($filename);
}
Expand Down
9 changes: 5 additions & 4 deletions test/expected/_icons.less
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
url('./Icons.svg#Icons') format('svg');
}

.icon-base:before {
.icon-base-pseudo {
font-family: "Icons";
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
Expand All @@ -26,10 +26,11 @@
content: @@filename;
}

.icon(@filename) {
.icon(@filename, @insert: before) {
@pseudo-selector: ~":@{insert}";

&:before {
&:extend(.icon-base:before);
&@{pseudo-selector} {
&:extend(.icon-base-pseudo);
.icon-char(@filename);
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/expected/_icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
@return $char;
}

@mixin icon($filename) {
&:before {
@mixin icon($filename, $insert: before) {
&:#{$insert} {
@extend %icon;
content: icon-char($filename);
}
Expand Down

0 comments on commit 9d41226

Please sign in to comment.