From 338a4e6bbd85ce76ba24654c1c3794fb1706c028 Mon Sep 17 00:00:00 2001
From: Olivia Simonet <91660674+Olivia206@users.noreply.github.com>
Date: Mon, 2 Sep 2024 11:18:30 +0200
Subject: [PATCH] [A11Y] Ajout d'attributs aria (#592)

---
 layouts/partials/blocks/templates/call_to_action.html         | 4 ++--
 layouts/partials/blocks/templates/chapter.html                | 3 ++-
 layouts/partials/blocks/templates/features.html               | 2 +-
 layouts/partials/blocks/templates/gallery/carousel-image.html | 2 +-
 layouts/partials/blocks/templates/gallery/large.html          | 2 +-
 layouts/partials/blocks/templates/image.html                  | 2 +-
 layouts/partials/blocks/templates/testimonials/single.html    | 2 +-
 layouts/partials/footer/footer.html                           | 2 +-
 layouts/partials/header/header.html                           | 2 +-
 layouts/partials/programs/image.html                          | 2 +-
 10 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/layouts/partials/blocks/templates/call_to_action.html b/layouts/partials/blocks/templates/call_to_action.html
index 04ec297e..547c4aa9 100644
--- a/layouts/partials/blocks/templates/call_to_action.html
+++ b/layouts/partials/blocks/templates/call_to_action.html
@@ -34,11 +34,11 @@
             {{- end -}}
           </div>
           {{ if .image }}
-            <figure>
+            <figure role="figure" {{- with or .alt .credit }} aria-label="{{ . | plainify }}" {{ end }}>
               {{ partial "commons/image.html"
                 (dict
                   "image"    .image.file
-                  "alt"      .image.alt
+                  "alt"      .alt
                   "sizes"    site.Params.image_sizes.blocks.call_to_action
               )}}
               {{ if partial "GetTextFromHTML" .credit }}
diff --git a/layouts/partials/blocks/templates/chapter.html b/layouts/partials/blocks/templates/chapter.html
index 98d83ac8..0360dcb9 100644
--- a/layouts/partials/blocks/templates/chapter.html
+++ b/layouts/partials/blocks/templates/chapter.html
@@ -30,7 +30,7 @@
             {{ end -}}
           </div>
           {{ if .image }}
-            <figure class="{{- $image_class -}}">
+            <figure role="figure" class="{{- $image_class -}}" {{- with or .alt .credit }} aria-label="{{ . | plainify }}" {{ end }}>
               {{ if not site.Params.image_sizes.design_system.lightbox.disabled }}
                 <a class="glightbox"
                   role="button"
@@ -44,6 +44,7 @@
                 {{ partial "commons/image.html"
                   (dict
                     "image"    .image
+                    "alt" .alt
                     "sizes"    site.Params.image_sizes.blocks.chapter
                   )}}
               {{ if not site.Params.image_sizes.design_system.lightbox.disabled }}
diff --git a/layouts/partials/blocks/templates/features.html b/layouts/partials/blocks/templates/features.html
index 8f7f9f82..b70ecccf 100644
--- a/layouts/partials/blocks/templates/features.html
+++ b/layouts/partials/blocks/templates/features.html
@@ -27,7 +27,7 @@
                   <p>{{ .description | safeHTML }}</p>
                 </div>
                 {{- if .image -}}
