forked from ofekashery/react-dashboard-design
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_app.tsx
51 lines (45 loc) · 1.86 KB
/
_app.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React, { useCallback, useEffect, useState } from 'react';
import Head from 'next/head';
import type { AppProps } from 'next/app';
import { GeistProvider, CssBaseline } from '@geist-ui/react';
import { PrefersContext, themes, ThemeType } from '@/lib/use-prefers';
import Menu from '@/components/navigation/menu';
import Footer from '@/components/footer';
const DashboardApp = ({ Component, pageProps }: AppProps) => {
const [themeType, setThemeType] = useState<ThemeType>('dark');
useEffect(() => {
document.documentElement.removeAttribute('style');
document.body.removeAttribute('style');
const theme = window.localStorage.getItem('theme') as ThemeType;
if (themes.includes(theme)) setThemeType(theme);
}, []);
const switchTheme = useCallback((theme: ThemeType) => {
setThemeType(theme);
if (typeof window !== 'undefined' && window.localStorage) window.localStorage.setItem('theme', theme);
}, []);
return (
<>
<Head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<title>React Dashboard Design</title>
<meta name="og:title" content="React Dashboard Design" />
<meta name="og:description" content="Inspired by and based on the Vercel™ Design System." />
<meta name="description" content="Inspired by and based on the Vercel™ Design System." />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap"
rel="stylesheet"
/>
</Head>
<GeistProvider themeType={themeType}>
<CssBaseline />
<PrefersContext.Provider value={{ themeType, switchTheme }}>
<Menu />
<Component {...pageProps} />
<Footer />
</PrefersContext.Provider>
</GeistProvider>
</>
);
};
export default DashboardApp;