Skip to content

Commit d43fae5

Browse files
committed
🔀 merging from mobile-sketch-view
2 parents 3ba1b26 + 7805acc commit d43fae5

File tree

9 files changed

+81
-57
lines changed

9 files changed

+81
-57
lines changed

client/common/icons.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import Plus from '../images/plus-icon.svg';
1010
import Close from '../images/close.svg';
1111
import Exit from '../images/exit.svg';
1212
import DropdownArrow from '../images/down-filled-triangle.svg';
13+
import Preferences from '../images/preferences.svg';
14+
import Play from '../images/triangle-arrow-right.svg';
1315

1416
// HOC that adds the right web accessibility props
1517
// https://www.scottohara.me/blog/2019/05/22/contextual-images-svgs-and-a11y.html
@@ -70,3 +72,5 @@ export const PlusIcon = withLabel(Plus);
7072
export const CloseIcon = withLabel(Close);
7173
export const ExitIcon = withLabel(Exit);
7274
export const DropdownArrowIcon = withLabel(DropdownArrow);
75+
export const PreferencesIcon = withLabel(Preferences);
76+
export const PlayIcon = withLabel(Play);

client/components/mobile/Footer.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import styled from 'styled-components';
33
import { prop, remSize } from '../../theme';
44

5-
const background = prop('Button.default.background');
5+
const background = prop('Panel.default.background');
66
const textColor = prop('primaryTextColor');
77

88
const Footer = styled.div`

client/components/mobile/Header.jsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import styled from 'styled-components';
33
import { prop, remSize } from '../../theme';
44

5-
const background = prop('Button.default.background');
5+
const background = prop('Panel.default.background');
66
const textColor = prop('primaryTextColor');
77

88
const Header = styled.div`
@@ -11,15 +11,20 @@ const Header = styled.div`
1111
background: ${background};
1212
color: ${textColor};
1313
padding: ${remSize(12)};
14-
padding-left: ${remSize(32)};
15-
padding-right: ${remSize(32)};
14+
padding-left: ${remSize(16)};
15+
padding-right: ${remSize(16)};
1616
z-index: 1;
1717
1818
display: flex;
1919
flex: 1;
2020
flex-direction: row;
2121
justify-content: flex-start;
2222
align-items: center;
23+
24+
// TODO:
25+
svg {
26+
height: 2rem;
27+
}
2328
`;
2429

2530
export default Header;
Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import styled from 'styled-components';
3-
import { prop, remSize } from '../../theme';
4+
import Button from '../../common/Button';
45

5-
const textColor = prop('primaryTextColor');
6-
7-
const IconButton = styled.button`
6+
const ButtonWrapper = styled(Button)`
87
width: 3rem;
98
> svg {
109
width: 100%;
11-
height: auto;
12-
fill: ${textColor};
13-
stroke: ${textColor};
10+
height: 100%;
1411
}
1512
`;
1613

14+
const IconButton = props => (<ButtonWrapper
15+
iconBefore={props.children}
16+
kind={Button.kinds.inline}
17+
{...{ ...props, children: null }}
18+
/>);
19+
20+
IconButton.propTypes = {
21+
children: PropTypes.element.isRequired
22+
};
23+
1724
export default IconButton;

client/modules/IDE/components/PreviewFrame.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import { hijackConsoleErrorsScript, startTag, getAllScriptOffsets }
2323
from '../../../utils/consoleUtils';
2424

2525

26-
// Kept inside class just for linter's
2726
const shouldRenderSketch = (props, prevProps = undefined) => {
2827
const { isPlaying, previewIsRefreshing, fullView } = props;
2928

@@ -337,7 +336,6 @@ class PreviewFrame extends React.Component {
337336
if (this.props.endSketchRefresh) {
338337
this.props.endSketchRefresh();
339338
}
340-
// debugger; // eslint-disable-line
341339
} else {
342340
doc.srcdoc = '';
343341
srcDoc.set(doc, ' ');

client/modules/IDE/pages/MobileIDEView.jsx

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,56 +22,56 @@ import { getHTMLFile } from '../reducers/files';
2222
import Editor from '../components/Editor';
2323
import { ExitIcon } from '../../../common/icons';
2424

25-
import PreferencesIcon from '../../../images/preferences.svg';
26-
import PlayIcon from '../../../images/triangle-arrow-right.svg';
25+
import { PreferencesIcon, PlayIcon } from '../../../common/icons';
2726

2827
import IconButton from '../../../components/mobile/IconButton';
2928
import Header from '../../../components/mobile/Header';
3029
import Screen from '../../../components/mobile/MobileScreen';
3130
import Footer from '../../../components/mobile/Footer';
3231
import IDEWrapper from '../../../components/mobile/IDEWrapper';
3332

34-
const IconLinkWrapper = styled(Link)`
35-
width: 3rem;
36-
margin-right: 1.25rem;
37-
margin-left: none;
33+
const IconContainer = styled.div`
34+
marginLeft: 2rem;
35+
display: flex;
36+
`;
37+
38+
const TitleContainer = styled.div`
39+
3840
`;
3941

4042
const isUserOwner = ({ project, user }) => (project.owner && project.owner.id === user.id);
4143

