From 9c89c3da6b43849934230ea9a3b6fc6374f17650 Mon Sep 17 00:00:00 2001
From: Olivia206 <olivia.simonet@mmibordeaux.com>
Date: Wed, 14 Feb 2024 18:25:04 +0100
Subject: [PATCH] moved lightbox links after pictures

---
 assets/sass/_theme/blocks/gallery.sass        |  6 +++++
 .../blocks/templates/gallery/carousel.html    | 14 +++++------
 .../blocks/templates/gallery/grid.html        | 24 +++++++++----------
 3 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/assets/sass/_theme/blocks/gallery.sass b/assets/sass/_theme/blocks/gallery.sass
index 609e87c3..bb4bcaf0 100644
--- a/assets/sass/_theme/blocks/gallery.sass
+++ b/assets/sass/_theme/blocks/gallery.sass
@@ -2,11 +2,17 @@
     figure
         display: block
         margin-bottom: 0
+        position: relative
         > a,
         img,
         picture
             display: block
         > a
+            position: absolute
+            top: 0
+            left: 0
+            height: 100%
+            width: 100%
             transition: filter .3s ease
             &:hover
                 // if low opacity means not selected, selected needs to be darker
diff --git a/layouts/partials/blocks/templates/gallery/carousel.html b/layouts/partials/blocks/templates/gallery/carousel.html
index c00ad366..3e838f5b 100644
--- a/layouts/partials/blocks/templates/gallery/carousel.html
+++ b/layouts/partials/blocks/templates/gallery/carousel.html
@@ -14,6 +14,12 @@
       {{- $image := partial "GetMedia" .file -}}
       {{- if $image -}}
         <figure {{ if $is_carousel }} class="splide__slide"{{ end }}>
+          {{ partial "commons/image.html"
+            (dict
+              "image"    .id
+              "alt"      .alt
+              "sizes"    site.Params.image_sizes.blocks.gallery.carousel
+            )}}
           {{ if not site.Params.image_sizes.design_system.lightbox.disabled }}
             <a  class="glightbox"
                 role="button"
@@ -21,14 +27,6 @@
                 href="{{ partial "GetLightboxUrl" (dict "id" .id) }}"
                 title="{{- i18n "commons.lightbox.link.title" -}}"
                 aria-label="{{- i18n "commons.lightbox.link.title" -}}">
-          {{ end }}
-              {{ partial "commons/image.html"
-                (dict
-                  "image"    .id
-                  "alt"      .alt
-                  "sizes"    site.Params.image_sizes.blocks.gallery.carousel
-                )}}
-          {{ if not site.Params.image_sizes.design_system.lightbox.disabled }}
             </a>
           {{ end }}
           {{ if or .text .credit }}
diff --git a/layouts/partials/blocks/templates/gallery/grid.html b/layouts/partials/blocks/templates/gallery/grid.html
index ce2d5a21..f5429d3e 100644
--- a/layouts/partials/blocks/templates/gallery/grid.html
+++ b/layouts/partials/blocks/templates/gallery/grid.html
@@ -10,6 +10,17 @@
       {{- $image := partial "GetMedia" .id -}}
       {{- if $image -}}
         <figure>
+          {{ partial "commons/image.html"
+            (dict
+              "image"    .file
+              "alt"      .alt
+              "sizes"    site.Params.image_sizes.blocks.gallery.grid
+            )}}
+          {{ if .text }}
+            <figcaption>
+              <p>{{- partial "PrepareText" .text -}}</p>
+            </figcaption>
+          {{ end }}
           {{ if not site.Params.image_sizes.design_system.lightbox.disabled }}
             {{ $lightbox_text := false }}
             {{ if and .text .credit }}
@@ -23,21 +34,8 @@
                 href="{{ partial "GetLightboxUrl" (dict "id" .id) }}"
                 title="{{- i18n "commons.lightbox.link.title" -}}"
                 aria-label="{{- i18n "commons.lightbox.link.title" -}}">
-          {{ end }}
-            {{ partial "commons/image.html"
-              (dict
-                "image"    .file
-                "alt"      .alt
-                "sizes"    site.Params.image_sizes.blocks.gallery.grid
-              )}}
-          {{ if not site.Params.image_sizes.design_system.lightbox.disabled }}
             </a>
           {{ end }}
-          {{ if .text }}
-            <figcaption>
-              <p>{{- partial "PrepareText" .text -}}</p>
-            </figcaption>
-          {{ end }}
         </figure>
       {{- end -}}
     {{ end }}
-- 
GitLab