From 509335a0611b6b64643a8f266c4cce8ad57a806c Mon Sep 17 00:00:00 2001 From: Fil Cesana Date: Tue, 21 Apr 2020 16:44:41 +0200 Subject: [PATCH] video component is finished and ready for those who want to be tested in the file light.js; tomorrow I will move everything back in Videocam.js (in devices) and with Andrea we will perform the connection with the backend. If you test it, enjoy the video I put in loop ;) --- .../src/components/dashboard/devices/Light.js | 58 +++++++------------ .../dashboard/devices/VideoModalStyle.css..js | 33 +++++++++++ .../dashboard/devices/VideocamModal.js | 41 +++++++++++++ 3 files changed, 94 insertions(+), 38 deletions(-) create mode 100644 smart-hut/src/components/dashboard/devices/VideoModalStyle.css..js create mode 100644 smart-hut/src/components/dashboard/devices/VideocamModal.js diff --git a/smart-hut/src/components/dashboard/devices/Light.js b/smart-hut/src/components/dashboard/devices/Light.js index d4debca..0db0596 100644 --- a/smart-hut/src/components/dashboard/devices/Light.js +++ b/smart-hut/src/components/dashboard/devices/Light.js @@ -10,44 +10,39 @@ import React, { Component } from "react"; import { - StyledDiv,hAbRNe + StyledDiv } from "./VideocmStyle"; import { Checkbox, Embed, Button, Grid, Responsive, Segment } from "semantic-ui-react"; import { RemoteService } from "../../../remote"; import { connect } from "react-redux"; +import VideocamModal from "./VideocamModal"; + class Light extends Component { constructor(props) { super(props); - this.state = { intensity: this.props.device.intensity, timeout: null }; - - this.iconOn = "/img/lightOn.svg"; - this.iconOff = "/img/lightOff.svg"; + this.state = { selectedVideo: undefined}; } - get turnedOn() { - return this.props.device.on; + openModal = () => { + this.setState((state) => { + return {selectedVideo: true} + + }); + }; + + closeModal = () => { + this.setState((state) => { + return {selectedVideo:undefined} + }) } - - onClickDevice = () => { - const on = !this.turnedOn; - this.props - .saveDevice({ ...this.props.device, on }) - .catch((err) => console.error("regular light update error", err)); - }; - - getIcon = () => { - return this.turnedOn ? this.iconOn : this.iconOff; - }; - - render() { const normalLightView = (
-
+
@@ -55,27 +50,14 @@ class Light extends Component { - - - - - - - - - - + -
); diff --git a/smart-hut/src/components/dashboard/devices/VideoModalStyle.css..js b/smart-hut/src/components/dashboard/devices/VideoModalStyle.css..js new file mode 100644 index 0000000..3570958 --- /dev/null +++ b/smart-hut/src/components/dashboard/devices/VideoModalStyle.css..js @@ -0,0 +1,33 @@ + + + +.ReactModalPortal > div { + opacity: 0; +} + +.ReactModalPortal .ReactModal__Overlay { + align-items: center; + display: flex; + justify-content: center; + transition: opacity 200ms ease-in-out; +} + +.ReactModalPortal .ReactModal__Overlay--after-open { + opacity: 1; +} + + +.ReactModalPortal .ReactModal__Overlay--before-close { + opacity: 0; +} + +.modal { + color: white; + max-width: 30rem; + outline: none; + text-align: center; +} + +.modal__body { + margin: 0 0 0 0; +} \ No newline at end of file diff --git a/smart-hut/src/components/dashboard/devices/VideocamModal.js b/smart-hut/src/components/dashboard/devices/VideocamModal.js new file mode 100644 index 0000000..589a65d --- /dev/null +++ b/smart-hut/src/components/dashboard/devices/VideocamModal.js @@ -0,0 +1,41 @@ +import React from 'react'; +import Modal from 'react-modal'; +import { Button } from "semantic-ui-react"; + +const customStyles = { + content: { + top: '35%', + left: '50%', + right: 'auto', + bottom: 'auto', + marginRight: '-50%', + width: '60%', + transform: 'translate(-40%, -10%)', + }, + }; + + +const VideocamModal = (props) => ( + + {props.selectedVideo && + + } + + + ); + + +export default VideocamModal; \ No newline at end of file