2026-02-22 21:35:53 +01:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import * as React from 'react';
|
|
|
|
|
import Link from 'next/link';
|
|
|
|
|
import { usePathname } from 'next/navigation';
|
|
|
|
|
import {
|
|
|
|
|
ChevronRight,
|
|
|
|
|
MousePointer2,
|
|
|
|
|
Palette,
|
|
|
|
|
Eye,
|
|
|
|
|
Languages,
|
|
|
|
|
Layers,
|
|
|
|
|
ChevronLeft,
|
|
|
|
|
X
|
|
|
|
|
} from 'lucide-react';
|
|
|
|
|
import { cn } from '@/lib/utils/cn';
|
|
|
|
|
import Logo from '@/components/Logo';
|
|
|
|
|
import { useSidebar } from './SidebarProvider';
|
2026-02-24 16:20:35 +01:00
|
|
|
import { Button } from '@/components/ui/button';
|
2026-02-26 17:48:16 +01:00
|
|
|
import { ColorIcon, UnitsIcon, ASCIIIcon, MediaIcon, FaviconIcon } from '@/components/AppIcons';
|
2026-02-22 21:35:53 +01:00
|
|
|
|
|
|
|
|
interface NavItem {
|
|
|
|
|
title: string;
|
|
|
|
|
href: string;
|
|
|
|
|
icon: React.ElementType | React.ReactNode;
|
|
|
|
|
items?: { title: string; href: string }[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface NavGroup {
|
|
|
|
|
label: string;
|
|
|
|
|
items: NavItem[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const navigation: NavGroup[] = [
|
|
|
|
|
{
|
|
|
|
|
label: 'Toolkit',
|
|
|
|
|
items: [
|
|
|
|
|
{
|
|
|
|
|
title: 'Units Converter',
|
|
|
|
|
href: '/units',
|
|
|
|
|
icon: <UnitsIcon className="h-4 w-4" />
|
|
|
|
|
},
|
|
|
|
|
{
|
2026-02-26 12:31:10 +01:00
|
|
|
title: 'ASCII Art',
|
|
|
|
|
href: '/ascii',
|
|
|
|
|
icon: <ASCIIIcon className="h-4 w-4" />
|
2026-02-22 21:35:53 +01:00
|
|
|
},
|
|
|
|
|
{
|
2026-02-26 12:19:22 +01:00
|
|
|
title: 'Color Manipulation',
|
|
|
|
|
href: '/color',
|
|
|
|
|
icon: <ColorIcon className="h-4 w-4" />
|
2026-02-22 21:35:53 +01:00
|
|
|
},
|
2026-02-25 10:06:50 +01:00
|
|
|
{
|
|
|
|
|
title: 'Media Converter',
|
|
|
|
|
href: '/media',
|
|
|
|
|
icon: <MediaIcon className="h-4 w-4" />
|
|
|
|
|
},
|
2026-02-26 17:48:16 +01:00
|
|
|
{
|
|
|
|
|
title: 'Favicon Generator',
|
|
|
|
|
href: '/favicon',
|
|
|
|
|
icon: <FaviconIcon className="h-4 w-4" />
|
|
|
|
|
},
|
2026-02-22 21:35:53 +01:00
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export function AppSidebar() {
|
|
|
|
|
const pathname = usePathname();
|
|
|
|
|
const { isOpen, isCollapsed, close, toggleCollapse } = useSidebar();
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{/* Mobile Overlay Backdrop */}
|
|
|
|
|
{isOpen && (
|
|
|
|
|
<div
|
|
|
|
|
className="fixed inset-0 bg-background/80 backdrop-blur-sm z-40 lg:hidden"
|
|
|
|
|
onClick={close}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<aside className={cn(
|
2026-02-23 02:04:46 +01:00
|
|
|
"fixed inset-y-0 left-0 z-50 flex flex-col border-r border-border bg-background/40 backdrop-blur-2xl transition-all duration-300 ease-in-out lg:relative lg:h-full",
|
2026-02-22 21:35:53 +01:00
|
|
|
isOpen ? "translate-x-0" : "-translate-x-full lg:translate-x-0",
|
|
|
|
|
isCollapsed ? "lg:w-20" : "w-64"
|
|
|
|
|
)}>
|
|
|
|
|
{/* Sidebar Header */}
|
2026-02-23 02:04:46 +01:00
|
|
|
<div className="flex h-16 items-center justify-between px-6 shrink-0 border-b border-border">
|
2026-02-22 21:35:53 +01:00
|
|
|
<Link href="/" className="flex items-center gap-3 group overflow-hidden">
|
|
|
|
|
<div className="shrink-0">
|
2026-02-23 13:33:17 +01:00
|
|
|
<Logo size={isCollapsed ? 24 : 24} />
|
2026-02-22 21:35:53 +01:00
|
|
|
</div>
|
|
|
|
|
{!isCollapsed && (
|
2026-02-24 19:19:34 +01:00
|
|
|
<span className="font-bold text-xl transition-colors text-foreground">
|
2026-02-22 21:35:53 +01:00
|
|
|
Kit
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
</Link>
|
|
|
|
|
<Button
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="icon"
|
|
|
|
|
className="lg:hidden text-muted-foreground"
|
|
|
|
|
onClick={close}
|
|
|
|
|
>
|
|
|
|
|
<X className="h-5 w-5" />
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Navigation */}
|
|
|
|
|
<nav className="flex-1 overflow-y-auto px-4 py-2 space-y-8 mt-4 scrollbar-hide">
|
|
|
|
|
{navigation.map((group) => (
|
|
|
|
|
<div key={group.label} className="space-y-2">
|
|
|
|
|
{!isCollapsed && (
|
|
|
|
|
<h4 className="px-3 text-xs font-semibold text-muted-foreground/50 uppercase tracking-wider">
|
|
|
|
|
{group.label}
|
|
|
|
|
</h4>
|
|
|
|
|
)}
|
|
|
|
|
<div className="space-y-1">
|
|
|
|
|
{group.items.map((item) => {
|
|
|
|
|
const isActive = pathname === item.href || (item.href !== '/' && pathname.startsWith(item.href));
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div key={item.href} className="space-y-1">
|
|
|
|
|
<Link
|
|
|
|
|
href={item.href}
|
|
|
|
|
onClick={() => { if (window.innerWidth < 1024) close(); }}
|
|
|
|
|
className={cn(
|
2026-02-24 16:58:17 +01:00
|
|
|
"flex items-center px-3 py-2 rounded-lg text-sm font-medium transition-all duration-300 relative group/item",
|
2026-02-22 21:35:53 +01:00
|
|
|
isActive
|
2026-02-24 16:58:17 +01:00
|
|
|
? "bg-primary/10 text-primary ring-1 ring-primary/20"
|
2026-02-23 02:04:46 +01:00
|
|
|
: "text-muted-foreground hover:bg-accent/50 hover:text-foreground",
|
2026-02-22 21:35:53 +01:00
|
|
|
isCollapsed ? "justify-center" : "justify-between"
|
|
|
|
|
)}
|
|
|
|
|
title={isCollapsed ? item.title : undefined}
|
|
|
|
|
>
|
|
|
|
|
<div className="flex items-center gap-3">
|
|
|
|
|
<span className={cn(
|
|
|
|
|
"transition-colors duration-300 shrink-0",
|
|
|
|
|
isActive ? "text-primary" : "text-muted-foreground group-hover/item:text-foreground"
|
|
|
|
|
)}>
|
|
|
|
|
{React.isValidElement(item.icon) ? item.icon : null}
|
|
|
|
|
</span>
|
|
|
|
|
{!isCollapsed && <span className="whitespace-nowrap">{item.title}</span>}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{!isCollapsed && item.items && (
|
|
|
|
|
<ChevronRight className={cn(
|
|
|
|
|
"h-3.5 w-3.5 transition-transform duration-300",
|
|
|
|
|
pathname.startsWith(item.href) && "rotate-90"
|
|
|
|
|
)} />
|
|
|
|
|
)}
|
|
|
|
|
</Link>
|
|
|
|
|
|
|
|
|
|
{item.items && pathname.startsWith(item.href) && !isCollapsed && (
|
2026-02-23 02:04:46 +01:00
|
|
|
<div className="ml-9 space-y-1 border-l border-border pl-2 mt-1">
|
2026-02-22 21:35:53 +01:00
|
|
|
{item.items.map((subItem) => (
|
|
|
|
|
<Link
|
|
|
|
|
key={subItem.href}
|
|
|
|
|
href={subItem.href}
|
|
|
|
|
onClick={() => { if (window.innerWidth < 1024) close(); }}
|
|
|
|
|
className={cn(
|
|
|
|
|
"block px-3 py-1.5 rounded-lg text-xs font-medium transition-all duration-200",
|
|
|
|
|
pathname === subItem.href
|
|
|
|
|
? "text-primary bg-primary/5 font-semibold"
|
2026-02-23 02:04:46 +01:00
|
|
|
: "text-muted-foreground hover:text-foreground hover:bg-accent/50"
|
2026-02-22 21:35:53 +01:00
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
{subItem.title}
|
|
|
|
|
</Link>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
|
|
{/* Sidebar Footer / Desktop Toggle */}
|
2026-02-23 02:04:46 +01:00
|
|
|
<div className="p-4 border-t border-border hidden lg:block">
|
2026-02-22 21:35:53 +01:00
|
|
|
<Button
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="sm"
|
|
|
|
|
className="w-full flex items-center justify-center gap-2 text-muted-foreground hover:text-foreground"
|
|
|
|
|
onClick={toggleCollapse}
|
|
|
|
|
>
|
|
|
|
|
{isCollapsed ? (
|
|
|
|
|
<ChevronRight className="h-4 w-4" />
|
|
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
<ChevronLeft className="h-4 w-4" />
|
|
|
|
|
<span className="text-xs font-semibold uppercase tracking-wider">Collapse Sidebar</span>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</aside>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|