From 01f40eb5f80002244f89c5a7a78b5122f995bda1 Mon Sep 17 00:00:00 2001 From: Casper Lamboo Date: Thu, 21 Feb 2019 20:39:05 +0100 Subject: [PATCH] Display settings inside accordion element --- src/interface/Accordion.js | 62 +++++++++++++++ src/interface/Settings.js | 157 ++++++++++++++++++++++++------------- 2 files changed, 163 insertions(+), 56 deletions(-) create mode 100644 src/interface/Accordion.js diff --git a/src/interface/Accordion.js b/src/interface/Accordion.js new file mode 100644 index 0000000..b23d32d --- /dev/null +++ b/src/interface/Accordion.js @@ -0,0 +1,62 @@ +import React from 'react'; +import PropTypes from 'proptypes'; +import injectSheet from 'react-jss'; +import ExpandIcon from 'material-ui-icons/ExpandMore'; + +const styles = { + button: { + cursor: 'pointer' + }, + body: { + overflow: 'hidden' + }, + closed: { + maxHeight: '0px' + }, + title: { + display: 'flex', + alignItems: 'flex-end' + } +}; + +class Accordion extends React.Component { + static propTypes = { + elements: PropTypes.arrayOf(PropTypes.shape({ body: PropTypes.node, title: PropTypes.string })), + classes: PropTypes.objectOf(PropTypes.string) + }; + static defaultProps: { + elements: [] + }; + + state = { + openAccordion: null + }; + + changeAccordion = (name) => { + const { openAccordion } = this.state; + if (openAccordion === name) { + this.setState({ openAccordion: null }); + } else { + this.setState({ openAccordion: name }); + } + }; + + render() { + const { openAccordion } = this.state; + const { elements, classes } = this.props; + + return elements.map(({ body, title }, i) => ( + + + +

this.changeAccordion(title)} className={classes.button}>{title}

+
+
+ {body} +
+
+ )); + } +} + +export default injectSheet(styles)(Accordion); diff --git a/src/interface/Settings.js b/src/interface/Settings.js index 9eb004a..ffc7e63 100644 --- a/src/interface/Settings.js +++ b/src/interface/Settings.js @@ -22,6 +22,7 @@ import SettingsIcon from 'material-ui-icons/Settings'; import ExitToAppIcon from 'material-ui-icons/ExitToApp'; import validateIp from 'validate-ip'; import { Doodle3DManager } from 'doodle3d-api'; +import Accordion from './Accordion.js'; const DOODLE_3D_MANAGER = new Doodle3DManager(); DOODLE_3D_MANAGER.checkNonServerBoxes = false; @@ -445,62 +446,106 @@ class Settings extends React.Component {
-

Layer

- -

Thickness

- - - -

Material

- - -

Bed

- - -

Brim

- - - -

Support

- - - - - - - -

First layer

- - -

Inner shell

- - -

Outer shell

- - -

Inner infill

- - - -

Outer infill

- - -

Travel

- - -

Retraction

- - - - -

Printer dimensions

-
- - - -
-

Nozzle

- + ) + }, { + title: 'Thickness', + body: ( + + + + ) + }, { + title: 'Material', + body: ( + + + ) + }, { + title: 'Bed', + body: ( + + + ) + }, { + title: 'Brim', + body: ( + + + + ) + }, { + title: 'Support', + body: ( + + + + + + + + ) + }, { + title: 'First layer', + body: ( + + + ) + }, { + title: 'Inner shell', + body: ( + + + ) + }, { + title: 'Outer shell', + body: ( + + + ) + }, { + title: 'Inner infill', + body: ( + + + + ) + }, { + title: 'Outer infill', + body: ( + + + ) + }, { + title: 'Travel', + body: ( + + + ) + }, { + title: 'Retraction', + body: ( + + + + + ) + }, { + title: 'Printer dimensions', + body: ( +
+ + + +
+
) + }, { + title: 'Nozzle', + body: ( + + ) + }]} />