diff --git a/src/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/authentication.tsx b/src/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/authentication.tsx index 6ac9145f..fe31fb6e 100644 --- a/src/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/authentication.tsx +++ b/src/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/authentication.tsx @@ -1,35 +1,73 @@ +import LoginRoundedIcon from "@mui/icons-material/LoginRounded"; +import { + ButtonProps as MButtonProps, + IconButton as MIconButton, + IconButtonProps as MIconButtonProps, +} from "@mui/material"; import { useRouter } from "next/router"; -import React, { useCallback } from "react"; +import React, { ElementType, useCallback } from "react"; import { useAuthentication } from "../../../../../../../../../../hooks/useAuthentication/useAuthentication"; import { AuthenticationMenu } from "./components/AuthenticationMenu/authenticationMenu"; -import { RequestAuthentication } from "./components/RequestAuthentication/requestAuthentication"; +import { StyledButton } from "./components/Button/button.styles"; export interface AuthenticationProps { authenticationEnabled?: boolean; + Button: ElementType | ElementType; closeMenu: () => void; } export const Authentication = ({ authenticationEnabled, + Button, closeMenu, -}: AuthenticationProps): JSX.Element => { +}: AuthenticationProps): JSX.Element | null => { const { isAuthenticated, requestAuthentication, userProfile } = useAuthentication(); const router = useRouter(); const onLogout = useCallback((): void => { location.href = router.basePath; }, [router]); + + if (!authenticationEnabled) return null; + return ( <> - {authenticationEnabled && - (isAuthenticated && userProfile ? ( - - ) : ( - - ))} + {isAuthenticated && userProfile ? ( + + ) : ( + - ) : ( - { - closeMenu(); - requestAuthorization(); - }} - > - - - ); -}; diff --git a/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.tsx b/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.tsx index 01f8f271..0ded3568 100644 --- a/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.tsx +++ b/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.tsx @@ -5,8 +5,14 @@ import { ComponentsConfig } from "../../../../../../../../../../../../config/ent import { Left, Right } from "../../../../../../../../header.styles"; import { Announcements } from "../../../../../../../Announcements/announcements"; import { Actions } from "../../../../actions"; -import { Authentication } from "../../../Authentication/authentication"; -import { Search } from "../../../Search/search"; +import { + Authentication, + renderIconButton as renderAuthenticationIconButton, +} from "../../../Authentication/authentication"; +import { + renderIconButton as renderSearchIconButton, + Search, +} from "../../../Search/search"; export interface DialogTitleProps { actions?: ReactNode; @@ -36,6 +42,7 @@ export const Toolbar = ({ {/* Search */} {/* Additional actions i.e. call-to-action button */} diff --git a/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/Button/button.styles.ts b/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/Button/button.styles.ts new file mode 100644 index 00000000..f06bdf7f --- /dev/null +++ b/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/Button/button.styles.ts @@ -0,0 +1,8 @@ +import styled from "@emotion/styled"; +import { Button as MButton } from "@mui/material"; + +export const StyledButton = styled(MButton)` + &.MuiButton-nav { + padding: 6px 12px; + } +`; diff --git a/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.styles.ts b/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.styles.ts deleted file mode 100644 index 34ea8ab3..00000000 --- a/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.styles.ts +++ /dev/null @@ -1,10 +0,0 @@ -import styled from "@emotion/styled"; -import { Button as MButton } from "@mui/material"; -import { textBody500 } from "../../../../../../../../../../../../styles/common/mixins/fonts"; - -export const Button = styled(MButton)` - & { - ${textBody500}; - padding: 6px 12px; - } -`; diff --git a/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.tsx b/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.tsx deleted file mode 100644 index a2bb274a..00000000 --- a/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { IconButton } from "@mui/material"; -import React from "react"; -import { useBreakpoint } from "../../../../../../../../../../../../hooks/useBreakpoint"; -import { SearchIcon } from "../../../../../../../../../../../common/CustomIcon/components/SearchIcon/searchIcon"; -import { Button } from "./searchButton.styles"; - -export interface SearchProps { - openSearch: () => void; -} - -export const SearchButton = ({ openSearch }: SearchProps): JSX.Element => { - const { mdUp } = useBreakpoint(); - return mdUp ? ( - - ) : ( - - - - ); -}; diff --git a/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/search.tsx b/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/search.tsx index 98373a69..c56f9737 100644 --- a/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/search.tsx +++ b/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/search.tsx @@ -1,24 +1,33 @@ -import React, { useState } from "react"; +import { + ButtonProps as MButtonProps, + IconButton as MIconButton, + IconButtonProps as MIconButtonProps, +} from "@mui/material"; +import React, { ElementType, useState } from "react"; +import { SearchIcon } from "../../../../../../../../../common/CustomIcon/components/SearchIcon/searchIcon"; +import { StyledButton } from "./components/Button/button.styles"; import SearchBar from "./components/SearchBar/searchBar"; -import { SearchButton } from "./components/SearchButton/searchButton"; export interface SearchProps { + Button: ElementType | ElementType; closeMenu: () => void; searchEnabled?: boolean; searchURL?: string; } export const Search = ({ + Button, closeMenu, searchEnabled, searchURL, -}: SearchProps): JSX.Element => { +}: SearchProps): JSX.Element | null => { const [searchOpen, setSearchOpen] = useState(false); + + if (!searchEnabled) return null; + return ( <> - {searchEnabled && ( - setSearchOpen(true)} /> - )} +