From 9ef160aeb79913eefeb3b47fcb49cab455647d55 Mon Sep 17 00:00:00 2001 From: Joeri Exelmans Date: Tue, 13 May 2025 13:11:57 +0200 Subject: [PATCH] simplify some things --- src/App.tsx | 43 +++++++++++++++++++++++++++++++++++-------- src/CallBlock.tsx | 8 +++----- src/CommandContext.ts | 3 +++ src/Editor.css | 2 +- src/Editor.tsx | 35 ++++++++++++++++++++++++++--------- src/LetInBlock.tsx | 38 ++++++++++++++++++++++++++++++++++---- tsconfig.app.json | 4 ++-- tsconfig.node.json | 2 +- 8 files changed, 105 insertions(+), 30 deletions(-) create mode 100644 src/CommandContext.ts diff --git a/src/App.tsx b/src/App.tsx index 9dddaec..a93ebde 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,6 +2,7 @@ import { useEffect, useRef, useState } from 'react'; import './App.css' import { Editor, type EditorState } from './Editor' import { initialEditorState, nonEmptyEditorState, tripleFunctionCallEditorState } from "./configurations"; +import { CommandContext } from './CommandContext'; export function App() { const [history, setHistory] = useState([initialEditorState]); @@ -48,22 +49,48 @@ export function App() { window.onkeydown = onKeyDown; }, []); + const commands = [ + ["call" , "[c] call" ], + ["eval" , "[u] [Tab] [Enter] eval"], + ["transform", "[t] transform" ], + ["let" , "[=] let ... in ..." ], + ]; + + const [highlighted, setHighlighted] = useState( + commands.map(() => false)); + + const doHighlight = Object.fromEntries(commands.map(([id], i) => { + return [id, () => { + setHighlighted(h => h.with(i, true)); + setTimeout(() => setHighlighted(h => h.with(i, false)), 100); + }]; + })); + return ( <>
+ Commands: + { + commands.map(([_, descr], i) => + + {descr} + ) + }
- {}} - onCancel={() => {}} - filter={() => true} - focus={true} - /> + + {}} + onCancel={() => {}} + filter={() => true} + focus={true} + /> +