feat: scrollbar dark mode (#24)

This commit is contained in:
nullptr 2024-11-15 07:47:41 +00:00 committed by GitHub
parent 531949606a
commit f06754e0f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 10 deletions

View File

@ -39,6 +39,7 @@
--fg-muted-alt: hsl(0, 0%, 75%); --fg-muted-alt: hsl(0, 0%, 75%);
--fg-highlight: hsl(303, 61%, 47%); --fg-highlight: hsl(303, 61%, 47%);
--fg-failure: hsl(0, 67%, 49%); --fg-failure: hsl(0, 67%, 49%);
color-scheme: light;
} }
@mixin dark { @mixin dark {
@ -51,25 +52,26 @@
--fg-muted-alt: hsl(0, 0%, 25%); --fg-muted-alt: hsl(0, 0%, 25%);
--fg-highlight: hsl(303, 64%, 65%); --fg-highlight: hsl(303, 64%, 65%);
--fg-failure: hsl(0, 67%, 80%); --fg-failure: hsl(0, 67%, 80%);
color-scheme: dark;
} }
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
body { :root {
@include dark; @include dark;
} }
} }
@media (prefers-color-scheme: light) { @media (prefers-color-scheme: light) {
body { :root {
@include light; @include light;
} }
} }
body.light { :root.light {
@include light; @include light;
} }
body.dark { :root.dark {
@include dark; @include dark;
} }

View File

@ -53,16 +53,16 @@
$effect(() => { $effect(() => {
if (!browser) return; if (!browser) return;
if (theme.dark) { if (theme.dark) {
document.body.classList.add("dark"); document.documentElement.classList.add("dark");
document.body.classList.remove("light"); document.documentElement.classList.remove("light");
JSCookie.set("theme", "dark", { JSCookie.set("theme", "dark", {
path: "/", path: "/",
sameSite: "lax", sameSite: "lax",
expires: 2147483647, expires: 2147483647,
}); });
} else { } else {
document.body.classList.add("light"); document.documentElement.classList.add("light");
document.body.classList.remove("dark"); document.documentElement.classList.remove("dark");
JSCookie.set("theme", "light", { JSCookie.set("theme", "light", {
path: "/", path: "/",
sameSite: "lax", sameSite: "lax",

View File

@ -28,8 +28,8 @@ export default {
plugins: [ plugins: [
plugin(function ({ addVariant }) { plugin(function ({ addVariant }) {
addVariant("dynadark", [ addVariant("dynadark", [
"body:not(.light).dark &", ":root:not(.light).dark &",
"@media (prefers-color-scheme: dark) { body:not(.light) &", "@media (prefers-color-scheme: dark) { :root:not(.light) &",
]); ]);
}), }),
], ],