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
@@ -79,7 +79,7 @@ export function AppLayout() {
|
|||||||
</SheetContent>
|
</SheetContent>
|
||||||
</Sheet>
|
</Sheet>
|
||||||
|
|
||||||
<main ref={mainRef} className="flex-1 overflow-y-auto md:ml-56">
|
<main ref={mainRef} className="flex-1 overflow-y-auto md:ml-20">
|
||||||
<div className="container mx-auto px-4 py-4 pt-18 md:px-6 md:py-6 md:pt-6">
|
<div className="container mx-auto px-4 py-4 pt-18 md:px-6 md:py-6 md:pt-6">
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { NavLink } from 'react-router-dom';
|
import { NavLink } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
LayoutDashboard,
|
LayoutDashboard,
|
||||||
Home,
|
Home,
|
||||||
@@ -12,21 +12,13 @@ import {
|
|||||||
Moon,
|
Moon,
|
||||||
Sun,
|
Sun,
|
||||||
Film,
|
Film,
|
||||||
// Search,
|
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { useThemeStore } from '@/stores/useThemeStore';
|
import { useThemeStore } from '@/stores/useThemeStore';
|
||||||
import { Button } from '@/components/ui/button';
|
|
||||||
import { Separator } from '@/components/ui/separator';
|
import { Separator } from '@/components/ui/separator';
|
||||||
import {
|
|
||||||
Tooltip,
|
|
||||||
TooltipContent,
|
|
||||||
TooltipTrigger,
|
|
||||||
} from '@/components/ui/tooltip';
|
|
||||||
|
|
||||||
const mainNav = [
|
const mainNav = [
|
||||||
{ to: '/dashboard', icon: LayoutDashboard, label: 'Dashboard' },
|
{ to: '/dashboard', icon: LayoutDashboard, label: 'Dashboard' },
|
||||||
{ to: '/', icon: Home, label: 'Home' },
|
{ to: '/', icon: Home, label: 'Home' },
|
||||||
// { to: '/search', icon: Search, label: 'Search' },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const libraryNav = [
|
const libraryNav = [
|
||||||
@@ -51,25 +43,20 @@ function NavItem({
|
|||||||
label: string;
|
label: string;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Tooltip>
|
<NavLink
|
||||||
<TooltipTrigger asChild>
|
to={to}
|
||||||
<NavLink
|
end={to === '/'}
|
||||||
to={to}
|
className={({ isActive }) =>
|
||||||
end={to === '/'}
|
`relative flex flex-col items-center gap-1 rounded-md px-2 py-2.5 transition-colors ${
|
||||||
className={({ isActive }) =>
|
isActive
|
||||||
`flex items-center gap-3 rounded-lg px-3 py-2 text-sm transition-colors ${
|
? 'bg-sidebar-accent text-sidebar-primary'
|
||||||
isActive
|
: 'text-sidebar-foreground/50 hover:bg-sidebar-accent/40 hover:text-sidebar-foreground'
|
||||||
? 'bg-sidebar-accent text-sidebar-primary font-medium'
|
}`
|
||||||
: 'text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground'
|
}
|
||||||
}`
|
>
|
||||||
}
|
<Icon className="h-5 w-5 shrink-0" />
|
||||||
>
|
<span className="text-[10px] font-medium leading-none tracking-wide">{label}</span>
|
||||||
<Icon className="h-4 w-4 shrink-0" />
|
</NavLink>
|
||||||
<span>{label}</span>
|
|
||||||
</NavLink>
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent side="right">{label}</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,60 +64,48 @@ export function Sidebar() {
|
|||||||
const { theme, toggleTheme } = useThemeStore();
|
const { theme, toggleTheme } = useThemeStore();
|
||||||
|
|
||||||
return (
|
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 */}
|
{/* 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" />
|
<Film className="h-6 w-6 text-sidebar-primary" />
|
||||||
<span className="text-lg font-bold text-sidebar-foreground">
|
|
||||||
Showy
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Separator className="bg-sidebar-border" />
|
<Separator className="bg-sidebar-border" />
|
||||||
|
|
||||||
{/* Nav */}
|
{/* Nav */}
|
||||||
<nav className="flex-1 space-y-1 overflow-y-auto px-3 py-4">
|
<nav className="flex-1 overflow-y-auto px-2 py-3 space-y-0.5">
|
||||||
<p className="mb-2 px-3 text-xs font-semibold uppercase tracking-wider text-sidebar-foreground/50">
|
|
||||||
Main
|
|
||||||
</p>
|
|
||||||
{mainNav.map((item) => (
|
{mainNav.map((item) => (
|
||||||
<NavItem key={item.to} {...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) => (
|
{libraryNav.map((item) => (
|
||||||
<NavItem key={item.to} {...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) => (
|
{otherNav.map((item) => (
|
||||||
<NavItem key={item.to} {...item} />
|
<NavItem key={item.to} {...item} />
|
||||||
))}
|
))}
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
{/* Bottom actions */}
|
{/* Bottom actions */}
|
||||||
<div className="border-t border-sidebar-border px-3 py-3 space-y-1">
|
<div className="border-t border-sidebar-border px-2 py-3 space-y-0.5">
|
||||||
<Button
|
<button
|
||||||
variant="ghost"
|
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"
|
||||||
size="sm"
|
|
||||||
className="w-full justify-start gap-3 text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground"
|
|
||||||
onClick={toggleTheme}
|
onClick={toggleTheme}
|
||||||
>
|
>
|
||||||
{theme === 'dark' ? (
|
{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>
|
<span className="text-[10px] font-medium leading-none tracking-wide">
|
||||||
</Button>
|
{theme === 'dark' ? 'Light' : 'Dark'}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
<NavItem to="/settings" icon={Settings} label="Settings" />
|
<NavItem to="/settings" icon={Settings} label="Settings" />
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
@@ -210,10 +185,8 @@ export function MobileSidebarContent({ onNavigate }: { onNavigate: () => void })
|
|||||||
|
|
||||||
{/* Bottom actions */}
|
{/* Bottom actions */}
|
||||||
<div className="border-t border-sidebar-border px-3 py-3 space-y-1">
|
<div className="border-t border-sidebar-border px-3 py-3 space-y-1">
|
||||||
<Button
|
<button
|
||||||
variant="ghost"
|
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"
|
||||||
size="sm"
|
|
||||||
className="w-full justify-start gap-3 text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground"
|
|
||||||
onClick={toggleTheme}
|
onClick={toggleTheme}
|
||||||
>
|
>
|
||||||
{theme === 'dark' ? (
|
{theme === 'dark' ? (
|
||||||
@@ -222,7 +195,7 @@ export function MobileSidebarContent({ onNavigate }: { onNavigate: () => void })
|
|||||||
<Moon className="h-4 w-4" />
|
<Moon className="h-4 w-4" />
|
||||||
)}
|
)}
|
||||||
<span>{theme === 'dark' ? 'Light Mode' : 'Dark Mode'}</span>
|
<span>{theme === 'dark' ? 'Light Mode' : 'Dark Mode'}</span>
|
||||||
</Button>
|
</button>
|
||||||
<MobileNavItem to="/settings" icon={Settings} label="Settings" onClick={onNavigate} />
|
<MobileNavItem to="/settings" icon={Settings} label="Settings" onClick={onNavigate} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user