initial theme picker logic
This commit is contained in:
@@ -35,8 +35,18 @@ const title = Astro.props.title || Astro.props.frontmatter?.title || "Unknown";
|
||||
</head>
|
||||
<body
|
||||
class="layout-simple"
|
||||
x-data="{ drawerOpen: false }"
|
||||
:class="drawerOpen ? 'lock-scroll' : ''"
|
||||
x-data="{
|
||||
drawerOpen: false,
|
||||
theme: $persist('system'),
|
||||
isDark() {
|
||||
const osIsDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
|
||||
if (this.theme === 'dark' || this.theme === 'system' && osIsDark) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}"
|
||||
:class="{ 'lock-scroll': drawerOpen, 'theme-dark': isDark()}"
|
||||
>
|
||||
<Header />
|
||||
<main transition:animate="initial">
|
||||
|
||||
Reference in New Issue
Block a user