Skip to content

Instantly share code, notes, and snippets.

@babsgosgens
Created June 8, 2014 09:16
Show Gist options
  • Save babsgosgens/6e53d18323f57c21bcaf to your computer and use it in GitHub Desktop.
Save babsgosgens/6e53d18323f57c21bcaf to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.3.8)
// Compass (v1.0.0.alpha.19)
// ----
@mixin smart-extend($placeholder-name)
{
@extend %#{$placeholder-name} !optional;
}
$smart-cache: ();
@mixin smart-cache($declarations) {
@debug $declarations;
// Looping through all properties/values from map
@each $property, $value in $declarations {
// Get the stored values for the current property
$stored-values: map-get($smart-cache, $property);
// If the value doesn't exist in stored values
@if not index($stored-values, $value) {
// Add it
$smart-cache: map-merge($smart-cache, ($property: append($stored-values or (), $value))) !global;
// And create a placeholder at root level
@at-root %#{$property}-#{length(map-get($smart-cache, $property))} {
#{$property}: $value;
}
}
// Extend the placeholder
@extend %#{$property}-#{index(map-get($smart-cache, $property), $value)};
}
}
%inline-block {
@include smart-cache((
display: inline-block
));
}
%no-padding {
@include smart-cache((
padding: 0
));
}
%no-margin {
@include smart-cache((
margin: 0
));
}
body {
@include smart-extend('inline-block');
@include smart-extend('no-margin');
@include smart-extend('no-padding');
}
div, p {
@include smart-extend('inline-block');
@include smart-extend('no-margin');
}
ul {
@include smart-extend('inline-block');
@include smart-extend('no-margin');
/* more rules */
}
body, div, p, ul {
display: inline-block;
}
body {
padding: 0;
}
body, div, p, ul {
margin: 0;
}
ul {
/* more rules */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment