Skip to content

Commit 0633c3b

Browse files
committed
🚧 mount <PreviewFrame /> on /mobile/preview
1 parent e5bbb53 commit 0633c3b

File tree

1 file changed

+69
-23
lines changed

1 file changed

+69
-23
lines changed

client/modules/Mobile/MobileSketchView.jsx

Lines changed: 69 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import React, { useState } from 'react';
2+
import PropTypes from 'prop-types';
23
import { Link } from 'react-router';
4+
import { connect } from 'react-redux';
35
import styled from 'styled-components';
46
import Header from '../../components/mobile/Header';
7+
import PreviewFrame from '../IDE/components/PreviewFrame';
58
import Screen from '../../components/mobile/MobileScreen';
9+
import { getHTMLFile, getJSFiles, getCSSFiles } from '../IDE/reducers/files';
610

711
import { ExitIcon } from '../../common/Icons';
812
import { remSize } from '../../theme';
@@ -19,9 +23,21 @@ const IconLinkWrapper = styled(Link)`
1923
margin-left: none;
2024
`;
2125

26+
const noop = () => {};
2227

2328
const MobileSketchView = (props) => {
2429
const [overlay, setOverlay] = useState(null);
30+
31+
// TODO: useSelector requires react-redux ^7.1.0
32+
// const htmlFile = useSelector(state => getHTMLFile(state.files));
33+
// const jsFiles = useSelector(state => getJSFiles(state.files));
34+
// const cssFiles = useSelector(state => getCSSFiles(state.files));
35+
// const files = useSelector(state => state.files);
36+
37+
const {
38+
htmlFile, jsFiles, cssFiles, files
39+
} = props;
40+
2541
return (
2642
<Screen>
2743
<Header>
@@ -44,33 +60,63 @@ const MobileSketchView = (props) => {
4460
</Header>
4561
<Content>
4662
<h1>Hello</h1>
63+
<PreviewFrame
64+
htmlFile={htmlFile}
65+
jsFiles={jsFiles}
66+
cssFiles={cssFiles}
67+
files={files}
68+
head={
69+
<link type="text/css" rel="stylesheet" href="/preview-styles.css" />
70+
}
71+
fullView
72+
isPlaying
73+
isAccessibleOutputPlaying={false}
74+
textOutput={false}
75+
gridOutput={false}
76+
soundOutput={false}
77+
dispatchConsoleEvent={noop}
78+
endSketchRefresh={noop}
79+
previewIsRefreshing={false}
80+
setBlobUrl={noop}
81+
stopSketch={noop}
82+
expandConsole={noop}
83+
clearConsole={noop}
84+
/>
4785
</Content>
4886
</Screen>);
4987
};
5088

89+
MobileSketchView.propTypes = {
90+
htmlFile: PropTypes.shape({
91+
id: PropTypes.string.isRequired,
92+
content: PropTypes.string.isRequired,
93+
name: PropTypes.string.isRequired
94+
}).isRequired,
95+
jsFiles: PropTypes.arrayOf(PropTypes.shape({
96+
id: PropTypes.string.isRequired,
97+
content: PropTypes.string.isRequired,
98+
name: PropTypes.string.isRequired
99+
})).isRequired,
100+
cssFiles: PropTypes.arrayOf(PropTypes.shape({
101+
id: PropTypes.string.isRequired,
102+
content: PropTypes.string.isRequired,
103+
name: PropTypes.string.isRequired
104+
})).isRequired,
105+
files: PropTypes.arrayOf(PropTypes.shape({
106+
id: PropTypes.string.isRequired,
107+
content: PropTypes.string.isRequired,
108+
name: PropTypes.string.isRequired
109+
})).isRequired,
110+
};
51111

52-
export default MobileSketchView;
112+
function mapStateToProps(state) {
113+
return {
114+
htmlFile: getHTMLFile(state.files),
115+
jsFiles: getJSFiles(state.files),
116+
cssFiles: getCSSFiles(state.files),
117+
files: state.files
118+
};
119+
}
53120

54121

55-
// <PreviewFrame
56-
// htmlFile={this.props.htmlFile}
57-
// jsFiles={this.props.jsFiles}
58-
// cssFiles={this.props.cssFiles}
59-
// files={this.props.files}
60-
// head={
61-
// <link type="text/css" rel="stylesheet" href="/preview-styles.css" />
62-
// }
63-
// fullView
64-
// isPlaying
65-
// isAccessibleOutputPlaying={false}
66-
// textOutput={false}
67-
// gridOutput={false}
68-
// soundOutput={false}
69-
// dispatchConsoleEvent={this.ident}
70-
// endSketchRefresh={this.ident}
71-
// previewIsRefreshing={false}
72-
// setBlobUrl={this.ident}
73-
// stopSketch={this.ident}
74-
// expandConsole={this.ident}
75-
// clearConsole={this.ident}
76-
// />
122+
export default connect(mapStateToProps)(MobileSketchView);

0 commit comments

Comments
 (0)