feat(app): add dark/light theme switcher via next-themes
This commit is contained in:
@@ -1,11 +1,15 @@
|
|||||||
import { NavLink } from "react-router";
|
import { NavLink } from "react-router";
|
||||||
import { Music } from "lucide-react";
|
import { Music, Sun, Moon } from "lucide-react";
|
||||||
|
import { useTheme } from "next-themes";
|
||||||
import { cn } from "~/lib/utils";
|
import { cn } from "~/lib/utils";
|
||||||
|
import { Button } from "~/components/ui/button";
|
||||||
|
|
||||||
export function BottomNav() {
|
export function BottomNav() {
|
||||||
|
const { resolvedTheme, setTheme } = useTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className="border-t bg-background shrink-0">
|
<nav className="border-t bg-background shrink-0">
|
||||||
<div className="max-w-lg mx-auto flex">
|
<div className="max-w-lg mx-auto flex items-center">
|
||||||
<NavLink
|
<NavLink
|
||||||
to="/"
|
to="/"
|
||||||
end
|
end
|
||||||
@@ -21,6 +25,20 @@ export function BottomNav() {
|
|||||||
<Music className="w-5 h-5" />
|
<Music className="w-5 h-5" />
|
||||||
<span>Library</span>
|
<span>Library</span>
|
||||||
</NavLink>
|
</NavLink>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
className="mr-2 text-muted-foreground hover:text-foreground"
|
||||||
|
onClick={() => setTheme(resolvedTheme === "dark" ? "light" : "dark")}
|
||||||
|
aria-label="Toggle theme"
|
||||||
|
>
|
||||||
|
{resolvedTheme === "dark" ? (
|
||||||
|
<Sun className="w-5 h-5" />
|
||||||
|
) : (
|
||||||
|
<Moon className="w-5 h-5" />
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
Scripts,
|
Scripts,
|
||||||
ScrollRestoration,
|
ScrollRestoration,
|
||||||
} from "react-router";
|
} from "react-router";
|
||||||
|
import { ThemeProvider } from "next-themes";
|
||||||
|
|
||||||
import type { Route } from "./+types/root";
|
import type { Route } from "./+types/root";
|
||||||
import "./app.css";
|
import "./app.css";
|
||||||
@@ -34,11 +35,13 @@ export function Layout({ children }: { children: React.ReactNode }) {
|
|||||||
<Links />
|
<Links />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<TooltipProvider>
|
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
|
||||||
{children}
|
<TooltipProvider>
|
||||||
<ScrollRestoration />
|
{children}
|
||||||
<Scripts />
|
<ScrollRestoration />
|
||||||
</TooltipProvider>
|
<Scripts />
|
||||||
|
</TooltipProvider>
|
||||||
|
</ThemeProvider>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user