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

feat(theme): add sorting select in the navbar on the mobile category view #653

Merged
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: 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
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