Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

feat: add home path in breadcrumb #905

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
12 changes: 9 additions & 3 deletions packages/default-theme/components/SwCurrencySwitcher.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
v-model="activeCurrency"
:size="availableCurrencies.length"
class="sw-currency__select sf-select--no-chevron"
@click="loadAvailableCurrencies"
data-cy="currency-switcher-select"
@click="loadAvailableCurrencies"
>
<SfSelectOption
v-for="currencyItem in availableCurrencies"
Expand All @@ -24,15 +24,17 @@
</div>
</template>
<script>
import { SfSelect, SfProductOption } from "@storefront-ui/vue"
import { SfSelect } from "@storefront-ui/vue"
import { useCurrency } from "@shopware-pwa/composables"
import { computed, onMounted } from "@vue/composition-api"

export default {
name: "SwCurrencySwitcher",

components: {
SfSelect,
},

setup(props, { root }) {
const {
currency,
Expand Down Expand Up @@ -63,6 +65,7 @@ export default {
},
}
</script>

<style lang="scss" scoped>
@import "@/assets/scss/variables";

Expand All @@ -72,6 +75,9 @@ export default {
--select-selected-padding: 0 var(--spacer-xs);
--select-selected-justify-content: center;
text-align: center;
cursor: pointer;

.sf-select {
cursor: pointer;
}
}
</style>
14 changes: 14 additions & 0 deletions packages/default-theme/components/SwHeader.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<template>
<div class="sw-top-navigation" data-cy="main-header">
<SfOverlay :visible="isOpen" class="sw-overlay" />

<SwTopBar />

<SfHeader
:title="$t('page.title')"
class="sw-header"
Expand Down Expand Up @@ -54,6 +56,15 @@ export default {
}
</script>

<style lang="scss">
.sf-header__wrapper {
header {
box-sizing: border-box;
max-width: 1320px;
}
}
</style>

<style lang="scss" scoped>
@import "@/assets/scss/variables";

Expand All @@ -79,12 +90,15 @@ export default {
}
}
}

