forked from eslint/code-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
74 lines (70 loc) · 2.31 KB
/
App.tsx
File metadata and controls
74 lines (70 loc) · 2.31 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import "./App.css";
import { Navbar } from "./components/navbar";
import { useExplorer } from "./hooks/use-explorer";
import { tools } from "./lib/tools";
import { Editor } from "./components/editor";
import { EsquerySelectorInput } from "./components/esquery-selector-input";
import { ToolSelector } from "./components/tool-selector";
import { ThemeProvider } from "./components/theme-provider";
import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";
import { useAST } from "@/hooks/use-ast";
import { convertNodesToRanges } from "@/lib/convert-nodes-to-ranges";
function App() {
const { language, tool, code, setCode } = useExplorer();
const astParseResult = useAST();
const activeTool = tools.find(({ value }) => value === tool) ?? tools[0];
return (
<ThemeProvider>
<div className="antialiased touch-manipulation font-sans">
<div className="flex flex-col h-screen">
<Navbar />
<div className="h-full overflow-hidden">
<div className="border-t h-full">
<PanelGroup
direction="horizontal"
className="border-t h-full"
>
<Panel defaultSize={50} minSize={25}>
<EsquerySelectorInput />
<Editor
value={code[language]}
highlightedRanges={
astParseResult.ok
? convertNodesToRanges(
astParseResult.esqueryMatchedNodes,
)
: undefined
}
onChange={value => {
setCode({
...code,
[language]: value,
});
}}
/>
</Panel>
<PanelResizeHandle className="w-2 bg-gutter dark:bg-gray-600 bg-gray-200 bg-no-repeat bg-center" />
<Panel defaultSize={50} minSize={25}>
<div className="bg-muted overflow-auto h-full relative flex flex-col">
<div className="flex sm:items-center flex-col sm:flex-row justify-between p-4 gap-2 z-10">
<ToolSelector />
<div className="flex items-center gap-1">
{activeTool.options.map(
(Option, index) => (
<Option key={index} />
),
)}
</div>
</div>
<activeTool.component />
</div>
</Panel>
</PanelGroup>
</div>
</div>
</div>
</div>
</ThemeProvider>
);
}
export default App;