-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: update header menu breakpoints (#173) * feat: update header menu breakpoint (#173) * feat: updated header action buttons (#173) --------- Co-authored-by: Fran McDade <[email protected]>
- Loading branch information
Showing
25 changed files
with
373 additions
and
255 deletions.
There are no files selected for viewing
62 changes: 50 additions & 12 deletions
62
...Header/components/Content/components/Actions/components/Authentication/authentication.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MButtonProps> | ElementType<MIconButtonProps>; | ||
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 ? ( | ||
<AuthenticationMenu onLogout={onLogout} userProfile={userProfile} /> | ||
) : ( | ||
<RequestAuthentication | ||
closeMenu={closeMenu} | ||
requestAuthorization={requestAuthentication} | ||
/> | ||
))} | ||
{isAuthenticated && userProfile ? ( | ||
<AuthenticationMenu onLogout={onLogout} userProfile={userProfile} /> | ||
) : ( | ||
<Button | ||
onClick={(): void => { | ||
requestAuthentication(); | ||
closeMenu(); | ||
}} | ||
/> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
/** | ||
* Renders authentication button. | ||
* @param props - Button props. | ||
* @returns button. | ||
*/ | ||
export function renderButton(props: MButtonProps): JSX.Element { | ||
return ( | ||
<StyledButton startIcon={<LoginRoundedIcon />} variant="nav" {...props}> | ||
Sign in | ||
</StyledButton> | ||
); | ||
} | ||
|
||
/** | ||
* Renders authentication icon button. | ||
* @param props - Button props. | ||
* @returns icon button. | ||
*/ | ||
export function renderIconButton(props: MIconButtonProps): JSX.Element { | ||
return ( | ||
<MIconButton color="ink" {...props}> | ||
<LoginRoundedIcon /> | ||
</MIconButton> | ||
); | ||
} |
8 changes: 8 additions & 0 deletions
8
...s/Content/components/Actions/components/Authentication/components/Button/button.styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
`; |
10 changes: 0 additions & 10 deletions
10
...omponents/Authentication/components/RequestAuthentication/requestAuthentication.styles.ts
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
...ions/components/Authentication/components/RequestAuthentication/requestAuthentication.tsx
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
...mponents/Header/components/Content/components/Actions/components/Menu/common/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { DialogProps as MDialogProps } from "@mui/material"; | ||
|
||
export const DIALOG_PROPS: Partial<MDialogProps> = { | ||
PaperProps: { elevation: 0 }, | ||
TransitionProps: { easing: "ease-out" }, | ||
fullScreen: true, | ||
hideBackdrop: true, | ||
keepMounted: false, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...omponents/Content/components/Actions/components/Search/components/Button/button.styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
`; |
10 changes: 0 additions & 10 deletions
10
...ntent/components/Actions/components/Search/components/SearchButton/searchButton.styles.ts
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
...nts/Content/components/Actions/components/Search/components/SearchButton/searchButton.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
.../components/Content/components/Navigation/components/NavigationDrawer/common/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { DialogProps as MDialogProps } from "@mui/material"; | ||
|
||
export const DIALOG_PROPS: Partial<MDialogProps> = { | ||
PaperProps: { elevation: 0 }, | ||
fullScreen: true, | ||
hideBackdrop: true, | ||
keepMounted: false, | ||
transitionDuration: 300, | ||
}; |
Oops, something went wrong.