Proper drawer behaviour
* Move the content to the left when the drawer is opened
This commit is contained in:
parent
0a2c46c37b
commit
4d40321975
2 changed files with 29 additions and 12 deletions
|
|
@ -76,10 +76,20 @@ class App extends React.PureComponent<AppProps & Classes, AppState> {
|
||||||
Object.assign({}, ...this.props.config.topics) : this.props.config.topics;
|
Object.assign({}, ...this.props.config.topics) : this.props.config.topics;
|
||||||
}
|
}
|
||||||
|
|
||||||
static styles() {
|
static styles(theme) {
|
||||||
return {
|
return {
|
||||||
drawerPaper: {
|
contentElement: {
|
||||||
width: 320
|
transition: theme.transitions.create(["width"], {
|
||||||
|
easing: theme.transitions.easing.sharp,
|
||||||
|
duration: theme.transitions.duration.leavingScreen
|
||||||
|
})
|
||||||
|
},
|
||||||
|
contentElementShifted: {
|
||||||
|
width: "calc(100% - 340px)",
|
||||||
|
transition: theme.transitions.create(["width"], {
|
||||||
|
easing: theme.transitions.easing.easeOut,
|
||||||
|
duration: theme.transitions.duration.enteringScreen
|
||||||
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -147,8 +157,15 @@ class App extends React.PureComponent<AppProps & Classes, AppState> {
|
||||||
state: this.state.mqttState,
|
state: this.state.mqttState,
|
||||||
changeState: this.changeState
|
changeState: this.changeState
|
||||||
}}>
|
}}>
|
||||||
|
<div className={
|
||||||
|
this.state.drawerOpened
|
||||||
|
? this.props.classes.contentElementShifted
|
||||||
|
: this.props.classes.contentElement
|
||||||
|
}>
|
||||||
<TopBar connected={this.state.mqttConnected}
|
<TopBar connected={this.state.mqttConnected}
|
||||||
onSearch={(s) => this.setState({ search: s })} />
|
onSearch={(s) => this.setState({ search: s })} />
|
||||||
|
{this.controlMap(this.state.search)}
|
||||||
|
</div>
|
||||||
<SideBar open={this.state.drawerOpened}
|
<SideBar open={this.state.drawerOpened}
|
||||||
control={this.state.selectedControl}
|
control={this.state.selectedControl}
|
||||||
onCloseRequest={this.closeDrawer}
|
onCloseRequest={this.closeDrawer}
|
||||||
|
|
@ -158,7 +175,6 @@ class App extends React.PureComponent<AppProps & Classes, AppState> {
|
||||||
{this.state.selectedControl == null
|
{this.state.selectedControl == null
|
||||||
|| <UiItemList controls={this.state.selectedControl.ui} />}
|
|| <UiItemList controls={this.state.selectedControl.ui} />}
|
||||||
</SideBar>
|
</SideBar>
|
||||||
{this.controlMap(this.state.search)}
|
|
||||||
<Snackbar
|
<Snackbar
|
||||||
anchorOrigin={{
|
anchorOrigin={{
|
||||||
vertical: "bottom",
|
vertical: "bottom",
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,11 @@ const SideBar = (props: Props) => (
|
||||||
<span>
|
<span>
|
||||||
{props.icon == null || renderRawIcon(props.icon, "mdi-36px")}
|
{props.icon == null || renderRawIcon(props.icon, "mdi-36px")}
|
||||||
</span>
|
</span>
|
||||||
<Typography variant="title" className={props.classes.flex}>
|
<Typography variant="title" className={props.classes.title}>
|
||||||
{props.control == null ? "" : props.control.name}
|
{props.control == null ? "" : props.control.name}
|
||||||
</Typography>
|
</Typography>
|
||||||
<IconButton onClick={props.onCloseRequest}>
|
<IconButton onClick={props.onCloseRequest}>
|
||||||
<i className="mdi mdi-close mdi-36px"></i>
|
<i className="mdi mdi-close"></i>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
</AppBar>
|
</AppBar>
|
||||||
|
|
@ -49,13 +49,14 @@ const SideBar = (props: Props) => (
|
||||||
</Drawer>
|
</Drawer>
|
||||||
);
|
);
|
||||||
|
|
||||||
const styles = {
|
const styles = (theme) => ({
|
||||||
drawerPaper: {
|
drawerPaper: {
|
||||||
width: 340
|
width: 340
|
||||||
},
|
},
|
||||||
flex: {
|
title: {
|
||||||
flex: 1
|
flex: 1,
|
||||||
|
marginLeft: theme.spacing.unit
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
export default withStyles(styles)(SideBar);
|
export default withStyles(styles)(SideBar);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue