Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(a11y): add aria-* entries to interface settings #2799

Merged
merged 3 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 55 additions & 53 deletions components/settings/SettingsBottomNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,59 +67,61 @@ function save() {
</script>

<template>
<!-- preview -->
<div flex="~ gap4 wrap" items-center select-settings h-14 p0>
<nav
v-for="availableNavButton in selectedNavButtons" :key="availableNavButton.name"
flex="~ 1" items-center justify-center text-xl
scrollbar-hide overscroll-none
>
<button btn-base :class="availableNavButton.icon" mx-4 tabindex="-1" />
</nav>
</div>
<form aria-labelledby="interface-bn" aria-describedby="interface-bn-desc" @submit.prevent="save">
<!-- preview -->
<div aria-hidden="true" flex="~ gap4 wrap" items-center select-settings h-14 p0>
<nav
v-for="availableNavButton in selectedNavButtons" :key="availableNavButton.name"
flex="~ 1" items-center justify-center text-xl
scrollbar-hide overscroll-none
>
<button btn-base :class="availableNavButton.icon" mx-4 tabindex="-1" />
</nav>
</div>

<!-- button selection -->
<div flex="~ gap4 wrap" py4>
<button
v-for="{ name, label, icon } in availableNavButtons"
:key="name"
btn-text flex="~ gap-2" items-center p2 border="~ base rounded" bg-base ws-nowrap
:class="isAdded(name) ? 'text-secondary hover:text-second bg-auto' : ''"
type="button"
role="switch"
:aria-checked="isAdded(name)"
@click="isAdded(name) ? remove(name) : append(name)"
>
<span :class="icon" />
{{ label ? $t(label) : 'More menu' }}
</button>
</div>
<!-- button selection -->
<div flex="~ gap4 wrap" py4>
<button
v-for="{ name, label, icon } in availableNavButtons"
:key="name"
btn-text flex="~ gap-2" items-center p2 border="~ base rounded" bg-base ws-nowrap
:class="isAdded(name) ? 'text-secondary hover:text-second bg-auto' : ''"
type="button"
role="switch"
:aria-checked="isAdded(name)"
@click="isAdded(name) ? remove(name) : append(name)"
>
<span :class="icon" />
{{ label ? $t(label) : 'More menu' }}
</button>
</div>

<div flex="~ col" gap-y-4 gap-x-2 py-1 sm="~ justify-end flex-row">
<button
btn-outline font-bold py2 full-w sm-wa flex="~ gap2 center"
type="button"
:disabled="selectedNavButtonNames.length === 0"
@click="clear"
>
<span aria-hidden="true" class="block i-ri:delete-bin-line" />
{{ $t('action.clear') }}
</button>
<button
btn-outline font-bold py2 full-w sm-wa flex="~ gap2 center"
type="button"
@click="reset"
>
<span aria-hidden="true" class="block i-ri:repeat-line" />
{{ $t('action.reset') }}
</button>
<button
btn-solid font-bold py2 full-w sm-wa flex="~ gap2 center"
:disabled="!canSave"
@click="save"
>
<span aria-hidden="true" i-ri:save-2-fill />
{{ $t('action.save') }}
</button>
</div>
<div flex="~ col" gap-y-4 gap-x-2 py-1 sm="~ justify-end flex-row">
<button
btn-outline font-bold py2 full-w sm-wa flex="~ gap2 center"
type="button"
:disabled="selectedNavButtonNames.length === 0"
:class="selectedNavButtonNames.length === 0 ? 'border-none' : undefined"
@click="clear"
>
<span aria-hidden="true" class="block i-ri:delete-bin-line" />
{{ $t('action.clear') }}
</button>
<button
btn-outline font-bold py2 full-w sm-wa flex="~ gap2 center"
type="reset"
@click="reset"
>
<span aria-hidden="true" class="block i-ri:repeat-line" />
{{ $t('action.reset') }}
</button>
<button
btn-solid font-bold py2 full-w sm-wa flex="~ gap2 center"
:disabled="!canSave"
>
<span aria-hidden="true" i-ri:save-2-fill />
{{ $t('action.save') }}
</button>
</div>
</form>
</template>
5 changes: 3 additions & 2 deletions components/settings/SettingsColorMode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ const modes = [
</script>

<template>
<div flex="~ gap4 wrap" w-full>
<div flex="~ gap4 wrap" w-full role="group" aria-labelledby="interface-cm">
<button
v-for="{ icon, label, mode } in modes"
:key="mode"
type="button"
btn-text flex-1 flex="~ gap-1 center" p4 border="~ base rounded" bg-base ws-nowrap
:tabindex="colorMode.preference === mode ? 0 : -1"
:aria-pressed="colorMode.preference === mode ? 'true' : 'false'"
:class="colorMode.preference === mode ? 'pointer-events-none' : 'filter-saturate-0'"
@click="setColorMode(mode)"
>
Expand Down
1 change: 1 addition & 0 deletions components/settings/SettingsFontSize.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function setFontSize(e: Event) {
<span text-xs text-secondary>Aa</span>
<div flex-1 relative flex items-center>
<input
aria-labelledby="interface-fs"
:value="sizes.indexOf(userSettings.fontSize)"
:aria-valuetext="`${userSettings.fontSize}${userSettings.fontSize === DEFAULT_FONT_SIZE ? ` ${$t('settings.interface.default')}` : ''}`"
:min="0"
Expand Down
4 changes: 3 additions & 1 deletion components/settings/SettingsThemeColors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ function updateTheme(theme: ThemeColors) {
</script>

<template>
<div flex="~ gap4 wrap" p2>
<div flex="~ gap4 wrap" p2 role="group" aria-labelledby="interface-tc">
<button
v-for="[key, theme] in themes" :key="key"
:style="{
'background': key,
'--local-ring-color': key,
}"
type="button"
:class="currentTheme === theme['--theme-color-name'] ? 'ring-2' : 'scale-90'"
:aria-pressed="currentTheme === theme['--theme-color-name'] ? 'true' : 'false'"
:title="theme['--theme-color-name']"
w-8 h-8 rounded-full transition-all
ring="$local-ring-color offset-3 offset-$c-bg-base"
Expand Down
10 changes: 5 additions & 5 deletions pages/settings/interface/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ useHydratedHead({
</template>
<div p6 flex="~ col gap6">
<label space-y-2>
userquin marked this conversation as resolved.
Show resolved Hide resolved
<p font-medium>{{ $t('settings.interface.font_size') }}</p>
<p id="interface-fs" font-medium>{{ $t('settings.interface.font_size') }}</p>
<SettingsFontSize select-settings />
</label>
<div space-y-2>
<p font-medium>
<p id="interface-cm" font-medium>
{{ $t('settings.interface.color_mode') }}
</p>
<SettingsColorMode />
</div>
<div space-y-2>
<p font-medium>
<p id="interface-tc" font-medium>
{{ $t('settings.interface.theme_color') }}
</p>
<SettingsThemeColors />
</div>
<div space-y-2>
<p font-medium>
<p id="interface-bn" font-medium>
{{ $t('settings.interface.bottom_nav') }}
</p>
<p>
<p id="interface-bn-desc">
{{ $t('settings.interface.bottom_nav_instructions') }}
</p>
<SettingsBottomNav />
Expand Down
Loading