Skip to content

Commit

Permalink
fix(default-theme): product carousel on mobile in the horizontal posi…
Browse files Browse the repository at this point in the history
…tion (#833)
  • Loading branch information
Przemek Spaczek authored Jun 8, 2020
1 parent 3f6f09e commit aabc31e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
29 changes: 27 additions & 2 deletions packages/default-theme/cms/elements/CmsElementProductSlider.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<template>
<div class="cms-element-product-slider">
<SfSection :title-heading="title" class="section">
<SfCarousel class="product-carousel">
<SfCarousel class="product-carousel" :settings="options">
<SfCarouselItem v-for="product in products" :key="product.id">
<SwProductCard :product="product" />
<SwProductCard :product="product" class="product-carousel__product" />
</SfCarouselItem>
</SfCarousel>
</SfSection>
Expand Down Expand Up @@ -39,6 +39,24 @@ export default {
: ""
},
},
data(){
return {
options: {
breakpoints: {
480: {
perView: 2,
peek: {
before: 0,
after: 50,
},
},
1023: {
perView: 4,
},
},
}
}
},
}
</script>

Expand All @@ -48,4 +66,11 @@ export default {
.cms-element-product-slider {
width: 100%;
}
.product-carousel {
&__product {
@include for-mobile {
max-width: unset;
}
}
}
</style>
23 changes: 21 additions & 2 deletions packages/default-theme/components/SwProductCarousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
class="section"
title-heading="You may also like"
>
<SfCarousel class="product-carousel">
<SfCarousel class="product-carousel" :settings="options">
<SfCarouselItem v-for="product in products" :key="product.id">
<SwProductCard :product="product" />
<SwProductCard :product="product" class="product-carousel__product" />
</SfCarouselItem>
</SfCarousel>
</SfSection>
Expand All @@ -31,6 +31,20 @@ export default {
data() {
return {
products: {},
options: {
breakpoints: {
480: {
perView: 2,
peek: {
before: 0,
after: 50,
},
},
1023: {
perView: 4,
},
},
}
}
},
async mounted() {
Expand Down Expand Up @@ -70,5 +84,10 @@ export default {
--carousel-padding: var(--spacer-base);
--carousel-max-width: calc(100% - 13.5rem);
}
&__product {
@include for-mobile {
max-width: unset;
}
}
}
</style>

1 comment on commit aabc31e

@vercel
Copy link

@vercel vercel bot commented on aabc31e Jun 8, 2020

Choose a reason for hiding this comment

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

Please sign in to comment.