From c078bb054af193cf22e5d09720867ecb7ee473c1 Mon Sep 17 00:00:00 2001 From: MagzyPotato Date: Tue, 28 Oct 2025 14:28:30 +0100 Subject: [PATCH] Fix dropdown for mobile in header.tsx --- components/header/header.tsx | 124 ++++++++++++++++++++++++----------- 1 file changed, 85 insertions(+), 39 deletions(-) diff --git a/components/header/header.tsx b/components/header/header.tsx index 2c304a6..c51e624 100644 --- a/components/header/header.tsx +++ b/components/header/header.tsx @@ -12,7 +12,7 @@ import { DropdownTrigger, DropdownMenu, DropdownItem, - Button as HeroUIButton + Button as HeroUIButton, } from "@heroui/react" import { useEffect, useState } from "react" import Image from "next/image" @@ -73,7 +73,10 @@ const Header: Component = () => { {paths.map((item, index) => { if (item.subpaths === undefined) { - return + return ( + { {item.name} + ) } else { // eslint-disable-next-line react/jsx-key - return - - - - {item.name} - - - - - {item.subpaths.map(subitem => - - {subitem.name} - - )} - - + return ( + + + + + {item.name} + + + + + {item.subpaths.map(subitem => ( + + {subitem.name} + + ))} + + + ) } })} @@ -121,20 +128,59 @@ const Header: Component = () => { {/*Innholdet i hamburgermeny - Vises bare på små skjermer*/} -
- {paths.map((item, index) => ( - - - {item.icon} +
+ {paths.map((item, index) => { + if (!item.subpaths) { + return ( + + setIsMenuOpen(false)}> + {item.icon} + {item.name} + + + ) + } + return ( +
+
+ + + {item.icon} + {item.name} + + + + + - {item.name} - - - ))} +
+ {item.subpaths.map(subitem => ( + setIsMenuOpen(false)}> + {subitem.name} + + ))} +
+
+
+ ) + })}