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: add skeleton loaders in category navbar #936

Merged
merged 1 commit into from
May 4, 2022
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
12 changes: 5 additions & 7 deletions packages/theme/components/SkeletonLoader/index.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<template>
<div>
<div
sethidden marked this conversation as resolved.
Show resolved Hide resolved
:class="componentClass"
:style="componentStyle"
>
<slot v-if="!isLoading" />
<span
v-else
:class="componentClass"
:style="componentStyle"
/>
</div>
</template>

<script>
<script lang="ts">
import { computed, defineComponent } from '@nuxtjs/composition-api';

export default defineComponent({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@
</SfButton>
<div class="navbar__sort">
<span class="navbar__label desktop-only">{{ $t('Sort by') }}:</span>
<SkeletonLoader
v-if="isLoading"
class="navbar__select navbar__select-skeleton"
height="26px"
width="185px"
margin="0"
/>
<SfSelect
v-else
:value="sortBy.selected"
class="navbar__select"
@input="doChangeSorting"
Expand All @@ -32,11 +40,17 @@
</div>

<div class="navbar__counter">
<span class="navbar__label desktop-only">{{ $t('Products found') }}</span>
<span class="desktop-only">{{ pagination.totalItems }}</span>
<span class="navbar__label smartphone-only">{{ pagination.totalItems }} {{
$t('Items')
}}</span>
<span class="navbar__label desktop-only">{{ $t('Products found') }}: </span>
<SkeletonLoader
v-if="isLoading"
width="15px"
height="26px"
margin="0"
/>
<span
v-else
>{{ pagination.totalItems }}</span>
<span class="navbar__label smartphone-only">&nbsp;{{ $t('Items') }}</span>
</div>

<div class="navbar__view">
Expand Down Expand Up @@ -73,9 +87,11 @@ import {
import SvgImage from '~/components/General/SvgImage.vue';
import { useUiHelpers, useUiState } from '~/composables';
import { AgnosticPagination, AgnosticSort } from '~/composables/types';
import SkeletonLoader from '~/components/SkeletonLoader/index.vue';

export default defineComponent({
components: {
SkeletonLoader,
SvgImage,
SfSelect,
SfButton,
Expand All @@ -89,6 +105,10 @@ export default defineComponent({
type: Object as PropType<AgnosticPagination>,
required: true,
},
isLoading: {
type: Boolean,
default: false,
},
},
setup(_, { emit }) {
const {
Expand Down Expand Up @@ -197,7 +217,7 @@ export default defineComponent({
}

&__select {
--select-width: 220px;
--select-width: 185px;
--select-padding: 0;
--select-height: auto;
--select-selected-padding: 0 var(--spacer-lg) 0 var(--spacer-2xs);
Expand All @@ -215,10 +235,6 @@ export default defineComponent({
::v-deep .sf-select__placeholder {
--select-option-font-size: var(--font-size-sm);
}

@include for-mobile {
--select-width: 135px;
}
}

&__sort {
Expand Down
1 change: 1 addition & 0 deletions packages/theme/modules/catalog/pages/category.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
v-if="isShowProducts"
:sort-by="sortBy"
:pagination="pagination"
:is-loading="$fetchState.pending"
@reloadProducts="fetch"
/>
<div class="products">
Expand Down