'use client' import styles from './styles.module.scss' import MenuIcon from './menu.svg' import Image from 'next/image' import classNames from 'classnames' import { MegaMenuItemProps, Menu as MenuType, MenuItem as MenuItemType, SimpleItemProps } from './menu.types' import { Logo } from '@/components/Logo/Logo' import { Fragment, useCallback, useState } from 'react' import { MegaMenu } from '@/components/MegaMenu/MegaMenu' import { CollapsibleArrow } from '@/components/CollapsibleArrow/CollapsibleArrow' import Link from 'next/link' /** * Represents a simple item component. * * @param {Object} SimpleItemProps - The properties for the SimpleItem component. * @param {string} SimpleItemProps.text - The text to display for the item. * @param {string} SimpleItemProps.href - The URL to navigate to when the item is clicked. * @param {string} SimpleItemProps.type - The type of the item ("default" or "button"). * @param {function} SimpleItemProps.onItemClick - The function to call when the item is clicked. * @returns {JSX.Element} A Link component with the specified text, href, type, and onItemClick function. */ const SimpleItem = ({text, href, type, onItemClick}: SimpleItemProps) => { const className = classNames({ [styles.menuLink]: type === "default", [styles.button]: type === "button" }); return ( {text} ) } /** * Represents a mega menu item component. * @param {Object} MegaMenuItemProps - The props for the MegaMenuItem component. * @param {string} MegaMenuItemProps.text - The text to display in the menu item. * @param {string} MegaMenuItemProps.quote - The quote to display in the mega menu. * @param {string} MegaMenuItemProps.source - The source of the quote. * @param {Array} MegaMenuItemProps.groups - The groups associated with the menu item. * @param {Function} MegaMenuItemProps.onItemClick - The function to handle item click event. * @returns {JSX.Element} A JSX element representing the MegaMenuItem component. */ const MegaMenuItem = ({text, quote, source, groups, onItemClick}: MegaMenuItemProps) => { const [isActive, setIsActive] = useState(false); const itemClicked = useCallback(() => { setIsActive(false); if (onItemClick) { onItemClick(); } }, [setIsActive, onItemClick]); return ( setIsActive(true)} onMouseLeave={() => setIsActive(false)} > {text}
) } type MenuItemsProps = { items: MenuItemType[] onItemClick: () => void } /** * Renders a list of menu items based on the provided props. * * @param {Object} items - An array of menu items to render. * @param {Function} onItemClick - Callback function to handle item click events. */ const MenuItems = ({items, onItemClick}: MenuItemsProps) => { return ( <> {items.map(item => ( { item.blockType === "simple-item" && } { item.blockType === "mega-menu" && } ) )} ) } type MenuProps = { menu: MenuType } /** * Represents a menu component that displays navigation items on the screen. * @param {Object} MenuProps - The props object containing menu items for left and right side of the menu. * @returns The rendered menu component. */ export const Menu = ({menu}: MenuProps) => { const [displayMenuMobile, setDisplayMenuMobile] = useState(false) return ( <> ) }