feat: Pass User in to main menu and introduce avatar and dropdown
This commit is contained in:
committed by
Michael Zetterberg
parent
88795b673d
commit
1326789683
@@ -7,6 +7,7 @@ import { myPages } from "@/constants/routes/myPages"
|
|||||||
import useDropdownStore from "@/stores/main-menu"
|
import useDropdownStore from "@/stores/main-menu"
|
||||||
|
|
||||||
import Image from "@/components/Image"
|
import Image from "@/components/Image"
|
||||||
|
import Avatar from "@/components/MyPages/Avatar"
|
||||||
import Link from "@/components/TempDesignSystem/Link"
|
import Link from "@/components/TempDesignSystem/Link"
|
||||||
|
|
||||||
import BookingButton from "../BookingButton"
|
import BookingButton from "../BookingButton"
|
||||||
@@ -24,7 +25,7 @@ export function MainMenu({
|
|||||||
languageSwitcher,
|
languageSwitcher,
|
||||||
myPagesMobileDropdown,
|
myPagesMobileDropdown,
|
||||||
bookingHref,
|
bookingHref,
|
||||||
isLoggedIn,
|
user,
|
||||||
lang,
|
lang,
|
||||||
}: MainMenuProps) {
|
}: MainMenuProps) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
@@ -73,7 +74,7 @@ export function MainMenu({
|
|||||||
className={`${styles.listWrapper} ${isHamburgerMenuOpen ? styles.isOpen : ""}`}
|
className={`${styles.listWrapper} ${isHamburgerMenuOpen ? styles.isOpen : ""}`}
|
||||||
>
|
>
|
||||||
<ul className={styles.linkRow}>
|
<ul className={styles.linkRow}>
|
||||||
{isLoggedIn ? (
|
{!!user ? (
|
||||||
<>
|
<>
|
||||||
<li>
|
<li>
|
||||||
<div className={styles.loggedInLogo} />
|
<div className={styles.loggedInLogo} />
|
||||||
@@ -144,17 +145,17 @@ export function MainMenu({
|
|||||||
</ul>
|
</ul>
|
||||||
<div className={styles.buttonContainer}>
|
<div className={styles.buttonContainer}>
|
||||||
<BookingButton href={bookingHref} />
|
<BookingButton href={bookingHref} />
|
||||||
{/* {myPagesMobileDropdown ? ( */}
|
{myPagesMobileDropdown && user ? (
|
||||||
{/* <div */}
|
<div
|
||||||
{/* role="button" */}
|
role="button"
|
||||||
{/* onClick={() => toggleMyPagesMobileMenu()} */}
|
onClick={() => toggleMyPagesMobileMenu()}
|
||||||
{/* className={styles.userAvatar} */}
|
className={styles.avatarButton}
|
||||||
{/* > */}
|
>
|
||||||
{/* <span className={styles.userAvatarInner}>CM</span> */}
|
<Avatar firstName={user.firstName} lastName={user.lastName} />
|
||||||
{/* </div> */}
|
</div>
|
||||||
{/* ) : null} */}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
{/* {isMyPagesMenuOpen ? myPagesMobileDropdown : null} */}
|
{isMyPagesMobileMenuOpen ? myPagesMobileDropdown : null}
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
.mainMenu {
|
.mainMenu {
|
||||||
background-color: #fff;
|
background-color: var(--Main-Grey-White);
|
||||||
background-image: none;
|
background-image: none;
|
||||||
box-shadow: 0 0 7px rgba(0, 0, 0, 0.75);
|
box-shadow: 0px 1.001px 1.001px 0px rgba(0, 0, 0, 0.05);
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
z-index: 99999;
|
z-index: 99999;
|
||||||
height: 52.39px;
|
height: 70.047px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
@@ -26,8 +26,11 @@
|
|||||||
.navBar {
|
.navBar {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 80px 1fr;
|
grid-template-columns: 1fr 80px 1fr;
|
||||||
|
grid-template-columns: auto auto 1fr auto;
|
||||||
|
grid-template-areas: "expanderBtn logoLink . buttonContainer";
|
||||||
grid-template-rows: 100%;
|
grid-template-rows: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
padding: 0 var(--Spacing-x2);
|
||||||
}
|
}
|
||||||
|
|
||||||
.expanderBtn {
|
.expanderBtn {
|
||||||
@@ -46,7 +49,7 @@
|
|||||||
background: #757575;
|
background: #757575;
|
||||||
border-radius: 2.3px;
|
border-radius: 2.3px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
height: 5px;
|
height: 3px;
|
||||||
position: relative;
|
position: relative;
|
||||||
transition: 0.3s;
|
transition: 0.3s;
|
||||||
width: 32px;
|
width: 32px;
|
||||||
@@ -98,16 +101,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.logoLink {
|
.logoLink {
|
||||||
display: inline;
|
/*padding: 16px 0 8px;*/
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 80px;
|
width: 80px;
|
||||||
padding: 16px 0 8px;
|
padding-left: var(--Spacing-x1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.logo {
|
.logo {
|
||||||
width: 80px;
|
width: 80px;
|
||||||
object-fit: fill;
|
object-fit: fill;
|
||||||
}
|
}
|
||||||
|
|
||||||
.listWrapper {
|
.listWrapper {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border-top: 1px solid #e3e0db;
|
border-top: 1px solid #e3e0db;
|
||||||
@@ -228,10 +234,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.buttonContainer {
|
.buttonContainer {
|
||||||
display: flex;
|
/*display: flex;*/
|
||||||
|
/*justify-content: flex-end;*/
|
||||||
|
/*align-items: center;*/
|
||||||
|
/*margin-right: 8px;*/
|
||||||
|
display: inline-flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
|
gap: var(--Spacing-x3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (min-width: 950px) {
|
@media screen and (min-width: 950px) {
|
||||||
@@ -255,8 +266,8 @@
|
|||||||
.navBar {
|
.navBar {
|
||||||
grid-template-columns: 132.18px 1fr auto;
|
grid-template-columns: 132.18px 1fr auto;
|
||||||
align-content: center;
|
align-content: center;
|
||||||
padding-bottom: 2px;
|
/*padding-bottom: 2px;*/
|
||||||
|
padding: 0px 0px var(--Spacing-x-quarter) 0px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +286,7 @@
|
|||||||
.logo {
|
.logo {
|
||||||
width: 102.17px;
|
width: 102.17px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding-bottom: 4px;
|
padding-bottom: 4px; /* TODO: Needed? */
|
||||||
}
|
}
|
||||||
|
|
||||||
.listWrapper {
|
.listWrapper {
|
||||||
@@ -300,10 +311,16 @@
|
|||||||
|
|
||||||
.link {
|
.link {
|
||||||
background-image: none;
|
background-image: none;
|
||||||
font-family: Helvetica, Arial, sans-serif;
|
font-family: var(--typography-Body-Regular-fontFamily);
|
||||||
font-weight: 700;
|
font-size: var(--typography-Body-Regular-fontSize);
|
||||||
line-height: 1.15;
|
font-feature-settings:
|
||||||
|
"clig" off,
|
||||||
|
"liga" off;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 125%;
|
||||||
padding: 30px 15px;
|
padding: 30px 15px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: var(--text-black); /* Design system should return #404040 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.linkRow {
|
.linkRow {
|
||||||
@@ -322,6 +339,10 @@
|
|||||||
.buttonContainer {
|
.buttonContainer {
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.avatarButton {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 1200px) {
|
@media (min-width: 1200px) {
|
||||||
|
|||||||
@@ -4,6 +4,6 @@
|
|||||||
|
|
||||||
@media screen and (max-width: 950px) {
|
@media screen and (max-width: 950px) {
|
||||||
.header {
|
.header {
|
||||||
height: 50px;
|
height: 70.047px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,10 +19,14 @@ export default async function Header({
|
|||||||
}: LangParams & { languageSwitcher: React.ReactNode } & {
|
}: LangParams & { languageSwitcher: React.ReactNode } & {
|
||||||
myPagesMobileDropdown: React.ReactNode
|
myPagesMobileDropdown: React.ReactNode
|
||||||
}) {
|
}) {
|
||||||
const data = await serverClient().contentstack.base.header({
|
const [data, session] = await Promise.all([
|
||||||
lang,
|
serverClient().contentstack.base.header({
|
||||||
})
|
lang,
|
||||||
const session = await auth()
|
}),
|
||||||
|
auth(),
|
||||||
|
])
|
||||||
|
|
||||||
|
const user = !!session ? await serverClient().user.get() : null
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return null
|
return null
|
||||||
@@ -54,7 +58,7 @@ export default async function Header({
|
|||||||
languageSwitcher={languageSwitcher}
|
languageSwitcher={languageSwitcher}
|
||||||
myPagesMobileDropdown={myPagesMobileDropdown}
|
myPagesMobileDropdown={myPagesMobileDropdown}
|
||||||
bookingHref={homeHref}
|
bookingHref={homeHref}
|
||||||
isLoggedIn={!!session}
|
user={user}
|
||||||
lang={lang}
|
lang={lang}
|
||||||
/>
|
/>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import type {
|
|||||||
CurrentHeaderLink,
|
CurrentHeaderLink,
|
||||||
TopMenuHeaderLink,
|
TopMenuHeaderLink,
|
||||||
} from "@/types/requests/currentHeader"
|
} from "@/types/requests/currentHeader"
|
||||||
|
import { User } from "@/types/user"
|
||||||
|
|
||||||
export type MainMenuProps = {
|
export type MainMenuProps = {
|
||||||
frontpageLinkText: string
|
frontpageLinkText: string
|
||||||
@@ -15,6 +16,6 @@ export type MainMenuProps = {
|
|||||||
languageSwitcher: React.ReactNode | null
|
languageSwitcher: React.ReactNode | null
|
||||||
myPagesMobileDropdown: React.ReactNode | null
|
myPagesMobileDropdown: React.ReactNode | null
|
||||||
bookingHref: string
|
bookingHref: string
|
||||||
isLoggedIn: boolean
|
user: User | null
|
||||||
lang: Lang
|
lang: Lang
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user