Skip to content

Commit e3ea72a

Browse files
authored
Merge branch 'develop' into update/tidy-code-shortcut
2 parents 7005999 + 9687be8 commit e3ea72a

40 files changed

+720
-370
lines changed

.env.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ EXAMPLE_USER_PASSWORD=hellop5js
1010
GG_EXAMPLES_USERNAME=generativedesign
1111
GG_EXAMPLES_EMAIL=benedikt.gross@generative-gestaltung.de
1212
GG_EXAMPLES_PASS=generativedesign
13-
ML5_EXAMPLES_USERNAME=ml5
14-
ML5_EXAMPLES_EMAIL=examples@ml5js.org
15-
ML5_EXAMPLES_PASS=helloml5
13+
ML5_LIBRARY_USERNAME=ml5
14+
ML5_LIBRARY_EMAIL=examples@ml5js.org
15+
ML5_LIBRARY_PASS=helloml5
1616
GITHUB_ID=<your-github-client-id>
1717
GITHUB_SECRET=<your-github-client-secret>
1818
GOOGLE_ID=<your-google-client-id> (use google+ api)

client/components/Nav.jsx

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ class Nav extends React.PureComponent {
4242
this.handleFind = this.handleFind.bind(this);
4343
this.handleAddFile = this.handleAddFile.bind(this);
4444
this.handleAddFolder = this.handleAddFolder.bind(this);
45-
this.handleFindNext = this.handleFindNext.bind(this);
4645
this.handleRun = this.handleRun.bind(this);
47-
this.handleFindPrevious = this.handleFindPrevious.bind(this);
4846
this.handleReplace = this.handleReplace.bind(this);
4947
this.handleStop = this.handleStop.bind(this);
5048
this.handleStartAccessible = this.handleStartAccessible.bind(this);
@@ -128,16 +126,6 @@ class Nav extends React.PureComponent {
128126
this.setDropdown('none');
129127
}
130128

131-
handleFindNext() {
132-
this.props.cmController.findNext();
133-
this.setDropdown('none');
134-
}
135-
136-
handleFindPrevious() {
137-
this.props.cmController.findPrev();
138-
this.setDropdown('none');
139-
}
140-
141129
handleReplace() {
142130
this.props.cmController.showReplace();
143131
this.setDropdown('none');
@@ -447,28 +435,6 @@ class Nav extends React.PureComponent {
447435
<span className="nav__keyboard-shortcut">{metaKeyName}+F</span>
448436
</button>
449437
</li>
450-
<li className="nav__dropdown-item">
451-
<button
452-
onClick={this.handleFindNext}
453-
onFocus={this.handleFocusForEdit}
454-
onBlur={this.handleBlur}
455-
>
456-
{this.props.t('Nav.Edit.FindNext')}
457-
<span className="nav__keyboard-shortcut">{metaKeyName}+G</span>
458-
</button>
459-
</li>
460-
<li className="nav__dropdown-item">
461-
<button
462-
onClick={this.handleFindPrevious}
463-
onFocus={this.handleFocusForEdit}
464-
onBlur={this.handleBlur}
465-
>
466-
{this.props.t('Nav.Edit.FindPrevious')}
467-
<span className="nav__keyboard-shortcut">
468-
{'\u21E7'}+{metaKeyName}+G
469-
</span>
470-
</button>
471-
</li>
472438
<li className="nav__dropdown-item">
473439
<button
474440
onClick={this.handleReplace}

client/components/__test__/Nav.test.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ describe('Nav', () => {
4646
},
4747
t: jest.fn(),
4848
setLanguage: jest.fn(),
49-
language: 'en-US'
49+
language: 'en-US',
50+
isUserOwner: true
5051
};
5152

5253
it('renders correctly', () => {

client/components/__test__/__snapshots__/Nav.test.jsx.snap

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -100,28 +100,6 @@ exports[`Nav renders correctly 1`] = `
100100
</span>
101101
</button>
102102
</li>
103-
<li
104-
class="nav__dropdown-item"
105-
>
106-
<button>
107-
<span
108-
class="nav__keyboard-shortcut"
109-
>
110-
⌃+G
111-
</span>
112-
</button>
113-
</li>
114-
<li
115-
class="nav__dropdown-item"
116-
>
117-
<button>
118-
<span
119-
class="nav__keyboard-shortcut"
120-
>
121-
⇧+⌃+G
122-
</span>
123-
</button>
124-
</li>
125103
<li
126104
class="nav__dropdown-item"
127105
>

client/components/useAsModal.jsx

Lines changed: 1 addition & 1 deletion
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 '../utils/custom-hooks';
3+
import { useModalBehavior } from '../modules/IDE/hooks/custom-hooks';
44

55
const BackgroundOverlay = styled.div`
66
position: fixed;
Lines changed: 13 additions & 0 deletions
Loading
Lines changed: 13 additions & 0 deletions
Loading
Lines changed: 13 additions & 0 deletions
Loading
Lines changed: 22 additions & 0 deletions
Loading

client/images/console-result-dark.svg

Lines changed: 22 additions & 0 deletions
Loading
Lines changed: 22 additions & 0 deletions
Loading

client/modules/IDE/components/Console.jsx

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

@@ -25,33 +25,51 @@ 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';
2836

2937
import UpArrowIcon from '../../../images/up-arrow.svg';
3038
import DownArrowIcon from '../../../images/down-arrow.svg';
3139

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

3646
const getConsoleFeedStyle = (theme, times, fontSize) => {
37-
const style = {};
47+
const style = {
48+
BASE_FONT_FAMILY: 'Inconsolata, monospace'
49+
};
3850
const CONSOLE_FEED_LIGHT_ICONS = {
3951
LOG_WARN_ICON: `url(${warnLightUrl})`,
4052
LOG_ERROR_ICON: `url(${errorLightUrl})`,
4153
LOG_DEBUG_ICON: `url(${debugLightUrl})`,
42-
LOG_INFO_ICON: `url(${infoLightUrl})`
54+
LOG_INFO_ICON: `url(${infoLightUrl})`,
55+
LOG_COMMAND_ICON: `url(${commandLightUrl})`,
56+
LOG_RESULT_ICON: `url(${resultLightUrl})`
4357
};
4458
const CONSOLE_FEED_DARK_ICONS = {
4559
LOG_WARN_ICON: `url(${warnDarkUrl})`,
4660
LOG_ERROR_ICON: `url(${errorDarkUrl})`,
4761
LOG_DEBUG_ICON: `url(${debugDarkUrl})`,
48-
LOG_INFO_ICON: `url(${infoDarkUrl})`
62+
LOG_INFO_ICON: `url(${infoDarkUrl})`,
63+
LOG_COMMAND_ICON: `url(${commandDarkUrl})`,
64+
LOG_RESULT_ICON: `url(${resultDarkUrl})`
4965
};
5066
const CONSOLE_FEED_CONTRAST_ICONS = {
5167
LOG_WARN_ICON: `url(${warnContrastUrl})`,
5268
LOG_ERROR_ICON: `url(${errorContrastUrl})`,
5369
LOG_DEBUG_ICON: `url(${debugContrastUrl})`,
54-
LOG_INFO_ICON: `url(${infoContrastUrl})`
70+
LOG_INFO_ICON: `url(${infoContrastUrl})`,
71+
LOG_COMMAND_ICON: `url(${commandContrastUrl})`,
72+
LOG_RESULT_ICON: `url(${resultContrastUrl})`
5573
};
5674
const CONSOLE_FEED_SIZES = {
5775
TREENODE_LINE_HEIGHT: 1.2,
@@ -94,6 +112,7 @@ const getConsoleFeedStyle = (theme, times, fontSize) => {
94112
const Console = ({ t }) => {
95113
const consoleEvents = useSelector((state) => state.console);
96114
const isExpanded = useSelector((state) => state.ide.consoleIsExpanded);
115+
const isPlaying = useSelector((state) => state.ide.isPlaying);
97116
const { theme, fontSize } = useSelector((state) => state.preferences);
98117

99118
const {
@@ -103,17 +122,20 @@ const Console = ({ t }) => {
103122
dispatchConsoleEvent
104123
} = bindActionCreators({ ...IDEActions, ...ConsoleActions }, useDispatch());
105124

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

113127
useDidUpdate(() => {
114128
cm.current.scrollTop = cm.current.scrollHeight;
115129
});
116130

131+
const handleMessageEvent = useHandleMessageEvent();
132+
useEffect(() => {
133+
const unsubscribe = listen(handleMessageEvent);
134+
return function cleanup() {
135+
unsubscribe();
136+
};
137+
});
138+
117139
const consoleClass = classNames({
118140
'preview-console': true,
119141
'preview-console--collapsed': !isExpanded
@@ -147,29 +169,39 @@ const Console = ({ t }) => {
147169
</button>
148170
</div>
149171
</header>
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-
})}
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+
)}
173205
</div>
174206
</section>
175207
);

0 commit comments

Comments
 (0)