1
1
import React , { useState } from 'react' ;
2
+ import PropTypes from 'prop-types' ;
2
3
import { Link } from 'react-router' ;
4
+ import { connect } from 'react-redux' ;
3
5
import styled from 'styled-components' ;
4
6
import Header from '../../components/mobile/Header' ;
7
+ import PreviewFrame from '../IDE/components/PreviewFrame' ;
5
8
import Screen from '../../components/mobile/MobileScreen' ;
9
+ import { getHTMLFile , getJSFiles , getCSSFiles } from '../IDE/reducers/files' ;
6
10
7
11
import { ExitIcon } from '../../common/Icons' ;
8
12
import { remSize } from '../../theme' ;
@@ -19,9 +23,21 @@ const IconLinkWrapper = styled(Link)`
19
23
margin-left: none;
20
24
` ;
21
25
26
+ const noop = ( ) => { } ;
22
27
23
28
const MobileSketchView = ( props ) => {
24
29
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
+
25
41
return (
26
42
< Screen >
27
43
< Header >
@@ -44,33 +60,63 @@ const MobileSketchView = (props) => {
44
60
</ Header >
45
61
< Content >
46
62
< 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
+ />
47
85
</ Content >
48
86
</ Screen > ) ;
49
87
} ;
50
88
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
+ } ;
51
111
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
+ }
53
120
54
121
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