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

107 lines
4.3 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;
2026-02-10 11:16:39 +09:00
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 2 .
* @summary UI 흐름: TradeDashboardContent -> DashboardLayout -> () + (/)
* @see features/trade/components/layout/TradeDashboardContent.tsx - .
2026-02-13 16:41:10 +09:00
*/
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(
"flex h-full min-h-0 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
className,
)}
>
{/* ========== 1. OPTIONAL HEADER AREA ========== */}
{header && (
<div className="flex-none border-b border-brand-100 bg-white dark:border-brand-800/45 dark:bg-brand-900/22">
{header}
</div>
)}
2026-02-10 11:16:39 +09:00
{/* ========== 2. MAIN CONTENT AREA ========== */}
<div className="flex-1 min-h-0 overflow-y-auto xl:overflow-hidden">
<div className="flex min-h-full flex-col xl:h-full xl:min-h-0 xl:overflow-hidden">
{/* ========== TOP: CHART AREA ========== */}
<section className="flex min-h-0 flex-col border-b border-border dark:border-brand-800/45 xl:h-[34%] xl:min-h-[200px]">
{/* 모바일 전용 차트 토글 */}
<div className="flex items-center justify-between gap-2 bg-muted/15 px-3 py-1.5 dark:bg-brand-900/25 sm:px-4 xl:hidden">
<div className="flex min-w-0 items-center gap-2">
<span className="h-2 w-2 rounded-full bg-green-400 shadow-[0_0_6px_rgba(74,222,128,0.6)]" />
<p className="text-xs font-semibold text-foreground dark:text-brand-50">
2026-02-13 16:41:10 +09:00
</p>
</div>
{/* UI 흐름: 토글 클릭 -> onToggleChart -> 상위 상태 변경 -> 차트 표시/숨김 */}
2026-02-13 16:41:10 +09:00
<Button
type="button"
variant="outline"
size="sm"
onClick={onToggleChart}
className="h-6 gap-1 border-brand-200 bg-white/70 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-7 sm:px-3"
2026-02-13 16:41:10 +09:00
aria-expanded={isChartVisible}
>
{isChartVisible ? (
<>
<ChevronUp className="h-3 w-3" />
2026-02-13 16:41:10 +09:00
</>
) : (
<>
<ChevronDown className="h-3 w-3" />
2026-02-13 16:41:10 +09:00
</>
)}
</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-300 dark:border-brand-800/45 xl:flex-1 xl:min-h-0 xl:max-h-none xl:opacity-100",
isChartVisible ? "max-h-[64vh] opacity-100" : "max-h-0 opacity-0",
2026-02-13 16:41:10 +09:00
)}
>
<div className="h-[29vh] min-h-[200px] w-full sm:h-[33vh] xl:h-full xl:min-h-0">
2026-02-13 16:41:10 +09:00
{chart}
</div>
</div>
</section>
{/* ========== BOTTOM: ORDERBOOK + ORDER AREA ========== */}
<section className="flex flex-1 min-h-0 flex-col xl:grid xl:grid-cols-[minmax(0,1fr)_480px] 2xl:grid-cols-[minmax(0,1fr)_540px] xl:overflow-hidden">
<div className="flex min-h-0 flex-col border-b border-border dark:border-brand-800/45 xl:border-b-0 xl:border-r">
<div className="min-h-0 xl:h-full xl:min-h-0">
2026-02-13 16:41:10 +09:00
{orderBook}
</div>
</div>
2026-02-13 16:41:10 +09:00
<div className="flex min-h-0 flex-col bg-background dark:bg-brand-900/12">
<div className="min-h-[280px] xl:h-full xl:min-h-0">{orderForm}</div>
</div>
</section>
2026-02-10 11:16:39 +09:00
</div>
</div>
</div>
);
}