Compare commits

...
Author SHA1 Message Date
Mario Pesch 328b9a141f open device selection only once 2022-11-09 16:17:31 +01:00
Mario Pesch d61d0cc5c4 update device Selector 2022-11-03 20:04:39 +01:00
6 changed files with 24 additions and 41 deletions
+10
View File
@@ -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;
}
+12 -37
View File
@@ -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,41 +27,32 @@ 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: this.props.selectedBoard !== "" ? false : true,
? !userWantToKeepBoard selectedBoard : this.props.selectedBoard,
: previousPageWasAnotherDomain,
selectedBoard : "",
saveSettings: false, saveSettings: false,
}; };
} }
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)
}; };
onChange = (e) => {
if (e.target.checked) {
this.setState({ saveSettings: true});
} else {
this.setState({ saveSettings: false});
}
};
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 +65,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,21 +114,6 @@ class DeviceSeclection extends Component {
</Grid> </Grid>
</Grid> </Grid>
</div> </div>
<FormControlLabel
style={{ marginTop: "20px" }}
classes={{ label: this.props.classes.label }}
control={
<Checkbox
size={"small"}
value={true}
checked={this.state.checked}
onChange={(e) => this.onChange(e)}
name="dialog"
color="primary"
/>
}
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>
+1
View File
@@ -187,6 +187,7 @@ class Home extends Component {
</Grid> </Grid>
) : null} ) : null}
</Grid> </Grid>
<DeviceSelection /> <DeviceSelection />
{/* <HintTutorialExists /> */} {/* <HintTutorialExists /> */}
{this.props.platform ? ( {this.props.platform ? (
Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

+1 -4
View File
@@ -1,10 +1,7 @@
import { BOARD } from '../actions/types'; import { BOARD } from '../actions/types';
const initialValue = () => { const initialValue = () => {
if (window.localStorage.getItem("board")) { return "";
return window.localStorage.getItem("board");
}
return "bla";
}; };
const initialState = { const initialState = {