feat(settings): improve switch setting accessibility

This commit is contained in:
2026-07-21 17:29:05 +02:00
parent 45b52c2c11
commit 82a11af017
3 changed files with 21 additions and 3 deletions
+13 -3
View File
@@ -16,6 +16,7 @@ limitations under the License.
<script setup> <script setup>
import { useSettingsStore } from '../stores/settingsStore'; import { useSettingsStore } from '../stores/settingsStore';
import { useId } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
const { t } = useI18n(); const { t } = useI18n();
@@ -29,6 +30,9 @@ const props = defineProps({
} }
}); });
const labelId = useId();
const switchId = useId();
const store = useSettingsStore(); const store = useSettingsStore();
const toggle = function toggle () { const toggle = function toggle () {
@@ -38,10 +42,16 @@ const toggle = function toggle () {
<template> <template>
<div class="switch-container" @click="toggle"> <div class="switch-container" @click="toggle">
<div> <label :for="switchId" :id="labelId">
{{ t(props.setting.i18n) }} {{ t(props.setting.i18n) }}
</div> </label>
<div class="switch-wrapper" :class="{ enabled: store.get(props.path) }"> <div
class="switch-wrapper"
:class="{ enabled: store.get(props.path) }"
:title="t('settings.switch.title')"
:aria-label="t('settings.switch.ariaLabel')"
:aria-labelledby="labelId"
>
<div class="switch-point"></div> <div class="switch-point"></div>
</div> </div>
</div> </div>
+4
View File
@@ -45,6 +45,10 @@
"title": "Wert speichern", "title": "Wert speichern",
"ariaLabel": "Speichert den eingegebenen Wert" "ariaLabel": "Speichert den eingegebenen Wert"
} }
},
"switch": {
"title": "Wert umschalten",
"ariaLabel": "Schaltet den Wert um"
} }
} }
} }
+4
View File
@@ -45,6 +45,10 @@
"title": "Save value", "title": "Save value",
"ariaLabel": "Saves the entered value" "ariaLabel": "Saves the entered value"
} }
},
"switch": {
"title": "Toggle value",
"ariaLabel": "Toggles the value"
} }
} }
} }