refactor: enhance component structure and styling for improved layout and usability #8
@ -1,14 +1,15 @@
|
||||
import * as React from 'react';
|
||||
import { SidebarInset } from '@/components/ui/sidebar';
|
||||
import { cn } from '@/lib/utils';
|
||||
import type { AppVariant } from '@/types';
|
||||
|
||||
type Props = React.ComponentProps<'main'> & {
|
||||
variant?: AppVariant;
|
||||
};
|
||||
|
||||
export function AppContent({ variant = 'sidebar', children, ...props }: Props) {
|
||||
export function AppContent({ variant = 'sidebar', children, className, ...props }: Props) {
|
||||
if (variant === 'sidebar') {
|
||||
return <SidebarInset {...props}>{children}</SidebarInset>;
|
||||
return <SidebarInset {...props} className={cn("overflow-hidden", className)}>{children}</SidebarInset>;
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
import { Link, usePage } from '@inertiajs/react';
|
||||
import { BookOpen, Folder, LayoutGrid, Menu, Search } from 'lucide-react';
|
||||
import AppLogo from '@/components/app-logo';
|
||||
import AppLogoIcon from '@/components/app-logo-icon';
|
||||
import { Breadcrumbs } from '@/components/breadcrumbs';
|
||||
@ -34,6 +32,8 @@ import { useInitials } from '@/hooks/use-initials';
|
||||
import { cn, toUrl } from '@/lib/utils';
|
||||
import { dashboard } from '@/routes';
|
||||
import type { BreadcrumbItem, NavItem } from '@/types';
|
||||
import { Link, usePage } from '@inertiajs/react';
|
||||
import { BookOpen, Folder, LayoutGrid, Menu, Search } from 'lucide-react';
|
||||
|
||||
type Props = {
|
||||
breadcrumbs?: BreadcrumbItem[];
|
||||
@ -71,7 +71,7 @@ export function AppHeader({ breadcrumbs = [] }: Props) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="border-b border-sidebar-border/80">
|
||||
<div className="sticky top-0 z-50 border-b border-sidebar-border/80 bg-white dark:bg-[#0a0a0a]">
|
||||
<div className="mx-auto flex h-16 items-center px-4 md:max-w-7xl">
|
||||
{/* Mobile Menu */}
|
||||
<div className="lg:hidden">
|
||||
@ -219,10 +219,10 @@ export function AppHeader({ breadcrumbs = [] }: Props) {
|
||||
<Avatar className="size-8 overflow-hidden rounded-full">
|
||||
<AvatarImage
|
||||
src={auth.user?.avatar}
|
||||
alt={auth.user?.name}
|
||||
alt={auth.user?.full_name}
|
||||
/>
|
||||
<AvatarFallback className="rounded-lg bg-neutral-200 text-black dark:bg-neutral-700 dark:text-white">
|
||||
{getInitials(auth.user?.name ?? '')}
|
||||
{getInitials(auth.user?.full_name ?? '')}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
</Button>
|
||||
|
||||
@ -17,5 +17,5 @@ export function AppShell({ children, variant = 'sidebar' }: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
return <SidebarProvider defaultOpen={isOpen}>{children}</SidebarProvider>;
|
||||
return <SidebarProvider defaultOpen={isOpen} className="max-h-svh overflow-hidden">{children}</SidebarProvider>;
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ export function AppSidebarHeader({
|
||||
breadcrumbs?: BreadcrumbItemType[];
|
||||
}) {
|
||||
return (
|
||||
<header className="flex h-16 shrink-0 items-center gap-2 border-b border-sidebar-border/50 px-6 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12 md:px-4">
|
||||
<header className="flex h-16 shrink-0 items-center gap-2 border-b border-sidebar-border/50 bg-background px-6 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12 md:px-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<SidebarTrigger className="-ml-1" />
|
||||
<Breadcrumbs breadcrumbs={breadcrumbs} />
|
||||
|
||||
@ -4,7 +4,7 @@ import { SidebarTrigger } from "@/components/ui/sidebar"
|
||||
|
||||
export function SiteHeader() {
|
||||
return (
|
||||
<header className="flex h-(--header-height) shrink-0 items-center gap-2 border-b transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-(--header-height)">
|
||||
<header className="sticky top-0 z-50 flex h-(--header-height) shrink-0 items-center gap-2 border-b bg-white transition-[width,height] ease-linear dark:bg-[#0a0a0a] group-has-data-[collapsible=icon]/sidebar-wrapper:h-(--header-height)">
|
||||
<div className="flex w-full items-center gap-1 px-4 lg:gap-2 lg:px-6">
|
||||
<SidebarTrigger className="-ml-1" />
|
||||
<Separator
|
||||
|
||||
@ -13,7 +13,9 @@ export default function AppSidebarLayout({
|
||||
<AppSidebar />
|
||||
<AppContent variant="sidebar" className="overflow-x-hidden">
|
||||
<AppSidebarHeader breadcrumbs={breadcrumbs} />
|
||||
{children}
|
||||
<div className="flex-1 overflow-y-auto">
|
||||
{children}
|
||||
</div>
|
||||
</AppContent>
|
||||
</AppShell>
|
||||
);
|
||||
|
||||
@ -1,36 +1,21 @@
|
||||
import { ChartAreaInteractive } from "@/components/chart-area-interactive";
|
||||
import { DataTable } from "@/components/data-table";
|
||||
import { SectionCards } from "@/components/section-cards";
|
||||
import {
|
||||
SidebarInset,
|
||||
SidebarProvider,
|
||||
} from "@/components/ui/sidebar";
|
||||
|
||||
import data from "./data/data.json";
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<SidebarProvider
|
||||
style={
|
||||
{
|
||||
"--sidebar-width": "calc(var(--spacing) * 72)",
|
||||
"--header-height": "calc(var(--spacing) * 12)",
|
||||
} as React.CSSProperties
|
||||
}
|
||||
>
|
||||
<SidebarInset>
|
||||
<div className="flex flex-1 flex-col">
|
||||
<div className="@container/main flex flex-1 flex-col gap-2">
|
||||
<div className="flex flex-col gap-4 py-4 md:gap-6 md:py-6">
|
||||
<SectionCards />
|
||||
<div className="px-4 lg:px-6">
|
||||
<ChartAreaInteractive />
|
||||
</div>
|
||||
<DataTable data={data} />
|
||||
</div>
|
||||
<div className="flex flex-1 flex-col">
|
||||
<div className="@container/main flex flex-1 flex-col gap-2">
|
||||
<div className="flex flex-col gap-4 py-4 md:gap-6 md:py-6">
|
||||
<SectionCards />
|
||||
<div className="px-4 lg:px-6">
|
||||
<ChartAreaInteractive />
|
||||
</div>
|
||||
<DataTable data={data} />
|
||||
</div>
|
||||
</SidebarInset>
|
||||
</SidebarProvider>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user