Merge pull request 'refactor: enhance component structure and styling for improved layout and usability' (#8) from refactor/fixed-header into dev
Reviewed-on: itm/siakad-itm#8
This commit is contained in:
commit
8dde2f8e26
@ -1,14 +1,15 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { SidebarInset } from '@/components/ui/sidebar';
|
import { SidebarInset } from '@/components/ui/sidebar';
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
import type { AppVariant } from '@/types';
|
import type { AppVariant } from '@/types';
|
||||||
|
|
||||||
type Props = React.ComponentProps<'main'> & {
|
type Props = React.ComponentProps<'main'> & {
|
||||||
variant?: AppVariant;
|
variant?: AppVariant;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function AppContent({ variant = 'sidebar', children, ...props }: Props) {
|
export function AppContent({ variant = 'sidebar', children, className, ...props }: Props) {
|
||||||
if (variant === 'sidebar') {
|
if (variant === 'sidebar') {
|
||||||
return <SidebarInset {...props}>{children}</SidebarInset>;
|
return <SidebarInset {...props} className={cn("overflow-hidden", className)}>{children}</SidebarInset>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
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 AppLogo from '@/components/app-logo';
|
||||||
import AppLogoIcon from '@/components/app-logo-icon';
|
import AppLogoIcon from '@/components/app-logo-icon';
|
||||||
import { Breadcrumbs } from '@/components/breadcrumbs';
|
import { Breadcrumbs } from '@/components/breadcrumbs';
|
||||||
@ -34,6 +32,8 @@ import { useInitials } from '@/hooks/use-initials';
|
|||||||
import { cn, toUrl } from '@/lib/utils';
|
import { cn, toUrl } from '@/lib/utils';
|
||||||
import { dashboard } from '@/routes';
|
import { dashboard } from '@/routes';
|
||||||
import type { BreadcrumbItem, NavItem } from '@/types';
|
import type { BreadcrumbItem, NavItem } from '@/types';
|
||||||
|
import { Link, usePage } from '@inertiajs/react';
|
||||||
|
import { BookOpen, Folder, LayoutGrid, Menu, Search } from 'lucide-react';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
breadcrumbs?: BreadcrumbItem[];
|
breadcrumbs?: BreadcrumbItem[];
|
||||||
@ -71,7 +71,7 @@ export function AppHeader({ breadcrumbs = [] }: Props) {
|
|||||||
|
|
||||||
return (
|
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">
|
<div className="mx-auto flex h-16 items-center px-4 md:max-w-7xl">
|
||||||
{/* Mobile Menu */}
|
{/* Mobile Menu */}
|
||||||
<div className="lg:hidden">
|
<div className="lg:hidden">
|
||||||
@ -219,10 +219,10 @@ export function AppHeader({ breadcrumbs = [] }: Props) {
|
|||||||
<Avatar className="size-8 overflow-hidden rounded-full">
|
<Avatar className="size-8 overflow-hidden rounded-full">
|
||||||
<AvatarImage
|
<AvatarImage
|
||||||
src={auth.user?.avatar}
|
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">
|
<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>
|
</AvatarFallback>
|
||||||
</Avatar>
|
</Avatar>
|
||||||
</Button>
|
</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[];
|
breadcrumbs?: BreadcrumbItemType[];
|
||||||
}) {
|
}) {
|
||||||
return (
|
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">
|
<div className="flex items-center gap-2">
|
||||||
<SidebarTrigger className="-ml-1" />
|
<SidebarTrigger className="-ml-1" />
|
||||||
<Breadcrumbs breadcrumbs={breadcrumbs} />
|
<Breadcrumbs breadcrumbs={breadcrumbs} />
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { SidebarTrigger } from "@/components/ui/sidebar"
|
|||||||
|
|
||||||
export function SiteHeader() {
|
export function SiteHeader() {
|
||||||
return (
|
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">
|
<div className="flex w-full items-center gap-1 px-4 lg:gap-2 lg:px-6">
|
||||||
<SidebarTrigger className="-ml-1" />
|
<SidebarTrigger className="-ml-1" />
|
||||||
<Separator
|
<Separator
|
||||||
|
|||||||
@ -13,7 +13,9 @@ export default function AppSidebarLayout({
|
|||||||
<AppSidebar />
|
<AppSidebar />
|
||||||
<AppContent variant="sidebar" className="overflow-x-hidden">
|
<AppContent variant="sidebar" className="overflow-x-hidden">
|
||||||
<AppSidebarHeader breadcrumbs={breadcrumbs} />
|
<AppSidebarHeader breadcrumbs={breadcrumbs} />
|
||||||
{children}
|
<div className="flex-1 overflow-y-auto">
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
</AppContent>
|
</AppContent>
|
||||||
</AppShell>
|
</AppShell>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,36 +1,21 @@
|
|||||||
import { ChartAreaInteractive } from "@/components/chart-area-interactive";
|
import { ChartAreaInteractive } from "@/components/chart-area-interactive";
|
||||||
import { DataTable } from "@/components/data-table";
|
import { DataTable } from "@/components/data-table";
|
||||||
import { SectionCards } from "@/components/section-cards";
|
import { SectionCards } from "@/components/section-cards";
|
||||||
import {
|
|
||||||
SidebarInset,
|
|
||||||
SidebarProvider,
|
|
||||||
} from "@/components/ui/sidebar";
|
|
||||||
|
|
||||||
import data from "./data/data.json";
|
import data from "./data/data.json";
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
return (
|
return (
|
||||||
<SidebarProvider
|
<div className="flex flex-1 flex-col">
|
||||||
style={
|
<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">
|
||||||
"--sidebar-width": "calc(var(--spacing) * 72)",
|
<SectionCards />
|
||||||
"--header-height": "calc(var(--spacing) * 12)",
|
<div className="px-4 lg:px-6">
|
||||||
} as React.CSSProperties
|
<ChartAreaInteractive />
|
||||||
}
|
|
||||||
>
|
|
||||||
<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>
|
</div>
|
||||||
|
<DataTable data={data} />
|
||||||
</div>
|
</div>
|
||||||
</SidebarInset>
|
</div>
|
||||||
</SidebarProvider>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user