Last active
September 23, 2019 09:54
-
-
Save mvsde/22f984a96e836417c8e9c5452ebff97a to your computer and use it in GitHub Desktop.
Simple color theme system with Dart Sass
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
<div class="is-primary"> | |
<button class="button">I'm primary</button> | |
</div> | |
<div class="is-secondary"> | |
<button class="button">I'm secondary</button> | |
</div> |
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
$color-themes: ( | |
primary: rebeccapurple, | |
secondary: lightgoldenrodyellow | |
); | |
@mixin theme { | |
@each $theme, $color in $color-themes { | |
.is-#{$theme} & { | |
@content($color); | |
} | |
} | |
} | |
.button { | |
@include theme using ($color) { | |
background: $color; | |
&:hover, | |
&:focus { | |
background: darken($color, 10%); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment