diff --git a/components/Header/MainMenu/MenuButton/index.tsx b/components/Header/MainMenu/MenuButton/index.tsx new file mode 100644 index 000000000..f0ee1f2f1 --- /dev/null +++ b/components/Header/MainMenu/MenuButton/index.tsx @@ -0,0 +1,11 @@ +import styles from "./menuButton.module.css" + +export default function MenuButton({ + className, + ...props +}: React.ButtonHTMLAttributes) { + const classNames = className + ? `${styles.menuButton} ${className}` + : styles.menuButton + return + ) : ( {title} diff --git a/components/Header/MainMenu/MenuItem/menuItem.module.css b/components/Header/MainMenu/MenuItem/menuItem.module.css index 4b8afc4de..c743f0649 100644 --- a/components/Header/MainMenu/MenuItem/menuItem.module.css +++ b/components/Header/MainMenu/MenuItem/menuItem.module.css @@ -1,17 +1,3 @@ -.navigationButton { - display: flex; - gap: var(--Spacing-x1); - align-items: center; - background-color: transparent; - color: var(--Base-Text-High-contrast); - border-width: 0; - padding: 0; - cursor: pointer; - font-family: var(--typography-Body-Bold-fontFamily); - font-weight: var(--typography-Body-Bold-fontWeight); - font-size: var(--typography-Body-Bold-fontSize); -} - .chevron { transition: transform 0.2s; } diff --git a/components/Header/MainMenu/User/Avatar/avatar.module.css b/components/Header/MainMenu/MyPages/Avatar/avatar.module.css similarity index 100% rename from components/Header/MainMenu/User/Avatar/avatar.module.css rename to components/Header/MainMenu/MyPages/Avatar/avatar.module.css diff --git a/components/Header/MainMenu/User/Avatar/avatar.ts b/components/Header/MainMenu/MyPages/Avatar/avatar.ts similarity index 77% rename from components/Header/MainMenu/User/Avatar/avatar.ts rename to components/Header/MainMenu/MyPages/Avatar/avatar.ts index 6156e0bbe..1cb269879 100644 --- a/components/Header/MainMenu/User/Avatar/avatar.ts +++ b/components/Header/MainMenu/MyPages/Avatar/avatar.ts @@ -2,5 +2,5 @@ import { ImageProps } from "next/image" export interface AvatarProps { image?: ImageProps - initials?: string + initials?: string | null } diff --git a/components/Header/MainMenu/User/Avatar/index.tsx b/components/Header/MainMenu/MyPages/Avatar/index.tsx similarity index 100% rename from components/Header/MainMenu/User/Avatar/index.tsx rename to components/Header/MainMenu/MyPages/Avatar/index.tsx diff --git a/components/Header/MainMenu/MyPages/index.tsx b/components/Header/MainMenu/MyPages/index.tsx new file mode 100644 index 000000000..580d9b1a3 --- /dev/null +++ b/components/Header/MainMenu/MyPages/index.tsx @@ -0,0 +1,53 @@ +"use client" + +import Link from "next/link" +import { useIntl } from "react-intl" + +import { myPages } from "@/constants/routes/myPages" +import { navigationQueryRouter } from "@/server/routers/contentstack/myPages/navigation/query" +import useDropdownStore from "@/stores/main-menu" + +import { ChevronDownIcon } from "@/components/Icons" +import useLang from "@/hooks/useLang" +import { getInitials } from "@/utils/user" + +import MenuButton from "../MenuButton" +import MyPagesMenu from "../MyPagesMenu" +import Avatar from "./Avatar" + +import styles from "./myPages.module.css" + +import { User } from "@/types/user" + +export default function MyPages({ + myPagesNavigation, + user, +}: { + myPagesNavigation: Awaited> + user: Pick | null +}) { + const intl = useIntl() + const lang = useLang() + + const { toggleMyPagesMobileMenu, isMyPagesMobileMenuOpen } = + useDropdownStore() + + return user ? ( + <> + + + {intl.formatMessage({ id: "Hi" })} {user.firstName}! + + + + + ) : ( + + + {intl.formatMessage({ id: "Log in/Join" })} + + ) +} diff --git a/components/Header/MainMenu/MyPages/myPages.module.css b/components/Header/MainMenu/MyPages/myPages.module.css new file mode 100644 index 000000000..2a5bc7a33 --- /dev/null +++ b/components/Header/MainMenu/MyPages/myPages.module.css @@ -0,0 +1,11 @@ +.button { + font-weight: 600; +} + +.chevron { + transition: transform 0.2s; +} + +.chevron.isExpanded { + transform: rotate(180deg); +} diff --git a/components/Header/MainMenu/MyPagesMenu/index.tsx b/components/Header/MainMenu/MyPagesMenu/index.tsx new file mode 100644 index 000000000..3d4e1ebf4 --- /dev/null +++ b/components/Header/MainMenu/MyPagesMenu/index.tsx @@ -0,0 +1,83 @@ +"use client" +import { useIntl } from "react-intl" + +import { logout } from "@/constants/routes/handleAuth" +import { navigationQueryRouter } from "@/server/routers/contentstack/myPages/navigation/query" +import useDropdownStore from "@/stores/main-menu" + +import { ArrowRightIcon } from "@/components/Icons" +import Link from "@/components/TempDesignSystem/Link" +import useLang from "@/hooks/useLang" + +import styles from "./myPagesMenu.module.css" + +type Navigation = Awaited> + +export default function MyPagesMenu({ + navigation, +}: { + navigation: Navigation +}) { + const { formatMessage } = useIntl() + const lang = useLang() + const { toggleMyPagesMobileMenu, isMyPagesMobileMenuOpen } = + useDropdownStore() + + if (!navigation) { + return null + } + + console.log(navigation) + + return ( + + ) +} diff --git a/components/Header/MainMenu/MyPagesMenu/myPagesMenu.module.css b/components/Header/MainMenu/MyPagesMenu/myPagesMenu.module.css new file mode 100644 index 000000000..94f096a6f --- /dev/null +++ b/components/Header/MainMenu/MyPagesMenu/myPagesMenu.module.css @@ -0,0 +1,58 @@ +.myPagesMenu { + position: absolute; + top: 46px; + right: 0; + background-color: #fff; + border-top: 1px solid #e3e0db; + display: none; + list-style: none; + overflow-y: visible; + margin: 0; + padding: var(--Spacing-x2) var(--Spacing-x4); + border-radius: var(--Corner-radius-Large); + box-shadow: 0px 0px 14px 6px #0000001a; +} + +.myPagesMenu.isExpanded { + display: block; +} + +.friendTypeWrapper { + padding: 0 var(--Spacing-x1) var(--Spacing-x2); + font-weight: 400; + color: var(--UI-Text-Medium-contrast); +} +.friendType { + font-family: var(--typography-Title-5-fontFamily); + letter-spacing: var(--typography-Title-5-letterSpacing); + font-size: var(--typography-Caption-Bold-fontSize); + text-transform: uppercase; +} + +.friendType::after { + content: " ยท "; + display: inline; + padding: 0 var(--Spacing-x-half); +} + +.groups, +.menuItems { + list-style: none; +} + +.group { + padding: var(--Spacing-x2) 0; + border-top: 1px solid var(--Base-Border-Subtle); +} + +.group:last-child { + padding-bottom: 0; +} + +.arrow { + opacity: 0; +} + +.link:hover .arrow { + opacity: 1; +} diff --git a/components/Header/MainMenu/User/index.tsx b/components/Header/MainMenu/User/index.tsx deleted file mode 100644 index d26bc1173..000000000 --- a/components/Header/MainMenu/User/index.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import Link from "next/link" - -import Avatar from "./Avatar" - -import styles from "./user.module.css" - -export default function User() { - return ( -
- - - Log in/Join - -
- ) -} diff --git a/components/Header/MainMenu/User/user.module.css b/components/Header/MainMenu/User/user.module.css deleted file mode 100644 index c43fa17fe..000000000 --- a/components/Header/MainMenu/User/user.module.css +++ /dev/null @@ -1,12 +0,0 @@ -.user { -} - -.link { - display: flex; - gap: var(--Spacing-x1); - align-items: center; - font-family: var(--typography-Body-Bold-fontFamily); - font-weight: 600; - color: var(--Base-Text-High-contrast); - text-decoration: none; -} diff --git a/components/Header/MainMenu/index.tsx b/components/Header/MainMenu/index.tsx index d0b85ceb4..d16f829f1 100644 --- a/components/Header/MainMenu/index.tsx +++ b/components/Header/MainMenu/index.tsx @@ -1,9 +1,11 @@ import Link from "next/link" +import { serverClient } from "@/lib/trpc/server" + import Image from "@/components/Image" import Menu from "./Menu" -import User from "./User" +import MyPages from "./MyPages" import styles from "./mainMenu.module.css" @@ -29,6 +31,11 @@ export interface MenuItem { } export default async function MainMenu() { + const myPagesNavigation = + await serverClient().contentstack.myPages.navigation.get() + + const user = await serverClient().user.name() + const menuItems: MenuItem[] = [ { id: "hotels", @@ -118,7 +125,7 @@ export default async function MainMenu() { /> - + ) diff --git a/components/Header/MainMenu/mainMenu.module.css b/components/Header/MainMenu/mainMenu.module.css index e58ac423c..99a9a67e7 100644 --- a/components/Header/MainMenu/mainMenu.module.css +++ b/components/Header/MainMenu/mainMenu.module.css @@ -1,11 +1,11 @@ .mainMenu { background-color: var(--Base-Surface-Primary-light-Normal); padding: var(--Spacing-x2); - border-top: 1px solid var(--Base-Border-Subtle); border-bottom: 1px solid var(--Base-Border-Subtle); } .content { + position: relative; max-width: 89.5rem; margin: 0 auto; display: flex; diff --git a/components/Header/TopMenu/topMenu.module.css b/components/Header/TopMenu/topMenu.module.css index 4d86f55d2..f23170779 100644 --- a/components/Header/TopMenu/topMenu.module.css +++ b/components/Header/TopMenu/topMenu.module.css @@ -1,6 +1,7 @@ .topMenu { background-color: var(--Base-Surface-Subtle-Normal); padding: var(--Spacing-x2) var(--Spacing-x-one-and-half); + border-bottom: 1px solid var(--Base-Border-Subtle); } .content { diff --git a/components/Header/header.module.css b/components/Header/header.module.css index a3d728549..54032e59b 100644 --- a/components/Header/header.module.css +++ b/components/Header/header.module.css @@ -1,4 +1,6 @@ .header { + position: relative; font-family: var(--typography-Body-Regular-fontFamily); color: var(--Base-Text-High-contrast); + z-index: 1; } diff --git a/components/TempDesignSystem/Link/link.module.css b/components/TempDesignSystem/Link/link.module.css index d7f157a30..3fc3b2582 100644 --- a/components/TempDesignSystem/Link/link.module.css +++ b/components/TempDesignSystem/Link/link.module.css @@ -41,26 +41,18 @@ font-family: var(--typography-Body-Regular-fontFamily); font-size: var(--typography-Body-Regular-fontSize); line-height: var(--typography-Body-Regular-lineHeight); - letter-spacing: 0.096px; - padding: var(--Spacing-x1) var(--Spacing-x1) var(--Spacing-x1) - var(--Spacing-x-one-and-half); - width: 100%; + letter-spacing: var(--typography-Body-Regular-letterSpacing); + padding: var(--Spacing-x1); border-radius: var(--Corner-radius-Medium); - gap: 4px; display: flex; + gap: var(--Spacing-x1); + justify-content: space-between; align-items: center; - gap: 4px; - align-self: stretch; } -.myPageMobileDropdown.active { - background-color: var(--Scandic-Brand-Pale-Peach); +.myPageMobileDropdown:hover { + background-color: var(--Base-Surface-Primary-light-Hover-alt); border-radius: var(--Corner-radius-Medium); - font-family: var(--typography-Body-Underline-fontFamily); - font-size: var(--typography-Body-Underline-fontSize); - font-weight: var(--typography-Body-Underline-fontWeight); - letter-spacing: var(--typography-Body-Underline-letterSpacing); - line-height: var(--typography-Body-Underline-lineHeight); } .shortcut { diff --git a/i18n/dictionaries/en.json b/i18n/dictionaries/en.json index 89a87b728..6a8459041 100644 --- a/i18n/dictionaries/en.json +++ b/i18n/dictionaries/en.json @@ -84,8 +84,10 @@ "Level 5": "Level 5", "Level 6": "Level 6", "Level 7": "Level 7", + "Hi": "Hi", "Level up to unlock": "Level up to unlock", "Log in": "Log in", + "Log in/Join": "Log in/Join", "Log in here": "Log in here", "Log out": "Log out", "Manage preferences": "Manage preferences", diff --git a/stores/main-menu.ts b/stores/main-menu.ts index cbd6f1004..68d4d2ba1 100644 --- a/stores/main-menu.ts +++ b/stores/main-menu.ts @@ -21,6 +21,7 @@ const useDropdownStore = create((set) => ({ toggleMyPagesMobileMenu: () => set((state) => { // Close the other dropdown if it's open + console.log({ state }) if (!state.isMyPagesMobileMenuOpen && state.isHamburgerMenuOpen) { set({ isHamburgerMenuOpen: false }) }