medkit/src/kit/page-frame.tsx

50 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import * as React from "react"
import { type LucideIcon } from "lucide-react"
import { cn } from "../lib/utils"
import { ScrollArea } from "../ui/scroll-area"
/**
* Рамка раздела без вкладок: карточка с шапкой (иконка, заголовок, действия)
* и прокручиваемым телом. Разделы со вкладками используют SectionFrame.
*/
export function PageFrame({
icon: Icon,
title,
actions,
toolbar,
scroll = true,
className,
children,
}: {
icon?: LucideIcon
title: React.ReactNode
actions?: React.ReactNode
/** Строка под шапкой: фильтры, поиск. */
toolbar?: React.ReactNode
/** false — тело само управляет прокруткой (списки с панелью деталей). */
scroll?: boolean
className?: string
children: React.ReactNode
}) {
return (
<div className="flex min-h-0 flex-1 flex-col p-2 lg:p-3">
<div className="flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border bg-card shadow-[0_1px_2px_rgba(15,40,60,0.04)]">
<header className="flex h-12 shrink-0 items-center gap-2 border-b px-4">
{Icon && <Icon className="size-4 text-primary" />}
<h1 className="text-sm font-semibold">{title}</h1>
{actions && <div className="ml-auto flex items-center gap-2">{actions}</div>}
</header>
{toolbar && <div className="shrink-0 border-b px-4 py-3">{toolbar}</div>}
{scroll ? (
<ScrollArea className="min-h-0 flex-1">
<div className={className}>{children}</div>
</ScrollArea>
) : (
<div className={cn("flex min-h-0 flex-1", className)}>{children}</div>
)}
</div>
</div>
)
}