Skip to content

Commit d2dcc1f

Browse files
committed
👌 restore Console.jsx classes
2 parents f5e901a + 77a40a9 commit d2dcc1f

File tree

15 files changed

+9145
-13994
lines changed

15 files changed

+9145
-13994
lines changed

client/components/Dropdown.jsx

Lines changed: 63 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,86 @@
1-
import PropTypes from 'prop-types';
21
import React from 'react';
2+
import PropTypes from 'prop-types';
33
import { Link } from 'react-router';
4+
import styled from 'styled-components';
5+
import { remSize, prop, common } from '../theme';
6+
import IconButton from './mobile/IconButton';
7+
import Button from '../common/Button';
48

9+
const DropdownWrapper = styled.ul`
10+
background-color: ${prop('Modal.background')};
11+
border: 1px solid ${prop('Modal.border')};
12+
box-shadow: 0 0 18px 0 ${prop('shadowColor')};
13+
color: ${prop('primaryTextColor')};
514
6-
// <ul className="nav__dropdown">
15+
position: absolute;
16+
top: ${remSize(64)};
17+
right: ${remSize(16)};
718
19+
text-align: left;
20+
width: ${remSize(180)};
21+
display: flex;
22+
flex-direction: column;
23+
height: auto;
24+
z-index: 9999;
25+
border-radius: ${remSize(6)};
826
9-
// <ul className="nav__dropdown">
27+
& li:first-child { border-radius: ${remSize(5)} ${remSize(5)} 0 0; }
28+
& li:last-child { border-radius: 0 0 ${remSize(5)} ${remSize(5)}; }
1029
11-
// <li className="nav__dropdown-item">
12-
// <button
13-
// onFocus={this.handleFocusForLang}
14-
// onBlur={this.handleBlur}
15-
// value="it"
16-
// onClick={e => this.handleLangSelection(e)}
17-
// >
18-
// Italian (Test Fallback)
19-
// </button>
20-
// </li>
21-
// <li className="nav__dropdown-item">
22-
// <button
23-
// onFocus={this.handleFocusForLang}
24-
// onBlur={this.handleBlur}
25-
// value="en-US"
26-
// onClick={e => this.handleLangSelection(e)}
27-
// >English
28-
// </button>
29-
// </li>
30-
// <li className="nav__dropdown-item">
31-
// <button
32-
// onFocus={this.handleFocusForLang}
33-
// onBlur={this.handleBlur}
34-
// value="es-419"
35-
// onClick={e => this.handleLangSelection(e)}
36-
// >
37-
// Español
38-
// </button>
39-
// </li>
40-
// </ul>
30+
& li:hover {
31+
32+
background-color: ${prop('Button.hover.background')};
33+
color: ${prop('Button.hover.foreground')};
34+
35+
& button, & a {
36+
color: ${prop('Button.hover.foreground')};
37+
}
38+
}
39+
40+
li {
41+
height: ${remSize(36)};
42+
cursor: pointer;
43+
display: flex;
44+
align-items: center;
45+
46+
& button,
47+
& a {
48+
color: ${prop('primaryTextColor')};
49+
width: 100%;
50+
text-align: left;
51+
padding: ${remSize(8)} ${remSize(16)};
52+
}
53+
}
54+
`;
4155

42-
// 'nav__item--open'
56+
// TODO: Add Icon to the left of the items in the menu
57+
// const MaybeIcon = (Element, label) => Element && <Element aria-label={label} />;
4358

4459
const Dropdown = ({ items }) => (
45-
<ul className="nav__dropdown">
46-
{items && items.map(item => (
47-
<li className="nav__dropdown-item">
60+
<DropdownWrapper>
61+
{/* className="nav__items-left" */}
62+
{items && items.map(({ title, icon, href }) => (
63+
<li key={`nav-${title && title.toLowerCase()}`}>
64+
<Link to={href}>
65+
{/* {MaybeIcon(icon, `Navigate to ${title}`)} */}
66+
{title}
67+
</Link>
4868
</li>
4969
))
5070
}
51-
</ul>
71+
</DropdownWrapper>
5272
);
5373

5474
Dropdown.propTypes = {
5575
items: PropTypes.arrayOf(PropTypes.shape({
56-
action: PropTypes.func
57-
}))
76+
action: PropTypes.func,
77+
icon: PropTypes.func,
78+
href: PropTypes.string
79+
})),
5880
};
5981

6082
Dropdown.defaultProps = {
61-
items: []
83+
items: [],
6284
};
6385

6486
export default Dropdown;

