Created
April 4, 2014 19:34
-
-
Save ezekg/9981683 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// Sass (v3.3.4) | |
// Compass (v1.0.0.alpha.18) | |
// ---- | |
// Making placeholders extendable within media queries | |
$prototypes: () !global; | |
@function exists($map, $value){ | |
@if type-of($map) == map { | |
@if map-has-key($map, $value) { | |
@return true; | |
} | |
@each $key, $i in $map { | |
@if exists($i, $value) { | |
@return true; | |
} | |
} | |
} @return false; | |
} | |
@mixin prototype__build($prototype) { | |
@each $property, $value in $prototype { | |
@if type-of($value) == map { | |
&:#{$property} { | |
@each $mod_property, $mod_value in $value { | |
#{$mod_property}: #{$mod_value}; | |
} | |
} | |
} @else { | |
#{$property}: $value; | |
} | |
} | |
} | |
@mixin prototype($n) { | |
@if exists($prototypes, $n) { | |
%#{$n}--media { | |
$init: map-get($prototypes, $n); | |
@include prototype__build($init); | |
} | |
} @else { | |
%#{$n} { | |
@content; | |
} | |
// Here is where interpolating a stringified `@content`, and slicing up the output | |
// into a map would come in handy... | |
$prototype: ( #{$n}: ( styles: here, hover: ( pseudo-stuff: here, ), ), ); | |
$prototypes: map-merge($prototypes, $prototype) !global; | |
} | |
} | |
@include prototype(clearfix) { | |
zoom: 1; | |
&:before, &:after { | |
content: "\0020"; | |
display: block; | |
height: 0; | |
overflow: hidden; | |
} | |
&:after { | |
clear: both; | |
} | |
} | |
.extendee { | |
@extend %clearfix; | |
} | |
.extendee_2 { | |
@extend %clearfix; | |
} | |
@media screen { | |
@include prototype(clearfix); | |
.media_extendee { | |
@extend %clearfix--media; | |
} | |
.media_extendee_2 { | |
@extend %clearfix--media; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.extendee, .extendee_2 { | |
zoom: 1; | |
} | |
.extendee:before, .extendee_2:before, .extendee:after, .extendee_2:after { | |
content: "\0020"; | |
display: block; | |
height: 0; | |
overflow: hidden; | |
} | |
.extendee:after, .extendee_2:after { | |
clear: both; | |
} | |
@media screen { | |
.media_extendee, .media_extendee_2 { | |
styles: here; | |
} | |
.media_extendee:hover, .media_extendee_2:hover { | |
pseudo-stuff: here; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment