From 2b1079525b86dad45df11e6ad29a89989a6416ab Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 4 Apr 2021 16:44:47 +0900 Subject: Separate Message to InfoMessage and ErrorMessage --- src/console/components/Console.tsx | 10 +++++++-- src/console/components/ErrorMessage.tsx | 15 ++++++++++++++ src/console/components/InfoMessage.tsx | 15 ++++++++++++++ src/console/components/console/Message.tsx | 33 ------------------------------ 4 files changed, 38 insertions(+), 35 deletions(-) create mode 100644 src/console/components/ErrorMessage.tsx create mode 100644 src/console/components/InfoMessage.tsx delete mode 100644 src/console/components/console/Message.tsx (limited to 'src/console/components') diff --git a/src/console/components/Console.tsx b/src/console/components/Console.tsx index fa91336..951b627 100644 --- a/src/console/components/Console.tsx +++ b/src/console/components/Console.tsx @@ -1,7 +1,8 @@ import React from "react"; import Input from "./console/Input"; import Completion from "./console/Completion"; -import Message from "./console/Message"; +import InfoMessage from "./InfoMessage"; +import ErrorMessage from "./ErrorMessage"; import * as consoleActions from "../../console/actions/console"; import CommandLineParser, { InputPhase, @@ -199,10 +200,15 @@ const Console: React.FC = () => { ); case "info": + return ( + + {state.messageText} + + ); case "error": return ( - {state.messageText} + {state.messageText} ); default: diff --git a/src/console/components/ErrorMessage.tsx b/src/console/components/ErrorMessage.tsx new file mode 100644 index 0000000..93b049b --- /dev/null +++ b/src/console/components/ErrorMessage.tsx @@ -0,0 +1,15 @@ +import React from "react"; +import { styled } from "./ColorSchemeProvider"; + +const Wrapper = styled.p` + border-top: 1px solid gray; + background-color: ${({ theme }) => theme.consoleErrorBackground}; + color: ${({ theme }) => theme.consoleErrorForeground}; + font-weight: bold; +`; + +const ErrorMessage: React.FC = ({ children }) => { + return {children}; +}; + +export default ErrorMessage; diff --git a/src/console/components/InfoMessage.tsx b/src/console/components/InfoMessage.tsx new file mode 100644 index 0000000..02ad27d --- /dev/null +++ b/src/console/components/InfoMessage.tsx @@ -0,0 +1,15 @@ +import React from "react"; +import { styled } from "./ColorSchemeProvider"; + +const Wrapper = styled.p` + border-top: 1px solid gray; + background-color: ${({ theme }) => theme.consoleInfoBackground}; + color: ${({ theme }) => theme.consoleInfoForeground}; + font-weight: normal; +`; + +const InfoMessage: React.FC = ({ children }) => { + return {children}; +}; + +export default InfoMessage; diff --git a/src/console/components/console/Message.tsx b/src/console/components/console/Message.tsx deleted file mode 100644 index 8dcdb5a..0000000 --- a/src/console/components/console/Message.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import React from "react"; -import { styled } from "../ColorSchemeProvider"; - -const Error = styled.p` - border-top: 1px solid gray; - background-color: ${({ theme }) => theme.consoleErrorBackground}; - color: ${({ theme }) => theme.consoleErrorForeground}; - font-weight: bold; -`; - -const Info = styled.p` - border-top: 1px solid gray; - background-color: ${({ theme }) => theme.consoleInfoBackground}; - color: ${({ theme }) => theme.consoleInfoForeground}; - font-weight: normal; -`; - -interface Props { - mode: string; - children: string; -} - -const Message: React.FC = ({ mode, children }) => { - switch (mode) { - case "error": - return {children}; - case "info": - return {children}; - } - return null; -}; - -export default Message; -- cgit v1.2.3