.sw-header {
z-index: 2;
background-color: #fff;

&__icons {
display: flex;
}

&__icon {
cursor: pointer;
}
Expand Down
13 changes: 8 additions & 5 deletions packages/default-theme/components/SwLanguageSwitcher.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
:selected="currentLocale"
:size="availableLanguages.length"
class="sw-language-switcher__select sf-select--no-chevron"
@change="changeLocale"
data-cy="language-switcher-select"
@change="changeLocale"
>
<SfSelectOption
v-for="language in availableLanguages"
Expand All @@ -19,16 +19,16 @@
</div>
</template>
<script>
import { SfSelect, SfProductOption } from "@storefront-ui/vue"
import { computed, onMounted, ref } from "@vue/composition-api"
import languagesMap from "sw-plugins/languages"
import { SfSelect } from "@storefront-ui/vue"
import { useLocales } from "@shopware-pwa/default-theme/logic/useLocales"

export default {
name: "SwLanguageSwitcher",

components: {
SfSelect,
},

setup(props, { root }) {
const { availableLanguages, currentLocale, changeLocale } = useLocales(root)
return {
Expand All @@ -48,6 +48,9 @@ export default {
--select-selected-padding: 0 var(--spacer-xs);
--select-selected-justify-content: center;
text-align: center;
cursor: pointer;

.sf-select {
cursor: pointer;
}
}
</style>
11 changes: 10 additions & 1 deletion packages/default-theme/components/SwTopBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,22 @@ export default {
}
</script>

<style lang="scss">
.sf-top-bar__container {
box-sizing: border-box;
margin: 0 auto;
max-width: 1320px;
padding: 0 1rem;
}
</style>

<style lang="scss" scoped>
@import "@/assets/scss/variables";

.sw-top-bar {
padding: 0 var(--spacer-sm);
position: relative;
z-index: 3;

&__location-label {
margin: 0 var(--spacer-sm) 0 0;
}
Expand Down
42 changes: 32 additions & 10 deletions packages/default-theme/layouts/default.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<template>
<div class="layout">
<SwPluginSlot name="page-top" />

<SwHeader />

<SwPluginSlot name="top-header-after" />
<SwPluginSlot name="breadcrumbs" :slotContext="getBreadcrumbs">

<SwPluginSlot name="breadcrumbs" :slot-context="getBreadcrumbs">
<SfBreadcrumbs
v-show="getBreadcrumbs.length > 0"
:breadcrumbs="getBreadcrumbs"
class="sw-breadcrumbs layout__sized"
@click="redirectTo"
/>
</SwPluginSlot>

<nuxt />
<SwCart v-if="isSidebarOpen" />
<SwPluginSlot name="footer-before" />
Expand Down Expand Up @@ -46,6 +50,7 @@ export default {
SwPluginSlot,
SwLoginModal,
},

setup(props, { root }) {
const { getBreadcrumbsObject } = useCms(root)
const { isOpen: isSidebarOpen } = useUIState(root, "CART_SIDEBAR_STATE")
Expand All @@ -63,22 +68,38 @@ export default {
}
})

const getBreadcrumbs = computed(() =>
Object.values(getBreadcrumbsObject.value).map((breadcrumb) => ({
text: breadcrumb.name,
link: root.$i18n.path(breadcrumb.path),
route: {
const getBreadcrumbs = computed(() => {
const breadcrumbs = Object.values(getBreadcrumbsObject.value).map(
(breadcrumb) => ({
text: breadcrumb.name,
link: root.$i18n.path(breadcrumb.path),
},
}))
)
route: {
link: root.$i18n.path(breadcrumb.path),
},
})
)

if (breadcrumbs.length > 0) {
breadcrumbs.unshift({
text: "Home",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not meet Acceptance criterium:
Text editable through i18n

link: root.$i18n.path("/"),
route: {
link: root.$i18n.path("/"),
},
})
}

return breadcrumbs
})

return {
getBreadcrumbs,
isSidebarOpen: loadSidebarComponent,
isLoginModalOpen,
switchLoginModalState,
}
},

methods: {
redirectTo(route) {
return this.$router.push(this.$i18n.path(route.link))
Expand Down Expand Up @@ -116,6 +137,7 @@ export default {
}

.sw-breadcrumbs {
padding: 0 var(--spacer-xl) var(--spacer-base) var(--spacer-xl);
box-sizing: border-box;
padding: 1rem;
}
</style>
22 changes: 16 additions & 6 deletions packages/default-theme/pages/_lang/account.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="my-account" :key="$route.fullPath">
<div :key="$route.fullPath" class="my-account">
<SfContentPages
:title="$t('My account')"
:active="activePage"
Expand All @@ -25,8 +25,9 @@
</SfContentPages>
</div>
</template>

<script>
import { computed, onBeforeMount } from "@vue/composition-api"
import { computed } from "@vue/composition-api"
import { SfContentPages, SfTabs } from "@storefront-ui/vue"
import { useUser } from "@shopware-pwa/composables"
import { PAGE_LOGIN } from "@shopware-pwa/default-theme/helpers/pages"
Expand All @@ -35,22 +36,27 @@ import authMiddleware from "@shopware-pwa/default-theme/middleware/auth"

export default {
name: "AccountPage",

components: {
SfContentPages,
SfTabs,
},

middleware: authMiddleware,

setup(props, { root }) {
const { logout, user, loadOrders, orders } = useUser(root)
const ordersCount = computed(() => user.value && user.value.orderCount)
return { logout, user, loadOrders, orders, ordersCount }
},

data() {
return {
activePage: "My profile",
allAddresses: [],
}
},

computed: {
activeBillingAddress() {
return (this.user && this.user && this.user.activeBillingAddress) || {}
Expand All @@ -59,16 +65,19 @@ export default {
return (this.user && this.user && this.user.activeShippingAddress) || {}
},
},
mounted() {
this.updateActivePage(this.activePage)
},

watch: {
$route(to, from) {
if (to.name === "account-profile") {
this.activePage = "My profile"
}
},
},

mounted() {
this.updateActivePage(this.activePage)
},

methods: {
async updateActivePage(title) {
switch (title) {
Expand All @@ -91,12 +100,13 @@ export default {
},
}
</script>

<style lang="scss" scoped>
@import "@/assets/scss/variables";

.my-account {
@include for-desktop {
max-width: 1272px;
max-width: 1320px;
margin: 0 auto;
padding: 0 var(--spacer-sm);
}
Expand Down