Skip to content

Commit 4aae54a

Browse files
fix: enhance header layout, improve error logging, and update router fallback
- adjust header styles for better responsiveness - improve error message for initial data load - add fallback element to router provider - optimize chunking in Vite configuration
1 parent c7ca557 commit 4aae54a

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

app/src/components/Header.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,14 @@ export const Header = memo(function Header({ stats, onRandom }: HeaderProps) {
8484
}, [onRandom]);
8585

8686
return (
87-
<Box component="header" sx={{ textAlign: 'center', mb: 4 }}>
87+
<Box component="header" sx={{
88+
textAlign: 'center',
89+
mb: 4,
90+
minHeight: { xs: '3.5rem', sm: '4.5rem', md: '6rem' },
91+
display: 'flex',
92+
flexDirection: 'column',
93+
justifyContent: 'center',
94+
}}>
8895
<Typography
8996
variant="h2"
9097
component="h1"

app/src/components/Layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ export function AppDataProvider({ children }: { children: ReactNode }) {
5959
setStats(data);
6060
}
6161
} catch (err) {
62-
console.error('Error loading initial data:', err);
62+
console.warn('Initial data load incomplete:', err instanceof Error ? err.message : err);
6363
}
64-
});
64+
}, { timeout: 2000 });
6565
return () => window.cancelIdleCallback(id);
6666
}, []);
6767

app/src/router.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function AppRouter() {
3939
<HelmetProvider>
4040
<ErrorBoundary>
4141
<AppDataProvider>
42-
<RouterProvider router={router} />
42+
<RouterProvider router={router} fallbackElement={<LazyFallback />} />
4343
</AppDataProvider>
4444
</ErrorBoundary>
4545
</HelmetProvider>

app/vite.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ export default defineConfig({
2020
rollupOptions: {
2121
output: {
2222
manualChunks(id) {
23+
if (id.includes('node_modules/@mui/icons-material/')) return 'mui-icons';
2324
if (id.includes('node_modules/@mui/')) return 'mui';
24-
if (id.includes('node_modules/react/') || id.includes('node_modules/react-dom/') || id.includes('node_modules/react-router-dom/')) return 'vendor';
25+
if (id.includes('node_modules/@emotion/')) return 'mui';
26+
if (id.includes('node_modules/react/') || id.includes('node_modules/react-dom/') || id.includes('node_modules/react-router')) return 'vendor';
2527
},
2628
},
2729
},

0 commit comments

Comments
 (0)