diff --git a/src/examples/compatibility-testing.jsx b/src/examples/compatibility-testing.jsx new file mode 100644 index 000000000..3fa8e71d9 --- /dev/null +++ b/src/examples/compatibility-testing.jsx @@ -0,0 +1,80 @@ +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); + +const DEFAULT_PROJECT_ID = '10015059'; + +class Player extends React.Component { + constructor (props) { + super(props); + this.updateProject = this.updateProject.bind(this); + + this.state = { + projectId: window.location.hash.substring(1) || DEFAULT_PROJECT_ID + }; + } + componentDidMount () { + window.addEventListener('hashchange', this.updateProject); + if (!window.location.hash.substring(1)) { + window.location.hash = DEFAULT_PROJECT_ID; + } + } + componentWillUnmount () { + window.addEventListener('hashchange', this.updateProject); + } + updateProject () { + this.setState({projectId: window.location.hash.substring(1)}); + } + render () { + const width = 480; + const height = 360; + return ( +