client/components/OverlayManager.jsx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import React, { useRef, useEffect } from 'react';
2+
import PropTypes from 'prop-types';
3+
import { createPortal } from 'react-dom';
4+
5+
import Dropdown from './Dropdown';
6+
7+
import { PreferencesIcon } from '../common/icons';
8+
9+
const OverlayManager = ({ overlay, hideOverlay }) => {
10+
const ref = useRef({});
11+
12+
const handleClickOutside = ({ target }) => {
13+
if (ref && ref.current && !ref.current.contains(target)) {
14+
hideOverlay();
15+
}
16+
};
17+
18+
useEffect(() => {
19+
document.addEventListener('mousedown', handleClickOutside);
20+
21+
return () => document.removeEventListener('mousedown', handleClickOutside);
22+
}, [ref]);
23+
24+
const headerNavOptions = [
25+
{
26+
icon: PreferencesIcon,
27+
title: 'Preferences',
28+
href: '/mobile/preferences',
29+
},
30+
{ icon: PreferencesIcon, title: 'Examples', href: '/mobile/examples' },
31+
{
32+
icon: PreferencesIcon,
33+
title: 'Original Editor',
34+
href: '/mobile/preferences',
35+
},
36+
];
37+
38+
const jsx = (
39+
<React.Fragment>
40+
<div ref={(r) => { ref.current = r; }} >
41+
{overlay === 'dropdown' && <Dropdown items={headerNavOptions} />}
42+
</div>
43+
</React.Fragment>
44+
);
45+
46+
return jsx && createPortal(jsx, document.body);
47+
};
48+
49+
50+
OverlayManager.propTypes = {
51+
overlay: PropTypes.string,
52+
hideOverlay: PropTypes.func.isRequired,
53+
};
54+
55+
OverlayManager.defaultProps = { overlay: null };
56+
57+
export default OverlayManager;

