-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(theme): create component for product gallery (#194)
* refactor: create component for product gallery * fix: review requests
- Loading branch information
Showing
3 changed files
with
112 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
packages/default-theme/components/cms/elements/SwProductGallery.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<template> | ||
<div class="sw-product-gallery gallery"> | ||
<template v-if="mediaGallery.length > 0"> | ||
<slot name="desktop-galery" v-bind="mediaGallery"> | ||
<div class="gallery__desktop" v-for="(image, id) in mediaGallery" :key="id"> | ||
<SfImage | ||
v-if="image.big" | ||
:src="image.big.url" | ||
class="image__big desktop-only" | ||
/> | ||
<SfImage | ||
v-else-if="image.medium" | ||
:src="image.medium.url" | ||
class="image__medium dektop-only" | ||
/> | ||
</div> | ||
</slot> | ||
</template> | ||
<div class="gallery__mobile mobile-only" v-if="mediaGallery.length > 0"> | ||
<slot name="mobile-galery" v-bind="mediaGallery"> | ||
<SfGallery | ||
class="gallery-mobile mobile-only" | ||
:images="mediaGallery" | ||
/> | ||
</slot> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { SfImage, SfGallery } from '@storefront-ui/vue' | ||
import { getProductMainImageUrl, getProductMediaGallery } from '@shopware-pwa/helpers' | ||
export default { | ||
components: { SfImage, SfGallery }, | ||
props: { | ||
product: { | ||
type: Object, | ||
default: () => ({}), | ||
} | ||
}, | ||
computed: { | ||
mediaGallery() { | ||
return getProductMediaGallery({product: this.product}) | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style lang="scss"> | ||
@import "~@storefront-ui/shared/styles/variables"; | ||
.gallery-mobile { | ||
$height-other: 240px; | ||
$height-iOS: 265px; | ||
height: calc(100vh - #{$height-other}); | ||
@supports (-webkit-overflow-scrolling: touch) { | ||
height: calc(100vh - #{$height-iOS}); | ||
} | ||
::v-deep .glide { | ||
&, | ||
* { | ||
height: 100%; | ||
} | ||
&__slide { | ||
position: relative; | ||
overflow: hidden; | ||
} | ||
img { | ||
position: absolute; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
min-width: calc((375 / 490) * (100vh - #{$height-other})); | ||
@supports (-webkit-overflow-scrolling: touch) { | ||
min-width: calc((375 / 490) * (100vh - #{$height-iOS})); | ||
} | ||
} | ||
} | ||
::v-deep .sf-gallery__stage { | ||
width: 100%; | ||
} | ||
} | ||
.sf-gallery { | ||
$this: &; | ||
::v-deep { | ||
ul { | ||
margin: 0; | ||
} | ||
#{$this}__thumbs { | ||
left: 50%; | ||
transform: translateX(-50%); | ||
top: auto; | ||
bottom: 10px; | ||
display: flex; | ||
} | ||
#{$this}__item { | ||
&:not(:first-child) { | ||
margin: 0 0 0 $spacer; | ||
} | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f7ff086
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for website ready!
Built with commit f7ff086
https://shopware-pwa-kjtm1vuda.now.sh