Skip to content

Commit a11bc44

Browse files
committed
✨ render sketch
1 parent d00506a commit a11bc44

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

client/modules/IDE/components/PreviewFrame.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,17 @@ class PreviewFrame extends React.Component {
2929
}
3030

3131
componentDidMount() {
32+
console.log(`componentDidMount: ${this.props.isPlaying}`);
3233
window.addEventListener('message', this.handleConsoleEvent);
34+
35+
// TODO: maybe encapsulate this into a function (together with code from componentDidUpdate)
36+
if (this.props.isPlaying && this.props.previewIsRefreshing) {
37+
this.renderSketch();
38+
}
3339
}
3440

3541
componentDidUpdate(prevProps) {
42+
console.log(`componentDidUpdate: ${this.props.isPlaying}`);
3643
// if sketch starts or stops playing, want to rerender
3744
if (this.props.isPlaying !== prevProps.isPlaying) {
3845
this.renderSketch();

client/modules/IDE/pages/IDEViewMobile.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable */
12
import React from 'react';
23
import PropTypes from 'prop-types';
34
import styled from 'styled-components';
@@ -66,7 +67,7 @@ const IDEViewMobile = (props) => {
6667
<Link
6768
to="/mobile/preview"
6869
onClick={() => {
69-
alert('starting sketch');
70+
// alert('starting sketch');
7071
startSketch();
7172
}}
7273
>

client/modules/Mobile/MobileSketchView.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import * as PreferencesActions from '../IDE/actions/preferences';
1313
import * as ConsoleActions from '../IDE/actions/console';
1414
import * as FilesActions from '../IDE/actions/files';
1515

16+
import FullView from '../IDE/pages/FullView';
17+
1618
import { getHTMLFile } from '../IDE/reducers/files';
1719

1820

@@ -71,15 +73,17 @@ const MobileSketchView = (props) => {
7173
<Content>
7274
<h1>Hello</h1>
7375
<section className="preview-frame-holder">
74-
7576
<PreviewFrame
7677
htmlFile={htmlFile}
7778
files={files}
78-
fullView
79+
head={
80+
<link type="text/css" rel="stylesheet" href="/preview-styles.css" />
81+
}
7982

8083
content={selectedFile.content}
8184

82-
isPlaying={ide.isPlaying}
85+
fullView
86+
isPlaying
8387
isAccessibleOutputPlaying={ide.isAccessibleOutputPlaying}
8488
previewIsRefreshing={ide.previewIsRefreshing}
8589

0 commit comments

Comments
 (0)