web: add fade-in animation

This commit is contained in:
dumbmoron 2024-09-02 14:16:21 +00:00
parent 7227a4ad6e
commit 2deb8aa53b
No known key found for this signature in database
2 changed files with 41 additions and 10 deletions

View file

@ -17,17 +17,46 @@
<link rel="apple-touch-icon" sizes="180x180" href="%sveltekit.assets%/icons/apple-touch-icon.png"> <link rel="apple-touch-icon" sizes="180x180" href="%sveltekit.assets%/icons/apple-touch-icon.png">
<link crossorigin="use-credentials" rel="manifest" href="%sveltekit.assets%/manifest.json"> <link crossorigin="use-credentials" rel="manifest" href="%sveltekit.assets%/manifest.json">
</head>
<style> <noscript>
body { <style>
background-color: black; #cobalt { opacity: 1 !important }
} </style>
@media (prefers-color-scheme: light) { </noscript>
body {
<style>
body, #body-dark {
background-color: black;
}
#body-light {
background-color: white; background-color: white;
} }
}
</style> @media (prefers-color-scheme: light) {
body {
background-color: white;
}
}
#cobalt {
opacity: 0;
}
#cobalt.loaded {
opacity: 1;
transition: opacity .2s ease-out;
}
</style>
<script>
document.addEventListener('DOMContentLoaded', function() {
let settings = localStorage.getItem('settings'), theme;
if (settings && ({ theme } = JSON.parse(settings)?.appearance)) {
document.body.id = `body-${theme}`;
}
});
</script>
</head>
<body data-sveltekit-preload-data="hover" data-sveltekit-preload-code="eager"> <body data-sveltekit-preload-data="hover" data-sveltekit-preload-code="eager">
<div style="display: contents"> <div style="display: contents">
%sveltekit.body% %sveltekit.body%

View file

@ -1,6 +1,7 @@
<script lang="ts"> <script lang="ts">
import { afterNavigate } from "$app/navigation"; import { afterNavigate } from "$app/navigation";
import { updated } from "$app/stores"; import { updated } from "$app/stores";
import { browser } from "$app/environment";
import env from "$lib/env"; import env from "$lib/env";
import settings from "$lib/state/settings"; import settings from "$lib/state/settings";
@ -46,9 +47,10 @@
{/if} {/if}
</svelte:head> </svelte:head>
<div style="display: contents" data-theme={$currentTheme} lang={$locale}> <div style="display: contents" data-theme={browser ? $currentTheme : undefined} lang={$locale}>
<div <div
id="cobalt" id="cobalt"
class:loaded={browser}
data-iphone={device.is.iPhone} data-iphone={device.is.iPhone}
data-reduce-motion={reduceMotion} data-reduce-motion={reduceMotion}
data-reduce-transparency={reduceTransparency} data-reduce-transparency={reduceTransparency}