Merge pull request #198 from sensebox/dev/update-deviceSelector
update device Selector
This commit is contained in:
commit
e00617ac78
10
src/App.css
10
src/App.css
@ -62,3 +62,13 @@ td {
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--url: url('./data/mcu_opacity.png');
|
||||||
|
}
|
||||||
|
|
||||||
|
.blocklySvg {
|
||||||
|
background-image: var(--url);
|
||||||
|
background-position: center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
@ -4,11 +4,11 @@ import { connect } from "react-redux";
|
|||||||
import Dialog from "./Dialog";
|
import Dialog from "./Dialog";
|
||||||
|
|
||||||
import { withStyles } from "@material-ui/core/styles";
|
import { withStyles } from "@material-ui/core/styles";
|
||||||
import Checkbox from "@material-ui/core/Checkbox";
|
|
||||||
import FormControlLabel from "@material-ui/core/FormControlLabel";
|
|
||||||
import * as Blockly from "blockly";
|
import * as Blockly from "blockly";
|
||||||
import { IconButton, Grid, Avatar, Typography } from "@material-ui/core";
|
import { IconButton, Grid, Avatar, Typography } from "@material-ui/core";
|
||||||
import { setBoard } from "../actions/boardAction";
|
import { setBoard } from "../actions/boardAction";
|
||||||
|
import mini_opacity from "../data/mini_opacity.png"
|
||||||
|
import mcu_opacity from "../data/mcu_opacity.png"
|
||||||
|
|
||||||
const styles = (theme) => ({
|
const styles = (theme) => ({
|
||||||
link: {
|
link: {
|
||||||
@ -27,15 +27,9 @@ const styles = (theme) => ({
|
|||||||
|
|
||||||
class DeviceSeclection extends Component {
|
class DeviceSeclection extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
var previousPageWasAnotherDomain = props.pageVisits === 0;
|
|
||||||
var userWantToKeepBoard = window.localStorage.getItem("board")
|
|
||||||
? true
|
|
||||||
: false;
|
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
open: userWantToKeepBoard
|
open: true,
|
||||||
? !userWantToKeepBoard
|
|
||||||
: previousPageWasAnotherDomain,
|
|
||||||
selectedBoard : "",
|
selectedBoard : "",
|
||||||
saveSettings: false,
|
saveSettings: false,
|
||||||
|
|
||||||
@ -43,10 +37,7 @@ class DeviceSeclection extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toggleDialog = () => {
|
toggleDialog = () => {
|
||||||
this.setState({ open: !this.state });
|
|
||||||
if(this.state.saveSettings){
|
|
||||||
window.localStorage.setItem("board", this.state.selectedBoard)
|
|
||||||
}
|
|
||||||
this.props.setBoard(this.state.selectedBoard)
|
this.props.setBoard(this.state.selectedBoard)
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -61,7 +52,14 @@ class DeviceSeclection extends Component {
|
|||||||
|
|
||||||
onclick = (e, value) => {
|
onclick = (e, value) => {
|
||||||
console.log(e, value)
|
console.log(e, value)
|
||||||
|
const root = document.querySelector(':root');
|
||||||
|
root.style.setProperty('--url', `url(${value === "mcu" ? mcu_opacity : mini_opacity })`);
|
||||||
this.setState({selectedBoard: value})
|
this.setState({selectedBoard: value})
|
||||||
|
this.props.setBoard(value)
|
||||||
|
this.setState({ open: !this.state });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@ -74,7 +72,6 @@ class DeviceSeclection extends Component {
|
|||||||
title={Blockly.Msg.deviceselection_head}
|
title={Blockly.Msg.deviceselection_head}
|
||||||
content={""}
|
content={""}
|
||||||
onClick={this.toggleDialog}
|
onClick={this.toggleDialog}
|
||||||
button={Blockly.Msg.button_accept}
|
|
||||||
disabled={this.state.selectedBoard===""}
|
disabled={this.state.selectedBoard===""}
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
@ -124,7 +121,7 @@ class DeviceSeclection extends Component {
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</div>
|
</div>
|
||||||
<FormControlLabel
|
{/* <FormControlLabel
|
||||||
style={{ marginTop: "20px" }}
|
style={{ marginTop: "20px" }}
|
||||||
classes={{ label: this.props.classes.label }}
|
classes={{ label: this.props.classes.label }}
|
||||||
control={
|
control={
|
||||||
@ -138,7 +135,7 @@ class DeviceSeclection extends Component {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
label={Blockly.Msg.deviceselection_keep_selection}
|
label={Blockly.Msg.deviceselection_keep_selection}
|
||||||
/>
|
/> */}
|
||||||
<Typography variant="body1" >
|
<Typography variant="body1" >
|
||||||
{Blockly.Msg.deviceselection_footnote} <a href="https://sensebox.github.io/blockly/">Arduino UNO</a> {Blockly.Msg.deviceselection_footnote_02} <a href="https://sensebox-blockly.netlify.app/ardublockly/?board=sensebox-mcu">senseBox MCU</a>
|
{Blockly.Msg.deviceselection_footnote} <a href="https://sensebox.github.io/blockly/">Arduino UNO</a> {Blockly.Msg.deviceselection_footnote_02} <a href="https://sensebox-blockly.netlify.app/ardublockly/?board=sensebox-mcu">senseBox MCU</a>
|
||||||
</Typography>
|
</Typography>
|
||||||
|
BIN
src/data/mcu_opacity.png
Normal file
BIN
src/data/mcu_opacity.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 167 KiB |
BIN
src/data/mini_opacity.png
Normal file
BIN
src/data/mini_opacity.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 105 KiB |
Loading…
x
Reference in New Issue
Block a user