4244
const MobileIDEView = (props) => {
4345
const {
44-
preferences, ide, editorAccessibility, project, updateLintMessage, clearLintMessage, selectedFile, updateFileContent, files, closeEditorOptions, showEditorOptions, showKeyboardShortcutModal, setUnsavedChanges, startRefreshSketch, stopSketch, expandSidebar, collapseSidebar, clearConsole, console, showRuntimeErrorWarning, hideRuntimeErrorWarning, startSketch
46+
preferences, ide, editorAccessibility, project, updateLintMessage, clearLintMessage,
47+
selectedFile, updateFileContent, files,
48+
closeEditorOptions, showEditorOptions, showKeyboardShortcutModal, setUnsavedChanges,
49+
startRefreshSketch, stopSketch, expandSidebar, collapseSidebar, clearConsole, console,
50+
showRuntimeErrorWarning, hideRuntimeErrorWarning, startSketch
4551
} = props;
4652

47-
const [tmController, setTmController] = useState(null);
48-
49-
const [overlay, setOverlay] = useState(null);
53+
const [tmController, setTmController] = useState(null); // eslint-disable-line
54+
const [overlay, setOverlay] = useState(null); // eslint-disable-line
5055

5156
return (
5257
<Screen fullscreen>
5358
<Header>
54-
<IconLinkWrapper to="/" aria-label="Return to original editor">
55-
<ExitIcon />
56-
</IconLinkWrapper>
57-
<div>
59+
<IconButton to="/mobile" aria-label="Return to original editor">
60+
<ExitIcon viewBox="0 0 16 16" />
61+
</IconButton>
62+
<div style={{ marginLeft: '1rem' }}>
5863
<h2>{project.name}</h2>
5964
<h3>{selectedFile.name}</h3>
6065
</div>
6166

62-
<div style={{ marginLeft: '2rem' }}>
63-
<Link to="/mobile/preferences">
64-
<IconButton onClick={() => setOverlay('preferences')}>
65-
<PreferencesIcon focusable="false" aria-hidden="true" />
66-
</IconButton>
67-
</Link>
68-
69-
<Link to="/mobile/preview" onClick={() => startSketch()}>
70-
<IconButton>
71-
<PlayIcon viewBox="-1 -1 7 7" focusable="false" aria-hidden="true" />
72-
</IconButton>
73-
</Link>
74-
</div>
67+
<IconContainer>
68+
<IconButton to="/mobile/preferences" onClick={() => setOverlay('preferences')}>
69+
<PreferencesIcon focusable="false" aria-hidden="true" />
70+
</IconButton>
71+
<IconButton to="/mobile/preview" onClick={() => { startSketch(); }}>
72+
<PlayIcon viewBox="-1 -1 7 7" focusable="false" aria-hidden="true" />
73+
</IconButton>
74+
</IconContainer>
7575
</Header>
7676

7777
<IDEWrapper>

client/modules/Mobile/MobileSketchView.jsx

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/* eslint-disable */
2-
import React, { useEffect } from 'react';
1+
import React from 'react';
32
import PropTypes from 'prop-types';
43
import { Link } from 'react-router';
54
import { bindActionCreators } from 'redux';
65
import { connect } from 'react-redux';
76
import styled from 'styled-components';
87
import Header from '../../components/mobile/Header';
8+
import IconButton from '../../components/mobile/IconButton';
99
import PreviewFrame from '../IDE/components/PreviewFrame';
1010
import Screen from '../../components/mobile/MobileScreen';
1111
import * as ProjectActions from '../IDE/actions/project';
@@ -26,12 +26,6 @@ const Content = styled.div`
2626
margin-top: ${remSize(68)};
2727
`;
2828

29-
const IconLinkWrapper = styled(Link)`
30-
width: 2rem;
31-
margin-right: 1.25rem;
32-
margin-left: none;
33-
`;
34-
3529
const MobileSketchView = (props) => {
3630
// TODO: useSelector requires react-redux ^7.1.0
3731
// const htmlFile = useSelector(state => getHTMLFile(state.files));
@@ -53,18 +47,13 @@ const MobileSketchView = (props) => {
5347

5448
const { preferences, ide } = props;
5549

56-
useEffect(() => {
57-
// console.log(params);
58-
// getProject(params.project_id, params.username);
59-
});
60-
6150
return (
6251
<Screen fullscreen>
6352
<Header>
64-
<IconLinkWrapper to="/mobile" aria-label="Return to original editor">
53+
<IconButton to="/mobile" aria-label="Return to original editor">
6554
<ExitIcon viewBox="0 0 16 16" />
66-
</IconLinkWrapper>
67-
<div>
55+
</IconButton>
56+
<div style={{ marginLeft: '1rem' }}>
6857
<h2>{projectName}</h2>
6958
<h3><br /></h3>
7059
</div>

client/routes.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const checkAuth = (store) => {
2323
store.dispatch(getUser());
2424
};
2525

26-
// This short-circuit seems unnecessary - using the mobile <Switch /> navigator (future) should prevent this from being called
26+
// TODO: This short-circuit seems unnecessary - using the mobile <Switch /> navigator (future) should prevent this from being called
2727
const onRouteChange = (store) => {
2828
const path = window.location.pathname;
2929
if (path.includes('/mobile')) return;

client/theme.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ export default {
8888
Icon: {
8989
default: grays.middleGray,
9090
hover: grays.darker
91+
},
92+
Panel: {
93+
default: {
94+
foreground: colors.black,
95+
background: grays.light,
96+
border: grays.middleLight,
97+
},
9198
}
9299
},
93100
[Theme.dark]: {
@@ -120,6 +127,13 @@ export default {
120127
Icon: {
121128
default: grays.middleLight,
122129
hover: grays.lightest
130+
},
131+
Panel: {
132+
default: {
133+
foreground: grays.light,
134+
background: grays.dark,
135+
border: grays.middleDark,
136+
},
123137
}
124138
},
125139
[Theme.contrast]: {
@@ -152,6 +166,13 @@ export default {
152166
Icon: {
153167
default: grays.mediumLight,
154168
hover: colors.yellow
169+
},
170+
Panel: {
171+
default: {
172+
foreground: grays.light,
173+
background: grays.dark,
174+
border: grays.middleDark,
175+
},
155176
}
156177
},
157178
};

0 commit comments

Comments
 (0)