enhance a11n

* enhance switch lang : now update html lang attribut + add aria and needed attributs on switch buttons
* remove uselss role img on preloader
* better nav
* fix som duplicates ids
This commit is contained in:
Jordan Blasenhauer 2024-06-18 13:23:01 +02:00
parent 49f8709b00
commit 66c71d384d
5 changed files with 20 additions and 18 deletions

View file

@ -1,5 +1,5 @@
<script setup>
import { reactive } from "vue";
import { onMounted, reactive } from "vue";
import { langIndex } from "@utils/tabindex.js";
/**
@ -11,12 +11,18 @@ import { langIndex } from "@utils/tabindex.js";
const lang = reactive({
isOpen: false,
curr: "",
});
function updateLangStorage(lang) {
sessionStorage.setItem("lang", lang);
document.location.reload();
}
onMounted(() => {
lang.curr = document.querySelector("#current-lang").textContent;
document.querySelector("html").setAttribute("lang", lang.curr);
});
</script>
<template>
@ -34,8 +40,10 @@ function updateLangStorage(lang) {
:aria-checked="$i18n.locale === locale ? 'true' : 'false'"
>
<button
type="button"
:tabindex="lang.isOpen ? langIndex : '-1'"
@click="
:aria-labelledby="`${locale}-${id}`"
@click.prevent="
() => {
lang.isOpen = false;
updateLangStorage(locale);

View file

@ -19,9 +19,9 @@ import { onMounted } from "vue";
</script>
<template>
<noscript class="no-script"
>Your browser does not support JavaScript!</noscript
>
<noscript class="no-script">
Your browser does not support JavaScript!
</noscript>
<Loader />
<LangSwitch />
<Banner />

View file

@ -50,7 +50,6 @@ onMounted(() => {
<p id="loader-text" class="sr-only">{{ $t("dashboard_loading") }}</p>
<img
ref="logo"
role="img"
aria-hidden="true"
:src="logoMenu2"
class="loader-container-img"

View file

@ -291,8 +291,8 @@ onBeforeMount(() => {
<!-- end logo version -->
</div>
<div :class="['menu-nav-list-container', bannerStore.bannerClass]">
<ul role="navigation" class="menu-nav-list">
<nav :class="['menu-nav-list-container', bannerStore.bannerClass]">
<ul class="menu-nav-list">
<!-- item -->
<li v-for="(item, id) in navList" :key="id" class="menu-nav-list-item">
<a
@ -354,7 +354,7 @@ onBeforeMount(() => {
</li>
</ul>
<!-- end plugins -->
</div>
</nav>
<!-- bottom sidebar -->
<div class="menu-bottom-content">

View file

@ -8,7 +8,6 @@ import { v4 as uuidv4 } from "uuid";
We can used it as a fixed alert or we can use it in a container as a list.
@example
{
id: "flash-alert-1",
position : "fixed",
type: "success",
title: "Success",
@ -26,11 +25,6 @@ import { v4 as uuidv4 } from "uuid";
*/
const props = defineProps({
id: {
type: [Number, String],
required: false,
default: uuidv4(),
},
isFixed: {
type: Boolean,
required: false,
@ -68,6 +62,7 @@ const props = defineProps({
const alert = reactive({
visible: true,
id: uuidv4(),
});
onMounted(() => {
@ -83,7 +78,7 @@ onMounted(() => {
<div
v-if="alert.visible"
:class="['feedback-alert-container', props.isFixed ? 'is-fixed' : '']"
:id="props.id || `feedback-alert-${props.message.substring(0, 10)}`"
:id="alert.id"
:role="props.type === 'success' ? 'status' : 'alert'"
:aria-description="$t('dashboard_feedback_alert_desc')"
>
@ -98,9 +93,9 @@ onMounted(() => {
data-close-flash-message
type="button"
class="feedback-alert-btn"
:aria-labelledby="`${props.id}-close`"
:aria-labelledby="`${alert.id}-close`"
>
<span class="sr-only" :id="`${props.id}-close`">
<span class="sr-only" :id="`${alert.id}-close`">
{{ $t("dashboard_feedback_alert_close") }}
</span>
<svg