medkit/src/kit/page-frame.tsx

54 lines
2.2 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-clip rounded-xl border bg-card shadow-[0_1px_2px_rgba(15,40,60,0.04)]">
{/* Шапка и заголовок — как у SectionTabsBar с активной корневой вкладкой (PageTabs, CHIP_CLASS):
разделы со вкладками и без выглядят одинаково. */}
<header className="flex h-12 shrink-0 items-center gap-2 border-b px-2">
<h1 className="flex h-8 min-w-0 items-center gap-2 rounded-lg bg-accent px-2.5 text-sm font-medium text-accent-foreground">
{Icon && <Icon className="size-4 shrink-0 text-primary" />}
<span className="truncate">{title}</span>
</h1>
{actions && <div className="ml-auto flex shrink-0 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>
)
}