aboutsummaryrefslogtreecommitdiff
path: root/src/console/components/Console.tsx
blob: 508c6eb091b66f7315dd1e091e8c5b58f79ca84b (plain) (blame)
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
import React from "react";
import FindPrompt from "./FindPrompt";
import CommandPrompt from "./CommandPrompt";
import InfoMessage from "./InfoMessage";
import ErrorMessage from "./ErrorMessage";
import AppContext from "./AppContext";
import { useColorSchemeRefresh } from "../colorscheme/hooks";

const Console: React.FC = () => {
  const { state } = React.useContext(AppContext);
  const refreshColorScheme = useColorSchemeRefresh();

  React.useEffect(() => {
    refreshColorScheme();
  }, []);

  switch (state.mode) {
    case "command":
      return <CommandPrompt initialInputValue={state.consoleText} />;
    case "find":
      return <FindPrompt />;
    case "info":
      return <InfoMessage>{state.messageText}</InfoMessage>;
    case "error":
      return <ErrorMessage>{state.messageText}</ErrorMessage>;
    default:
      return null;
  }
};

export default Console;