From 3339d27ee78f2cdda48a4eb4c75b989840dd6e7b Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Wed, 3 Oct 2018 14:18:43 -0400 Subject: [PATCH] Add code reload component --- embark-ui/src/components/FiddleLayout.js | 22 +++++---- .../containers/ApplicationPreviewContainer.js | 45 +++++++++++++++++++ 2 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 embark-ui/src/containers/ApplicationPreviewContainer.js diff --git a/embark-ui/src/components/FiddleLayout.js b/embark-ui/src/components/FiddleLayout.js index aeb0d4b6..fc95306b 100644 --- a/embark-ui/src/components/FiddleLayout.js +++ b/embark-ui/src/components/FiddleLayout.js @@ -4,21 +4,25 @@ import { Grid } from "tabler-react"; +import ApplicationPreviewContainer from '../containers/ApplicationPreviewContainer'; import TextEditorContainer from '../containers/TextEditorContainer'; import FileExplorerContainer from '../containers/FileExplorerContainer'; class FiddleLayout extends React.Component { render() { return ( - - - Fiddle - - - - - - + + + + Fiddle + + + + + + + + ); } } diff --git a/embark-ui/src/containers/ApplicationPreviewContainer.js b/embark-ui/src/containers/ApplicationPreviewContainer.js new file mode 100644 index 00000000..443e4181 --- /dev/null +++ b/embark-ui/src/containers/ApplicationPreviewContainer.js @@ -0,0 +1,45 @@ +import PropTypes from 'prop-types'; +import React from 'react'; + +class ApplicationPreviewContainer extends React.Component { + constructor(props) { + super(props); + this.state = { + previewUrl: props.previewUrl || 'http://localhost:8000' + }; + } + + render() { + return ( +
+
+ this.locationInput = input} value={this.props.previewUrl} /> +
+ +
+
+ +
+ ); + } + + handlePreviewChange(ev) { + try { + let url = ev.target.contentWindow.location.toString(); + this.setState({previewUrl: url}); + } catch(e) { + // Nothing here. + } + } + + handlePreviewGo() { + this.previewIframe.src = this.locationInput.value; + } +} + +ApplicationPreviewContainer.propTypes = { + previewUrl: PropTypes.string +}; + +export default ApplicationPreviewContainer; +