Refactor navbar menu button rendering

This commit is contained in:
Mitchell Simon 2019-09-03 00:34:08 -04:00
parent ba61e2fa2c
commit a28a8916d9
1 changed files with 13 additions and 10 deletions

View File

@ -18,13 +18,23 @@ class Navbar extends React.Component<{}, State> {
this.toggleMenu = this.toggleMenu.bind(this)
this.renderButtons = this.renderButtons.bind(this)
this.closeMenu = this.closeMenu.bind(this)
this.menuButton = this.menuButton.bind(this)
}
public render() {
let menuButton: JSX.Element | null = null
return (
<div className="navbar">
{this.menuButton()}
{this.state.showMenu && (
<div className="navbar-menu">{this.renderButtons()}</div>
)}
</div>
)
}
private menuButton() {
if (this.isMobile()) {
menuButton = (
return (
<div
className={
this.state.showMenu
@ -38,14 +48,7 @@ class Navbar extends React.Component<{}, State> {
)
}
return (
<div className="navbar">
{menuButton}
{this.state.showMenu ? (
<div className="navbar-menu">{this.renderButtons()}</div>
) : null}
</div>
)
return null
}
private isMobile() {