client/modules/IDE/components/Console.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ const Console = () => {
8888

8989
const cm = useRef({});
9090

91-
useDidUpdate(() => { cm.current.scrollTop = cm.current.scrollHeight; });
92-
9391
const consoleClass = classNames({
9492
'preview-console': true,
9593
'preview-console--collapsed': !isExpanded

client/modules/IDE/components/NewFileForm.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class NewFileForm extends React.Component {
4848

4949
NewFileForm.propTypes = {
5050
fields: PropTypes.shape({
51-
name: PropTypes.object.isRequired
51+
name: PropTypes.object.isRequired // eslint-disable-line
5252
}).isRequired,
5353
handleSubmit: PropTypes.func.isRequired,
5454
createFile: PropTypes.func.isRequired,

client/modules/IDE/components/NewFolderForm.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class NewFolderForm extends React.Component {
4949

5050
NewFolderForm.propTypes = {
5151
fields: PropTypes.shape({
52-
name: PropTypes.object.isRequired
52+
name: PropTypes.object.isRequired // eslint-disable-line
5353
}).isRequired,
5454
handleSubmit: PropTypes.func.isRequired,
5555
createFolder: PropTypes.func.isRequired,

client/modules/IDE/pages/IDEView.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ IDEView.propTypes = {
478478
ide: PropTypes.shape({
479479
isPlaying: PropTypes.bool.isRequired,
480480
isAccessibleOutputPlaying: PropTypes.bool.isRequired,
481-
consoleEvent: PropTypes.array,
481+
consoleEvent: PropTypes.array, // eslint-disable-line
482482
modalIsVisible: PropTypes.bool.isRequired,
483483
sidebarIsExpanded: PropTypes.bool.isRequired,
484484
consoleIsExpanded: PropTypes.bool.isRequired,
@@ -513,7 +513,7 @@ IDEView.propTypes = {
513513
updatedAt: PropTypes.string
514514
}).isRequired,
515515
editorAccessibility: PropTypes.shape({
516-
lintMessages: PropTypes.array.isRequired,
516+
lintMessages: PropTypes.array.isRequired, // eslint-disable-line
517517
}).isRequired,
518518
updateLintMessage: PropTypes.func.isRequired,
519519
clearLintMessage: PropTypes.func.isRequired,

client/modules/IDE/pages/MobileIDEView.jsx

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import styled from 'styled-components';
77

88
// Imports to be Refactored
99
import { bindActionCreators } from 'redux';
10+
1011
import * as FileActions from '../actions/files';
1112
import * as IDEActions from '../actions/ide';
1213
import * as ProjectActions from '../actions/project';
@@ -19,7 +20,7 @@ import { getHTMLFile } from '../reducers/files';
1920

2021
// Local Imports
2122
import Editor from '../components/Editor';
22-
import { PreferencesIcon, PlayIcon, ExitIcon, MoreIcon } from '../../../common/icons';
23+
import { PlayIcon, ExitIcon, MoreIcon } from '../../../common/icons';
2324

2425
import IconButton from '../../../components/mobile/IconButton';
2526
import Header from '../../../components/mobile/Header';
@@ -28,7 +29,7 @@ import Footer from '../../../components/mobile/Footer';
2829
import IDEWrapper from '../../../components/mobile/IDEWrapper';
2930
import Console from '../components/Console';
3031
import { remSize } from '../../../theme';
31-
import Dropdown from '../../../components/Dropdown';
32+
import OverlayManager from '../../../components/OverlayManager';
3233
import ActionStrip from '../../../components/mobile/ActionStrip';
3334

3435
const isUserOwner = ({ project, user }) => (project.owner && project.owner.id === user.id);
@@ -39,15 +40,6 @@ const Expander = styled.div`
3940
`;
4041

4142

42-
// TODO: Move to new file?
43-
// const overlays = {};
44-
// const OverlayManager = name => overlays[name] || null;
45-
46-
const headerNavOptions = [
47-
{ icon: PreferencesIcon, title: 'Preferences', route: '/mobile/preferences' }
48-
];
49-
50-
5143
const MobileIDEView = (props) => {
5244
const {
5345
preferences, ide, editorAccessibility, project, updateLintMessage, clearLintMessage,
@@ -58,9 +50,11 @@ const MobileIDEView = (props) => {
5850
} = props;
5951

6052
const [tmController, setTmController] = useState(null); // eslint-disable-line
61-
const [overlay, setOverlay] = useState(null); // eslint-disable-line
53+
const [overlayName, setOverlay] = useState(null); // eslint-disable-line
6254

63-
// const overlayActive = name => (overlay === name);
55+
// TODO: Move this to OverlayController (?)
56+
const hideOverlay = () => setOverlay(null);
57+
// const overlayRef = useRef({});
6458

6559
return (
6660
<Screen fullscreen>
@@ -72,7 +66,6 @@ const MobileIDEView = (props) => {
7266
}
7367
>
7468
<IconButton
75-
// to="/mobile/preferences"
7669
onClick={() => setOverlay('dropdown')}
7770
icon={MoreIcon}
7871
aria-label="Options"
@@ -116,18 +109,21 @@ const MobileIDEView = (props) => {
116109
provideController={setTmController}
117110
/>
118111
</IDEWrapper>
112+
119113
<Footer>
120114
{ide.consoleIsExpanded && <Expander expanded><Console /></Expander>}
121115
<ActionStrip />
122116
</Footer>
123117

124-
{/* Overlays */}
125-
<Dropdown hidden={overlay !== 'dropdown'} items={headerNavOptions} />
118+
<OverlayManager
119+
// ref={overlayRef}
120+
overlay={overlayName}
121+
hideOverlay={hideOverlay}
122+
/>
126123
</Screen>
127124
);
128125
};
129126

130-
131127
MobileIDEView.propTypes = {
132128

133129
preferences: PropTypes.shape({
@@ -146,7 +142,7 @@ MobileIDEView.propTypes = {
146142
ide: PropTypes.shape({
147143
isPlaying: PropTypes.bool.isRequired,
148144
isAccessibleOutputPlaying: PropTypes.bool.isRequired,
149-
consoleEvent: PropTypes.array,
145+
consoleEvent: PropTypes.arrayOf(PropTypes.shape({})),
150146
modalIsVisible: PropTypes.bool.isRequired,
151147
sidebarIsExpanded: PropTypes.bool.isRequired,
152148
consoleIsExpanded: PropTypes.bool.isRequired,
@@ -172,7 +168,7 @@ MobileIDEView.propTypes = {
172168
}).isRequired,
173169

174170
editorAccessibility: PropTypes.shape({
175-
lintMessages: PropTypes.array.isRequired,
171+
lintMessages: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
176172
}).isRequired,
177173

178174
project: PropTypes.shape({

client/modules/User/components/APIKeyForm.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import CopyableInput from '../../IDE/components/CopyableInput';
88
import APIKeyList from './APIKeyList';
99

1010
export const APIKeyPropType = PropTypes.shape({
11-
id: PropTypes.object.isRequired,
12-
token: PropTypes.object,
11+
id: PropTypes.object.isRequired, // eslint-disable-line
12+
token: PropTypes.object, // eslint-disable-line
1313
label: PropTypes.string.isRequired,
1414
createdAt: PropTypes.string.isRequired,
1515
lastUsedAt: PropTypes.string,

client/modules/User/components/AccountForm.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ function AccountForm(props) {
103103

104104
AccountForm.propTypes = {
105105
fields: PropTypes.shape({
106-
username: PropTypes.object.isRequired,
107-
email: PropTypes.object.isRequired,
108-
currentPassword: PropTypes.object.isRequired,
109-
newPassword: PropTypes.object.isRequired,
106+
username: PropTypes.object.isRequired, // eslint-disable-line
107+
email: PropTypes.object.isRequired, // eslint-disable-line
108+
currentPassword: PropTypes.object.isRequired, // eslint-disable-line
109+
newPassword: PropTypes.object.isRequired, // eslint-disable-line
110110
}).isRequired,
111111
user: PropTypes.shape({
112112
verified: PropTypes.number.isRequired,

client/modules/User/components/LoginForm.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ function LoginForm(props) {
4444

4545
LoginForm.propTypes = {
4646
fields: PropTypes.shape({
47-
email: PropTypes.object.isRequired,
48-
password: PropTypes.object.isRequired
47+
email: PropTypes.object.isRequired, // eslint-disable-line
48+
password: PropTypes.object.isRequired // eslint-disable-line
4949
}).isRequired,
5050
handleSubmit: PropTypes.func.isRequired,
5151
validateAndLoginUser: PropTypes.func.isRequired,

0 commit comments

Comments
 (0)