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

product page - gallery zoom photoswipe #436

Merged
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
3 changes: 0 additions & 3 deletions src/scss/custom/components/_slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ $component-name: carousel;
justify-content: center;
height: 100%;

&.active {
display: flex;
}

img {
width: 100%;
Expand Down
17 changes: 17 additions & 0 deletions src/scss/custom/pages/product/_product.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@
overflow: hidden;
border-radius: 8px;
}

&__modal-opener {
position: absolute;
right: 0.635rem;
bottom: 0.635rem;
z-index: 10;
display: flex;
align-items: center;
justify-content: center;
width: 2.5rem;
min-width: 2.5rem;
height: 2.5rem;
background-color: #fff;
border: none;
border-radius: 50%;
box-shadow: 0.125rem -0.125rem 0.25rem 0 rgb(0 0 0 / 20%);
}
}

&__description-short {
Expand Down
15 changes: 12 additions & 3 deletions templates/catalog/_partials/product-cover-thumbnails.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@

<div class="product__images js-images-container">
{if $product.images|@count > 0}
<div id="product-images" class="carousel slide js-product-carousel"
data-bs-ride="carousel">
<div
id="product-images"
class="carousel slide js-product-carousel"
data-bs-ride="carousel"
>

<div class="carousel-inner">
{include file='catalog/_partials/product-flags.tpl'}
Expand All @@ -24,7 +27,10 @@

{block name='product_cover'}
{foreach from=$product.images item=image key=key name=productImages}
<div class="carousel-item{if $image.id_image == $product.default_image.id_image} active{/if}">
<div class="carousel-item{if $image.id_image == $product.default_image.id_image} active{/if}"
data-bs-target="#product-images-modal"
data-bs-slide-to="{$key}"
>
<picture>
{if isset($image.bySize.default_md.sources.avif)}
<source
Expand Down Expand Up @@ -64,6 +70,9 @@
data-full-size-image-url="{$image.bySize.home_default.url}"
>
</picture>
<div class="product__images__modal-opener" data-bs-toggle="modal" data-bs-target="#product-modal">
<i class="material-icons zoom-in">search</i>
</div>
</div>
{/foreach}
{/block}
Expand Down
112 changes: 64 additions & 48 deletions templates/catalog/_partials/product-images-modal.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,72 @@
* file that was distributed with this source code.
*}
<div class="modal fade js-product-images-modal" id="product-modal">
<div class="modal-dialog" role="document">
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-body">
{assign var=imagesCount value=$product.images|count}
<figure>
{if $product.default_image}
<img
class="js-modal-product-cover product-cover-modal"
width="{$product.default_image.bySize.large_default.width}"
src="{$product.default_image.bySize.large_default.url}"
alt="{$product.default_image.legend}"
title="{$product.default_image.legend}"
height="{$product.default_image.bySize.large_default.height}"
>
{else}
<img src="{$urls.no_picture_image.bySize.large_default.url}" loading="lazy" width="{$urls.no_picture_image.bySize.large_default.width}" height="{$urls.no_picture_image.bySize.large_default.height}" />
{/if}
<figcaption class="image-caption">
{block name='product_description_short'}
<div id="product-description-short">{$product.description_short nofilter}</div>
{/block}
</figcaption>
</figure>
<aside id="thumbnails" class="thumbnails js-thumbnails text-sm-center">
{block name='product_images'}
<div class="js-modal-mask mask {if $imagesCount <= 5} nomargin {/if}">
<ul class="product-images js-modal-product-images">
{foreach from=$product.images item=image}
<li class="thumb-container js-thumb-container">
<img
data-image-large-src="{$image.large.url}"
class="thumb js-modal-thumb"
src="{$image.medium.url}"
alt="{$image.legend}"
title="{$image.legend}"
width="{$image.medium.width}"
height="148"
>
</li>
{/foreach}
</ul>
</div>
{/block}
{if $imagesCount> 5}
<div class="arrows js-modal-arrows">
<i class="material-icons arrow-up js-modal-arrow-up">&#xE5C7;</i>
<i class="material-icons arrow-down js-modal-arrow-down">&#xE5C5;</i>
</div>
{/if}
</aside>
<div
id="product-images-modal"
class="carousel slide js-product-images-modal-carousel"
data-bs-ride="carousel"
>
<div class="carousel-inner">

{if $product.images|@count > 1}
<button class="carousel-control-prev" type="button" data-bs-target="#product-images-modal" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#product-images-modal" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
{/if}

{foreach from=$product.images item=image key=key name=productImages}
<div class="carousel-item{if $image.id_image == $product.default_image.id_image} active{/if}">
<picture>
{if isset($image.bySize.default_md.sources.avif)}
<source
srcset="
{$image.bySize.default_md.sources.avif} 320w,
{$image.bySize.product_main.sources.avif} 720w,
{$image.bySize.product_main_2x.sources.avif} 1440w"
sizes="(min-width: 1300px) 720px, (min-width: 768px) 50vw, 100vw"
type="image/avif"
>
{/if}

{if isset($image.bySize.default_md.sources.webp)}
<source
srcset="
{$image.bySize.default_md.sources.webp} 320w,
{$image.bySize.product_main.sources.webp} 720w,
{$image.bySize.product_main_2x.sources.webp} 1440w"
sizes="(min-width: 1300px) 720px, (min-width: 768px) 50vw, 100vw"
type="image/webp"
>
{/if}

<img
class="img-fluid"
srcset="
{$image.bySize.default_md.url} 320w,
{$image.bySize.product_main.url} 720w,
{$image.bySize.product_main_2x.url} 1440w"
sizes="(min-width: 1300px) 720px, (min-width: 768px) 50vw, 100vw"
src="{$image.bySize.product_main.url}"
width="{$image.bySize.product_main.width}"
height="{$image.bySize.product_main.height}"
loading="{if $smarty.foreach.productImages.first}eager{else}lazy{/if}"
alt="{$image.legend}"
title="{$image.legend}"
data-full-size-image-url="{$image.bySize.home_default.url}"
>
</picture>
</div>
{/foreach}
</div>
</div>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
Expand Down