Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f6c1b0
commit f32c3ec
Showing
15 changed files
with
361 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
95 changes: 95 additions & 0 deletions
95
packages/commercetools/theme/components/Header/HeaderNav.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<template> | ||
<SfHeaderNavigation> | ||
<SfHeaderNavigationItem | ||
v-for="(category, index) in categories" | ||
:key="index" | ||
:label="category.name" | ||
@mouseenter="() => handleMouseEnter(category.slug)" | ||
@mouseleave="() => handleMouseLeave()" | ||
@click="handleMouseLeave()" | ||
:link="localePath(`/c/${category.slug}`)" | ||
> | ||
<SfMegaMenu | ||
:is-absolute="true" | ||
:visible="currentCatSlug === category.slug" | ||
:title="category.name" | ||
@close="currentCatSlug = ''" | ||
v-if="category && category.children.length" | ||
> | ||
<SfMegaMenuColumn | ||
v-for="(subCategory, subIndex) in category.children" | ||
:key="subIndex" | ||
:title="subCategory.name" | ||
> | ||
<SfLoader :loading="subCategoriesLoading"> | ||
<SfList> | ||
<SfListItem | ||
v-for="(subCategoryChild, childIndex) in subCategory.children" | ||
:key="childIndex" | ||
> | ||
<SfMenuItem :label="subCategoryChild.name" :link="localePath(`/c/${subCategoryChild.slug}`)"> | ||
<SfLink> | ||
{{ subCategoryChild.name }} | ||
</SfLink> | ||
</SfMenuItem> | ||
</SfListItem> | ||
</SfList> | ||
</SfLoader> | ||
</SfMegaMenuColumn> | ||
<NewCatBanners v-if="currentCatSlug === 'new'" /> | ||
</SfMegaMenu> | ||
</SfHeaderNavigationItem> | ||
</SfHeaderNavigation> | ||
</template> | ||
|
||
<script> | ||
import { SfMegaMenu, SfMenuItem, SfList, SfBanner, SfLoader } from '@storefront-ui/vue'; | ||
import { useCategory } from '@vue-storefront/commercetools'; | ||
import { onSSR } from '@vue-storefront/core'; | ||
import { ref } from '@vue/composition-api'; | ||
import debounce from 'lodash.debounce'; | ||
export default { | ||
name: 'HeaderNav', | ||
components: { | ||
SfMegaMenu, | ||
SfMenuItem, | ||
SfList, | ||
SfBanner, | ||
SfLoader, | ||
NewCatBanners: () => import('./NewCatBanners') | ||
}, | ||
setup (_, { emit }) { | ||
const { categories, search } = useCategory('menu-categories'); | ||
const { categories: subCategories, search: subCategoriesSearch, loading: subCategoriesLoading } = useCategory('menu-subCategories'); | ||
const currentCatSlug = ref(''); | ||
const handleMouseEnter = debounce((slug) => { | ||
if (currentCatSlug.value) return; | ||
currentCatSlug.value = slug; | ||
const catChild = categories.value.find(category => category.slug === currentCatSlug.value); | ||
emit('setOverlay', Boolean(catChild.childCount)); | ||
subCategoriesSearch({ slug }); | ||
}, 200); | ||
const handleMouseLeave = debounce(() => { | ||
emit('setOverlay', false); | ||
currentCatSlug.value = ''; | ||
}, 200); | ||
onSSR(async () => { | ||
await search({ customQuery: { categories: 'root-categories-query' } }); | ||
}); | ||
return { | ||
categories, | ||
subCategories, | ||
currentCatSlug, | ||
subCategoriesLoading, | ||
handleMouseEnter, | ||
handleMouseLeave | ||
}; | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
description: 'added MegaMenu to theme', | ||
link: 'https://github.com/vuestorefront/vue-storefront/issues/5267', | ||
isBreaking: false, | ||
breakingChanges: [], | ||
author: 'Łukasz Jędrasik', | ||
linkToGitHubAccount: 'https://github.com/lukaszjedrasik' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.