|
1 | 1 | /* Copyright 2026 Marimo. All rights reserved. */ |
2 | 2 |
|
3 | 3 | import type React from "react"; |
| 4 | +import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; |
4 | 5 | import { useCellDataAtoms, useCellIds } from "@/core/cells/cells"; |
5 | 6 | import { useVariables } from "@/core/variables/state"; |
6 | 7 | import { cn } from "@/utils/cn"; |
7 | 8 | import { DependencyGraph } from "../../../dependency-graph/dependency-graph"; |
8 | 9 | import { MinimapContent } from "../../../dependency-graph/minimap-content"; |
9 | 10 | import { useDependencyPanelTab } from "../wrapper/useDependencyPanelTab"; |
| 11 | +import { usePanelSection } from "./panel-context"; |
10 | 12 |
|
11 | 13 | const DependencyGraphPanel: React.FC = () => { |
12 | | - const { dependencyPanelTab } = useDependencyPanelTab(); |
| 14 | + const { dependencyPanelTab, setDependencyPanelTab } = useDependencyPanelTab(); |
13 | 15 | const variables = useVariables(); |
14 | 16 | const cellIds = useCellIds(); |
15 | 17 | const [cells] = useCellDataAtoms(); |
| 18 | + const panelSection = usePanelSection(); |
| 19 | + |
| 20 | + // Show toggle inside panel when in developer panel (horizontal layout) |
| 21 | + // since the sidebar has its own header with the toggle |
| 22 | + const showInlineToggle = panelSection === "developer-panel"; |
16 | 23 |
|
17 | 24 | return ( |
18 | | - <div className={cn("w-full h-full flex-1 mx-auto -mb-4 relative")}> |
19 | | - {dependencyPanelTab === "minimap" ? ( |
20 | | - <MinimapContent /> |
21 | | - ) : ( |
22 | | - <DependencyGraph |
23 | | - cellAtoms={cells} |
24 | | - variables={variables} |
25 | | - cellIds={cellIds.inOrderIds} |
26 | | - /> |
| 25 | + <div className={cn("w-full h-full flex-1 mx-auto -mb-4 flex flex-col")}> |
| 26 | + {showInlineToggle && ( |
| 27 | + <div className="p-2 shrink-0"> |
| 28 | + <Tabs |
| 29 | + value={dependencyPanelTab} |
| 30 | + onValueChange={(value) => { |
| 31 | + if (value === "minimap" || value === "graph") { |
| 32 | + setDependencyPanelTab(value); |
| 33 | + } |
| 34 | + }} |
| 35 | + > |
| 36 | + <TabsList> |
| 37 | + <TabsTrigger |
| 38 | + value="minimap" |
| 39 | + className="py-0.5 text-xs uppercase tracking-wide font-bold" |
| 40 | + > |
| 41 | + Minimap |
| 42 | + </TabsTrigger> |
| 43 | + <TabsTrigger |
| 44 | + value="graph" |
| 45 | + className="py-0.5 text-xs uppercase tracking-wide font-bold" |
| 46 | + > |
| 47 | + Graph |
| 48 | + </TabsTrigger> |
| 49 | + </TabsList> |
| 50 | + </Tabs> |
| 51 | + </div> |
27 | 52 | )} |
| 53 | + <div className="flex-1 min-h-0 relative"> |
| 54 | + {dependencyPanelTab === "minimap" ? ( |
| 55 | + <MinimapContent /> |
| 56 | + ) : ( |
| 57 | + <DependencyGraph |
| 58 | + cellAtoms={cells} |
| 59 | + variables={variables} |
| 60 | + cellIds={cellIds.inOrderIds} |
| 61 | + /> |
| 62 | + )} |
| 63 | + </div> |
28 | 64 | </div> |
29 | 65 | ); |
30 | 66 | }; |
|
0 commit comments