122 lines
3.4 KiB
Vue
122 lines
3.4 KiB
Vue
<!--
|
||
CommutateurMode — B4a-M4. En tête de la carte unifiée : deux onglets, « Entraide » et
|
||
« Pratiques inspirantes » (rôle tablist, aria-selected, 44 px, flèches ← → entre les deux),
|
||
puis « Bibliothèque », un LIEN vers /bibliotheque (lot B9 ; il menait à /media, qui reste à sa
|
||
place). Il n'écrit pas l'URL : il émet `choisir`, la page s'en charge. Rien n'anime.
|
||
-->
|
||
<template>
|
||
<div class="modes">
|
||
<div class="modes__onglets" role="tablist" aria-label="Ce que montre la carte">
|
||
<button
|
||
v-for="(m, i) in MODES"
|
||
:id="`mode-${m.valeur}`"
|
||
:key="m.valeur"
|
||
ref="onglets"
|
||
type="button"
|
||
role="tab"
|
||
class="modes__onglet"
|
||
:aria-selected="mode === m.valeur"
|
||
:aria-controls="panneau"
|
||
:tabindex="mode === m.valeur ? 0 : -1"
|
||
@click="emit('choisir', m.valeur)"
|
||
@keydown.right.prevent="voisin(i, 1)"
|
||
@keydown.left.prevent="voisin(i, -1)"
|
||
>{{ m.court }}<span v-if="m.suite" class="modes__suite">{{ m.suite }}</span></button>
|
||
</div>
|
||
<NuxtLink to="/bibliotheque" class="modes__lien">Bibliothèque</NuxtLink>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
export type ModeCarte = 'entraide' | 'pratiques'
|
||
|
||
defineProps<{
|
||
mode: ModeCarte
|
||
/** Id du panneau que les onglets commandent (la vue fiches). */
|
||
panneau: string
|
||
}>()
|
||
|
||
const emit = defineEmits<{ choisir: [mode: ModeCarte] }>()
|
||
|
||
/** « Pratiques inspirantes » : « inspirantes » se replie sous 420 px (gardé pour les lecteurs d'écran). */
|
||
const MODES: { valeur: ModeCarte; court: string; suite?: string }[] = [
|
||
{ valeur: 'entraide', court: 'Entraide' },
|
||
{ valeur: 'pratiques', court: 'Pratiques', suite: ' inspirantes' },
|
||
]
|
||
|
||
const onglets = ref<HTMLButtonElement[]>([])
|
||
|
||
function voisin(i: number, pas: number) {
|
||
const j = (i + pas + MODES.length) % MODES.length
|
||
emit('choisir', MODES[j].valeur)
|
||
nextTick(() => onglets.value[j]?.focus())
|
||
}
|
||
</script>
|
||
|
||
<style scoped>
|
||
.modes {
|
||
flex-shrink: 0;
|
||
display: flex;
|
||
align-items: stretch;
|
||
gap: 0;
|
||
padding: 0 var(--space-xs);
|
||
background: var(--surface);
|
||
border-bottom: 1px solid var(--border);
|
||
min-width: 0;
|
||
}
|
||
.modes__onglets {
|
||
display: flex;
|
||
min-width: 0;
|
||
}
|
||
.modes__onglet,
|
||
.modes__lien {
|
||
min-height: 44px;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
padding: 0 var(--space-sm);
|
||
border: none;
|
||
border-bottom: 3px solid transparent;
|
||
background: none;
|
||
color: var(--text);
|
||
font: inherit;
|
||
font-size: var(--fs-sm);
|
||
font-weight: var(--fw-medium);
|
||
white-space: nowrap;
|
||
cursor: pointer;
|
||
}
|
||
.modes__onglet[aria-selected='true'] {
|
||
border-bottom-color: var(--nav-primary-solid);
|
||
font-weight: var(--fw-bold);
|
||
}
|
||
.modes__lien {
|
||
margin-left: auto;
|
||
color: var(--text);
|
||
text-decoration: underline;
|
||
text-underline-offset: 3px;
|
||
}
|
||
.modes__onglet:focus-visible,
|
||
.modes__lien:focus-visible {
|
||
outline: 2px solid var(--focus-ring);
|
||
outline-offset: -2px;
|
||
}
|
||
/* Mobile-first (PROTOCOLE §1, checkpoint 07/11) : étroit en base, « inspirantes » repliée ; à partir de 26.25rem (420 px) le libellé entier et les espacements. */
|
||
.modes__suite {
|
||
position: absolute;
|
||
width: 1px;
|
||
height: 1px;
|
||
overflow: hidden;
|
||
clip: rect(0 0 0 0);
|
||
white-space: nowrap;
|
||
}
|
||
@media (min-width: 26.25rem) {
|
||
.modes { padding: 0 var(--space-md); gap: var(--space-sm); }
|
||
.modes__suite {
|
||
position: static;
|
||
width: auto;
|
||
height: auto;
|
||
overflow: visible;
|
||
clip: auto;
|
||
}
|
||
}
|
||
</style>
|