simulation panel now opens, it still misses the content
This commit is contained in:
parent
367159e3cf
commit
bf9919560a
2 changed files with 81 additions and 15 deletions
|
@ -11,6 +11,7 @@ import { Segment, Image } from "semantic-ui-react";
|
||||||
import { RemoteService } from "../remote";
|
import { RemoteService } from "../remote";
|
||||||
import { withRouter } from "react-router-dom";
|
import { withRouter } from "react-router-dom";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
|
import SimulationPanel from "./SimulationPanel";
|
||||||
|
|
||||||
const IconHomeImage = () => (
|
const IconHomeImage = () => (
|
||||||
<Image
|
<Image
|
||||||
|
@ -27,7 +28,7 @@ const TitleImage = () => <Image src="sm_logo.png" size="medium" centered />;
|
||||||
export class MyHeader extends React.Component {
|
export class MyHeader extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
this.state = { simulationPanel: undefined };
|
||||||
this.getInfo();
|
this.getInfo();
|
||||||
this.logout = this.logout.bind(this);
|
this.logout = this.logout.bind(this);
|
||||||
}
|
}
|
||||||
|
@ -52,6 +53,19 @@ export class MyHeader extends React.Component {
|
||||||
.catch((err) => console.error("Camera enabled", err));
|
.catch((err) => console.error("Camera enabled", err));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openSimulationPanel = () => {
|
||||||
|
this.setState((state) => {
|
||||||
|
return { simulationPanel: true };
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
closeSimulationPanel = () => {
|
||||||
|
this.setState((state) => {
|
||||||
|
return { simulationPanel: undefined };
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
@ -66,7 +80,13 @@ export class MyHeader extends React.Component {
|
||||||
</Grid.Row>
|
</Grid.Row>
|
||||||
<Divider />
|
<Divider />
|
||||||
<Grid.Row>
|
<Grid.Row>
|
||||||
|
<div onClick={this.openSimulationPanel}>
|
||||||
<Button > Similuation Panel </Button>
|
<Button > Similuation Panel </Button>
|
||||||
|
</div>
|
||||||
|
<SimulationPanel
|
||||||
|
simulationPanel={this.state.simulationPanel}
|
||||||
|
closeSimulationPanel={this.closeSimulationPanel}
|
||||||
|
/>
|
||||||
</Grid.Row>
|
</Grid.Row>
|
||||||
</Grid.Column>
|
</Grid.Column>
|
||||||
<Grid.Column>
|
<Grid.Column>
|
||||||
|
@ -114,11 +134,14 @@ export class MyHeader extends React.Component {
|
||||||
<IconHomeImage />
|
<IconHomeImage />
|
||||||
</Grid.Column>
|
</Grid.Column>
|
||||||
<Grid.Column>
|
<Grid.Column>
|
||||||
|
<Grid.Row>
|
||||||
<Label as="a" image color="black">
|
<Label as="a" image color="black">
|
||||||
<img alt="SmartHut logo" src="smart-home.png" />
|
<img alt="SmartHut logo" src="smart-home.png" />
|
||||||
{this.props.username}
|
{this.props.username}
|
||||||
</Label>
|
</Label>
|
||||||
|
</Grid.Row>
|
||||||
<Divider />
|
<Divider />
|
||||||
|
<Grid.Row>
|
||||||
<Button onClick={this.logout}>Logout</Button>
|
<Button onClick={this.logout}>Logout</Button>
|
||||||
<Segment
|
<Segment
|
||||||
compact
|
compact
|
||||||
|
@ -136,6 +159,7 @@ export class MyHeader extends React.Component {
|
||||||
onChange={(e, val) => this.setCameraEnabled(val.checked)}
|
onChange={(e, val) => this.setCameraEnabled(val.checked)}
|
||||||
/>
|
/>
|
||||||
</Segment>
|
</Segment>
|
||||||
|
</Grid.Row>
|
||||||
</Grid.Column>
|
</Grid.Column>
|
||||||
</Grid.Row>
|
</Grid.Row>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
42
smart-hut/src/components/SimulationPanel.js
Normal file
42
smart-hut/src/components/SimulationPanel.js
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
import React from "react";
|
||||||
|
import Modal from "react-modal";
|
||||||
|
import { Button } from "semantic-ui-react";
|
||||||
|
|
||||||
|
const ReactModalPortal = {
|
||||||
|
opacity: 0
|
||||||
|
};
|
||||||
|
|
||||||
|
const ReactModal__Overlay = {
|
||||||
|
alignItems: 'center',
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center',
|
||||||
|
transition: 'opacity 200ms ease-in-out'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const modal = {
|
||||||
|
background: 'grey',
|
||||||
|
color: 'white',
|
||||||
|
maxWidth: '2rem',
|
||||||
|
outline: 'none',
|
||||||
|
padding: '2rem',
|
||||||
|
textAlign: 'center'
|
||||||
|
};
|
||||||
|
|
||||||
|
const SimulationPanel = (props) => (
|
||||||
|
<Modal
|
||||||
|
isOpen={!!props.simulationPanel}
|
||||||
|
contentLabel="Simulation Panel"
|
||||||
|
onRequestClose={props.closeSimulationPanel}
|
||||||
|
style={ReactModalPortal,ReactModal__Overlay, modal}
|
||||||
|
>
|
||||||
|
{props.simulationPanel && (
|
||||||
|
<p> hey man </p>
|
||||||
|
)}
|
||||||
|
<Button fluid primary onClick={props.closeSimulationPanel}>
|
||||||
|
Exit
|
||||||
|
</Button>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default SimulationPanel;
|
Loading…
Reference in a new issue