Skip to content

Commit

Permalink
minor menu refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Dereje1 committed Apr 4, 2023
1 parent 8e77656 commit 5874c89
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
24 changes: 13 additions & 11 deletions client/src/components/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,20 @@ export class Menu extends React.Component<MenuProps, MenuState> {
const {
displaySignIn,
} = this.state;
if (authenticated) {
return (
<CollapsibleMenu
pathname={pathname}
menuClicked={this.handleMenuClick}
/>
);
}

return (
<>
<Login showSignIn={() => this.setState({ displaySignIn: true })} />
<Brand />
{
authenticated ? (
<CollapsibleMenu
pathname={pathname}
menuClicked={this.handleMenuClick}
/>
)
: <Login showSignIn={() => this.setState({ displaySignIn: true })} />
}

{displaySignIn && (
<SignIn
removeSignin={() => this.setState({ displaySignIn: false })}
Expand Down Expand Up @@ -127,14 +130,13 @@ export class Menu extends React.Component<MenuProps, MenuState> {
document.body.classList.remove('cover');
return (
<div className="menu">
{!showSearch && <Brand /> }
<Search
isShowing={showSearch}
openSearch={() => this.setState({ showSearch: true })}
closeSearch={() => this.setState({ showSearch: false })}
pathname={pathname}
/>
{ !showSearch && this.renderMenu(authenticated)}
{!showSearch && this.renderMenu(authenticated)}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ exports[`The Menu component will render for an authenticated user 1`] = `
<div
className="menu"
>
<Brand />
<Search
closeSearch={[Function]}
isShowing={false}
openSearch={[Function]}
pathname="/"
/>
<Brand />
<CollapsibleMenu
menuClicked={[Function]}
pathname="/"
Expand All @@ -22,13 +22,13 @@ exports[`The Menu component will render for users authenticated as guest 1`] = `
<div
className="menu"
>
<Brand />
<Search
closeSearch={[Function]}
isShowing={false}
openSearch={[Function]}
pathname="/"
/>
<Brand />
<Login
showSignIn={[Function]}
/>
Expand Down

0 comments on commit 5874c89

Please sign in to comment.