Files
front-ui-registry/registry/components/layout/KriMainLayout.tsx

51 lines
1.2 KiB
TypeScript

'use client'
import type { CSSProperties, ReactNode } from 'react'
import { cn } from '@/lib/utils'
export interface KriMainLayoutProps {
children: ReactNode
header?: ReactNode
sidebar?: ReactNode
sidebarOpen?: boolean
onSidebarOpenChange?: (open: boolean) => void
fullHeight?: boolean
className?: string
bodyClassName?: string
mainClassName?: string
mainStyle?: CSSProperties
}
export function KriMainLayout({
children,
header,
sidebar,
sidebarOpen = false,
onSidebarOpenChange,
fullHeight = true,
className,
bodyClassName,
mainClassName,
mainStyle,
}: KriMainLayoutProps) {
return (
<div className={cn('flex flex-col bg-muted/30', fullHeight && 'min-h-screen', className)}>
{header}
<div className={cn('flex min-h-0 flex-1', bodyClassName)}>
{sidebar}
<main className={cn('min-w-0 flex-1 overflow-y-auto p-4', mainClassName)} style={mainStyle}>
{children}
</main>
</div>
{sidebar && sidebarOpen ? (
<button
type="button"
aria-label="사이드바 닫기"
className="fixed inset-0 z-20 bg-black/20 lg:hidden"
onClick={() => onSidebarOpenChange?.(false)}
/>
) : null}
</div>
)
}