Skip to content

Commit 8a9e036

Browse files
committed
Merge branch 'release-1.3.1' into release
2 parents 9201d29 + c31199f commit 8a9e036

22 files changed

+116
-520
lines changed

client/components/useAsModal.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import styled from 'styled-components';
3-
import { useModalBehavior } from '../modules/IDE/hooks/custom-hooks';
3+
import { useModalBehavior } from '../utils/custom-hooks';
44

55
const BackgroundOverlay = styled.div`
66
position: fixed;

client/images/console-command-contrast.svg

-13
This file was deleted.

client/images/console-command-dark.svg

-13
This file was deleted.

client/images/console-command-light.svg

-13
This file was deleted.

client/images/console-result-contrast.svg

-22
This file was deleted.

client/images/console-result-dark.svg

-22
This file was deleted.

client/images/console-result-light.svg

-22
This file was deleted.

client/modules/IDE/components/Console.jsx

+34-66
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useRef, useEffect } from 'react';
1+
import React, { useRef } from 'react';
22
import PropTypes from 'prop-types';
33
import { withTranslation } from 'react-i18next';
44

@@ -25,51 +25,33 @@ import debugContrastUrl from '../../../images/console-debug-contrast.svg?byUrl';
2525
import infoLightUrl from '../../../images/console-info-light.svg?byUrl';
2626
import infoDarkUrl from '../../../images/console-info-dark.svg?byUrl';
2727
import infoContrastUrl from '../../../images/console-info-contrast.svg?byUrl';
28-
import ConsoleInput from './ConsoleInput';
29-
30-
import commandLightUrl from '../../../images/console-command-light.svg?byUrl';
31-
import resultLightUrl from '../../../images/console-result-light.svg?byUrl';
32-
import commandDarkUrl from '../../../images/console-command-dark.svg?byUrl';
33-
import resultDarkUrl from '../../../images/console-result-dark.svg?byUrl';
34-
import commandContrastUrl from '../../../images/console-command-contrast.svg?byUrl';
35-
import resultContrastUrl from '../../../images/console-result-contrast.svg?byUrl';
3628

3729
import UpArrowIcon from '../../../images/up-arrow.svg';
3830
import DownArrowIcon from '../../../images/down-arrow.svg';
3931

4032
import * as IDEActions from '../../IDE/actions/ide';
4133
import * as ConsoleActions from '../../IDE/actions/console';
42-
import { useDidUpdate } from '../hooks/custom-hooks';
43-
import useHandleMessageEvent from '../hooks/useHandleMessageEvent';
44-
import { listen } from '../../../utils/dispatcher';
34+
import { useDidUpdate } from '../../../utils/custom-hooks';
4535

4636
const getConsoleFeedStyle = (theme, times, fontSize) => {
47-
const style = {
48-
BASE_FONT_FAMILY: 'Inconsolata, monospace'
49-
};
37+
const style = {};
5038
const CONSOLE_FEED_LIGHT_ICONS = {
5139
LOG_WARN_ICON: `url(${warnLightUrl})`,
5240
LOG_ERROR_ICON: `url(${errorLightUrl})`,
5341
LOG_DEBUG_ICON: `url(${debugLightUrl})`,
54-
LOG_INFO_ICON: `url(${infoLightUrl})`,
55-
LOG_COMMAND_ICON: `url(${commandLightUrl})`,
56-
LOG_RESULT_ICON: `url(${resultLightUrl})`
42+
LOG_INFO_ICON: `url(${infoLightUrl})`
5743
};
5844
const CONSOLE_FEED_DARK_ICONS = {
5945
LOG_WARN_ICON: `url(${warnDarkUrl})`,
6046
LOG_ERROR_ICON: `url(${errorDarkUrl})`,
6147
LOG_DEBUG_ICON: `url(${debugDarkUrl})`,
62-
LOG_INFO_ICON: `url(${infoDarkUrl})`,
63-
LOG_COMMAND_ICON: `url(${commandDarkUrl})`,
64-
LOG_RESULT_ICON: `url(${resultDarkUrl})`
48+
LOG_INFO_ICON: `url(${infoDarkUrl})`
6549
};
6650
const CONSOLE_FEED_CONTRAST_ICONS = {
6751
LOG_WARN_ICON: `url(${warnContrastUrl})`,
6852
LOG_ERROR_ICON: `url(${errorContrastUrl})`,
6953
LOG_DEBUG_ICON: `url(${debugContrastUrl})`,
70-
LOG_INFO_ICON: `url(${infoContrastUrl})`,
71-
LOG_COMMAND_ICON: `url(${commandContrastUrl})`,
72-
LOG_RESULT_ICON: `url(${resultContrastUrl})`
54+
LOG_INFO_ICON: `url(${infoContrastUrl})`
7355
};
7456
const CONSOLE_FEED_SIZES = {
7557
TREENODE_LINE_HEIGHT: 1.2,
@@ -112,7 +94,6 @@ const getConsoleFeedStyle = (theme, times, fontSize) => {
11294
const Console = ({ t }) => {
11395
const consoleEvents = useSelector((state) => state.console);
11496
const isExpanded = useSelector((state) => state.ide.consoleIsExpanded);
115-
const isPlaying = useSelector((state) => state.ide.isPlaying);
11697
const { theme, fontSize } = useSelector((state) => state.preferences);
11798

11899
const {
@@ -122,20 +103,17 @@ const Console = ({ t }) => {
122103
dispatchConsoleEvent
123104
} = bindActionCreators({ ...IDEActions, ...ConsoleActions }, useDispatch());
124105

106+
useDidUpdate(() => {
107+
clearConsole();
108+
dispatchConsoleEvent(consoleEvents);
109+
}, [theme, fontSize]);
110+
125111
const cm = useRef({});
126112

127113
useDidUpdate(() => {
128114
cm.current.scrollTop = cm.current.scrollHeight;
129115
});
130116

131-
const handleMessageEvent = useHandleMessageEvent();
132-
useEffect(() => {
133-
const unsubscribe = listen(handleMessageEvent);
134-
return function cleanup() {
135-
unsubscribe();
136-
};
137-
});
138-
139117
const consoleClass = classNames({
140118
'preview-console': true,
141119
'preview-console--collapsed': !isExpanded
@@ -169,39 +147,29 @@ const Console = ({ t }) => {
169147
</button>
170148
</div>
171149
</header>
172-
<div className="preview-console__body">
173-
<div ref={cm} className="preview-console__messages">
174-
{consoleEvents.map((consoleEvent) => {
175-
const { method, times } = consoleEvent;
176-
return (
177-
<div
178-
key={consoleEvent.id}
179-
className={`preview-console__message preview-console__message--${method}`}
180-
>
181-
{times > 1 && (
182-
<div
183-
className="preview-console__logged-times"
184-
style={{ fontSize, borderRadius: fontSize / 2 }}
185-
>
186-
{times}
187-
</div>
188-
)}
189-
<ConsoleFeed
190-
styles={getConsoleFeedStyle(theme, times, fontSize)}
191-
logs={[consoleEvent]}
192-
key={`${consoleEvent.id}-${theme}-${fontSize}`}
193-
/>
194-
</div>
195-
);
196-
})}
197-
</div>
198-
{isExpanded && isPlaying && (
199-
<ConsoleInput
200-
theme={theme}
201-
dispatchConsoleEvent={dispatchConsoleEvent}
202-
fontSize={fontSize}
203-
/>
204-
)}
150+
<div ref={cm} className="preview-console__messages">
151+
{consoleEvents.map((consoleEvent) => {
152+
const { method, times } = consoleEvent;
153+
return (
154+
<div
155+
key={consoleEvent.id}
156+
className={`preview-console__message preview-console__message--${method}`}
157+
>
158+
{times > 1 && (
159+
<div
160+
className="preview-console__logged-times"
161+
style={{ fontSize, borderRadius: fontSize / 2 }}
162+
>
163+
{times}
164+
</div>
165+
)}
166+
<ConsoleFeed
167+
styles={getConsoleFeedStyle(theme, times, fontSize)}
168+
logs={[consoleEvent]}
169+
/>
170+
</div>
171+
);
172+
})}
205173
</div>
206174
</section>
207175
);

0 commit comments

Comments
 (0)