-                  <figure>
+                  <figure role="figure" {{- with or .alt .credit }} aria-label="{{ . | plainify }}" {{ end }}>
                     {{- partial "commons/image.html"
                       (dict
                         "image"    .image
diff --git a/layouts/partials/blocks/templates/gallery/carousel-image.html b/layouts/partials/blocks/templates/gallery/carousel-image.html
index 020b8142..e030a38f 100644
--- a/layouts/partials/blocks/templates/gallery/carousel-image.html
+++ b/layouts/partials/blocks/templates/gallery/carousel-image.html
@@ -5,7 +5,7 @@
   {{ if .file }}
     {{- $image := partial "GetMedia" .file -}}
     {{- if $image -}}
-      <figure {{ if $is_carousel }} id="carousel-item-{{$index}}" role="{{$role}}" aria-roledescription="slide" class="carousel__slide" aria-label="item-{{$index}}" {{ end }}>
+      <figure role="figure" {{ if $is_carousel }} id="carousel-item-{{$index}}" role="{{$role}}" aria-roledescription="slide" class="carousel__slide" aria-label="item-{{$index}} {{- with or .text .alt .credit }} | {{ . | plainify }} {{- end }}" {{ end }}>
         {{ partial "commons/image.html"
           (dict
             "image"    .id
diff --git a/layouts/partials/blocks/templates/gallery/large.html b/layouts/partials/blocks/templates/gallery/large.html
index 1e075c81..f51efb93 100644
--- a/layouts/partials/blocks/templates/gallery/large.html
+++ b/layouts/partials/blocks/templates/gallery/large.html
@@ -4,7 +4,7 @@
       {{- $image := partial "GetMedia" .id -}}
       {{- $image_class := printf "image-%s" (partial "GetImageDirection" .) -}}
       {{- if $image -}}
-        <figure class="{{ $image_class  }}">
+        <figure role="figure" class="{{ $image_class  }}" {{- with or .text .alt .credit }} aria-label="{{ . | plainify }}" {{ end }}>
           {{ partial "commons/image.html"
             (dict
               "image"    .file
diff --git a/layouts/partials/blocks/templates/image.html b/layouts/partials/blocks/templates/image.html
index 9ca7cf9c..663f52f7 100644
--- a/layouts/partials/blocks/templates/image.html
+++ b/layouts/partials/blocks/templates/image.html
@@ -17,7 +17,7 @@
         )}}
 
         {{- with .image -}}
-          <figure class="{{ $image_class }}">
+          <figure role="figure" class="{{ $image_class }}" {{- with or $text .alt .credit }} aria-label="{{ . | plainify }}" {{ end }}>
             {{ if not site.Params.image_sizes.design_system.lightbox.disabled }}
               <a  class="glightbox"
                   role="button"
diff --git a/layouts/partials/blocks/templates/testimonials/single.html b/layouts/partials/blocks/templates/testimonials/single.html
index 78413b78..620628dd 100644
--- a/layouts/partials/blocks/templates/testimonials/single.html
+++ b/layouts/partials/blocks/templates/testimonials/single.html
@@ -1,4 +1,4 @@
-<figure {{- if .is_carousel }} id="carousel-item-{{.index}}" role="{{.role}}" aria-roledescription="slide" class="carousel__slide" aria-label="{{.index}} / {{ .total }}" {{ end }} class="{{ if .is_carousel }}carousel__slide{{ end }} {{ if .params.photo }}with-picture{{ end }}">
+<figure role="figure" {{- if .is_carousel }} id="carousel-item-{{.index}}" role="{{.role}}" aria-roledescription="slide" class="carousel__slide" aria-label="{{.index}} / {{ .total }}" {{ end }} class="{{ if .is_carousel }}carousel__slide{{ end }} {{ if .params.photo }}with-picture{{ end }}">
   {{ with .params }}
     {{ $is_long := gt (len .text) 150 }}
     <blockquote {{- if $is_long }} class="is-long" {{- end }}>
diff --git a/layouts/partials/footer/footer.html b/layouts/partials/footer/footer.html
index c736c8a8..14d44214 100644
--- a/layouts/partials/footer/footer.html
+++ b/layouts/partials/footer/footer.html
@@ -1,3 +1,3 @@
-<footer id="document-footer">
+<footer id="document-footer" role="contentinfo">
   {{ partial "footer/footer-simple.html" . }}
 </footer>
diff --git a/layouts/partials/header/header.html b/layouts/partials/header/header.html
index e92304f4..5a5877ae 100644
--- a/layouts/partials/header/header.html
+++ b/layouts/partials/header/header.html
@@ -1,6 +1,6 @@
 {{ $primary := partial "GetMenu" "primary" }}
 
-<header id="document-header">
+<header id="document-header" role="banner">
   <nav aria-label="{{ i18n "commons.menu.main" }}">
     <div class="container">
       {{ partial "header/logo.html" }}
diff --git a/layouts/partials/programs/image.html b/layouts/partials/programs/image.html
index 5774db7c..6101fcdf 100644
--- a/layouts/partials/programs/image.html
+++ b/layouts/partials/programs/image.html
@@ -1,5 +1,5 @@
 {{ if . }}
-  <figure class="featured-image">
+  <figure role="figure" class="featured-image">
     {{ partial "commons/image.html"
           (dict
             "image"    .
-- 
GitLab