Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/refactor shared util layout #49

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions components/Cms/Element/CmsElementImageSlider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const sliderItems = config.getConfigValue('sliderItems');
</script>

<template>
<LayoutSlider
<SharedSlider
:navigation-arrows="config.getConfigValue('navigationArrows')"
:navigation-dots="config.getConfigValue('navigationDots')"
:autoplay="config.getConfigValue('autoSlide') ? config.getConfigValue('autoplayTimeout') : false"
Expand All @@ -18,7 +18,7 @@ const sliderItems = config.getConfigValue('sliderItems');
v-for="(sliderItem, index) in sliderItems"
:key="index"
>
<LayoutSliderSlide>
<SharedSliderSlide>
<template v-if="sliderItem.url">
<NuxtLink
:to="sliderItem.url"
Expand Down Expand Up @@ -47,7 +47,7 @@ const sliderItems = config.getConfigValue('sliderItems');
"
loading="lazy"
/>
</LayoutSliderSlide>
</SharedSliderSlide>
</template>
</LayoutSlider>
</SharedSlider>
</template>
2 changes: 1 addition & 1 deletion components/Cms/Element/CmsElementProductListing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const changePage = async (page: number) => {
</template>
</div>

<LayoutPagination
<UtilityPagination
:total="getTotal"
:items-per-page="getLimit"
:default-page="getCurrentPage"
Expand Down
26 changes: 26 additions & 0 deletions components/Footer/Footer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<script setup lang="ts">
const { navigationElements, loadNavigationElements } = useNavigation({ type: 'footer-navigation' });
const { navigationElements: serviceNavigationElements, loadNavigationElements: loadServiceElements } = useNavigation({
type: 'service-navigation',
});

onMounted(async () => {
await loadNavigationElements({ depth: 1 });
await loadServiceElements({ depth: 1 });
});
</script>

<template>
<div class="mt-auto">
<footer class="mt-4 bg-gray-light md:mt-10">
<div class="container py-5 md:pb-5 md:pt-10">
<FooterNavigation :navigation-elements="navigationElements" />

<LanguageSwitch />

<!-- footer service navigation -->
<FooterServiceNavigation :navigation-elements="serviceNavigationElements" />
</div>
</footer>
</div>
</template>
30 changes: 30 additions & 0 deletions components/Footer/FooterNavigation.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<script setup lang="ts">
import type { Schemas } from '@shopware/api-client/api-types';

defineProps<{
navigationElements: Schemas['Category'];
}>();
</script>

<template>
<div class="grid gap-5 md:flex md:justify-between lg:justify-normal lg:gap-28">
<ul
v-for="navigationElement in navigationElements"
:key="navigationElement.id"
class="list-none"
>
<li class="mb-1 max-w-max">
<NavigationLink
:navigation-element="navigationElement"
classes="font-bold"
/>
</li>
<li
v-for="navigationChild in navigationElement.children"
:key="navigationChild.id"
>
<NavigationLink :navigation-element="navigationChild" />
</li>
</ul>
</div>
</template>
17 changes: 17 additions & 0 deletions components/Footer/FooterServiceNavigation.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script setup lang="ts">
import type { Schemas } from '@shopware/api-client/api-types';

defineProps<{
navigationElements: Schemas['Category'];
}>();
</script>

<template>
<div class="mt-4 grid gap-1 border-t-2 border-white pt-4 md:flex md:gap-6">
<NavigationLink
v-for="navigationElement in navigationElements"
:key="navigationElement.id"
:navigation-element="navigationElement"
/>
</div>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ const { loading } = storeToRefs(customerStore);
<!-- mobile menu -->
<NavigationSidebar />

<LayoutLogo logo-classes="w-36 md:w-40" />
<UtilityLogo logo-classes="w-36 md:w-40" />
</div>

<LayoutHeaderActions />
<HeaderActions />
</div>
</div>

Expand Down
11 changes: 11 additions & 0 deletions components/Header/HeaderActions.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template>
<div class="flex items-center gap-3.5">
<HeaderSearch />

<HeaderWishlist />

<HeaderAccount />

<HeaderCart />
</div>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const cartItemCount = computed(() => getCartItemsCount(cartItems.value));
/>
</button>

<LazyLayoutSidebar
<LazySharedSidebar
v-if="offcanvasCartController.isOpen"
:controller="offcanvasCartController"
side="right"
Expand All @@ -48,5 +48,5 @@ const cartItemCount = computed(() => getCartItemsCount(cartItems.value));
to the cart
</NuxtLink>
</template>
</LazyLayoutSidebar>
</LazySharedSidebar>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ onClickOutside(searchComponent, event => {

<ClientOnly>
<teleport to="#flyouts">
<LayoutHeaderSearchBar
<HeaderSearchBar
v-if="searchVisible"
ref="searchComponent"
@close-search="searchVisible = false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ onMounted(() => {
:to="getProductRoute(product)"
@click="$emit('closeSearch')"
>
<LayoutHeaderSearchSuggestions :product="product" />
<HeaderSearchSuggestions :product="product" />
</NuxtLink>

<div class="bg-gray-light text-center text-sm hover:bg-gray-medium">
Expand Down
28 changes: 15 additions & 13 deletions components/LanguageSwitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ const languageOptions = computed(() => entityArrayToOptions<Schemas['language']>
</script>

<template>
<div
v-if="languages"
class="py-4 md:w-1/5"
>
<FormKit
v-model="languageIdChain"
type="select"
name="language"
prefix-icon="globe"
:options="languageOptions"
@change="onLanguageChange"
/>
</div>
<ClientOnly>
<div
v-if="languages"
class="py-4 md:w-1/5"
>
<FormKit
v-model="languageIdChain"
type="select"
name="language"
prefix-icon="globe"
:options="languageOptions"
@change="onLanguageChange"
/>
</div>
</ClientOnly>
</template>
11 changes: 0 additions & 11 deletions components/Layout/Header/LayoutHeaderActions.vue

This file was deleted.

72 changes: 0 additions & 72 deletions components/Layout/LayoutFooter.vue

This file was deleted.

2 changes: 0 additions & 2 deletions components/Navigation/NavigationFlyout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const selfNotHovered = refDebounced(isOutsideFlyout, 200);
:navigation-element="child"
classes="text-lg font-bold py-2"
active-classes="text-brand-primary"
:as-link="child.type !== 'folder'"
/>
<div class="flex flex-col gap-2">
<template v-if="child.childCount > 0">
Expand All @@ -39,7 +38,6 @@ const selfNotHovered = refDebounced(isOutsideFlyout, 200);
:navigation-element="subChild"
classes="py-2"
active-classes="text-brand-primary"
:as-link="subChild.type !== 'folder'"
/>
</template>
</div>
Expand Down
4 changes: 3 additions & 1 deletion components/Navigation/NavigationLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ const isActive = (path: Schemas['SeoUrl'][] | undefined, onlyExactMatch: boolean

return onlyExactMatch ? formattedPath === currentPath : currentPath.includes(formattedPath);
};

const isFolder = computed(() => props.navigationElement.type !== 'folder');
</script>

<template>
<NuxtLink
v-if="asLink"
v-if="isFolder && asLink"
:target="isExternalLink || linkNewTab ? '_blank' : ''"
:rel="isExternalLink || linkNewTab ? 'noopener noreferrer nofollow' : ''"
:aria-label="getTranslatedProperty(navigationElement, 'name')"
Expand Down
3 changes: 1 addition & 2 deletions components/Navigation/NavigationMainItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ const debounced = refDebounced(isOutsideNavItem, 300);
:class="{
'text-brand-primary': !debounced,
}"
:as-link="navigationElement.type !== 'folder'"
/>
</div>

<NavigationFlyout
<LazyNavigationFlyout
v-if="navigationElement?.childCount > 0"
:navigation-element="navigationElement"
:parent-hovered="!debounced"
Expand Down
4 changes: 2 additions & 2 deletions components/Navigation/NavigationSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const lastPreviousItem = computed(() =>
class="w-4 cursor-pointer md:hidden"
@click="sideMenuController.open()"
/>
<LazyLayoutSidebar
<LazySharedSidebar
v-if="sideMenuController.isOpen"
:controller="sideMenuController"
>
Expand Down Expand Up @@ -88,5 +88,5 @@ const lastPreviousItem = computed(() =>
/>
</div>
</template>
</LazyLayoutSidebar>
</LazySharedSidebar>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { notifications } = useNotifications();

<template>
<div class="fixed bottom-10 right-5 z-[2147483647] flex max-h-fit w-96 max-w-[calc(100vw-2.5rem)] flex-col gap-2.5">
<UtilityToastNotification
<NotificationToast
v-for="notification in notifications"
:key="notification.id"
:notification="notification"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ const staticNotification: Notification = {
</script>

<template>
<UtilityToastNotification :notification="staticNotification" />
<NotificationToast :notification="staticNotification" />
</template>
4 changes: 2 additions & 2 deletions components/Product/ProductAvailability.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const props = defineProps<{

const availableStock = props.product.availableStock ?? props.product.deliveryInformation.stock ?? 0;
const minPurchase = props.product.minPurchase ?? props.product.quantityInformation.minPurchase ?? 0;
const deliveryTime = props.product.deliveryTime ?? props.product.deliveryInformation.deliveryTime;
const restockTime = props.product.restockTime ?? props.product.deliveryInformation.restockTime;
const deliveryTime = props.product?.deliveryTime ?? props.product.deliveryInformation?.deliveryTime;
const restockTime = props.product?.restockTime ?? props.product.deliveryInformation?.restockTime;
</script>

<template>
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions error.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ refreshCart();
<NuxtLoadingIndicator />
<UtilityLoadingSpinner v-if="loading" />

<LayoutHeader v-show="!loading" />
<Header v-show="!loading" />

<UtilityToastNotifications />
<NotificationContainer />

<main
v-show="!loading"
Expand All @@ -37,5 +37,5 @@ refreshCart();
</div>
</main>

<LayoutFooter v-show="!loading" />
<Footer v-show="!loading" />
</template>
Loading