Skip to content
This repository was archived by the owner on Dec 23, 2025. It is now read-only.

Commit 57bd4dc

Browse files
committed
feat(web): add auto theme switcher
1 parent 0235ad1 commit 57bd4dc

4 files changed

Lines changed: 27 additions & 5 deletions

File tree

apps/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"loglevel": "^1.9.1",
3838
"lucide-react": "^0.363.0",
3939
"next": "14.1.4",
40+
"next-themes": "^0.3.0",
4041
"numeral": "^2.0.6",
4142
"react": "^18",
4243
"react-dom": "^18",

apps/web/src/app/layout.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import { Analytics } from '@vercel/analytics/react'
22
import { SpeedInsights } from '@vercel/speed-insights/next'
33
import { Provider as JotaiProvider } from 'jotai'
44
import type { Metadata } from 'next'
5-
import { Inter } from 'next/font/google'
5+
import { DM_Sans } from 'next/font/google'
66

77
import './globals.css'
8+
import { ThemeProvider } from '@/components/theme-provider'
89

9-
const inter = Inter({ subsets: ['latin'] })
10+
const fontFamily = DM_Sans({ subsets: ['latin'] })
1011

1112
// eslint-disable-next-line react-refresh/only-export-components
1213
export const metadata: Metadata = {
@@ -20,16 +21,26 @@ export default function RootLayout({
2021
children: React.ReactNode
2122
}>) {
2223
return (
23-
<html lang="en">
24+
<html suppressHydrationWarning lang="en">
2425
<head>
2526
<meta
2627
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
2728
name="viewport"
2829
/>
2930
<link href="/images/logo/logo-base-32x32.png" rel="icon" sizes="any" />
3031
</head>
31-
<body className={inter.className}>
32-
<JotaiProvider>{children}</JotaiProvider>
32+
<body className={fontFamily.className}>
33+
<JotaiProvider>
34+
<ThemeProvider
35+
disableTransitionOnChange
36+
enableSystem
37+
attribute="class"
38+
defaultTheme="system"
39+
storageKey="theme"
40+
>
41+
{children}
42+
</ThemeProvider>
43+
</JotaiProvider>
3344
<Analytics />
3445
<SpeedInsights />
3546
</body>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use client'
2+
3+
import * as React from 'react'
4+
5+
import { ThemeProvider as NextThemesProvider } from 'next-themes'
6+
import { type ThemeProviderProps } from 'next-themes/dist/types'
7+
8+
export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
9+
return <NextThemesProvider {...props}>{children}</NextThemesProvider>
10+
}

bun.lockb

2.62 KB
Binary file not shown.

0 commit comments

Comments
 (0)