move navbar menu to a separate function

This commit is contained in:
2019-04-13 22:22:43 +03:00
parent 7352f6794d
commit 6a6e7e374c

View File

@@ -78,40 +78,13 @@ export class HomeComponent extends React.PureComponent<IHomeProps> {
{this.props.user.username} {this.props.user.username}
</Button> </Button>
} }
content={ content={this.menu()}
<Menu>
<Menu.Item
icon="log-out"
text="Logout"
onClick={this.props.logout}
/>
{this.props.darkMode ? (
<Menu.Item
icon="flash"
text="Light Mode"
onClick={
this.props
.dispatchToggleDarkMode
}
/>
) : (
<Menu.Item
icon="moon"
text="Dark Mode"
onClick={
this.props
.dispatchToggleDarkMode
}
/>
)}
</Menu>
}
/> />
</Navbar.Group> </Navbar.Group>
</Navbar> </Navbar>
<div id="MainScreen" className="animationWrapper"> <div id="MainScreen" className="animationWrapper">
<Transition <Transition
native={true} native={true}
config={{ config={{
...config.default, ...config.default,
clamp: true, clamp: true,
@@ -133,7 +106,10 @@ export class HomeComponent extends React.PureComponent<IHomeProps> {
}} }}
> >
{(_location: any) => (style: any) => ( {(_location: any) => (style: any) => (
<animated.div style={style} className="viewComponent"> <animated.div
style={style}
className="viewComponent"
>
<Switch location={_location}> <Switch location={_location}>
<Route <Route
path="/docs/:id/edit" path="/docs/:id/edit"
@@ -153,6 +129,31 @@ export class HomeComponent extends React.PureComponent<IHomeProps> {
) )
); );
} }
private menu() {
return (
<Menu>
<Menu.Item
icon="log-out"
text="Logout"
onClick={this.props.logout}
/>
{this.props.darkMode ? (
<Menu.Item
icon="flash"
text="Light Mode"
onClick={this.props.dispatchToggleDarkMode}
/>
) : (
<Menu.Item
icon="moon"
text="Dark Mode"
onClick={this.props.dispatchToggleDarkMode}
/>
)}
</Menu>
);
}
} }
function mapStateToProps(state: IAppState) { function mapStateToProps(state: IAppState) {