@@ -4,6 +4,8 @@ import { reaction } from 'mobx';
44import { inject , observer } from 'mobx-react' ;
55
66import BasePreview from 'app/components/Preview' ;
7+ import RunOnClick from 'common/components/RunOnClick' ;
8+
79import FlyingContainer from './FlyingContainer' ;
810import Tests from './DevTools/Tests' ;
911import Console from './DevTools/Console' ;
@@ -13,6 +15,7 @@ type Props = {
1315 height : ?number ,
1416 store : any ,
1517 signals : any ,
18+ runOnClick ?: boolean ,
1619} ;
1720
1821type State = {
@@ -22,6 +25,7 @@ type State = {
2225class Preview extends React . Component < Props , State > {
2326 state = {
2427 aligned : window . innerHeight > window . innerWidth ? 'bottom' : 'right' ,
28+ running : ! this . props . runOnClick ,
2529 } ;
2630
2731 onPreviewInitialized = preview => {
@@ -253,32 +257,42 @@ class Preview extends React.Component<Props, State> {
253257 { content === 'console' && (
254258 < Console alignRight = { alignRight } alignBottom = { alignBottom } />
255259 ) }
256- < BasePreview
257- onInitialized = { this . onPreviewInitialized }
258- sandbox = { store . editor . currentSandbox }
259- extraModules = { { '/package.json' : packageJSON } }
260- currentModule = { store . editor . currentModule }
261- settings = { store . preferences . settings }
262- initialPath = { store . editor . initialPath }
263- isInProjectView = { store . editor . isInProjectView }
264- onClearErrors = { ( ) => signals . editor . errorsCleared ( ) }
265- onAction = { action =>
266- signals . editor . previewActionReceived ( { action } )
267- }
268- hide = { hide }
269- noPreview = { completelyHidden }
270- onOpenNewWindow = { ( ) =>
271- this . props . signals . preferences . viewModeChanged ( {
272- showEditor : true ,
273- showPreview : false ,
274- } )
275- }
276- onToggleProjectView = { ( ) => signals . editor . projectViewToggled ( ) }
277- showDevtools = { store . preferences . showDevtools }
278- isResizing = { store . editor . isResizing }
279- alignRight = { alignRight }
280- alignBottom = { alignBottom }
281- />
260+ { this . state . running ? (
261+ < BasePreview
262+ onInitialized = { this . onPreviewInitialized }
263+ sandbox = { store . editor . currentSandbox }
264+ extraModules = { { '/package.json' : packageJSON } }
265+ currentModule = { store . editor . currentModule }
266+ settings = { store . preferences . settings }
267+ initialPath = { store . editor . initialPath }
268+ isInProjectView = { store . editor . isInProjectView }
269+ onClearErrors = { ( ) => signals . editor . errorsCleared ( ) }
270+ onAction = { action =>
271+ signals . editor . previewActionReceived ( { action } )
272+ }
273+ hide = { hide }
274+ noPreview = { completelyHidden }
275+ onOpenNewWindow = { ( ) =>
276+ this . props . signals . preferences . viewModeChanged ( {
277+ showEditor : true ,
278+ showPreview : false ,
279+ } )
280+ }
281+ onToggleProjectView = { ( ) =>
282+ signals . editor . projectViewToggled ( )
283+ }
284+ showDevtools = { store . preferences . showDevtools }
285+ isResizing = { store . editor . isResizing }
286+ alignRight = { alignRight }
287+ alignBottom = { alignBottom }
288+ />
289+ ) : (
290+ < RunOnClick
291+ onClick = { ( ) => {
292+ this . setState ( { running : true } ) ;
293+ } }
294+ />
295+ ) }
282296 </ React . Fragment >
283297 ) ;
284298 } }
0 commit comments