Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Megamenu - Fix mega menu not appearing on app router pages #3133

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/components/MenuWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from "react";
type MenuWrapperProps = {
children: React.ReactNode;
};
export const MenuWrapper = (props: MenuWrapperProps) => {
return <div className="mx-auto max-w-9xl px-8">{props.children}</div>;
};
19 changes: 11 additions & 8 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Open_Sans } from "next/font/google";
// import Head from "next/head";
// import { Theme } from "../components/layout/theme";
import { Footer } from "@/components/layout/footer/footer";
import { MenuWrapper } from "@/components/server/MenuWrapper";
import { MegaMenuWrapper } from "@/components/server/MegaMenuWrapper";
import ChatBaseBot from "@/components/zendeskButton/chatBaseBot";
import { Metadata, Viewport } from "next";

Expand All @@ -21,6 +21,7 @@ import timezone from "dayjs/plugin/timezone";
import utc from "dayjs/plugin/utc";
import { Suspense } from "react";
import client from "../tina/__generated__/client";
import { MenuWrapper } from "./components/MenuWrapper";
import { LiveStream } from "./live-steam-banner/live-stream";
import { DEFAULT } from "./meta-data/default";
import { getMegamenu } from "./utils/get-mega-menu";
Expand Down Expand Up @@ -57,12 +58,10 @@ export default async function RootLayout({
top: 1,
calendarType: "User Groups",
});

const liveStreamData: EventInfoStatic =
nextUG?.data?.eventsCalendarConnection?.edges?.length > 0
? nextUG?.data?.eventsCalendarConnection?.edges[0]?.node
: null;

return (
<html lang="en" className={openSans.className}>
<body>
Expand All @@ -75,13 +74,17 @@ export default async function RootLayout({
)}
>
<header className="no-print">
<Suspense>
{liveStreamData && (
{liveStreamData ? (
<Suspense>
<LiveStream event={liveStreamData}>
<MenuWrapper menu={menuData.data.megamenu.menuGroups} />
<MegaMenuWrapper menu={menuData.data.megamenu.menuGroups} />
</LiveStream>
)}
</Suspense>
</Suspense>
) : (
<MenuWrapper>
<MegaMenuWrapper menu={menuData.data.megamenu.menuGroups} />
</MenuWrapper>
)}
</header>
<main className="grow bg-white">{children}</main>

Expand Down
5 changes: 3 additions & 2 deletions app/live-steam-banner/live-stream.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import { MenuWrapper } from "app/components/MenuWrapper";
import dayjs from "dayjs";
import advancedFormat from "dayjs/plugin/advancedFormat";
import isBetween from "dayjs/plugin/isBetween";
Expand Down Expand Up @@ -110,7 +111,7 @@ export function LiveStream({ event, children }: LiveStreamProps) {
isLive={!!isLive}
/>
)}
<div className="mx-auto max-w-9xl px-8">
<MenuWrapper>
{(isLive || params.get("liveStream")) && (
<LiveStreamWidget
{...{ eventDynamic, liveStreamDelayMinutes }}
Expand All @@ -119,7 +120,7 @@ export function LiveStream({ event, children }: LiveStreamProps) {
/>
)}
{children}
</div>
</MenuWrapper>
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import classNames from "classnames";
import { MegaMenuLayout } from "ssw.megamenu";
import { CustomLink } from "../customLink";

export function MenuWrapper(props) {
export function MegaMenuWrapper(props) {
return (
<MegaMenuLayout
menuBarItems={props.menu}
Expand Down
Loading