Created
June 23, 2022 14:23
-
-
Save norin89/51eb9a66a9950d8937b087a4005e7d53 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains hidden or 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
@use "sass:map"; | |
// Sass map, ideally imported from JSON (e.g. with https://github.com/pmowrer/node-sass-json-importer) | |
// Based on MUI palette example - https://mui.com/material-ui/customization/color/#picking-colors | |
$palette: ( | |
primary: ( | |
light: '#757ce8', | |
main: '#3f50b5', | |
dark: '#002884', | |
contrastText: '#fff', | |
), | |
secondary: ( | |
light: '#ff7961', | |
main: '#f44336', | |
dark: '#ba000d', | |
contrastText: '#000', | |
) | |
); | |
@function color-var($name, $variant) { | |
@if map.has-key($palette, $name, $variant) { | |
@return --#{$name}-#{$variant}; | |
} | |
// @warn "Color '#{$name}' or it's variant '#{$variant}' not found!"; | |
@return "Color '#{$name}' or it's variant '#{$variant}' not found!"; | |
} | |
:root { | |
@each $name, $variants in $palette { | |
@each $variant, $color in $variants { | |
#{color-var($name, $variant)}: #{$color}; | |
} | |
} | |
} | |
body { | |
background: color-var(primary, dark); | |
color: color-var(primary, contrastText); | |
border: color-var(primary, nonExisting); | |
} |
This file contains hidden or 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 { | |
--primary-light: #757ce8; | |
--primary-main: #3f50b5; | |
--primary-dark: #002884; | |
--primary-contrastText: #fff; | |
--secondary-light: #ff7961; | |
--secondary-main: #f44336; | |
--secondary-dark: #ba000d; | |
--secondary-contrastText: #000; | |
} | |
body { | |
background: --primary-dark; | |
color: --primary-contrastText; | |
border: "Color 'primary' or it's variant 'nonExisting' not found!"; | |
} |
This file contains hidden or 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.32.12", | |
"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