Skip to content

Commit

Permalink
close menu popup after click on link inside (#2785)
Browse files Browse the repository at this point in the history
  • Loading branch information
tvikito authored Sep 13, 2023
2 parents 550eaa1 + 19b2239 commit bde1c05
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ export const NavigationItem: FC<NavigationItemProps> = (props) => {

{hasChildren && isMenuOpened && (
<div className="absolute left-0 right-0 z-menu grid grid-cols-4 gap-11 bg-white py-12 px-10 shadow-md">
<NavigationItemColumn columnCategories={props.navigationItem.categoriesByColumns} />
<NavigationItemColumn
columnCategories={props.navigationItem.categoriesByColumns}
onLinkClick={() => setIsMenuOpened(false)}
/>
</div>
)}
</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,58 @@
import { NavigationItemColumnCategory } from 'components/Layout/Header/Navigation/NavigationItemColumnCategory';
import { ExtendedNextLink } from 'components/Basic/ExtendedNextLink/ExtendedNextLink';
import { ColumnCategoriesFragmentApi } from 'graphql/generated';
import { Image } from 'components/Basic/Image/Image';

type NavigationItemColumnProps = {
columnCategories: ColumnCategoriesFragmentApi[];
onLinkClick: () => void;
};

export const NavigationItemColumn: FC<NavigationItemColumnProps> = ({ columnCategories }) => (
export const NavigationItemColumn: FC<NavigationItemColumnProps> = ({ columnCategories, onLinkClick }) => (
<>
{columnCategories.map((columnCategories, columnIndex) => (
<ul className="flex flex-col gap-9" key={columnIndex}>
{columnCategories.categories.map((columnCategory, columnCategoryIndex) => (
<NavigationItemColumnCategory key={columnCategoryIndex} columnCategory={columnCategory} />
<li key={columnCategoryIndex}>
<ExtendedNextLink
href={columnCategory.slug}
type="static"
className="mb-4 flex justify-center rounded bg-dark bg-opacity-5 p-2"
onClick={onLinkClick}
>
<Image
image={columnCategory.mainImage}
type="default"
alt={columnCategory.mainImage?.name || columnCategory.name}
className="h-16 mix-blend-multiply"
/>
</ExtendedNextLink>

<ExtendedNextLink
href={columnCategory.slug}
type="static"
className="mb-1 block font-bold text-dark no-underline"
onClick={onLinkClick}
>
{columnCategory.name}
</ExtendedNextLink>

{!!columnCategory.children.length && (
<ul className="flex w-full flex-col gap-1">
{columnCategory.children.map((columnCategoryChild) => (
<li key={columnCategoryChild.name}>
<ExtendedNextLink
type="category"
href={columnCategoryChild.slug}
className="block text-sm text-dark no-underline"
onClick={onLinkClick}
>
{columnCategoryChild.name}
</ExtendedNextLink>
</li>
))}
</ul>
)}
</li>
))}
</ul>
))}
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit bde1c05

Please sign in to comment.