feat: 亮色暗色模式切换。
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
.wrapper {
|
||||
@apply bg-green-400 text-white;
|
||||
@apply bg-green-400 text-white min-h-screen;
|
||||
:global(.dark) & {
|
||||
@apply bg-gray-800 text-gray-400;
|
||||
}
|
||||
}
|
||||
.sidebar {
|
||||
@apply overflow-hidden flex flex-col fixed top-0;
|
||||
@apply text-center shadow-2xl;
|
||||
height: 100vh;
|
||||
@apply text-center shadow-2xl h-screen;
|
||||
padding-top: 10vh;
|
||||
}
|
||||
|
||||
|
10
components/switch-theme.tsx
Normal file
10
components/switch-theme.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { useTheme } from "../commons/theme";
|
||||
|
||||
export const SwitchTheme = () => {
|
||||
const { setMode, mode } = useTheme();
|
||||
|
||||
if (mode === "light") {
|
||||
return <button onClick={() => setMode("dark")}>暗色</button>;
|
||||
}
|
||||
return <button onClick={() => setMode("light")}>亮色</button>;
|
||||
};
|
Reference in New Issue
Block a user