-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathpage.jsx
More file actions
47 lines (43 loc) · 1.63 KB
/
Copy pathpage.jsx
File metadata and controls
47 lines (43 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"use client";
import { useState } from 'react';
import Navbar from '@/components/navbar';
import { getTree, recursionActions } from '@/lib/algorithms/recursion';
import { buchheimLayout } from '@/components/tree/layout';
import { useTreeEditor } from '@/components/tree/use-tree-editor';
import TreeCanvas from '@/components/tree/tree-canvas';
import Menu from './menu';
export default function RecursionTree() {
const [n, setN] = useState(0);
const [r, setR] = useState(2);
const [algo, setAlgo] = useState(0);
const g = useTreeEditor();
const onStart = () => g.run(recursionActions(getTree(n, algo, r)));
return (
<div className="flex flex-col h-screen">
<Navbar />
<div className="flex flex-1 overflow-hidden">
<Menu
setN={setN}
setR={setR}
setAlgo={setAlgo}
onStart={onStart}
disabled={g.isRunning}
/>
<div className="relative flex-1 p-6">
{g.status && (
<div className="absolute top-3 left-3 z-10 rounded-md bg-slate-800 px-3 py-1.5 text-xs font-semibold text-white shadow">
{g.status}
</div>
)}
<TreeCanvas
tree={g.tree}
layout={buchheimLayout}
nodeState={g.nodeState}
edgeState={g.edgeState}
labels={g.labels}
/>
</div>
</div>
</div>
);
}