From b84d16890f466ecaa031ba379120f576335ad196 Mon Sep 17 00:00:00 2001 From: Jeremy Thomas Date: Tue, 11 Jun 2024 03:03:31 +0100 Subject: [PATCH] Add photoswipe --- docs/assets/javascript/shop.js | 13 ++++++++++++- docs/shop.html | 9 +++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/assets/javascript/shop.js b/docs/assets/javascript/shop.js index bcd08fd2..2c5f2082 100644 --- a/docs/assets/javascript/shop.js +++ b/docs/assets/javascript/shop.js @@ -533,11 +533,22 @@ document.addEventListener("DOMContentLoaded", () => { if (images) { images.forEach(img => { - const $figure = El("shop-product-image image is-square", "figure"); + const $figure = El("shop-product-image image is-square", "a"); + $figure.href = img.url; + $figure.dataset.pswpHeight = img.height; + $figure.dataset.pswpWidth = img.width; + $figure.target = "_blank"; const $img = document.createElement("img"); $img.src = img.url; $figure.appendChild($img); $carousel.appendChild($figure); + + const lightbox = new window.PhotoSwipeLightbox({ + gallery: '.shop-product-image', + pswpModule: window.PhotoSwipe + }); + + lightbox.init(); }); $images.appendChild($carousel); diff --git a/docs/shop.html b/docs/shop.html index 1bce695c..5babbbbc 100644 --- a/docs/shop.html +++ b/docs/shop.html @@ -9,6 +9,8 @@ breadcrumb: - shop --- + +