- Created WatchBuddy model - M:N junctions to EntrySeen/EpisodeSeen and Media relation for profile pictures - Full CRUD + search + profile picture upload - WatchBuddySelect multi-select with search and inline create, replaced all seen_with text inputs - WatchBuddiesPage (grid) and WatchBuddyProfilePage (edit form, icon-based contacts, poster-grid watch history, monthly timeline)
217 lines
6.1 KiB
TypeScript
217 lines
6.1 KiB
TypeScript
import { NavLink } from "react-router-dom";
|
|
import {
|
|
LayoutDashboard,
|
|
Home,
|
|
Library,
|
|
ListVideo,
|
|
FolderOpen,
|
|
Image,
|
|
CalendarDays,
|
|
Users,
|
|
UserRoundPlus,
|
|
Settings,
|
|
Moon,
|
|
Sun,
|
|
Film,
|
|
} from "lucide-react";
|
|
import { useThemeStore } from "@/stores/useThemeStore";
|
|
import { Separator } from "@/components/ui/separator";
|
|
|
|
const mainNav = [
|
|
{ to: "/dashboard", icon: LayoutDashboard, label: "Dashboard" },
|
|
{ to: "/", icon: Home, label: "Home" },
|
|
];
|
|
|
|
const libraryNav = [
|
|
{ to: "/library", icon: Library, label: "Library" },
|
|
{ to: "/watchlist", icon: ListVideo, label: "Watchlist" },
|
|
{ to: "/collections", icon: FolderOpen, label: "Collections" },
|
|
{ to: "/media", icon: Image, label: "Media" },
|
|
];
|
|
|
|
const otherNav = [
|
|
{ to: "/calendar", icon: CalendarDays, label: "Calendar" },
|
|
{ to: "/people", icon: Users, label: "People" },
|
|
{ to: "/watch-buddies", icon: UserRoundPlus, label: "Buddies" },
|
|
];
|
|
|
|
function NavItem({
|
|
to,
|
|
icon: Icon,
|
|
label,
|
|
}: {
|
|
to: string;
|
|
icon: React.ComponentType<{ className?: string }>;
|
|
label: string;
|
|
}) {
|
|
return (
|
|
<NavLink
|
|
to={to}
|
|
end={to === "/"}
|
|
className={({ isActive }) =>
|
|
`relative flex flex-col items-center gap-1 rounded-md px-2 py-2.5 transition-colors ${
|
|
isActive
|
|
? "bg-sidebar-accent text-sidebar-primary"
|
|
: "text-sidebar-foreground/50 hover:bg-sidebar-accent/40 hover:text-sidebar-foreground"
|
|
}`
|
|
}
|
|
>
|
|
<Icon className="h-5 w-5 shrink-0" />
|
|
<span className="text-[10px] font-medium leading-none tracking-wide">
|
|
{label}
|
|
</span>
|
|
</NavLink>
|
|
);
|
|
}
|
|
|
|
export function Sidebar() {
|
|
const { theme, toggleTheme } = useThemeStore();
|
|
|
|
return (
|
|
<aside className="fixed inset-y-0 left-0 z-50 hidden md:flex w-20 flex-col border-r border-sidebar-border bg-sidebar">
|
|
{/* Logo */}
|
|
<div className="flex h-14 items-center justify-center">
|
|
<Film className="h-6 w-6 text-sidebar-primary" />
|
|
</div>
|
|
|
|
<Separator className="bg-sidebar-border" />
|
|
|
|
{/* Nav */}
|
|
<nav className="flex-1 overflow-y-auto px-2 py-3 space-y-0.5">
|
|
{mainNav.map((item) => (
|
|
<NavItem key={item.to} {...item} />
|
|
))}
|
|
|
|
<Separator className="my-2 bg-sidebar-border" />
|
|
|
|
{libraryNav.map((item) => (
|
|
<NavItem key={item.to} {...item} />
|
|
))}
|
|
|
|
<Separator className="my-2 bg-sidebar-border" />
|
|
|
|
{otherNav.map((item) => (
|
|
<NavItem key={item.to} {...item} />
|
|
))}
|
|
</nav>
|
|
|
|
{/* Bottom actions */}
|
|
<div className="border-t border-sidebar-border px-2 py-3 space-y-0.5">
|
|
<button
|
|
className="w-full flex flex-col items-center gap-1 rounded-md px-2 py-2.5 text-sidebar-foreground/50 hover:bg-sidebar-accent/40 hover:text-sidebar-foreground transition-colors"
|
|
onClick={toggleTheme}
|
|
>
|
|
{theme === "dark" ? (
|
|
<Sun className="h-5 w-5" />
|
|
) : (
|
|
<Moon className="h-5 w-5" />
|
|
)}
|
|
<span className="text-[10px] font-medium leading-none tracking-wide">
|
|
{theme === "dark" ? "Light" : "Dark"}
|
|
</span>
|
|
</button>
|
|
<NavItem to="/settings" icon={Settings} label="Settings" />
|
|
</div>
|
|
</aside>
|
|
);
|
|
}
|
|
|
|
function MobileNavItem({
|
|
to,
|
|
icon: Icon,
|
|
label,
|
|
onClick,
|
|
}: {
|
|
to: string;
|
|
icon: React.ComponentType<{ className?: string }>;
|
|
label: string;
|
|
onClick?: () => void;
|
|
}) {
|
|
return (
|
|
<NavLink
|
|
to={to}
|
|
end={to === "/"}
|
|
onClick={onClick}
|
|
className={({ isActive }) =>
|
|
`flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm transition-colors ${
|
|
isActive
|
|
? "bg-sidebar-accent text-sidebar-primary font-medium"
|
|
: "text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground"
|
|
}`
|
|
}
|
|
>
|
|
<Icon className="h-4 w-4 shrink-0" />
|
|
<span>{label}</span>
|
|
</NavLink>
|
|
);
|
|
}
|
|
|
|
export function MobileSidebarContent({
|
|
onNavigate,
|
|
}: {
|
|
onNavigate: () => void;
|
|
}) {
|
|
const { theme, toggleTheme } = useThemeStore();
|
|
|
|
return (
|
|
<div className="flex h-full flex-col bg-sidebar">
|
|
{/* Logo */}
|
|
<div className="flex h-14 items-center gap-2 px-4">
|
|
<Film className="h-6 w-6 text-sidebar-primary" />
|
|
<span className="text-lg font-bold text-sidebar-foreground">Showy</span>
|
|
</div>
|
|
|
|
<Separator className="bg-sidebar-border" />
|
|
|
|
{/* Nav */}
|
|
<nav className="flex-1 space-y-1 overflow-y-auto px-3 py-4">
|
|
<p className="mb-2 px-3 text-xs font-semibold uppercase tracking-wider text-sidebar-foreground/50">
|
|
Main
|
|
</p>
|
|
{mainNav.map((item) => (
|
|
<MobileNavItem key={item.to} {...item} onClick={onNavigate} />
|
|
))}
|
|
|
|
<Separator className="my-3 bg-sidebar-border" />
|
|
|
|
<p className="mb-2 px-3 text-xs font-semibold uppercase tracking-wider text-sidebar-foreground/50">
|
|
Library
|
|
</p>
|
|
{libraryNav.map((item) => (
|
|
<MobileNavItem key={item.to} {...item} onClick={onNavigate} />
|
|
))}
|
|
|
|
<Separator className="my-3 bg-sidebar-border" />
|
|
|
|
<p className="mb-2 px-3 text-xs font-semibold uppercase tracking-wider text-sidebar-foreground/50">
|
|
Other
|
|
</p>
|
|
{otherNav.map((item) => (
|
|
<MobileNavItem key={item.to} {...item} onClick={onNavigate} />
|
|
))}
|
|
</nav>
|
|
|
|
{/* Bottom actions */}
|
|
<div className="border-t border-sidebar-border px-3 py-3 space-y-1">
|
|
<button
|
|
className="w-full flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground transition-colors"
|
|
onClick={toggleTheme}
|
|
>
|
|
{theme === "dark" ? (
|
|
<Sun className="h-4 w-4" />
|
|
) : (
|
|
<Moon className="h-4 w-4" />
|
|
)}
|
|
<span>{theme === "dark" ? "Light Mode" : "Dark Mode"}</span>
|
|
</button>
|
|
<MobileNavItem
|
|
to="/settings"
|
|
icon={Settings}
|
|
label="Settings"
|
|
onClick={onNavigate}
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|