From c419dc0b8ef1f97d1bd2958a0f3aff38746927c9 Mon Sep 17 00:00:00 2001 From: shinytang6 <1074461480@qq.com> Date: Sun, 24 Jun 2018 00:20:20 +0800 Subject: [PATCH 01/22] init v2 --- client/images/console-debug-dark.svg | 1 + client/images/console-debug-light.svg | 1 + client/images/console-error-dark.svg | 1 + client/images/console-error-light.svg | 1 + client/images/console-info-dark.svg | 1 + client/images/console-info-light.svg | 1 + client/images/console-warn-dark.svg | 1 + client/images/console-warn-light.svg | 1 + client/modules/IDE/components/Console.jsx | 53 +++++- .../modules/IDE/components/PreviewFrame.jsx | 152 ++++++++++++++---- client/modules/IDE/pages/IDEView.jsx | 2 + client/styles/abstracts/_variables.scss | 21 ++- client/styles/components/_console.scss | 57 ++++--- client/utils/consoleUtils.js | 71 +++++++- package.json | 7 +- 15 files changed, 306 insertions(+), 65 deletions(-) create mode 100644 client/images/console-debug-dark.svg create mode 100644 client/images/console-debug-light.svg create mode 100644 client/images/console-error-dark.svg create mode 100644 client/images/console-error-light.svg create mode 100644 client/images/console-info-dark.svg create mode 100644 client/images/console-info-light.svg create mode 100644 client/images/console-warn-dark.svg create mode 100644 client/images/console-warn-light.svg diff --git a/client/images/console-debug-dark.svg b/client/images/console-debug-dark.svg new file mode 100644 index 0000000000..58aebc9d84 --- /dev/null +++ b/client/images/console-debug-dark.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/client/images/console-debug-light.svg b/client/images/console-debug-light.svg new file mode 100644 index 0000000000..65a0b0a846 --- /dev/null +++ b/client/images/console-debug-light.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/client/images/console-error-dark.svg b/client/images/console-error-dark.svg new file mode 100644 index 0000000000..56caaebc32 --- /dev/null +++ b/client/images/console-error-dark.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/client/images/console-error-light.svg b/client/images/console-error-light.svg new file mode 100644 index 0000000000..7ddff3564c --- /dev/null +++ b/client/images/console-error-light.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/client/images/console-info-dark.svg b/client/images/console-info-dark.svg new file mode 100644 index 0000000000..37e7526097 --- /dev/null +++ b/client/images/console-info-dark.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/client/images/console-info-light.svg b/client/images/console-info-light.svg new file mode 100644 index 0000000000..f239a82f5b --- /dev/null +++ b/client/images/console-info-light.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/client/images/console-warn-dark.svg b/client/images/console-warn-dark.svg new file mode 100644 index 0000000000..bcfcb47590 --- /dev/null +++ b/client/images/console-warn-dark.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/client/images/console-warn-light.svg b/client/images/console-warn-light.svg new file mode 100644 index 0000000000..83a70db4f0 --- /dev/null +++ b/client/images/console-warn-light.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/client/modules/IDE/components/Console.jsx b/client/modules/IDE/components/Console.jsx index fdb4e09235..611e620a79 100644 --- a/client/modules/IDE/components/Console.jsx +++ b/client/modules/IDE/components/Console.jsx @@ -2,13 +2,43 @@ import PropTypes from 'prop-types'; import React from 'react'; import InlineSVG from 'react-inlinesvg'; import classNames from 'classnames'; +import { Console as ConsoleFeed } from 'console-feed'; +import { CONSOLE_FEED_WITHOUT_ICONS, CONSOLE_FEED_LIGHT_STYLES, CONSOLE_FEED_DARK_STYLES, CONSOLE_FEED_CONTRAST_STYLES } from '../../../utils/consoleUtils'; const upArrowUrl = require('../../../images/up-arrow.svg'); const downArrowUrl = require('../../../images/down-arrow.svg'); class Console extends React.Component { - componentDidUpdate() { + componentDidUpdate(prevProps) { this.consoleMessages.scrollTop = this.consoleMessages.scrollHeight; + if (this.props.theme !== prevProps.theme) { + this.props.clearConsole(); + this.props.dispatchConsoleEvent(this.props.consoleEvents); + } + } + + getConsoleFeedStyle(theme, times) { + const style = {}; + if (times > 1) { + Object.assign(style, CONSOLE_FEED_WITHOUT_ICONS); + } + switch (theme) { + case 'light': + return Object.assign(style, CONSOLE_FEED_LIGHT_STYLES); + case 'dark': + return Object.assign(style, CONSOLE_FEED_DARK_STYLES); + case 'contrast': + return Object.assign(style, CONSOLE_FEED_CONTRAST_STYLES); + default: + return ''; + } + } + + formatData(args) { + if (!Array.isArray(args)) { + return Array.of(args); + } + return args; } render() { @@ -39,17 +69,26 @@ class Console extends React.Component {