Skip to content

Commit d2fa9be

Browse files
committed
fix(theme): update theme handling and improve CSS variant matching
- Changed theme state management to use resolvedTheme for accurate theme detection - Updated CSS custom variant for dark mode to align with next-themes attribute usage - Adjusted import path for route types to ensure compatibility with Next.js updates
1 parent f3ac660 commit d2fa9be

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

components/theme.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import Sun from './icons/sun';
44
import { useTheme } from 'next-themes';
55

66
const Theme = () => {
7-
const { theme, setTheme } = useTheme();
7+
const { setTheme, resolvedTheme } = useTheme();
88

99
if (process.env.theme !== 'both') return <></>;
1010

1111
return (
12-
theme === 'light'
12+
resolvedTheme === 'light'
1313
? <Moon width="2em" height="2em" onClick={() => setTheme('dark')}/>
1414
: <Sun width="2em" height="2em" onClick={() => setTheme('light')}/>
1515
);

next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
import "./.next/dev/types/routes.d.ts";
3+
import "./.next/types/routes.d.ts";
44

55
// NOTE: This file should not be edited
66
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.

styles/globals.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@import 'tailwindcss';
22

3-
@custom-variant dark (&:is([data-theme="dark"] *));
3+
/* Match next-themes `attribute="class"` (html.dark) */
4+
@custom-variant dark (&:where(.dark, .dark *));
45

56
@theme {
67
--font-*: initial;

0 commit comments

Comments
 (0)