Skip to content

Commit 0303b22

Browse files
fix: smooth blur circle transition, default to dark mode
- Add animation-fill-mode: forwards to view transition pseudo-elements to prevent flash when library removes injected style element - Increase blur circle duration to 600ms for smoother finish - Default to dark mode when no user preference is stored - Simplify FOUC script to match (dark unless explicitly light)
1 parent 1a029bc commit 0303b22

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

client/index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
<link rel="manifest" href="/site.webmanifest" />
1313
<title>Prunerr</title>
1414
<script>
15-
// Prevent flash of wrong theme (FOUC) - runs before CSS loads
15+
// Prevent flash of wrong theme (FOUC) - default to dark
1616
document.documentElement.classList.toggle(
1717
'dark',
18-
localStorage.theme === 'dark' ||
19-
(!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)
18+
localStorage.theme !== 'light'
2019
);
2120
</script>
2221
<link rel="preconnect" href="https://fonts.googleapis.com">

client/src/contexts/ThemeContext.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ function resolveTheme(theme: Theme): ResolvedTheme {
2525
function getInitialTheme(): Theme {
2626
const stored = localStorage.getItem('theme') as Theme | null;
2727
if (stored === 'light' || stored === 'dark' || stored === 'system') return stored;
28-
if (!('theme' in localStorage)) return 'system';
29-
return 'system';
28+
// Default to dark mode when no preference is stored
29+
return 'dark';
3030
}
3131

3232
function updateMetaThemeColor(isDark: boolean) {
@@ -48,7 +48,7 @@ export function ThemeProvider({ children }: { children: ReactNode }) {
4848
const { ref, toggleSwitchTheme, isDarkMode } = useModeAnimation({
4949
isDarkMode: resolvedTheme === 'dark',
5050
animationType: ThemeAnimationType.BLUR_CIRCLE,
51-
duration: 500,
51+
duration: 600,
5252
blurAmount: 6,
5353
easing: 'cubic-bezier(0.4, 0, 0.2, 1)',
5454
globalClassName: 'dark',

client/src/index.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,20 @@
115115

116116
}
117117

118+
/* View Transition: prevent flash at end of blur circle animation */
119+
::view-transition-old(root),
120+
::view-transition-new(root) {
121+
animation-fill-mode: forwards !important;
122+
}
123+
124+
::view-transition-old(root) {
125+
z-index: 1;
126+
}
127+
128+
::view-transition-new(root) {
129+
z-index: 9999;
130+
}
131+
118132
@layer components {
119133
/* Glass card effect */
120134
.glass {

0 commit comments

Comments
 (0)