feat: 💫 Animate color scheme changes

This commit is contained in:
Jesse Wierzbinski 2024-12-25 17:39:07 +01:00
parent 53cd4fc57d
commit 14c1dea7a5
No known key found for this signature in database

12
app.vue
View file

@ -39,7 +39,14 @@ const theme = useSetting(SettingIds.Theme) as Ref<EnumSetting>;
const colorMode = useColorMode();
watch(theme.value, () => {
// Add theme-changing class to html to trigger transition
document.documentElement.classList.add("theme-changing");
colorMode.preference = theme.value.value;
setTimeout(() => {
// Remove theme-changing class after transition
document.documentElement.classList.remove("theme-changing");
}, 1000);
});
useSeoMeta({
@ -87,4 +94,9 @@ useCacheRefresh(client);
body {
font-family: Inter, sans-serif;
}
html.theme-changing * {
/* Stroke and fill aren't animatable */
transition: background 1s ease, border 1s ease, color 1s ease, box-shadow 1s ease;
}
</style>