2026-07-03 22:30:31 -04:00
|
|
|
"use client";
|
2026-07-03 22:57:49 -04:00
|
|
|
import { useEffect } from "react";
|
2026-07-03 22:30:31 -04:00
|
|
|
import { SidebarNav } from "./SidebarNav";
|
|
|
|
|
import { WatchlistSidebar } from "./WatchlistSidebar";
|
|
|
|
|
import { SymbolHeader } from "./SymbolHeader";
|
2026-07-03 22:57:49 -04:00
|
|
|
import { CollapsibleProvider, useCollapsibleContext } from "@/lib/collapsible-context";
|
2026-07-03 22:30:31 -04:00
|
|
|
|
|
|
|
|
/**
|
2026-07-03 22:57:49 -04:00
|
|
|
* Inner component that attaches the global Escape listener.
|
|
|
|
|
* Wrapped in CollapsibleProvider so all CollapsibleSections can register.
|
2026-07-03 22:30:31 -04:00
|
|
|
*/
|
2026-07-03 22:57:49 -04:00
|
|
|
function LayoutShellInner({ children }: { children: React.ReactNode }) {
|
|
|
|
|
const { openSectionId, setOpenSectionId } = useCollapsibleContext();
|
|
|
|
|
|
|
|
|
|
// Global Escape listener: collapse the currently open section.
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const handler = (e: KeyboardEvent) => {
|
|
|
|
|
if (e.key === "Escape" && openSectionId) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
// Collapse the currently open section by clearing the shared state.
|
|
|
|
|
// Individual CollapsibleSection Escape handlers also respond to this.
|
|
|
|
|
setOpenSectionId(null);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
window.addEventListener("keydown", handler, true); // capture phase
|
|
|
|
|
return () => window.removeEventListener("keydown", handler, true);
|
|
|
|
|
}, [openSectionId, setOpenSectionId]);
|
|
|
|
|
|
2026-07-03 22:30:31 -04:00
|
|
|
return (
|
|
|
|
|
<div className="min-h-screen bg-[#0a0b0f] text-[#e6e7ec] flex flex-col">
|
|
|
|
|
{/* Symbol Header — always visible */}
|
|
|
|
|
<SymbolHeader />
|
|
|
|
|
|
|
|
|
|
{/* Main Content Area */}
|
|
|
|
|
<div className="flex flex-1 overflow-hidden">
|
|
|
|
|
{/* Left Sidebar Navigation — hidden on tablet/mobile */}
|
|
|
|
|
<SidebarNav />
|
|
|
|
|
|
|
|
|
|
{/* Watchlist Sidebar — hidden on mobile */}
|
|
|
|
|
<WatchlistSidebar />
|
|
|
|
|
|
2026-07-03 22:57:49 -04:00
|
|
|
{/* Content */}
|
|
|
|
|
<main className="flex-1 overflow-y-auto p-4 sm:p-6">
|
|
|
|
|
<div className="max-w-7xl mx-auto space-y-6">
|
|
|
|
|
{children}
|
|
|
|
|
</div>
|
|
|
|
|
</main>
|
2026-07-03 22:52:21 -04:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2026-07-03 22:57:49 -04:00
|
|
|
* Main layout shell for the redesigned terminal.
|
|
|
|
|
* - Desktop (>1024px): Sidebar + Watchlist + Header + Content (3-column)
|
|
|
|
|
* - Tablet (768-1024px): Watchlist + Header + Content (2-column, sidebar hidden)
|
|
|
|
|
* - Mobile (<768px): Header + Content (single column)
|
2026-07-03 22:52:21 -04:00
|
|
|
*/
|
2026-07-03 22:57:49 -04:00
|
|
|
export function LayoutShell({ children }: { children: React.ReactNode }) {
|
2026-07-03 22:52:21 -04:00
|
|
|
return (
|
2026-07-03 22:57:49 -04:00
|
|
|
<CollapsibleProvider>
|
|
|
|
|
<LayoutShellInner>{children}</LayoutShellInner>
|
|
|
|
|
</CollapsibleProvider>
|
2026-07-03 22:30:31 -04:00
|
|
|
);
|
|
|
|
|
}
|