Skip to content

Instantly share code, notes, and snippets.

@tdhooper
Last active August 29, 2015 14:06
Show Gist options
  • Save tdhooper/d36b80d9e4d2dc1c0900 to your computer and use it in GitHub Desktop.
Save tdhooper/d36b80d9e4d2dc1c0900 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.1)
// Compass (v1.0.1)
// ----
$icon-data: (
play: (
normal: (filename: 'something.png', top: 1px , left: 2px),
big: (filename: 'something-big.png', top: 1px , left: 2px),
),
stop: (
normal: (filename: 'else.png', top: 5px , left: 9px),
big: (filename: 'else-big.png', top: 1px , left: 2px),
)
);
@mixin iconleft($name) {
$icon: map-get($icon-data, $name);
$icon-size: map-get($icon, normal);
background: url(map-get($icon-size, filename));
default-icon-styles: yes;
}
@mixin iconleft--big($name) {
$icon: map-get($icon-data, $name);
$icon-size: map-get($icon, big);
background: url(map-get($icon-size, filename));
make: big;
}
@each $name, $data in $icon-data {
.iconleft--#{$name} {
@include iconleft($name);
&.iconleft--big {
@include iconleft--big($name);
}
}
}
/*
So the following are equivilent:
<a href="#" class="iconleft--play iconleft--big">Something</a>
<a href="#" class="test">Something</a>
*/
.test {
@include iconleft(play);
@include iconleft--big(play);
}
/* Changing the icon size with media queries */
.test-two {
@include iconleft(play);
}
@media (min-width: 100px) {
.test-two {
@include iconleft--big(play);
}
}
.iconleft--play {
background: url("something.png");
default-icon-styles: yes;
}
.iconleft--play.iconleft--big {
background: url("something-big.png");
make: big;
}
.iconleft--stop {
background: url("else.png");
default-icon-styles: yes;
}
.iconleft--stop.iconleft--big {
background: url("else-big.png");
make: big;
}
/*
So the following are equivilent:
<a href="#" class="iconleft--play iconleft--big">Something</a>
<a href="#" class="test">Something</a>
*/
.test {
background: url("something.png");
default-icon-styles: yes;
background: url("something-big.png");
make: big;
}
/* Changing the icon size with media queries */
.test-two {
background: url("something.png");
default-icon-styles: yes;
}
@media (min-width: 100px) {
.test-two {
background: url("something-big.png");
make: big;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment