Created
November 16, 2020 19:31
-
-
Save joshblack/a9e12046eca6f6b311349abd2f83f285 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
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
@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)); | |
} |
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
.theme { | |
--white: #ffffff; | |
--black: #000000; | |
} | |
.title { | |
color: var(--white, #ffffff); | |
color: var(--white, #ffffff); | |
} |
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
{ | |
"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