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

perf: category page CLS improvement #1179

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: 5 additions & 3 deletions packages/theme/components/SkeletonLoader/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</template>

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

type ComponentStyles = { width?: string, height?: string, borderRadius: string, margin: string };

Expand All @@ -26,9 +26,11 @@ export default defineComponent({
},
width: {
type: String,
default: '',
},
height: {
type: String,
default: '',
},
margin: {
type: String,
Expand All @@ -50,10 +52,10 @@ export default defineComponent({
props.animation ? `skeleton--${props.animation}` : null,
]);

const componentStyle = computed<ComponentStyles>(() => ({
const componentStyle = ref<ComponentStyles>({
borderRadius: props.radius,
margin: props.margin,
}));
});

if (props.width) {
componentStyle.value.width = props.width;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.filters {
position: relative;
&__title {
::v-deep &__title {
--heading-title-font-size: var(--font-size--xl);
margin: var(--spacer-xl) 0 var(--spacer-base) 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@
:key="i"
data-testid="category-filter"
>
<SfHeading
:key="`filter-title-${filter.attribute_code}`"
:level="4"
:title="filter.label"
class="filters__title sf-heading--left"
/>
<component
:is="getFilterConfig(filter.attribute_code).component"
:filter="filter"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,50 @@
<template>
<component
:is="filter.options.length > 4 ? 'SfScrollable' : 'div' "
max-content-height="6.875rem"
:show-text="$t('Show more')"
:hide-text="$t('Show less')"
>
<SfCheckbox
v-for="option in filter.options"
:key="`${filter.attribute_code}-${option.value}`"
:label="option.label"
:selected="Boolean(selected(filter.attribute_code, option.value))"
class="filters__item"
data-testid="category-filter"
@change="$emit('selectFilter', option)"
<div>
<SfHeading
:key="`filter-title-${filter.attribute_code}`"
:level="4"
:title="filter.label"
class="filters__title sf-heading--left"
/>
<component
:is="filter.options.length > 4 ? 'SfScrollable' : 'div' "
max-content-height="6.875rem"
:show-text="$t('Show more')"
:hide-text="$t('Show less')"
>
<template #label="{ label }">
<!-- eslint-disable-next-line vue/no-v-html -->
<span
:class="{ 'display-none': !label }"
class="sf-checkbox__label"
v-html="$dompurify(label)"
/>
</template>
</SfCheckbox>
</component>
<SfCheckbox
v-for="option in filter.options"
:key="`${filter.attribute_code}-${option.value}`"
:label="option.label"
:selected="Boolean(selected(filter.attribute_code, option.value))"
class="filters__item"
data-testid="category-filter"
@change="$emit('selectFilter', option)"
>
<template #label="{ label }">
<!-- eslint-disable-next-line vue/no-v-html -->
<span
:class="{ 'display-none': !label }"
class="sf-checkbox__label"
v-html="$dompurify(label)"
/>
</template>
</SfCheckbox>
</component>
</div>
</template>
<script lang="ts">
import {
computed, defineComponent, inject, PropType,
} from '@nuxtjs/composition-api';
import { SfCheckbox, SfScrollable } from '@storefront-ui/vue';
import { SfCheckbox, SfScrollable, SfHeading } from '@storefront-ui/vue';
import type { Aggregation } from '~/modules/GraphQL/types';

export default defineComponent({
components: {
SfCheckbox,
SfScrollable,
SfHeading,
},
props: {
filter: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,53 @@
<template>
<component
:is="filter.options.length > 4 ? 'SfScrollable' : 'div' "
max-content-height="6.875rem"
:show-text="$t('Show more')"
:hide-text="$t('Show less')"
>
<SfRadio
v-for="option in filter.options"
:key="`${filter.attribute_code}-${option.value}`"
class="radio-filter"
:label="`${option.label}`"
:selected="selected(filter.attribute_code, option.value)"
:value="option.value"
name="filter__price"
data-testid="category-filter"
@change="$emit('selectFilter', option)"
<div>
<SfHeading
:key="`filter-title-${filter.attribute_code}`"
:level="4"
:title="filter.label"
class="filters__title sf-heading--left"
/>
<component
:is="filter.options.length > 4 ? 'SfScrollable' : 'div' "
max-content-height="6.875rem"
:show-text="$t('Show more')"
:hide-text="$t('Show less')"
>
<template #label="{ label }">
<!-- eslint-disable-next-line vue/no-v-html -->
<span
:class="{ 'display-none': !label }"
class="sf-radio__label"
v-html="$dompurify(label)"
/>
</template>
</SfRadio>
</component>
<SfRadio
v-for="option in filter.options"
:key="`${filter.attribute_code}-${option.value}`"
class="radio-filter"
:label="`${option.label}`"
:selected="selected(filter.attribute_code, option.value)"
:value="option.value"
name="filter__price"
data-testid="category-filter"
@change="$emit('selectFilter', option)"
>
<template #label="{ label }">
<!-- eslint-disable-next-line vue/no-v-html -->
<span
:class="{ 'display-none': !label }"
class="sf-radio__label"
v-html="$dompurify(label)"
/>
</template>
</SfRadio>
</component>
</div>
</template>
<script lang="ts">
import {
computed,
defineComponent, inject, PropType,
} from '@nuxtjs/composition-api';
import { SfRadio, SfScrollable } from '@storefront-ui/vue';
import { SfRadio, SfScrollable, SfHeading } from '@storefront-ui/vue';
import type { Aggregation } from '~/modules/GraphQL/types';

export default defineComponent({
components: {
SfRadio,
SfScrollable,
SfHeading,
},
props: {
filter: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
<template>
<div class="swatch_color_wrapper">
<SfColor
v-for="option in filter.options"
:key="`${filter.attribute_code}-${option.value}`"
:color="option.label"
:selected="Boolean(selected(filter.attribute_code, option.value))"
class="swatch_color"
role="button"
@click="$emit('selectFilter', option)"
<div>
<SfHeading
:key="`filter-title-${filter.attribute_code}`"
:level="4"
:title="filter.label"
class="filters__title sf-heading--left"
/>
<div class="swatch_color_wrapper">
<SfColor
v-for="option in filter.options"
:key="`${filter.attribute_code}-${option.value}`"
:color="option.label"
:selected="Boolean(selected(filter.attribute_code, option.value))"
class="swatch_color"
role="button"
@click="$emit('selectFilter', option)"
/>
</div>
</div>
</template>
<script lang="ts">
import {
computed, defineComponent, inject, PropType,
} from '@nuxtjs/composition-api';
import { SfColor } from '@storefront-ui/vue';
import { SfColor, SfHeading } from '@storefront-ui/vue';
import type { Aggregation } from '~/modules/GraphQL/types';

export default defineComponent({
components: {
SfColor,
SfHeading,
},
props: {
filter: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<template>
<div>
<SfHeading
:key="`filter-title-${filter.attribute_code}`"
:level="4"
:title="filter.label"
class="filters__title sf-heading--left"
/>
<SfRadio
v-for="option in filter.options"
:key="`${filter.attribute_code}-${option.value}`"
Expand All @@ -18,12 +24,13 @@ import {
computed,
defineComponent, inject, PropType, useContext,
} from '@nuxtjs/composition-api';
import { SfRadio } from '@storefront-ui/vue';
import { SfRadio, SfHeading } from '@storefront-ui/vue';
import type { Aggregation, AggregationOption } from '~/modules/GraphQL/types';

export default defineComponent({
components: {
SfRadio,
SfHeading,
},
props: {
filter: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,27 @@ export default defineComponent({
}
}

::v-deep .sf-product-card__add-button {
@include for-mobile {
opacity: 1;
display: flex;
bottom: 1rem;
right: 0;
::v-deep .sf-product-card {
.card {
will-change: transform, opacity;
}

&__image-wrapper {
height: 257px;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because of the lack of control over SFUI components, I had to take some space to prevent content jump.

}

&__add-button {
@include for-mobile {
opacity: 1;
display: flex;
bottom: 1rem;
right: 0;
}
}
}

::v-deep .sf-product-card::after {
content: none;
}

</style>
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export default defineComponent({
@import "./transition.scss";

.list-layout {
will-change: transform;
display: flex;
flex-wrap: wrap;
align-content: flex-start;
Expand Down Expand Up @@ -165,13 +166,23 @@ export default defineComponent({
}
}

::v-deep .sf-product-card__add-button {
@include for-mobile {
opacity: 1;
display: flex;
bottom: 1rem;
right: 0;
::v-deep .sf-product-card {
&__image-wrapper {
height: 257px;
}

&__add-button {
@include for-mobile {
opacity: 1;
display: flex;
bottom: 1rem;
right: 0;
}
}
}

::v-deep .sf-product-card::after {
content: none;
}

</style>
Loading