Skip to content

Instantly share code, notes, and snippets.

@mvsde
Last active September 23, 2019 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvsde/22f984a96e836417c8e9c5452ebff97a to your computer and use it in GitHub Desktop.
Save mvsde/22f984a96e836417c8e9c5452ebff97a to your computer and use it in GitHub Desktop.
Simple color theme system with Dart Sass
<div class="is-primary">
<button class="button">I'm primary</button>
</div>
<div class="is-secondary">
<button class="button">I'm secondary</button>
</div>
$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