Add Modal

This commit is contained in:
Daniel Kluge
2022-01-14 14:27:19 +01:00
parent ee8e4b9fb9
commit a2f035ce1a
13 changed files with 592 additions and 101 deletions
+10 -2
View File
@@ -4,7 +4,15 @@ import REPLHistory from "./REPLHistory";
import styles from "../../styles/REPL/REPLComplete.module.css";
import type { NextPage } from "next";
const REPL: NextPage<{inputRef: MutableRefObject<HTMLInputElement|undefined>}> = ({ inputRef }) => {
interface IREPLProps {
inputRef: MutableRefObject<HTMLInputElement|undefined>;
modalManipulation: {
setModalVisible: CallableFunction;
setModalProject: CallableFunction;
}
}
const REPL: NextPage<IREPLProps> = ({ inputRef, modalManipulation }) => {
const [history, manipulateHistory] = useState<string[]>([]);
const onCommandExecuted = (result: string[]) => manipulateHistory(result.reverse().concat(history).slice(0, 1000));
const onClearHistory = () => manipulateHistory([]);
@@ -15,7 +23,7 @@ const REPL: NextPage<{inputRef: MutableRefObject<HTMLInputElement|undefined>}> =
return (<div className={styles.container}>
<REPLHistory history={history} inputRef={inputRef} />
<REPLInput historyCallback={onCommandExecuted} historyClear={onClearHistory} inputRef={inputRef} />
<REPLInput historyCallback={onCommandExecuted} historyClear={onClearHistory} inputRef={inputRef} modalManipulation={modalManipulation} />
<div style={{flexGrow: 2}} onClick={focusInput}></div>
</div>);
};