Skip to content

Commit

Permalink
feat(theme): add sorting select in the navbar on the mobile category …
Browse files Browse the repository at this point in the history
…view
  • Loading branch information
bartoszherba committed Feb 23, 2022
1 parent 659db4e commit 375a1f7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
8 changes: 6 additions & 2 deletions packages/composables/src/composables/useCart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,13 @@ const factoryParams: UseCartFactoryParams<Cart, CartItem, Product> = {
) => !!currentCart?.items.find((cartItem) => cartItem?.product?.uid === product.uid),
loadTotalQty: async (context: Context) => {
const apiState = context.$magento.config.state;
const { data } : any = await context.$magento.api.cartTotalQty(apiState.getCartId());
if (apiState.getCartId()) {
const { data } : any = await context.$magento.api.cartTotalQty(apiState.getCartId());

return data?.cart?.total_quantity ?? 0;
return data?.cart?.total_quantity ?? 0;
}

return 0;
},
};

Expand Down
2 changes: 1 addition & 1 deletion packages/theme/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default () => {
'@vue-storefront/middleware/nuxt',
'@nuxt/image',
['@vue-storefront/cache/nuxt', {
enabled: process.env.REDIS__ENABLED,
enabled: false,
invalidation: {
endpoint: process.env.REDIS__CACHE_INVALIDATE_URL,
key: process.env.REDIS__CACHE_INVALIDATE_KEY,
Expand Down
12 changes: 10 additions & 2 deletions packages/theme/pages/Category.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
</SfButton>
</LazyHydrate>

<div class="navbar__sort desktop-only">
<span class="navbar__label">{{ $t('Sort by') }}:</span>
<div class="navbar__sort">
<span class="navbar__label desktop-only">{{ $t('Sort by') }}:</span>
<LazyHydrate when-visible>
<SfSelect
:value="sortBy.selected"
Expand Down Expand Up @@ -814,12 +814,20 @@ export default defineComponent({
::v-deep .sf-select__placeholder {
--select-option-font-size: var(--font-size-sm);
}
@include for-mobile {
--select-width: 135px;
}
}
&__sort {
display: flex;
align-items: center;
margin: 0 auto 0 var(--spacer-2xl);
@include for-mobile {
margin: 0;
order: 1;
}
}
&__counter {
Expand Down

0 comments on commit 375a1f7

Please sign in to comment.