🚧 mount <PreviewFrame /> on /mobile/preview

This commit is contained in:
ghalestrilo 2020-06-18 16:29:46 -03:00
parent e5bbb53b37
commit 0633c3b395

View file

@ -1,8 +1,12 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router'; import { Link } from 'react-router';
import { connect } from 'react-redux';
import styled from 'styled-components'; import styled from 'styled-components';
import Header from '../../components/mobile/Header'; import Header from '../../components/mobile/Header';
import PreviewFrame from '../IDE/components/PreviewFrame';
import Screen from '../../components/mobile/MobileScreen'; import Screen from '../../components/mobile/MobileScreen';
import { getHTMLFile, getJSFiles, getCSSFiles } from '../IDE/reducers/files';
import { ExitIcon } from '../../common/Icons'; import { ExitIcon } from '../../common/Icons';
import { remSize } from '../../theme'; import { remSize } from '../../theme';
@ -19,9 +23,21 @@ const IconLinkWrapper = styled(Link)`
margin-left: none; margin-left: none;
`; `;
const noop = () => {};
const MobileSketchView = (props) => { const MobileSketchView = (props) => {
const [overlay, setOverlay] = useState(null); const [overlay, setOverlay] = useState(null);
// TODO: useSelector requires react-redux ^7.1.0
// const htmlFile = useSelector(state => getHTMLFile(state.files));
// const jsFiles = useSelector(state => getJSFiles(state.files));
// const cssFiles = useSelector(state => getCSSFiles(state.files));
// const files = useSelector(state => state.files);
const {
htmlFile, jsFiles, cssFiles, files
} = props;
return ( return (
<Screen> <Screen>
<Header> <Header>
@ -44,33 +60,63 @@ const MobileSketchView = (props) => {
</Header> </Header>
<Content> <Content>
<h1>Hello</h1> <h1>Hello</h1>
<PreviewFrame
htmlFile={htmlFile}
jsFiles={jsFiles}
cssFiles={cssFiles}
files={files}
head={
<link type="text/css" rel="stylesheet" href="/preview-styles.css" />
}
fullView
isPlaying
isAccessibleOutputPlaying={false}
textOutput={false}
gridOutput={false}
soundOutput={false}
dispatchConsoleEvent={noop}
endSketchRefresh={noop}
previewIsRefreshing={false}
setBlobUrl={noop}
stopSketch={noop}
expandConsole={noop}
clearConsole={noop}
/>
</Content> </Content>
</Screen>); </Screen>);
}; };
MobileSketchView.propTypes = {
htmlFile: PropTypes.shape({
id: PropTypes.string.isRequired,
content: PropTypes.string.isRequired,
name: PropTypes.string.isRequired
}).isRequired,
jsFiles: PropTypes.arrayOf(PropTypes.shape({
id: PropTypes.string.isRequired,
content: PropTypes.string.isRequired,
name: PropTypes.string.isRequired
})).isRequired,
cssFiles: PropTypes.arrayOf(PropTypes.shape({
id: PropTypes.string.isRequired,
content: PropTypes.string.isRequired,
name: PropTypes.string.isRequired
})).isRequired,
files: PropTypes.arrayOf(PropTypes.shape({
id: PropTypes.string.isRequired,
content: PropTypes.string.isRequired,
name: PropTypes.string.isRequired
})).isRequired,
};
export default MobileSketchView; function mapStateToProps(state) {
return {
htmlFile: getHTMLFile(state.files),
jsFiles: getJSFiles(state.files),
cssFiles: getCSSFiles(state.files),
files: state.files
};
}
// <PreviewFrame export default connect(mapStateToProps)(MobileSketchView);
// htmlFile={this.props.htmlFile}
// jsFiles={this.props.jsFiles}
// cssFiles={this.props.cssFiles}
// files={this.props.files}
// head={
// <link type="text/css" rel="stylesheet" href="/preview-styles.css" />
// }
// fullView
// isPlaying
// isAccessibleOutputPlaying={false}
// textOutput={false}
// gridOutput={false}
// soundOutput={false}
// dispatchConsoleEvent={this.ident}
// endSketchRefresh={this.ident}
// previewIsRefreshing={false}
// setBlobUrl={this.ident}
// stopSketch={this.ident}
// expandConsole={this.ident}
// clearConsole={this.ident}
// />