mirror of https://github.com/mitchell/mjfs.us.git
Refactor navbar menu button rendering
This commit is contained in:
parent
ba61e2fa2c
commit
a28a8916d9
|
@ -18,13 +18,23 @@ class Navbar extends React.Component<{}, State> {
|
||||||
this.toggleMenu = this.toggleMenu.bind(this)
|
this.toggleMenu = this.toggleMenu.bind(this)
|
||||||
this.renderButtons = this.renderButtons.bind(this)
|
this.renderButtons = this.renderButtons.bind(this)
|
||||||
this.closeMenu = this.closeMenu.bind(this)
|
this.closeMenu = this.closeMenu.bind(this)
|
||||||
|
this.menuButton = this.menuButton.bind(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
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()) {
|
if (this.isMobile()) {
|
||||||
menuButton = (
|
return (
|
||||||
<div
|
<div
|
||||||
className={
|
className={
|
||||||
this.state.showMenu
|
this.state.showMenu
|
||||||
|
@ -38,14 +48,7 @@ class Navbar extends React.Component<{}, State> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return null
|
||||||
<div className="navbar">
|
|
||||||
{menuButton}
|
|
||||||
{this.state.showMenu ? (
|
|
||||||
<div className="navbar-menu">{this.renderButtons()}</div>
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private isMobile() {
|
private isMobile() {
|
||||||
|
|
Loading…
Reference in New Issue