-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fbbeb4a
commit cadd96d
Showing
8 changed files
with
402 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import { ThemeChooser } from '~/components/theme-chooser' | ||
|
||
export default function HomePage() { | ||
return ( | ||
<main className="flex min-h-screen flex-col items-center justify-center"></main> | ||
<main className="flex min-h-screen flex-col items-center justify-center"> | ||
<ThemeChooser /> | ||
</main> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use client' | ||
|
||
import { MoonIcon, SunIcon } from 'lucide-react' | ||
import { useTheme } from 'next-themes' | ||
|
||
import { Button } from '~/components/ui/button' | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuRadioGroup, | ||
DropdownMenuRadioItem, | ||
DropdownMenuTrigger, | ||
} from '~/components/ui/dropdown-menu' | ||
|
||
export const ThemeChooser = () => { | ||
const { theme, setTheme } = useTheme() | ||
|
||
console.log('theme', theme) | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button | ||
variant="ghost" | ||
size="icon" | ||
title="设置主题" | ||
aria-label="设置主题" | ||
> | ||
<SunIcon className="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" /> | ||
<MoonIcon className="absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" /> | ||
<span className="sr-only">设置主题</span> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent align="end"> | ||
<DropdownMenuRadioGroup value={theme} onValueChange={setTheme}> | ||
<DropdownMenuRadioItem value="light">明</DropdownMenuRadioItem> | ||
<DropdownMenuRadioItem value="dark">暗</DropdownMenuRadioItem> | ||
<DropdownMenuRadioItem value="system">跟随系统</DropdownMenuRadioItem> | ||
</DropdownMenuRadioGroup> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use client' | ||
|
||
import { ThemeProvider as NextThemesProvider } from 'next-themes' | ||
import { type ThemeProviderProps } from 'next-themes/dist/types' | ||
|
||
export const ThemeProvider = ({ children, ...props }: ThemeProviderProps) => { | ||
return <NextThemesProvider {...props}>{children}</NextThemesProvider> | ||
} |
Oops, something went wrong.