fix: theme transition error

This commit is contained in:
radishzzz 2025-02-05 16:39:28 +00:00
parent bdc2aa32e6
commit 45385fd84a
4 changed files with 13 additions and 1 deletions

View file

@ -19,6 +19,7 @@ const marginBottom = {
<a
href={getLocalizedPath('/')}
transition:name="site-title"
data-disable-transition-on-theme
>
{title}
</a>

View file

@ -11,6 +11,7 @@ const { getLocalizedPath } = getPagePath(currentPath)
class="mt--1.4 text-8.32 c-secondary font-bold font-title"
href={getLocalizedPath('/')}
transition:name="site-title"
data-disable-transition-on-theme
>
{title}
</a>

View file

@ -19,6 +19,7 @@ function toggleTheme() {
// Set temporary transition name for theme toggle
document.documentElement.style.setProperty('view-transition-name', 'theme-transition')
document.documentElement.setAttribute('data-theme-transition', '')
const transition = document.startViewTransition(() => {
switchTheme()
@ -27,6 +28,7 @@ function toggleTheme() {
// Clean up after transition
transition.finished.then(() => {
document.documentElement.style.removeProperty('view-transition-name')
document.documentElement.removeAttribute('data-theme-transition')
})
}

View file

@ -78,10 +78,18 @@ html:not(.dark) {
z-index: 1;
}
html[data-theme-transition] [data-disable-transition-on-theme] {
view-transition-name: none !important;
}
@supports not (view-transition-name: none) {
html:not([data-restore-theme]) {
--at-apply: 'transition-colors duration-500 ease-in-out';
}
html:not([data-restore-theme]) [data-disable-transition-on-theme] {
--at-apply: 'transition-none!';
}
}
/* Snell Roundhand static Font */