component: reuse component Backdrop in component SideDrawer
This commit is contained in:
parent
1fd471f58a
commit
b79cb5e3ff
@ -1,18 +1,31 @@
|
||||
import React from 'react';
|
||||
import React, { Component } from 'react';
|
||||
|
||||
import Aux from '../../hoc/Auxiliary';
|
||||
import classes from './Layout.css';
|
||||
import Toolbar from '../Navigation/Toolbar/Toolbar';
|
||||
import SideDrawer from '../Navigation/SideDrawer/SideDrawer';
|
||||
|
||||
const layout = (props) => (
|
||||
<Aux>
|
||||
<Toolbar />
|
||||
<SideDrawer />
|
||||
<main className={classes.Content}>
|
||||
{props.children}
|
||||
</main>
|
||||
</Aux>
|
||||
)
|
||||
class Layout extends Component {
|
||||
state = {
|
||||
showSideDrawer: true
|
||||
}
|
||||
|
||||
export default layout;
|
||||
sideDrawerClosedHandler = () => {
|
||||
this.setState({showSideDrawer: false});
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Aux>
|
||||
<Toolbar />
|
||||
<SideDrawer open={this.state.showSideDrawer} closed={this.sideDrawerClosedHandler} />
|
||||
<main className={classes.Content}>
|
||||
{this.state.children}
|
||||
</main>
|
||||
</Aux>
|
||||
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export default Layout;
|
@ -3,17 +3,28 @@ import React from 'react';
|
||||
import classes from './SideDrawer.css';
|
||||
import Logo from '../../Logo/Logo';
|
||||
import NavigationItems from '../NavigationItems/NavigationItems';
|
||||
import Aux from '../../../hoc/Auxiliary';
|
||||
import Backdrop from '../../UI/Backdrop/Backdrop';
|
||||
|
||||
const sideDrawer = (props) => {
|
||||
let attachedClasses = [classes.SideDrawer, classes.Close];
|
||||
if (props.open){
|
||||
attachedClasses = [classes.SideDrawer, classes.Open];
|
||||
}
|
||||
|
||||
const sideDrawer = () => {
|
||||
return (
|
||||
<div className={classes.SideDrawer}>
|
||||
<div className={classes.Logo}>
|
||||
<Logo />
|
||||
<Aux>
|
||||
<Backdrop show={props.open} clicked={props.closed} />
|
||||
<div className={attachedClasses.join(' ')}>
|
||||
<div className={classes.Logo}>
|
||||
<Logo />
|
||||
</div>
|
||||
<nav>
|
||||
<NavigationItems />
|
||||
</nav>
|
||||
</div>
|
||||
<nav>
|
||||
<NavigationItems />
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
</Aux>
|
||||
)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user