fix(layout): adjust sidebar and main layout for improved responsiveness
This commit is contained in:
1 parent
022c9a271b
commit
070aea3c51
2 files changed
+33
-60
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import {
|
||||
LayoutDashboard,
|
||||
Home,
|
||||
@@ -12,21 +12,13 @@ import {
|
||||
Moon,
|
||||
Sun,
|
||||
Film,
|
||||
// Search,
|
||||
} from 'lucide-react';
|
||||
import { useThemeStore } from '@/stores/useThemeStore';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Separator } from '@/components/ui/separator';
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from '@/components/ui/tooltip';
|
||||
|
||||
const mainNav = [
|
||||
{ to: '/dashboard', icon: LayoutDashboard, label: 'Dashboard' },
|
||||
{ to: '/', icon: Home, label: 'Home' },
|
||||
// { to: '/search', icon: Search, label: 'Search' },
|
||||
];
|
||||
|
||||
const libraryNav = [
|
||||
@@ -51,25 +43,20 @@ function NavItem({
|
||||
label: string;
|
||||
}) {
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<NavLink
|
||||
to={to}
|
||||
end={to === '/'}
|
||||
className={({ isActive }) =>
|
||||
`flex items-center gap-3 rounded-lg px-3 py-2 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>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right">{label}</TooltipContent>
|
||||
</Tooltip>
|
||||
<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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -77,60 +64,48 @@ export function Sidebar() {
|
||||
const { theme, toggleTheme } = useThemeStore();
|
||||
|
||||
return (
|
||||
<aside className="fixed inset-y-0 left-0 z-50 hidden md:flex w-56 flex-col border-r border-sidebar-border bg-sidebar">
|
||||
<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 gap-2 px-4">
|
||||
<div className="flex h-14 items-center justify-center">
|
||||
<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>
|
||||
<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-3 bg-sidebar-border" />
|
||||
<Separator className="my-2 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) => (
|
||||
<NavItem key={item.to} {...item} />
|
||||
))}
|
||||
|
||||
<Separator className="my-3 bg-sidebar-border" />
|
||||
<Separator className="my-2 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) => (
|
||||
<NavItem key={item.to} {...item} />
|
||||
))}
|
||||
</nav>
|
||||
|
||||
{/* Bottom actions */}
|
||||
<div className="border-t border-sidebar-border px-3 py-3 space-y-1">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="w-full justify-start gap-3 text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground"
|
||||
<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-4 w-4" />
|
||||
<Sun className="h-5 w-5" />
|
||||
) : (
|
||||
<Moon className="h-4 w-4" />
|
||||
<Moon className="h-5 w-5" />
|
||||
)}
|
||||
<span>{theme === 'dark' ? 'Light Mode' : 'Dark Mode'}</span>
|
||||
</Button>
|
||||
<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>
|
||||
@@ -210,10 +185,8 @@ export function MobileSidebarContent({ onNavigate }: { onNavigate: () => void })
|
||||
|
||||
{/* Bottom actions */}
|
||||
<div className="border-t border-sidebar-border px-3 py-3 space-y-1">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="w-full justify-start gap-3 text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground"
|
||||
<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' ? (
|
||||
@@ -222,7 +195,7 @@ export function MobileSidebarContent({ onNavigate }: { onNavigate: () => void })
|
||||
<Moon className="h-4 w-4" />
|
||||
)}
|
||||
<span>{theme === 'dark' ? 'Light Mode' : 'Dark Mode'}</span>
|
||||
</Button>
|
||||
</button>
|
||||
<MobileNavItem to="/settings" icon={Settings} label="Settings" onClick={onNavigate} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user