add language and mcu settings to navbar
This commit is contained in:
parent
77b338ffb6
commit
360169c8c9
@ -29,6 +29,7 @@
|
|||||||
"qrcode.react": "^3.1.0",
|
"qrcode.react": "^3.1.0",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-cookie-consent": "^7.2.1",
|
"react-cookie-consent": "^7.2.1",
|
||||||
|
"react-country-flag": "^3.0.2",
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
"react-markdown": "^8.0.0",
|
"react-markdown": "^8.0.0",
|
||||||
"react-markdown-editor-lite": "^1.3.3",
|
"react-markdown-editor-lite": "^1.3.3",
|
||||||
|
@ -13,8 +13,8 @@ export const IO = {
|
|||||||
ARD_DIGITALREAD_TIP: "Read digital value on a pin: HIGH or LOW",
|
ARD_DIGITALREAD_TIP: "Read digital value on a pin: HIGH or LOW",
|
||||||
ARD_DIGITALWRITE: "set digitial pin#",
|
ARD_DIGITALWRITE: "set digitial pin#",
|
||||||
ARD_DIGITALWRITE_TIP: "Write digital value HIGH or LOW to a specific Port",
|
ARD_DIGITALWRITE_TIP: "Write digital value HIGH or LOW to a specific Port",
|
||||||
ARD_FUN_RUN_LOOP: "Arduino loop forever:",
|
ARD_FUN_RUN_LOOP: "Loop()",
|
||||||
ARD_FUN_RUN_SETUP: "Arduino run first:",
|
ARD_FUN_RUN_SETUP: "Setup()",
|
||||||
ARD_FUN_RUN_TIP: "Defines the Arduino setup() and loop() functions.",
|
ARD_FUN_RUN_TIP: "Defines the Arduino setup() and loop() functions.",
|
||||||
ARD_HIGH: "HIGH",
|
ARD_HIGH: "HIGH",
|
||||||
ARD_HIGHLOW_TIP: "Set a pin state logic High or Low.",
|
ARD_HIGHLOW_TIP: "Set a pin state logic High or Low.",
|
||||||
|
@ -41,6 +41,7 @@ import {
|
|||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import * as Blockly from "blockly";
|
import * as Blockly from "blockly";
|
||||||
import Tooltip from "@material-ui/core/Tooltip";
|
import Tooltip from "@material-ui/core/Tooltip";
|
||||||
|
import NavbarSettings from "./NavbarSettings";
|
||||||
|
|
||||||
const styles = (theme) => ({
|
const styles = (theme) => ({
|
||||||
drawerWidth: {
|
drawerWidth: {
|
||||||
@ -127,6 +128,7 @@ class Navbar extends Component {
|
|||||||
<Link to={"/"} style={{ marginLeft: "10px" }}>
|
<Link to={"/"} style={{ marginLeft: "10px" }}>
|
||||||
<img src={senseboxLogo} alt="senseBox-Logo" width="30" />
|
<img src={senseboxLogo} alt="senseBox-Logo" width="30" />
|
||||||
</Link>
|
</Link>
|
||||||
|
<NavbarSettings />
|
||||||
{isTutorial ? (
|
{isTutorial ? (
|
||||||
<Link
|
<Link
|
||||||
to={"/tutorial"}
|
to={"/tutorial"}
|
||||||
@ -149,7 +151,7 @@ class Navbar extends Component {
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
this.openTour();
|
this.openTour();
|
||||||
}}
|
}}
|
||||||
style={{ margin: "0 30px 0 auto" }}
|
style={{ margin: "0 30px 0 0" }}
|
||||||
>
|
>
|
||||||
<FontAwesomeIcon icon={faQuestionCircle} />
|
<FontAwesomeIcon icon={faQuestionCircle} />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
@ -163,7 +165,7 @@ class Navbar extends Component {
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
this.openTour();
|
this.openTour();
|
||||||
}}
|
}}
|
||||||
style={{ margin: "0 30px 0 auto" }}
|
style={{ margin: "0 30px 0 0" }}
|
||||||
>
|
>
|
||||||
<FontAwesomeIcon icon={faQuestionCircle} />
|
<FontAwesomeIcon icon={faQuestionCircle} />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
@ -214,11 +216,11 @@ class Navbar extends Component {
|
|||||||
</div>
|
</div>
|
||||||
<List>
|
<List>
|
||||||
{[
|
{[
|
||||||
{
|
{
|
||||||
text: Blockly.Msg.navbar_blockly,
|
text: Blockly.Msg.navbar_blockly,
|
||||||
icon: faPuzzlePiece,
|
icon: faPuzzlePiece,
|
||||||
link: "/",
|
link: "/",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: Blockly.Msg.navbar_tutorials,
|
text: Blockly.Msg.navbar_tutorials,
|
||||||
icon: faChalkboardTeacher,
|
icon: faChalkboardTeacher,
|
||||||
@ -329,9 +331,9 @@ class Navbar extends Component {
|
|||||||
onClick={
|
onClick={
|
||||||
item.function
|
item.function
|
||||||
? () => {
|
? () => {
|
||||||
item.function();
|
item.function();
|
||||||
this.toggleDrawer();
|
this.toggleDrawer();
|
||||||
}
|
}
|
||||||
: this.toggleDrawer
|
: this.toggleDrawer
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
68
src/components/NavbarSettings.js
Normal file
68
src/components/NavbarSettings.js
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
import React, { Component } from 'react';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import { setLanguage } from '../actions/generalActions';
|
||||||
|
import MenuItem from '@material-ui/core/MenuItem';
|
||||||
|
import Select from '@material-ui/core/Select';
|
||||||
|
import { setBoard } from '../actions/boardAction';
|
||||||
|
import ReactCountryFlag from "react-country-flag";
|
||||||
|
|
||||||
|
class NavbarSettings extends Component {
|
||||||
|
componentDidMount() {
|
||||||
|
// Ensure that Blockly.setLocale is adopted in the component.
|
||||||
|
// Otherwise, the text will not be displayed until the next update of the component.
|
||||||
|
this.forceUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
handleChange = (event) => {
|
||||||
|
this.props.setLanguage(event.target.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div style={{ margin: "0 0 0 auto", display: "flex" }}>
|
||||||
|
<div style={{ margin: "0 30px 0 auto", display: "flex" }}>
|
||||||
|
<Select
|
||||||
|
value={this.props.selectedBoard}
|
||||||
|
onChange={(e) => this.props.setBoard(e.target.value)}
|
||||||
|
disableUnderline={true}
|
||||||
|
>
|
||||||
|
<MenuItem value="mcu">senseBox MCU</MenuItem>
|
||||||
|
<MenuItem value="mini">senseBox MCU mini</MenuItem>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
<div style={{ margin: "0 0 0 auto", display: "flex" }}>
|
||||||
|
<Select
|
||||||
|
value={this.props.language}
|
||||||
|
onChange={this.handleChange}
|
||||||
|
disableUnderline={true}
|
||||||
|
IconComponent={() => null}
|
||||||
|
>
|
||||||
|
<MenuItem value={'en_US'} >
|
||||||
|
<ReactCountryFlag
|
||||||
|
countryCode="US"
|
||||||
|
svg
|
||||||
|
cdnSuffix="svg"
|
||||||
|
title="US"
|
||||||
|
/>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem value={'de_DE'}>
|
||||||
|
<ReactCountryFlag
|
||||||
|
countryCode="DE"
|
||||||
|
svg
|
||||||
|
cdnSuffix="svg"
|
||||||
|
title="DE"
|
||||||
|
/>
|
||||||
|
</MenuItem>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
</div >
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const mapStateToProps = state => ({
|
||||||
|
language: state.general.language,
|
||||||
|
selectedBoard: state.board.board
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, { setLanguage, setBoard })(NavbarSettings);
|
Loading…
x
Reference in New Issue
Block a user