Created
July 31, 2023 13:45
-
-
Save jrson83/57f11e9efc751db2c2e968ebaf9f1cb1 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'; | |
$colors: () !default; | |
$colors: map.merge( | |
( | |
'light': ( | |
'color-bg': hsl(0deg 0 100), | |
'color-surface': hsl(0deg 0 90), | |
'color-text': hsl(0deg 0 0), | |
'color-text-2': hsl(0deg 0 10), | |
), | |
'dark': ( | |
'color-bg': hsl(0deg 0 0), | |
'color-surface': hsl(0deg 0 10), | |
'color-text': hsl(0deg 0 100), | |
'color-text-2': hsl(0deg 0 90), | |
), | |
), | |
$colors | |
); | |
/// Map deep get. | |
/// @param {Map} $map - The map. | |
/// @param {Arglist} $keys - The key chain. | |
/// @return {*} - The desired value. | |
@function map-deep-get($map, $keys...) { | |
@each $key in $keys { | |
$map: map.get($map, $key); | |
} | |
@return $map; | |
} | |
@mixin mix-themes( | |
$themes: $colors, | |
$selector: ':root' | |
) { | |
@each $theme, $map in $themes { | |
@media (prefers-color-scheme: #{$theme}) { | |
#{$selector} { | |
color-scheme: #{$theme}; | |
@each $key, $submap in $map { | |
--#{$key}: #{map-deep-get($themes, $theme, "#{$key}")}; | |
} | |
} | |
} | |
} | |
} | |
@include mix-themes(); |
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
@media (prefers-color-scheme: light) { | |
:root { | |
color-scheme: light; | |
--color-bg: white; | |
--color-surface: #e6e6e6; | |
--color-text: black; | |
--color-text-2: #1a1a1a; | |
} | |
} | |
@media (prefers-color-scheme: dark) { | |
:root { | |
color-scheme: dark; | |
--color-bg: black; | |
--color-surface: #1a1a1a; | |
--color-text: white; | |
--color-text-2: #e6e6e6; | |
} | |
} |
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