Files
auto-trade/features/trade/components/layout/DashboardLayout.tsx

114 lines
4.4 KiB
TypeScript
Raw Normal View History

2026-02-10 11:16:39 +09:00
import { ReactNode } from "react";
2026-02-13 16:41:10 +09:00
import { ChevronDown, ChevronUp } from "lucide-react";
import { Button } from "@/components/ui/button";
2026-02-10 11:16:39 +09:00
import { cn } from "@/lib/utils";
interface DashboardLayoutProps {
header: ReactNode;
chart: ReactNode;
orderBook: ReactNode;
orderForm: ReactNode;
2026-02-13 16:41:10 +09:00
isChartVisible: boolean;
onToggleChart: () => void;
2026-02-10 11:16:39 +09:00
className?: string;
}
2026-02-13 16:41:10 +09:00
/**
* @description . / .
* @see features/trade/components/layout/TradeDashboardContent.tsx .
*/
2026-02-10 11:16:39 +09:00
export function DashboardLayout({
header,
chart,
orderBook,
orderForm,
2026-02-13 16:41:10 +09:00
isChartVisible,
onToggleChart,
2026-02-10 11:16:39 +09:00
className,
}: DashboardLayoutProps) {
return (
<div
className={cn(
2026-02-11 14:06:06 +09:00
"flex flex-col bg-background dark:bg-[linear-gradient(135deg,rgba(53,35,86,0.18),rgba(13,13,20,0.98))]",
2026-02-10 11:16:39 +09:00
// Mobile: Scrollable page height
"min-h-[calc(100vh-64px)]",
// Desktop: Fixed height, no window scroll
"xl:h-[calc(100vh-64px)] xl:overflow-hidden",
className,
)}
>
{/* 1. Header Area */}
2026-02-11 14:06:06 +09:00
<div className="flex-none border-b border-brand-100 bg-white dark:border-brand-800/45 dark:bg-brand-900/22">
2026-02-10 11:16:39 +09:00
{header}
</div>
{/* 2. Main Content Area */}
<div
className={cn(
2026-02-13 16:41:10 +09:00
"flex-1 min-h-0 overflow-y-auto",
"xl:overflow-hidden",
2026-02-10 11:16:39 +09:00
)}
>
2026-02-13 16:41:10 +09:00
<div className="flex min-h-full flex-col xl:h-full xl:min-h-0">
{/* ========== CHART SECTION ========== */}
<section className="flex-none border-b border-border dark:border-brand-800/45">
<div className="flex items-center justify-between gap-2 bg-muted/20 px-3 py-1.5 dark:bg-brand-900/30 sm:px-4">
<div className="min-w-0">
<p className="text-xs font-semibold text-foreground dark:text-brand-50 sm:text-sm">
</p>
<p className="text-[10px] text-muted-foreground dark:text-brand-100/70 sm:text-[11px]">
.
</p>
</div>
{/* UI 흐름: 차트 토글 버튼 -> onToggleChart 호출 -> TradeDashboardContent의 상태 변경 -> 차트 wrapper 높이 반영 */}
<Button
type="button"
variant="outline"
size="sm"
onClick={onToggleChart}
className="h-7 gap-1 border-brand-200 bg-white px-2 text-[11px] text-brand-700 hover:bg-brand-50 dark:border-brand-700/55 dark:bg-brand-900/35 dark:text-brand-100 dark:hover:bg-brand-800/35 sm:h-8 sm:px-3 sm:text-xs"
aria-expanded={isChartVisible}
>
{isChartVisible ? (
<>
<ChevronUp className="h-3.5 w-3.5" />
</>
) : (
<>
<ChevronDown className="h-3.5 w-3.5" />
</>
)}
</Button>
</div>
2026-02-10 11:16:39 +09:00
2026-02-13 16:41:10 +09:00
<div
className={cn(
"overflow-hidden border-t border-border/70 transition-[max-height,opacity] duration-200 dark:border-brand-800/45",
isChartVisible ? "max-h-[56vh] opacity-100" : "max-h-0 opacity-0",
)}
>
<div className="h-[34vh] min-h-[280px] w-full sm:h-[40vh] xl:h-[34vh] 2xl:h-[38vh]">
{chart}
</div>
</div>
</section>
{/* ========== ORDERBOOK + ORDER SECTION ========== */}
<div className="flex flex-1 min-h-0 flex-col xl:flex-row xl:overflow-hidden">
<section className="flex min-h-0 flex-col border-b border-border dark:border-brand-800/45 xl:flex-1 xl:border-b-0 xl:border-r">
<div className="h-[390px] min-h-0 sm:h-[430px] xl:h-full">
{orderBook}
</div>
</section>
<section className="flex min-h-0 flex-col bg-background dark:bg-brand-900/12 xl:w-[430px] 2xl:w-[470px]">
<div className="min-h-[320px] xl:h-full">{orderForm}</div>
</section>
2026-02-10 11:16:39 +09:00
</div>
</div>
</div>
</div>
);
}