Skip to content

Resolved Issue no #934 #1916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 18 additions & 37 deletions client/modules/IDE/components/Console.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { useSelector, useDispatch } from 'react-redux';
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
Expand Down Expand Up @@ -43,7 +42,7 @@ import { useDidUpdate } from '../hooks/custom-hooks';
import useHandleMessageEvent from '../hooks/useHandleMessageEvent';
import { listen } from '../../../utils/dispatcher';

const getConsoleFeedStyle = (theme, times, fontSize) => {
const getConsoleFeedStyle = (theme, fontSize) => {
const style = {
BASE_FONT_FAMILY: 'Inconsolata, monospace'
};
Expand Down Expand Up @@ -73,33 +72,30 @@ const getConsoleFeedStyle = (theme, times, fontSize) => {
};
const CONSOLE_FEED_SIZES = {
TREENODE_LINE_HEIGHT: 1.2,
BASE_FONT_SIZE: fontSize,
ARROW_FONT_SIZE: fontSize,
LOG_ICON_WIDTH: fontSize,
LOG_ICON_HEIGHT: 1.45 * fontSize
BASE_FONT_SIZE: `${fontSize}px`,
ARROW_FONT_SIZE: `${fontSize}px`,
LOG_ICON_WIDTH: `${fontSize}px`,
LOG_ICON_HEIGHT: `${1.45 * fontSize}px`
};

if (times > 1) {
Object.assign(style, CONSOLE_FEED_WITHOUT_ICONS);
}
switch (theme) {
case 'light':
return Object.assign(
CONSOLE_FEED_LIGHT_STYLES,
CONSOLE_FEED_LIGHT_STYLES || {},
CONSOLE_FEED_LIGHT_ICONS,
CONSOLE_FEED_SIZES,
style
);
case 'dark':
return Object.assign(
CONSOLE_FEED_DARK_STYLES,
CONSOLE_FEED_DARK_STYLES || {},
CONSOLE_FEED_DARK_ICONS,
CONSOLE_FEED_SIZES,
style
);
case 'contrast':
return Object.assign(
CONSOLE_FEED_CONTRAST_STYLES,
CONSOLE_FEED_CONTRAST_STYLES || {},
CONSOLE_FEED_CONTRAST_ICONS,
CONSOLE_FEED_SIZES,
style
Expand All @@ -114,7 +110,6 @@ const Console = ({ t }) => {
const isExpanded = useSelector((state) => state.ide.consoleIsExpanded);
const isPlaying = useSelector((state) => state.ide.isPlaying);
const { theme, fontSize } = useSelector((state) => state.preferences);

const {
collapseConsole,
expandConsole,
Expand Down Expand Up @@ -170,30 +165,16 @@ const Console = ({ t }) => {
</div>
</header>
<div className="preview-console__body">
<div ref={cm} className="preview-console__messages">
{consoleEvents.map((consoleEvent) => {
const { method, times } = consoleEvent;
return (
<div
key={consoleEvent.id}
className={`preview-console__message preview-console__message--${method}`}
>
{times > 1 && (
<div
className="preview-console__logged-times"
style={{ fontSize, borderRadius: fontSize / 2 }}
>
{times}
</div>
)}
<ConsoleFeed
styles={getConsoleFeedStyle(theme, times, fontSize)}
logs={[consoleEvent]}
key={`${consoleEvent.id}-${theme}-${fontSize}`}
/>
</div>
);
})}
<div
ref={cm}
className="preview-console__messages"
style={{ fontSize }}
>
<ConsoleFeed
styles={getConsoleFeedStyle(theme, fontSize)}
logs={consoleEvents}
key={`${theme}-${fontSize}`}
/>
</div>
{isExpanded && isPlaying && (
<ConsoleInput
Expand Down
18 changes: 0 additions & 18 deletions client/modules/IDE/hooks/useHandleMessageEvent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useDispatch } from 'react-redux';
import { Decode } from 'console-feed';
import { isEqual } from 'lodash';
import { dispatchConsoleEvent } from '../actions/console';
import { stopSketch, expandConsole } from '../actions/ide';

Expand All @@ -27,23 +26,6 @@ export default function useHandleMessageEvent() {
if (hasInfiniteLoop) {
return false;
}
if (index === arr.length - 1) {
Object.assign(message, { times: 1 });
return false;
}
// this should be done in the reducer probs
const cur = Object.assign(message, { times: 1 });
const nextIndex = index + 1;
while (
isEqual(cur.data, arr[nextIndex].data) &&
cur.method === arr[nextIndex].method
) {
cur.times += 1;
arr.splice(nextIndex, 1);
if (nextIndex === arr.length) {
return false;
}
}
return true;
});
dispatch(dispatchConsoleEvent(decodedMessages));
Expand Down
2 changes: 1 addition & 1 deletion client/modules/IDE/reducers/console.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as ActionTypes from '../../../constants';

const consoleMax = 500;
const consoleMax = 5000;
const initialState = [];

const console = (state = initialState, action) => {
Expand Down
19 changes: 17 additions & 2 deletions client/styles/components/_console-feed.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ $CONSOLE_FEED_LIGHT_STYLES: (
OBJECT_VALUE_NUMBER_COLOR: '#333',
OBJECT_VALUE_BOOLEAN_COLOR: '#D52889',
OBJECT_VALUE_FUNCTION_KEYWORD_COLOR: '#0B7CA9',
LOG_AMOUNT_BACKGROUND: '#5276B7',
LOG_AMOUNT_COLOR: '#FFF',
LOG_WARN_AMOUNT_BACKGROUND: '#996B00',
LOG_ERROR_AMOUNT_BACKGROUND: '#D11518',
LOG_DEBUG_AMOUNT_BACKGROUND: '#0071AD'
);

$CONSOLE_FEED_DARK_STYLES: (
Expand Down Expand Up @@ -57,7 +62,12 @@ $CONSOLE_FEED_DARK_STYLES: (
TABLE_SORT_ICON_COLOR: 'grey',
TABLE_DATA_BACKGROUND_IMAGE: 'grey',
TABLE_DATA_BACKGROUND_SIZE: 'grey',
ARROW_COLOR: '#D9D9D9'
ARROW_COLOR: '#D9D9D9',
LOG_AMOUNT_BACKGROUND: '#5276B7',
LOG_AMOUNT_COLOR: '#333',
LOG_WARN_AMOUNT_BACKGROUND: '#996B00',
LOG_ERROR_AMOUNT_BACKGROUND: '#D11518',
LOG_DEBUG_AMOUNT_BACKGROUND: '#0071AD'
);

$CONSOLE_FEED_CONTRAST_STYLES: (
Expand Down Expand Up @@ -88,5 +98,10 @@ $CONSOLE_FEED_CONTRAST_STYLES: (
TABLE_SORT_ICON_COLOR: 'grey',
TABLE_DATA_BACKGROUND_IMAGE: 'grey',
TABLE_DATA_BACKGROUND_SIZE: 'grey',
ARROW_COLOR: '#D9D9D9'
ARROW_COLOR: '#D9D9D9',
LOG_AMOUNT_BACKGROUND: '#5276B7',
LOG_AMOUNT_COLOR: '#333',
LOG_WARN_AMOUNT_BACKGROUND: '#966C08',
LOG_ERROR_AMOUNT_BACKGROUND: '#DD3134',
LOG_DEBUG_AMOUNT_BACKGROUND: '#097BB3'
);
44 changes: 5 additions & 39 deletions client/styles/components/_console.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
flex: 1;
flex-direction: column;
overflow-y: auto;
& div div div:first-child {
height: unset;
line-height: unset;
font-size: unset;
}
}

.preview-console__collapse {
Expand Down Expand Up @@ -97,47 +102,8 @@
}
}

.preview-console__logged-times {

font-weight: bold;
margin: #{2 / $base-font-size}rem 0 0 #{8 / $base-font-size}rem;
border-radius: #{10 / $base-font-size}rem;
padding: #{1 / $base-font-size}rem #{4 / $base-font-size}rem;
z-index: 100;
left: 0;
position: absolute;

.preview-console__message--info &, .preview-console__message--log & {
@include themify() {
background-color: getThemifyVariable('console-info-background-color');
}
}
.preview-console__message--warn & {
@include themify() {
background-color: getThemifyVariable('console-warn-background-color');
}
}
.preview-console__message--debug & {
@include themify() {
background-color: getThemifyVariable('console-debug-background-color');
}
}
.preview-console__message--error & {
@include themify() {
background-color: getThemifyVariable('console-error-background-color');
}
}
}

.preview-console__body {
display: flex;
flex-direction: column;
height: calc(100% - #{30 / $base-font-size}rem);

.preview-console__message {
position: relative;
@include themify() {
color: getThemifyVariable('console-logged-times-color');
}
}
}
Loading