diff --git a/assets/css/gallery.css b/assets/css/gallery.css new file mode 100644 index 0000000..e557e43 --- /dev/null +++ b/assets/css/gallery.css @@ -0,0 +1,54 @@ + .gallery { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); + gap: 10px; + padding: 20px; + } + + .gallery-item { + overflow: hidden; + } + + .gallery-item img { + width: 100%; + height: auto; + display: block; + } + + .modal { + display: none; + position: fixed; + z-index: 1; + padding-top: 100px; + left: 0; + top: 0; + width: 100%; + height: 100%; + overflow: auto; + background-color: rgba(0, 0, 0, 0.9); + } + + .modal-content { + margin: auto; + display: block; + width: auto; + height: auto; + } + + .close { + position: absolute; + top: 15px; + right: 35px; + color: #f1f1f1; + font-size: 40px; + font-weight: bold; + transition: 0.3s; + } + + .close:hover, + .close:focus { + color: #bbb; + text-decoration: none; + cursor: pointer; + } + diff --git a/assets/js/gallery.js b/assets/js/gallery.js new file mode 100644 index 0000000..c260cf2 --- /dev/null +++ b/assets/js/gallery.js @@ -0,0 +1,11 @@ +function openModal(imageSrc) { + let modal = document.getElementById("myModal"); + let modalImg = document.getElementById("modalImage"); + modal.style.display = "block"; + modalImg.src = imageSrc; +} + +function closeModal() { + let modal = document.getElementById("myModal"); + modal.style.display = "none"; +} diff --git a/layouts/partials/footer-mobile.html b/layouts/partials/footer-mobile.html index cd1aaad..b566c7e 100644 --- a/layouts/partials/footer-mobile.html +++ b/layouts/partials/footer-mobile.html @@ -9,4 +9,12 @@ {{ $script := resources.Get "js/main.js" | minify | fingerprint -}} + + {{ $js := resources.Get "js/gallery.js" }} + {{ $jsFile := $js | resources.Minify }} + + + {{ $css := resources.Get "css/gallery.css" }} + {{ $cssFile := $css | resources.Minify }} + diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 903c18e..ae6589f 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -5,4 +5,12 @@
+ + {{ $js := resources.Get "js/gallery.js" }} + {{ $jsFile := $js | resources.Minify }} + + + {{ $css := resources.Get "css/gallery.css" }} + {{ $cssFile := $css | resources.Minify }} + diff --git a/layouts/shortcodes/image-gallery.html b/layouts/shortcodes/image-gallery.html index 76b7e92..d483753 100644 --- a/layouts/shortcodes/image-gallery.html +++ b/layouts/shortcodes/image-gallery.html @@ -1,4 +1,4 @@ -{{/* https://hugocodex.org/add-ons/image-gallery/ */}} +{{/* https://www.geeksforgeeks.org/how-to-make-image-gallery-using-html-css-and-javascript/ */}} {{/* Add this to your config yaml to serve images from `static/albums`` @@ -9,16 +9,10 @@ module: */}} - {{ $dir := string .Params.gallery_dir }} -