# Add the "Header — Mega Menu" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/header-mega-menu) to this Pantheon Content Publisher (P1) Next.js project. Top-level items open full-width panels of grouped link columns with an intro and featured promo; phones get an accordion menu.

## Steps

1. Create `components/puck/header-mega-menu-block.tsx` with the exact file contents below. If `components/puck/` doesn't exist, find the folder where this project keeps its Puck components (look at the imports in `puck.config.tsx`) and put it there.
2. In `puck.config.tsx`, import it: `import { headerMegaMenuBlock } from "./components/puck/header-mega-menu-block";`
3. Register it under `components` as `HeaderMegaMenuBlock: headerMegaMenuBlock`.
4. Add `"HeaderMegaMenuBlock"` to the best-fitting entry in `categories` (this block's library category is "Headers"). Create a category only if none fits.
5. Run the project's type check (usually `pnpm typecheck`) and resolve anything project-specific.
6. If `package.json` has a `sync:registry` script, tell the user it must run (or that CI will run it) before the new component appears in the P1 editor.

## Rules

- Do not add dependencies. The block is self-contained by design: one type-only import from `@puckeditor/core`, Tailwind v4 classes, no client JavaScript.
- Keep the files as-is unless the user asks for changes. The accent color is `indigo-*`; if the project has brand colors, offer to swap them with a find-and-replace on `indigo-`.
- Images are plain `imageUrl` + `imageAlt` text fields. If this project defines a P1 media-library field (search for `"p1-media"`), offer to switch to it.
- Don't change prop names in `defaultProps`. Content editors' saved pages depend on them.

## File: `components/puck/header-mega-menu-block.tsx`

```tsx
import type { ComponentConfig } from "@puckeditor/core";

/**
 * Header (Mega Menu) — top-level items open a full-width panel of grouped link columns,
 * with an intro and an optional featured promo. Panels are native <details> (one open at a time),
 * and phones get an accordion menu. Register: `HeaderMegaMenuBlock: headerMegaMenuBlock` in puck.config.tsx.
 */

type MegaLink = { label: string; href: string };
type MegaGroup = { heading: string; links: MegaLink[] };
type MegaItem = {
  label: string;
  href: string;
  intro: string;
  groups: MegaGroup[];
  featureTitle: string;
  featureBody: string;
  featureHref: string;
};

export type HeaderMegaMenuProps = {
  logoText: string;
  logoImageUrl: string;
  logoImageAlt: string;
  logoHref: string;
  navLabel: string;
  items: MegaItem[];
  ctaLabel: string;
  ctaHref: string;
  menuLabel: string;
};

const focusRing = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600";

const arrow = (
  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4 shrink-0 transition group-hover/link:translate-x-0.5">
    <path fillRule="evenodd" d="M3 10a.75.75 0 0 1 .75-.75h10.64l-3.22-3.22a.75.75 0 1 1 1.06-1.06l4.5 4.5a.75.75 0 0 1 0 1.06l-4.5 4.5a.75.75 0 1 1-1.06-1.06l3.22-3.22H3.75A.75.75 0 0 1 3 10Z" clipRule="evenodd" />
  </svg>
);

const chevronPath = "M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z";

export const headerMegaMenuBlock: ComponentConfig<HeaderMegaMenuProps> = {
  label: "Header (Mega Menu)",
  fields: {
    logoText: { type: "text", label: "Site name" },
    logoImageUrl: { type: "text", label: "Logo image URL", metadata: { help: "Optional. Leave blank for a text wordmark." } },
    logoImageAlt: {
      type: "text",
      label: "Logo alt text",
      metadata: { help: "Leave blank when the site name shows next to the logo, so screen readers don't hear the name twice." },
    },
    logoHref: { type: "text", label: "Logo link", metadata: { help: "Usually / for the home page." } },
    navLabel: { type: "text", label: "Navigation name", metadata: { help: "Read by screen readers, like Main. Name each menu on a page differently." } },
    items: {
      type: "array",
      label: "Top-level items",
      min: 1,
      max: 6,
      getItemSummary: (item) => (item?.label ? `${item.label}${item?.groups?.length ? ` (${item.groups.length} columns)` : ""}` : "Item"),
      defaultItemProps: { label: "New item", href: "/", intro: "", groups: [], featureTitle: "", featureBody: "", featureHref: "" },
      arrayFields: {
        label: { type: "text", label: "Label" },
        href: { type: "text", label: "Link", metadata: { help: "With columns, this becomes the overview link inside the panel." } },
        intro: { type: "textarea", label: "Panel intro", metadata: { help: "One or two sentences at the start of the panel. Leave blank to hide it." } },
        groups: {
          type: "array",
          label: "Columns",
          min: 0,
          max: 3,
          getItemSummary: (item) => item?.heading || "Column",
          defaultItemProps: { heading: "New column", links: [{ label: "New page", href: "/" }] },
          arrayFields: {
            heading: { type: "text", label: "Column label" },
            links: {
              type: "array",
              label: "Links",
              min: 1,
              max: 8,
              getItemSummary: (item) => item?.label || "Link",
              defaultItemProps: { label: "New page", href: "/" },
              arrayFields: {
                label: { type: "text", label: "Label" },
                href: { type: "text", label: "Link" },
              },
            },
          },
          metadata: { help: "Leave empty for a plain link with no panel." },
        },
        featureTitle: { type: "text", label: "Feature title", metadata: { help: "A highlighted promo card at the end of the panel. Leave blank to hide it." } },
        featureBody: { type: "textarea", label: "Feature text" },
        featureHref: { type: "text", label: "Feature link" },
      },
    },
    ctaLabel: { type: "text", label: "Button text", metadata: { help: "Leave blank to hide the button." } },
    ctaHref: { type: "text", label: "Button link" },
    menuLabel: { type: "text", label: "Mobile menu label" },
  },
  defaultProps: {
    logoText: "Lakeshore State University",
    logoImageUrl: "",
    logoImageAlt: "",
    logoHref: "/",
    navLabel: "Main",
    items: [
      {
        label: "Academics",
        href: "/academics",
        intro: "More than 140 majors across six colleges, taught in classes that average 24 students.",
        groups: [
          {
            heading: "Study",
            links: [
              { label: "Undergraduate majors", href: "/academics/majors" },
              { label: "Graduate programs", href: "/academics/graduate" },
              { label: "Online & evening", href: "/academics/online" },
              { label: "Certificates", href: "/academics/certificates" },
            ],
          },
          {
            heading: "Colleges",
            links: [
              { label: "Arts & Sciences", href: "/colleges/arts-sciences" },
              { label: "Business", href: "/colleges/business" },
              { label: "Education", href: "/colleges/education" },
              { label: "Nursing & Health", href: "/colleges/nursing" },
            ],
          },
          {
            heading: "Support",
            links: [
              { label: "Academic calendar", href: "/calendar" },
              { label: "Advising", href: "/advising" },
              { label: "Libraries", href: "/libraries" },
              { label: "Tutoring center", href: "/tutoring" },
            ],
          },
        ],
        featureTitle: "Sit in on a class",
        featureBody: "Admitted students can join a lecture in their intended major any weekday this spring.",
        featureHref: "/visit/class",
      },
      {
        label: "Admissions",
        href: "/admissions",
        intro: "Apply free through March 1. Most first-year students receive a scholarship.",
        groups: [
          {
            heading: "Apply",
            links: [
              { label: "First-year", href: "/admissions/first-year" },
              { label: "Transfer", href: "/admissions/transfer" },
              { label: "International", href: "/admissions/international" },
              { label: "Returning adults", href: "/admissions/adult" },
            ],
          },
          {
            heading: "Afford",
            links: [
              { label: "Tuition & costs", href: "/tuition" },
              { label: "Scholarships", href: "/scholarships" },
              { label: "Financial aid", href: "/aid" },
            ],
          },
        ],
        featureTitle: "Visit campus",
        featureBody: "Student-led tours leave the Welcome Center weekdays at 10 a.m. and 2 p.m.",
        featureHref: "/visit",
      },
      {
        label: "Research",
        href: "/research",
        intro: "",
        groups: [
          {
            heading: "Explore",
            links: [
              { label: "Centers & institutes", href: "/research/centers" },
              { label: "Undergraduate research", href: "/research/undergraduate" },
              { label: "Great Lakes Water Lab", href: "/research/water" },
            ],
          },
        ],
        featureTitle: "",
        featureBody: "",
        featureHref: "",
      },
      { label: "Campus life", href: "/life", intro: "", groups: [], featureTitle: "", featureBody: "", featureHref: "" },
      { label: "About", href: "/about", intro: "", groups: [], featureTitle: "", featureBody: "", featureHref: "" },
    ],
    ctaLabel: "Apply",
    ctaHref: "/apply",
    menuLabel: "Menu",
  },
  render: ({ id, logoText, logoImageUrl, logoImageAlt, logoHref, navLabel, items, ctaLabel, ctaHref, menuLabel }) => {
    const list = (items ?? []).filter((i) => i?.label);
    const label = navLabel || "Main";
    const uid = `mega-${id}`;
    const groupsOf = (item: MegaItem) => (item.groups ?? []).filter((g) => g?.heading || (g?.links ?? []).some((l) => l?.label));
    const linksOf = (g: MegaGroup) => (g.links ?? []).filter((l) => l?.label);

    const cta = (extra: string) =>
      ctaLabel ? (
        <a
          href={ctaHref || "#"}
          className={`min-h-11 items-center justify-center rounded-lg bg-indigo-600 px-5 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-indigo-700 ${focusRing} ${extra}`}
        >
          {ctaLabel}
        </a>
      ) : null;

    return (
      <header className="relative z-30 border-b border-neutral-200 bg-white">
        <div className="mx-auto flex min-h-16 max-w-7xl items-center justify-between gap-6 px-4 py-2 sm:px-6 lg:min-h-20 lg:px-8">
          {logoText || logoImageUrl ? (
            <a href={logoHref || "/"} className={`-m-1.5 inline-flex min-h-11 min-w-0 items-center gap-3 rounded-lg p-1.5 ${focusRing}`}>
              {logoImageUrl ? <img src={logoImageUrl} alt={logoImageAlt || ""} className="h-9 w-auto shrink-0" /> : null}
              {logoText ? <span className="text-base leading-tight font-semibold tracking-tight text-balance sm:text-lg text-neutral-950">{logoText}</span> : null}
            </a>
          ) : (
            <span />
          )}

          {list.length ? (
            <nav aria-label={label} className="hidden lg:block">
              <ul role="list" className="flex items-center gap-1">
                {list.map((item, i) => {
                  const groups = groupsOf(item);
                  const top = `inline-flex min-h-11 items-center gap-1 rounded-lg px-3 text-sm font-semibold text-neutral-800 transition hover:bg-neutral-100 hover:text-neutral-950 ${focusRing}`;
                  if (!groups.length) {
                    return (
                      <li key={`${item.label}-${i}`}>
                        <a href={item.href || "#"} className={top}>
                          {item.label}
                        </a>
                      </li>
                    );
                  }
                  const hasFeature = Boolean(item.featureTitle);
                  return (
                    <li key={`${item.label}-${i}`}>
                      <details name={uid} className="group/panel">
                        <summary className={`${top} cursor-pointer list-none group-open/panel:bg-indigo-50 group-open/panel:text-indigo-800 [&::-webkit-details-marker]:hidden`}>
                          {item.label}
                          <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 text-neutral-500 transition group-open/panel:rotate-180 group-open/panel:text-indigo-700">
                            <path fillRule="evenodd" d={chevronPath} clipRule="evenodd" />
                          </svg>
                        </summary>
                        <div className="absolute inset-x-0 top-full z-40 border-t border-neutral-200 bg-white shadow-2xl shadow-neutral-950/10">
                          <div className="mx-auto grid max-w-7xl grid-cols-1 gap-10 px-8 py-10 lg:grid-cols-12">
                            <div className="lg:col-span-3">
                              <p className="text-2xl font-semibold tracking-tight text-neutral-950">{item.label}</p>
                              {item.intro ? <p className="mt-3 text-sm leading-6 text-pretty text-neutral-600">{item.intro}</p> : null}
                              {item.href ? (
                                <a href={item.href} className={`group/link mt-5 inline-flex min-h-11 items-center gap-1.5 rounded text-sm font-semibold text-indigo-700 hover:text-indigo-900 ${focusRing}`}>
                                  {item.label} overview
                                  {arrow}
                                </a>
                              ) : null}
                            </div>
                            <div className={`grid grid-cols-1 gap-8 sm:grid-cols-3 lg:border-l lg:border-neutral-200 lg:pl-10 ${hasFeature ? "lg:col-span-6" : "lg:col-span-9"}`}>
                              {groups.map((g, j) => {
                                const gid = `${uid}-${i}-${j}`;
                                return (
                                  <div key={`${g.heading}-${j}`}>
                                    {g.heading ? (
                                      <p id={gid} className="text-xs font-semibold tracking-widest text-neutral-500 uppercase">
                                        {g.heading}
                                      </p>
                                    ) : null}
                                    <ul role="list" aria-labelledby={g.heading ? gid : undefined} className={g.heading ? "mt-3" : ""}>
                                      {linksOf(g).map((l, k) => (
                                        <li key={`${l.label}-${k}`}>
                                          <a href={l.href || "#"} className={`-mx-2 flex min-h-11 items-center rounded-md px-2 text-sm font-medium text-neutral-800 transition hover:bg-neutral-50 hover:text-indigo-700 ${focusRing}`}>
                                            {l.label}
                                          </a>
                                        </li>
                                      ))}
                                    </ul>
                                  </div>
                                );
                              })}
                            </div>
                            {hasFeature ? (
                              <a
                                href={item.featureHref || item.href || "#"}
                                className={`group/link relative isolate flex flex-col justify-end overflow-hidden rounded-2xl bg-indigo-950 p-6 lg:col-span-3 ${focusRing}`}
                              >
                                <svg aria-hidden="true" viewBox="0 0 200 200" fill="none" stroke="currentColor" strokeWidth="1" className="absolute -top-16 -right-16 -z-10 size-56 text-indigo-400/30">
                                  <circle cx="100" cy="100" r="30" />
                                  <circle cx="100" cy="100" r="55" />
                                  <circle cx="100" cy="100" r="80" />
                                </svg>
                                <span className="text-lg font-semibold text-white">{item.featureTitle}</span>
                                {item.featureBody ? <span className="mt-2 text-sm leading-6 text-indigo-100">{item.featureBody}</span> : null}
                                <span className="mt-5 inline-flex items-center gap-1.5 text-sm font-semibold text-white">
                                  Learn more
                                  {arrow}
                                </span>
                              </a>
                            ) : null}
                          </div>
                        </div>
                      </details>
                    </li>
                  );
                })}
              </ul>
            </nav>
          ) : null}

          <div className="flex shrink-0 items-center gap-2">
            {cta("hidden sm:inline-flex")}
            {list.length || ctaLabel ? (
              <details className="group/menu lg:hidden">
                <summary
                  className={`inline-flex min-h-11 cursor-pointer list-none items-center gap-2 rounded-lg px-3 text-sm font-semibold text-neutral-900 ring-1 ring-neutral-300 ring-inset hover:bg-neutral-50 [&::-webkit-details-marker]:hidden ${focusRing}`}
                >
                  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 group-open/menu:hidden">
                    <path fillRule="evenodd" d="M2 4.75A.75.75 0 0 1 2.75 4h14.5a.75.75 0 0 1 0 1.5H2.75A.75.75 0 0 1 2 4.75ZM2 10a.75.75 0 0 1 .75-.75h14.5a.75.75 0 0 1 0 1.5H2.75A.75.75 0 0 1 2 10Zm0 5.25a.75.75 0 0 1 .75-.75h14.5a.75.75 0 0 1 0 1.5H2.75a.75.75 0 0 1-.75-.75Z" clipRule="evenodd" />
                  </svg>
                  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="hidden size-5 group-open/menu:block">
                    <path d="M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z" />
                  </svg>
                  {menuLabel || "Menu"}
                </summary>
                <div className="absolute inset-x-0 top-full z-40 max-h-svh overflow-y-auto border-b border-neutral-200 bg-white px-4 pt-2 pb-6 shadow-lg sm:px-6">
                  {list.length ? (
                    <nav aria-label={`${label} (mobile)`}>
                      <ul role="list" className="divide-y divide-neutral-100">
                        {list.map((item, i) => {
                          const groups = groupsOf(item);
                          if (!groups.length) {
                            return (
                              <li key={`${item.label}-${i}`}>
                                <a href={item.href || "#"} className={`flex min-h-12 items-center rounded-lg px-3 text-base font-semibold text-neutral-900 hover:bg-neutral-50 ${focusRing}`}>
                                  {item.label}
                                </a>
                              </li>
                            );
                          }
                          return (
                            <li key={`${item.label}-${i}`}>
                              <details className="group/sub">
                                <summary
                                  className={`flex min-h-12 cursor-pointer list-none items-center justify-between rounded-lg px-3 text-base font-semibold text-neutral-900 hover:bg-neutral-50 [&::-webkit-details-marker]:hidden ${focusRing}`}
                                >
                                  {item.label}
                                  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 text-neutral-500 transition group-open/sub:rotate-180">
                                    <path fillRule="evenodd" d={chevronPath} clipRule="evenodd" />
                                  </svg>
                                </summary>
                                <div className="px-3 pb-4">
                                  {item.href ? (
                                    <a href={item.href} className={`group/link flex min-h-11 items-center gap-1.5 rounded text-sm font-semibold text-indigo-700 ${focusRing}`}>
                                      {item.label} overview
                                      {arrow}
                                    </a>
                                  ) : null}
                                  {groups.map((g, j) => {
                                    const gid = `${uid}-m-${i}-${j}`;
                                    return (
                                      <div key={`${g.heading}-${j}`} className="mt-3">
                                        {g.heading ? (
                                          <p id={gid} className="text-xs font-semibold tracking-widest text-neutral-500 uppercase">
                                            {g.heading}
                                          </p>
                                        ) : null}
                                        <ul role="list" aria-labelledby={g.heading ? gid : undefined} className="mt-1 border-l border-neutral-200 pl-3">
                                          {linksOf(g).map((l, k) => (
                                            <li key={`${l.label}-${k}`}>
                                              <a href={l.href || "#"} className={`flex min-h-11 items-center rounded-lg px-2 text-base text-neutral-700 hover:bg-neutral-50 hover:text-neutral-950 ${focusRing}`}>
                                                {l.label}
                                              </a>
                                            </li>
                                          ))}
                                        </ul>
                                      </div>
                                    );
                                  })}
                                </div>
                              </details>
                            </li>
                          );
                        })}
                      </ul>
                    </nav>
                  ) : null}
                  {ctaLabel ? <div className="mt-4 grid grid-cols-1 sm:hidden">{cta("flex text-base")}</div> : null}
                </div>
              </details>
            ) : null}
          </div>
        </div>
      </header>
    );
  },
};
```
