Skip to content

Instantly share code, notes, and snippets.

@lunelson
Created May 13, 2015 07:30
Show Gist options
  • Select an option

  • Save lunelson/0599282aab00e03fc500 to your computer and use it in GitHub Desktop.

Select an option

Save lunelson/0599282aab00e03fc500 to your computer and use it in GitHub Desktop.
// ----
// Sass (v3.4.13)
// Compass (v1.0.3)
// ----
// theme mixin
@mixin theme(
// DEFAULTS
$post_title: null,
$post_subtitle: null
) {
// IF first arg is a map, pass that
@if type-of($post_title) == 'map' { @include theme($post_title...); }
// otherwise assume named arguments
@else {
@if $post_title {
%theme_post_title {
color: $post_title;
}
}
@if $post_subtitle {
%theme_post_subtitle {
color: $post_subtitle;
}
}
}
}
.post_title {
@extend %theme_post_title !optional;
color: black;
}
.post_subtitle {
@extend %theme_post_subtitle !optional;
color: black;
}
.page--forest {
@include theme((
post_title: forestgreen,
post_subtitle: green
));
}
.page--ocean {
@include theme((
post_subtitle: navy
));
}
.post_title {
color: black;
}
.post_subtitle {
color: black;
}
.page--forest .post_title {
color: forestgreen;
}
.page--forest .post_subtitle {
color: green;
}
.page--ocean .post_subtitle {
color: navy;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment