diff --git a/src/components/Header.astro b/src/components/Header.astro index 3c6c9dd..31f239d 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -1,5 +1,34 @@ --- -import NavItem from "./navigation/NavItem.astro"; +import type { NavItem } from "../types"; +import HeaderNavigation from "./HeaderNavigation.astro"; + +const NAVIGATION: NavItem[] = [ + { + title: "Om TG", + path: "/about", + items: [ + { title: "Bli utstiller", path: "/about/expo" }, + { title: "Bli sponsor", path: "/about/sponsor" }, + ], + }, + { + title: "Billetter", + path: "/tickets", + items: [ + { title: "Vilkår", path: "/tickets/terms-and-conditions" }, + { title: "Arrangementsregler", path: "/event/rules" }, + { title: "Konstruksjonsregler", path: "/event/construction-rules" }, + ], + }, + { + title: "Konkurranser", + items: [ + { title: "Kreative", path: "/competitions/creative" }, + { title: "Esport", path: "/competitions/esport" }, + ], + }, + { title: "Kontakt oss", path: "/contact" }, +]; --- + + diff --git a/src/components/navigation/NavItem.astro b/src/components/navigation/NavItem.astro index 0168c21..3bdade3 100644 --- a/src/components/navigation/NavItem.astro +++ b/src/components/navigation/NavItem.astro @@ -1,37 +1,36 @@ --- -export interface Props { - title: string; - path?: string; - subAlignment?: "left" | "right"; - subItems?: SubItem[]; +import type { NavItem } from "../../types"; +export interface Props extends NavItem { class?: string; -} -interface SubItem { - title: string; - path: string; + subAlignment?: "left" | "right"; + interactionMode?: "click" | "hover"; + hamburger?: boolean; } const { title, path, - subItems = [], + items = [], subAlignment = "left", class: className = "", + interactionMode = "click", + hamburger = false, } = Astro.props; + const key = `${title.toLowerCase().replace(" ", "-")}-${path || ""}`; const clickable = !!path; -const expandable = !!subItems.length; +const expandable = !!items.length; const TextContainer = clickable ? "a" : "span"; const isActive = path === Astro.url.pathname || - subItems.some((item) => item.path === Astro.url.pathname); + items.some((item) => item.path === Astro.url.pathname); -const subItemsWithParent: Array< - SubItem & { +const itemsWithParent: Array< + NavItem & { touchOnly?: boolean; } -> = path ? [{ path, title, touchOnly: true }, ...subItems] : subItems; +> = path ? [{ path, title, touchOnly: true }, ...items] : items; ---
  • - + {title} { @@ -122,7 +127,7 @@ const subItemsWithParent: Array< data-part="trigger" aria-controls={`nav-item-sub-${key}`} aria-expanded="false" - class="block p-1 ml-auto rounded group-[.touch-device]:bg-neutral-800" + class="block p-1 ml-auto rounded group-[.interaction-mode-click]:bg-neutral-800" > - {subItemsWithParent.map((subItem) => ( + {itemsWithParent.map((subItem) => (