From 93eca1fa7afa1d1faad5742e290ff83d6d607c68 Mon Sep 17 00:00:00 2001 From: radishzzz Date: Wed, 5 Feb 2025 17:07:45 +0000 Subject: [PATCH] fix: theme transition error on ios --- src/components/Header.astro | 1 + src/components/Navbar.astro | 12 ++++++------ src/components/SiteTitle.astro | 2 +- src/pages/index.astro | 2 +- src/styles/global.css | 15 ++++----------- uno.config.ts | 11 ++++++++++- 6 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/components/Header.astro b/src/components/Header.astro index b329ee2..03469be 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -17,6 +17,7 @@ const marginBottom = {

{currentUI.posts} @@ -31,8 +31,8 @@ const isAboutActive = isAbout; href={getLocalizedPath('/tags')} class:list={[ isTagActive - ? 'font-bold text-primary' - : 'hover:text-primary hover:font-bold', + ? 'font-bold c-primary' + : 'hover:c-primary hover:font-bold', ]} > {currentUI.tags} @@ -43,8 +43,8 @@ const isAboutActive = isAbout; href={getLocalizedPath('/about')} class:list={[ isAboutActive - ? 'font-bold text-primary' - : 'hover:text-primary hover:font-bold', + ? 'font-bold c-primary' + : 'hover:c-primary hover:font-bold', ]} > {currentUI.about} diff --git a/src/components/SiteTitle.astro b/src/components/SiteTitle.astro index 4c8cd67..eabca0c 100644 --- a/src/components/SiteTitle.astro +++ b/src/components/SiteTitle.astro @@ -8,7 +8,7 @@ const { getLocalizedPath } = getPagePath(currentPath) --- {/* Post Title */} - {post.data.title} + {post.data.title} {/* Post Date */}
{post.data.published.toLocaleDateString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '-')} diff --git a/src/styles/global.css b/src/styles/global.css index 55d7607..f8c1ba6 100644 --- a/src/styles/global.css +++ b/src/styles/global.css @@ -5,9 +5,7 @@ } html { - --at-apply: 'bg-background c-secondary text-62.5% antialiased scroll-smooth'; - scrollbar-width: none; - -ms-overflow-style: none; + --at-apply: 'bg-background c-secondary text-62.5% antialiased scroll-smooth scrollbar-hidden'; } html::-webkit-scrollbar { @@ -15,10 +13,7 @@ html::-webkit-scrollbar { } body { - --at-apply: 'text-1.6rem'; - /* Fix for iOS browser flash issue */ - backface-visibility: hidden; - -webkit-backface-visibility: hidden; + --at-apply: 'text-1.6rem ios-flash-fix'; } h1 { @@ -46,10 +41,8 @@ h6 { } article img { - --at-apply: 'cursor-zoom-in'; /* Optimize animation performance of Scrollbar */ - transform: translateZ(0); - -webkit-transform: translateZ(0); + --at-apply: 'cursor-zoom-in ios-flash-fix'; } /* Horizontal reveal animation on theme toggle */ @@ -84,7 +77,7 @@ html[data-theme-transition] [data-disable-transition-on-theme] { @supports not (view-transition-name: none) { html:not([data-restore-theme]) { - --at-apply: 'transition-colors duration-500 ease-in-out'; + --at-apply: 'transition-colors duration-300 ease-in-out'; } html:not([data-restore-theme]) [data-disable-transition-on-theme] { diff --git a/uno.config.ts b/uno.config.ts index 0e6409a..6b74f7f 100644 --- a/uno.config.ts +++ b/uno.config.ts @@ -35,7 +35,16 @@ export default defineConfig({ }, }, shortcuts: {}, - rules: [], + rules: [ + ['scrollbar-hidden', { + 'scrollbar-width': 'none', + '-ms-overflow-style': 'none', + }], + ['ios-flash-fix', { + 'backface-visibility': 'hidden', + '-webkit-backface-visibility': 'hidden', + }], + ], transformers: [ transformerDirectives(), transformerVariantGroup(),