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,34 +78,7 @@ export class HomeComponent extends React.PureComponent<IHomeProps> {
{this.props.user.username}
</Button>
}
content={
<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>
}
content={this.menu()}
/>
</Navbar.Group>
</Navbar>
@@ -133,7 +106,10 @@ export class HomeComponent extends React.PureComponent<IHomeProps> {
}}
>
{(_location: any) => (style: any) => (
<animated.div style={style} className="viewComponent">
<animated.div
style={style}
className="viewComponent"
>
<Switch location={_location}>
<Route
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) {