1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-09-18 13:25:32 -04:00

move light/dark class from <body> to <html> and inline restoration script to (hopefully) improve the white flashes

This commit is contained in:
2021-12-15 13:49:56 -05:00
parent c2789e24d4
commit 766362a9da
14 changed files with 61 additions and 67 deletions

View File

@@ -1,25 +1,18 @@
@use "sass:map";
// Takes a map of CSS properties and theme keys (see below) and set both body.light and body.dark selectors.
// Takes a map of CSS properties and theme keys (see below) and set both html.light and html.dark selectors.
// ex. @include themes.themed((color: "text", background-color: "background-inner"));
@mixin themed($properties) {
// keep track of the original selector(s) calling this mixin for below
$selectors: #{&};
// add corresponding body.light and body.dark root selectors
// add corresponding html.light and html.dark root selectors
@each $theme, $map in $themes {
@at-root body.#{$theme} {
// support theming root body element
@if $selectors == "body" {
@at-root html.#{$theme} {
#{$selectors} {
@each $property, $color in $properties {
#{$property}: map.get($map, $color);
}
} @else {
#{$selectors} {
@each $property, $color in $properties {
#{$property}: map.get($map, $color);
}
}
}
}
}