feat: add inline theme script to prevent FOUC

This commit is contained in:
2026-06-05 16:24:07 +02:00
committed by Milas Holsting
parent 2df8b7863d
commit b2f6db8ae1

View File

@@ -11,6 +11,13 @@
<title>MyAnimeList: {{template "title" .}}</title>
<link rel="manifest" href="/static/assets/manifest.json">
<link rel="icon" type="image/svg+xml" href="/static/assets/favicon.svg">
<script>
(function () {
var theme = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
document.documentElement.dataset.theme = theme;
document.documentElement.style.colorScheme = theme;
})();
</script>
<link rel="stylesheet" href="/dist/tailwind.css">
<style>
/* Prevent transition on load */
@@ -48,12 +55,6 @@
transition-duration: 300ms;
}
/* Theme toggle icon visibility */
html[data-theme="dark"] .theme-icon-dark { display: none; }
html[data-theme="dark"] .theme-icon-light { display: block; }
html[data-theme="light"] .theme-icon-light { display: none; }
html[data-theme="light"] .theme-icon-dark { display: block; }
[data-htmx-loading="true"] {
opacity: 0.65;
pointer-events: none;