Skip to content

Commit

Permalink
Merge branch 'staging' into fix-data-panel
Browse files Browse the repository at this point in the history
  • Loading branch information
Anchel123 authored Nov 21, 2024
2 parents 1701a65 + 9e01868 commit 2ad1bf6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 2 additions & 0 deletions app/components/code-graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,9 @@ export function CodeGraph({
<Toolbar
className="pointer-events-auto"
chartRef={chartRef}
setSelectedObj={setSelectedObj}
/>
<Toolbar className="pointer-events-auto" chartRef={chartRef} />
</div>
</div>
<ElementTooltip
Expand Down
20 changes: 14 additions & 6 deletions app/components/toolbar.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
import { CircleDot, Minus, Plus } from "lucide-react";
import { cn } from "@/lib/utils"
import { Dispatch, RefObject, SetStateAction } from "react";
import { Node } from "./model";

export function Toolbar(params: {
chartRef: React.RefObject<cytoscape.Core>, className?: string
}) {
interface Props {
chartRef: RefObject<cytoscape.Core>
setSelectedObj: Dispatch<SetStateAction<Node | undefined>>
className?: string
}

export function Toolbar({ chartRef, setSelectedObj, className }: Props) {

function handleZoomClick(changefactor: number) {
let chart = params.chartRef.current
let chart = chartRef.current
if (chart) {
chart.zoom(chart.zoom() * changefactor)
}
setSelectedObj(undefined)
}

function handleCenterClick() {
let chart = params.chartRef.current
let chart = chartRef.current
if (chart) {
chart.fit(undefined, 80)
chart.center()
}
setSelectedObj(undefined)
}

return (
<div className={cn("bg-white flex flex-row rounded overflow-hidden", params.className)}>
<div className={cn("bg-white flex flex-row rounded overflow-hidden", className)}>
<button
className="border p-2"
onClick={() => handleZoomClick(0.9)}
Expand Down

0 comments on commit 2ad1bf6

Please sign in to comment.