feat: add settings page and theme toggle component
- Implemented a new SettingsPage component for user preferences including appearance, behavior, and account security settings. - Added a ThemeToggle component to switch between light, dark, and system modes. - Created reusable UI components: AlertDialog, Avatar, Badge, Button, Card, Dialog, Input, Label, Progress, ScrollArea, Separator, Sheet, Skeleton, Tooltip. - Introduced utility functions for class name merging and formatting bytes/uptime. - Added a custom hook for media query handling
This commit is contained in:
65 files changed
+4687
-4530
No files matched your search
@@ -0,0 +1,88 @@
|
||||
import { useEffect, useState, type ReactNode } from 'react';
|
||||
import { motion, AnimatePresence } from 'motion/react';
|
||||
import { Sheet, SheetContent } from '@/components/ui/sheet';
|
||||
import { ScrollArea } from '@/components/ui/scroll-area';
|
||||
import { Sidebar, type Page } from '@/components/layout/sidebar';
|
||||
import { TopBar } from '@/components/layout/top-bar';
|
||||
import { useMediaQuery } from '@/hooks/use-media-query';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface MainLayoutProps {
|
||||
active: Page;
|
||||
onNavigate: (page: Page) => void;
|
||||
status: string;
|
||||
onLogout: () => void;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export function MainLayout({ active, onNavigate, status, onLogout, children }: MainLayoutProps) {
|
||||
const isMobile = !useMediaQuery('(min-width: 768px)');
|
||||
const [collapsed, setCollapsed] = useState(() => {
|
||||
return localStorage.getItem('snowluma_sidebar_collapsed') === '1';
|
||||
});
|
||||
const [mobileOpen, setMobileOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('snowluma_sidebar_collapsed', collapsed ? '1' : '0');
|
||||
}, [collapsed]);
|
||||
|
||||
return (
|
||||
<div className="flex h-screen w-screen overflow-hidden bg-background text-foreground">
|
||||
{/* Desktop sidebar */}
|
||||
{!isMobile && (
|
||||
<motion.aside
|
||||
initial={false}
|
||||
animate={{ width: collapsed ? 64 : 248 }}
|
||||
transition={{ type: 'spring', stiffness: 280, damping: 32 }}
|
||||
className="relative h-full shrink-0 border-r overflow-hidden"
|
||||
>
|
||||
<Sidebar active={active} onNavigate={onNavigate} collapsed={collapsed} />
|
||||
</motion.aside>
|
||||
)}
|
||||
|
||||
{/* Mobile sidebar in sheet */}
|
||||
{isMobile && (
|
||||
<Sheet open={mobileOpen} onOpenChange={setMobileOpen}>
|
||||
<SheetContent side="left" className="w-64 max-w-[80vw] p-0">
|
||||
<Sidebar
|
||||
active={active}
|
||||
onNavigate={onNavigate}
|
||||
onItemClick={() => setMobileOpen(false)}
|
||||
/>
|
||||
</SheetContent>
|
||||
</Sheet>
|
||||
)}
|
||||
|
||||
{/* Main column */}
|
||||
<div className="flex min-w-0 flex-1 flex-col">
|
||||
<TopBar
|
||||
active={active}
|
||||
status={status}
|
||||
collapsed={collapsed}
|
||||
onToggleCollapse={() => setCollapsed((v) => !v)}
|
||||
onOpenMobile={() => setMobileOpen(true)}
|
||||
onLogout={onLogout}
|
||||
isMobile={isMobile}
|
||||
/>
|
||||
|
||||
<main className={cn('flex min-h-0 flex-1 flex-col')}>
|
||||
<ScrollArea className="flex-1 min-h-0" viewportClassName="[&>div]:!block">
|
||||
<div className="mx-auto w-full max-w-7xl px-4 py-5 sm:px-6 sm:py-6 lg:px-8">
|
||||
<AnimatePresence mode="wait">
|
||||
<motion.div
|
||||
key={active}
|
||||
initial={{ opacity: 0, y: 10 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
exit={{ opacity: 0, y: -8 }}
|
||||
transition={{ duration: 0.22, ease: [0.16, 1, 0.3, 1] }}
|
||||
>
|
||||
{children}
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user