Merge pull request #11 from appwrite/preferred-color-theme

Preferred color theme
This commit is contained in:
Torsten Dittmann authored and GitHub committed 2022-05-18 17:26:57 +02:00
commit c05b1eefb5
2 files changed
+11 -2

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en" data-theme="light">
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="description" content="" />
+10 -1
View File
@@ -29,7 +29,16 @@
$: {
if (browser) {
document.body.setAttribute('class', `theme-${$app.theme}`);
if ($app.theme === 'auto') {
const darkThemeMq = window.matchMedia('(prefers-color-scheme: dark)');
if (darkThemeMq.matches) {
document.body.setAttribute('class', `theme-dark`);
} else {
document.body.setAttribute('class', `theme-light`);
}
} else {
document.body.setAttribute('class', `theme-${$app.theme}`);
}
}
}
</script>