From 058476cb29f98cc58d467e0775baf5b6c769600a Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Fri, 3 Nov 2017 12:52:15 -0400 Subject: [PATCH 1/2] Add compatibility testing example page --- src/examples/compatibility-testing.jsx | 74 ++++++++++++++++++++++++++ webpack.config.js | 7 +++ 2 files changed, 81 insertions(+) create mode 100644 src/examples/compatibility-testing.jsx diff --git a/src/examples/compatibility-testing.jsx b/src/examples/compatibility-testing.jsx new file mode 100644 index 000000000..11c9bc4bf --- /dev/null +++ b/src/examples/compatibility-testing.jsx @@ -0,0 +1,74 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import {connect} from 'react-redux'; + +import AppStateHOC from '../lib/app-state-hoc.jsx'; +import Controls from '../containers/controls.jsx'; +import Stage from '../containers/stage.jsx'; +import Box from '../components/box/box.jsx'; +import GUI from '../containers/gui.jsx'; +import ProjectLoaderHOC from '../lib/project-loader-hoc.jsx'; + +const mapStateToProps = state => ({vm: state.vm}); + +const VMStage = connect(mapStateToProps)(Stage); +const VMControls = connect(mapStateToProps)(Controls); + +class Player extends React.Component { + constructor (props) { + super(props); + this.updateProject = this.updateProject.bind(this); + this.state = { + projectId: window.location.hash.substring(1) || '10015059' + }; + } + componentDidMount () { + window.addEventListener('hashchange', this.updateProject); + } + componentWillUnmount () { + window.addEventListener('hashchange', this.updateProject); + } + updateProject () { + this.setState({projectId: window.location.hash.substring(1)}); + } + render () { + const width = 480; + const height = 360; + return ( +
+ + + + + + +