Skip to content

Instantly share code, notes, and snippets.

@joshblack
Created November 16, 2020 19:31
Show Gist options
  • Save joshblack/a9e12046eca6f6b311349abd2f83f285 to your computer and use it in GitHub Desktop.
Save joshblack/a9e12046eca6f6b311349abd2f83f285 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
@mixin theme($tokens) {
& {
@each $token, $value in $tokens {
--#{$token}: #{$value};
}
}
}
$theme: (
white: #ffffff,
black: #000000,
);
@function theme($token) {
@if map-has-key($theme, $token) == false {
@error 'Unable to find token #{$token} in theme';
}
@return map-get($theme, $token);
}
@function t($token) {
@return var(--#{$token}, theme($token));
}
.theme {
@include theme($theme);
}
.title {
color: t(white);
color: var(--white, theme(white));
}
.theme {
--white: #ffffff;
--black: #000000;
}
.title {
color: var(--white, #ffffff);
color: var(--white, #ffffff);
}
{
"sass": {
"compiler": "dart-sass/1.26.11",
"extensions": {},
"syntax": "SCSS",
"outputStyle": "expanded"
},
"autoprefixer": false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment