Last active
October 24, 2020 09:35
-
-
Save michaeldeboeve/a28b5783d0a756aa951bbd11f48694f8 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 setProp($prop, $val) { | |
--#{$prop}: #{$val}; | |
} | |
@mixin prop($customProp, $renderedValue) { | |
// #{$customProp}: map-get($VariablesMap, $renderedValue); | |
#{$customProp}: var(unquote('--#{$renderedValue}')); | |
} | |
// Colors | |
$black: #000; | |
$white: #fff; | |
$red: #E25050; | |
$green: #6DE250; | |
$text-color: #1f1f1f; | |
$error-color: $red; | |
$success-color: $green; | |
// Sass Variables Map | |
$VariablesMap: ( | |
text-color: $black, | |
backgroun-color: $white, | |
error: $red, | |
success: $green, | |
); | |
// :root custom properties generator | |
:root { | |
@each $prop, $val in $VariablesMap { | |
@include setProp($prop, $val); | |
} | |
} | |
h2 { | |
@include prop('background-color', 'error'); | |
} | |
.grey { | |
@include setProp('error', #ccc) | |
} | |
.main { | |
@include setProp('error', $green) | |
} |
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
:root { | |
--text-color: #000; | |
--backgroun-color: #fff; | |
--error: #E25050; | |
--success: #6DE250; | |
} | |
h2 { | |
background-color: var(--error); | |
} | |
.grey { | |
--error: #ccc; | |
} | |
.main { | |
--error: #6DE250; | |
} |
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