Created
May 13, 2015 07:30
-
-
Save lunelson/0599282aab00e03fc500 to your computer and use it in GitHub Desktop.
Theming mixin for Sass; forked from http://www.developwithpurpose.com/creating-a-sass-theme-engine/
This file contains hidden or 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.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 | |
| )); | |
| } |
This file contains hidden or 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
| .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