From 2bae543492e233c7a54ee561d18a502fadbb4826 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Fri, 21 Feb 2025 12:02:04 +0100 Subject: [PATCH] Theme toggle --- src/components/app.tsx | 70 +++++++--------------------------- src/components/themeToggle.tsx | 27 +++++++++++++ 2 files changed, 40 insertions(+), 57 deletions(-) create mode 100644 src/components/themeToggle.tsx diff --git a/src/components/app.tsx b/src/components/app.tsx index 7a0302f..8d0cbd1 100644 --- a/src/components/app.tsx +++ b/src/components/app.tsx @@ -1,16 +1,7 @@ 'use client'; import * as React from 'react'; -import { Menu } from 'lucide-react'; -import { Button } from '@/components/ui/button'; import { usePathname } from 'next/navigation'; -import { - Sheet, - SheetContent, - SheetFooter, - SheetTitle, - SheetTrigger, -} from '@/components/ui/sheet'; import { SidebarContent, @@ -27,6 +18,7 @@ import { import { Calendar, LayoutDashboardIcon, Settings } from 'lucide-react'; import Link from 'next/link'; import useSmallScreen from '@/hooks/is-small'; +import ThemeToggle from './themeToggle'; // Menu items. const items = [ @@ -50,58 +42,15 @@ const footer = [ }, ]; -export function HamburgerMenu() { - const [open, setOpen] = React.useState(false); - const pathname = usePathname(); - - return ( - - Menu - - - - - {items.map((item, i) => ( -
- - {pathname === item.url ? ( - - ) : ( - - )} - -
- ))} - -
- - - {footer.map((item, i) => ( - - {pathname === item.url ? ( - - ) : ( - - )} - - ))} - - - - ); -} - export default function App({ children }: { children?: any }) { const isSmall = useSmallScreen(); const pathname = usePathname(); return isSmall ? ( -
-
-
+
+
+ {/* Navigation Items */} +
{items.map((item, i) => (
@@ -115,7 +64,8 @@ export default function App({ children }: { children?: any }) { ))}
-
+ {/* Footer Items */} +
{footer.map((item, i) => (
@@ -128,7 +78,12 @@ export default function App({ children }: { children?: any }) {
))}
+ +
+ +
+ {children}
) : ( @@ -177,6 +132,7 @@ export default function App({ children }: { children?: any }) { ))} + diff --git a/src/components/themeToggle.tsx b/src/components/themeToggle.tsx new file mode 100644 index 0000000..b4fc515 --- /dev/null +++ b/src/components/themeToggle.tsx @@ -0,0 +1,27 @@ +'use client'; + +import { useTheme } from 'next-themes'; +import { useEffect } from 'react'; +import { Button } from './ui/button'; +import { Lightbulb } from 'lucide-react'; + +export default function ThemeToggle( + props: React.DetailedHTMLProps< + React.HTMLAttributes, + HTMLSpanElement + > +) { + const { setTheme, theme } = useTheme(); + + return ( + + + + ); +}