Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Layout } from './components/layout';
import { Toaster } from './components/ui/sonner';
import { Layout } from "./components/Layout";
import { Toaster } from "./components/ui/sonner";

export default function App() {
return (
Expand Down
112 changes: 61 additions & 51 deletions app/frontend/src/components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
import { BottomPanel } from '@/components/panels/bottom/bottom-panel';
import { LeftSidebar } from '@/components/panels/left/left-sidebar';
import { RightSidebar } from '@/components/panels/right/right-sidebar';
import { TabBar } from '@/components/tabs/tab-bar';
import { TabContent } from '@/components/tabs/tab-content';
import { SidebarProvider } from '@/components/ui/sidebar';
import { FlowProvider, useFlowContext } from '@/contexts/flow-context';
import { LayoutProvider, useLayoutContext } from '@/contexts/layout-context';
import { TabsProvider, useTabsContext } from '@/contexts/tabs-context';
import { useLayoutKeyboardShortcuts } from '@/hooks/use-keyboard-shortcuts';
import { cn } from '@/lib/utils';
import { SidebarStorageService } from '@/services/sidebar-storage';
import { TabService } from '@/services/tab-service';
import { ReactFlowProvider } from '@xyflow/react';
import { ReactNode, useEffect, useState } from 'react';
import { TopBar } from './layout/top-bar';
import { BottomPanel } from "@/components/panels/bottom/bottom-panel";
import { LeftSidebar } from "@/components/panels/left/left-sidebar";
import { RightSidebar } from "@/components/panels/right/right-sidebar";
import { TabBar } from "@/components/tabs/tab-bar";
import { TabContent } from "@/components/tabs/tab-content";
import { SidebarProvider } from "@/components/ui/sidebar";
import { FlowProvider, useFlowContext } from "@/contexts/flow-context";
import { LayoutProvider, useLayoutContext } from "@/contexts/layout-context";
import { TabsProvider, useTabsContext } from "@/contexts/tabs-context";
import { useLayoutKeyboardShortcuts } from "@/hooks/use-keyboard-shortcuts";
import { cn } from "@/lib/utils";
import { SidebarStorageService } from "@/services/sidebar-storage";
import { TabService } from "@/services/tab-service";
import { ReactFlowProvider } from "@xyflow/react";
import { ReactNode, useEffect, useState } from "react";
import { TopBar } from "./layout/top-bar";

// Create a LayoutContent component to access the FlowContext, TabsContext, and LayoutContext
function LayoutContent({ children }: { children: ReactNode }) {
const { reactFlowInstance } = useFlowContext();
const { openTab } = useTabsContext();
const { isBottomCollapsed, expandBottomPanel, collapseBottomPanel, toggleBottomPanel } = useLayoutContext();

const {
isBottomCollapsed,
expandBottomPanel,
collapseBottomPanel,
toggleBottomPanel,
} = useLayoutContext();

// Initialize sidebar states from storage service
const [isLeftCollapsed, setIsLeftCollapsed] = useState(() =>
SidebarStorageService.loadLeftSidebarState(false)
const [isLeftCollapsed, setIsLeftCollapsed] = useState(() =>
SidebarStorageService.loadLeftSidebarState(false),
);
const [isRightCollapsed, setIsRightCollapsed] = useState(() =>
SidebarStorageService.loadRightSidebarState(false)

const [isRightCollapsed, setIsRightCollapsed] = useState(() =>
SidebarStorageService.loadRightSidebarState(false),
);

// Track actual sidebar widths for dynamic positioning
Expand All @@ -43,7 +48,7 @@ function LayoutContent({ children }: { children: ReactNode }) {
// Add keyboard shortcuts for toggling sidebars and fit view
useLayoutKeyboardShortcuts(
() => setIsRightCollapsed(!isRightCollapsed), // Cmd+I for right sidebar
() => setIsLeftCollapsed(!isLeftCollapsed), // Cmd+B for left sidebar
() => setIsLeftCollapsed(!isLeftCollapsed), // Cmd+B for left sidebar
() => reactFlowInstance.fitView({ padding: 0.1, duration: 500 }), // Cmd+O for fit view
// Note: undo/redo will be handled directly in the Flow component for now
undefined, // undo
Expand All @@ -65,15 +70,15 @@ function LayoutContent({ children }: { children: ReactNode }) {
const getSidebarBasedStyle = () => {
let left = 0;
let right = 0;

if (!isLeftCollapsed) {
left = leftSidebarWidth;
}

if (!isRightCollapsed) {
right = rightSidebarWidth;
}

return {
left: `${left}px`,
right: `${right}px`,
Expand All @@ -85,18 +90,18 @@ function LayoutContent({ children }: { children: ReactNode }) {
const tabBarHeight = 40; // Approximate tab bar height
let top = tabBarHeight;
let bottom = 0;

if (!isBottomCollapsed) {
bottom = bottomPanelHeight;
}

return {
top: `${top}px`,
bottom: `${bottom}px`,
left: '0',
right: '0',
width: 'auto',
height: 'auto',
left: "0",
right: "0",
width: "auto",
height: "auto",
};
};

Expand All @@ -114,31 +119,33 @@ function LayoutContent({ children }: { children: ReactNode }) {
/>

{/* Tab Bar - positioned absolutely like bottom panel */}
<div
<div
className="absolute top-0 z-10 transition-all duration-200"
style={getSidebarBasedStyle()}
>
<TabBar />
</div>

{/* Main content area */}
<main
className="absolute inset-0 overflow-hidden"
<main
className="absolute inset-0 overflow-hidden"
style={{
left: !isLeftCollapsed ? `${leftSidebarWidth}px` : '0px',
right: !isRightCollapsed ? `${rightSidebarWidth}px` : '0px',
top: '40px', // Tab bar height
bottom: !isBottomCollapsed ? `${bottomPanelHeight}px` : '0px',
left: !isLeftCollapsed ? `${leftSidebarWidth}px` : "0px",
right: !isRightCollapsed ? `${rightSidebarWidth}px` : "0px",
top: "40px", // Tab bar height
bottom: !isBottomCollapsed ? `${bottomPanelHeight}px` : "0px",
}}
>
<TabContent className="h-full w-full" />
</main>

{/* Floating left sidebar */}
<div className={cn(
"absolute top-0 left-0 z-30 h-full transition-transform",
isLeftCollapsed && "transform -translate-x-full opacity-0"
)}>
<div
className={cn(
"absolute top-0 left-0 z-30 h-full transition-transform",
isLeftCollapsed && "transform -translate-x-full opacity-0",
)}
>
<LeftSidebar
isCollapsed={isLeftCollapsed}
onCollapse={() => setIsLeftCollapsed(true)}
Expand All @@ -148,10 +155,12 @@ function LayoutContent({ children }: { children: ReactNode }) {
</div>

{/* Floating right sidebar */}
<div className={cn(
"absolute top-0 right-0 z-30 h-full transition-transform",
isRightCollapsed && "transform translate-x-full opacity-0"
)}>
<div
className={cn(
"absolute top-0 right-0 z-30 h-full transition-transform",
isRightCollapsed && "transform translate-x-full opacity-0",
)}
>
<RightSidebar
isCollapsed={isRightCollapsed}
onCollapse={() => setIsRightCollapsed(true)}
Expand All @@ -161,10 +170,10 @@ function LayoutContent({ children }: { children: ReactNode }) {
</div>

{/* Bottom panel */}
<div
<div
className={cn(
"absolute bottom-0 z-20 transition-transform",
isBottomCollapsed && "transform translate-y-full opacity-0"
isBottomCollapsed && "transform translate-y-full opacity-0",
)}
style={getSidebarBasedStyle()}
>
Expand Down Expand Up @@ -198,4 +207,5 @@ export function Layout({ children }: LayoutProps) {
</ReactFlowProvider>
</SidebarProvider>
);
}
}

6 changes: 6 additions & 0 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.