fix(a11y): show bottom nav button labels

This commit is contained in:
TAKAHASHI Shuuji 2025-01-01 23:49:00 +09:00
parent ed70b3c611
commit 411fcc83f0
16 changed files with 91 additions and 15 deletions

View file

@ -2,10 +2,14 @@
defineProps<{ defineProps<{
activeClass: string activeClass: string
}>() }>()
const userSettings = useUserSettings()
const hideLabel = getPreferences(userSettings.value, 'hideBottomNavLabel')
</script> </script>
<template> <template>
<NuxtLink to="/bookmarks" :aria-label="$t('nav.bookmarks')" :active-class="activeClass" flex flex-row items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop"> <NuxtLink to="/bookmarks" :aria-label="$t('nav.bookmarks')" :active-class="activeClass" flex flex-col items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop">
<div i-ri:bookmark-line /> <div i-ri:bookmark-line />
<span v-if="!hideLabel" text-xs>{{ $t('nav.bookmarks') }}</span>
</NuxtLink> </NuxtLink>
</template> </template>

View file

@ -2,10 +2,14 @@
defineProps<{ defineProps<{
activeClass: string activeClass: string
}>() }>()
const userSettings = useUserSettings()
const hideLabel = getPreferences(userSettings.value, 'hideBottomNavLabel')
</script> </script>
<template> <template>
<NuxtLink to="/compose" :aria-label="$t('nav.favourites')" :active-class="activeClass" flex flex-row items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop"> <NuxtLink to="/compose" :aria-label="$t('nav.favourites')" :active-class="activeClass" flex flex-col items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop">
<div i-ri:quill-pen-line /> <div i-ri:quill-pen-line />
<span v-if="!hideLabel" text-xs>{{ $t('nav.favourites') }}</span>
</NuxtLink> </NuxtLink>
</template> </template>

View file

@ -6,10 +6,20 @@ defineProps<{
}>() }>()
const lastAccessedExploreRoute = useLocalStorage(STORAGE_KEY_LAST_ACCESSED_EXPLORE_ROUTE, '') const lastAccessedExploreRoute = useLocalStorage(STORAGE_KEY_LAST_ACCESSED_EXPLORE_ROUTE, '')
const userSettings = useUserSettings()
const hideLabel = getPreferences(userSettings.value, 'hideBottomNavLabel')
</script> </script>
<template> <template>
<NuxtLink :to="`/${currentServer}/explore/${lastAccessedExploreRoute}`" :aria-label="$t('nav.explore')" :active-class="activeClass" flex flex-row items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop"> <NuxtLink
:to="`/${currentServer}/explore/${lastAccessedExploreRoute}`"
:aria-label="$t('nav.explore')"
:active-class="activeClass"
flex flex-col items-center place-content-center h-full flex-1 class="coarse-pointer:select-none"
@click="$scrollToTop"
>
<div i-ri:compass-3-line /> <div i-ri:compass-3-line />
<span v-if="!hideLabel" text-xs>{{ $t('nav.explore') }}</span>
</NuxtLink> </NuxtLink>
</template> </template>

View file

@ -2,10 +2,14 @@
defineProps<{ defineProps<{
activeClass: string activeClass: string
}>() }>()
const userSettings = useUserSettings()
const hideLabel = getPreferences(userSettings.value, 'hideBottomNavLabel')
</script> </script>
<template> <template>
<NuxtLink to="/favourites" :aria-label="$t('nav.favourites')" :active-class="activeClass" flex flex-row items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop"> <NuxtLink to="/favourites" :aria-label="$t('nav.favourites')" :active-class="activeClass" flex flex-col items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop">
<div i-ri:heart-line /> <div i-ri:heart-line />
<span v-if="!hideLabel" text-xs>{{ $t('nav.favourites') }}</span>
</NuxtLink> </NuxtLink>
</template> </template>

View file

@ -2,10 +2,14 @@
defineProps<{ defineProps<{
activeClass: string activeClass: string
}>() }>()
const userSettings = useUserSettings()
const hideLabel = getPreferences(userSettings.value, 'hideBottomNavLabel')
</script> </script>
<template> <template>
<NuxtLink :to="`/${currentServer}/public`" :aria-label="$t('nav.federated')" :active-class="activeClass" flex flex-row items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop"> <NuxtLink :to="`/${currentServer}/public`" :aria-label="$t('nav.federated')" :active-class="activeClass" flex flex-col items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop">
<div i-ri:earth-line /> <div i-ri:earth-line />
<span v-if="!hideLabel" text-xs>{{ $t('nav.federated') }}</span>
</NuxtLink> </NuxtLink>
</template> </template>

View file

@ -2,10 +2,14 @@
defineProps<{ defineProps<{
activeClass: string activeClass: string
}>() }>()
const userSettings = useUserSettings()
const hideLabel = getPreferences(userSettings.value, 'hideBottomNavLabel')
</script> </script>
<template> <template>
<NuxtLink to="/hashtags" :aria-label="$t('nav.hashtags')" :active-class="activeClass" flex flex-row items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop"> <NuxtLink to="/hashtags" :aria-label="$t('nav.hashtags')" :active-class="activeClass" flex flex-col items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop">
<div i-ri:hashtag /> <div i-ri:hashtag />
<span v-if="!hideLabel" text-xs>{{ $t('nav.hashtags') }}</span>
</NuxtLink> </NuxtLink>
</template> </template>

View file

@ -2,10 +2,14 @@
defineProps<{ defineProps<{
activeClass: string activeClass: string
}>() }>()
const userSettings = useUserSettings()
const hideLabel = getPreferences(userSettings.value, 'hideBottomNavLabel')
</script> </script>
<template> <template>
<NuxtLink to="/home" :aria-label="$t('nav.home')" :active-class="activeClass" flex flex-row items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop"> <NuxtLink to="/home" :aria-label="$t('nav.home')" :active-class="activeClass" flex flex-col items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop">
<div i-ri:home-5-line /> <div i-ri:home-5-line />
<span v-if="!hideLabel" text-xs>{{ $t('nav.home') }}</span>
</NuxtLink> </NuxtLink>
</template> </template>

View file

@ -2,6 +2,9 @@
defineProps<{ defineProps<{
activeClass: string activeClass: string
}>() }>()
const userSettings = useUserSettings()
const hideLabel = getPreferences(userSettings.value, 'hideBottomNavLabel')
</script> </script>
<template> <template>
@ -9,9 +12,10 @@ defineProps<{
to="/lists" to="/lists"
:aria-label="$t('nav.lists')" :aria-label="$t('nav.lists')"
:active-class="activeClass" :active-class="activeClass"
flex flex-row items-center place-content-center h-full flex-1 flex flex-col items-center place-content-center h-full flex-1
class="coarse-pointer:select-none" @click="$scrollToTop" class="coarse-pointer:select-none" @click="$scrollToTop"
> >
<div i-ri:list-check /> <div i-ri:list-check />
<span v-if="!hideLabel" text-xs>{{ $t('nav.lists') }}</span>
</NuxtLink> </NuxtLink>
</template> </template>

View file

@ -2,10 +2,20 @@
defineProps<{ defineProps<{
activeClass: string activeClass: string
}>() }>()
const userSettings = useUserSettings()
const hideLabel = getPreferences(userSettings.value, 'hideBottomNavLabel')
</script> </script>
<template> <template>
<NuxtLink group :to="`/${currentServer}/public/local`" :aria-label="$t('nav.local')" :active-class="activeClass" flex flex-row items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop"> <NuxtLink
group
:to="`/${currentServer}/public/local`"
:aria-label="$t('nav.local')" :active-class="activeClass"
flex flex-col items-center place-content-center h-full flex-1 class="coarse-pointer:select-none"
@click="$scrollToTop"
>
<div i-ri:group-2-line /> <div i-ri:group-2-line />
<span v-if="!hideLabel" text-xs>{{ $t('nav.local') }}</span>
</NuxtLink> </NuxtLink>
</template> </template>

View file

@ -2,14 +2,19 @@
defineProps<{ defineProps<{
activeClass: string activeClass: string
}>() }>()
const userSettings = useUserSettings()
const hideLabel = getPreferences(userSettings.value, 'hideBottomNavLabel')
</script> </script>
<template> <template>
<NuxtLink <NuxtLink
to="/conversations" :aria-label="$t('nav.conversations')" to="/conversations"
:active-class="activeClass" flex flex-row items-center place-content-center h-full :aria-label="$t('nav.conversations')"
flex-1 class="coarse-pointer:select-none" @click="$scrollToTop" :active-class="activeClass" flex flex-col items-center place-content-center h-full flex-1 class="coarse-pointer:select-none"
@click="$scrollToTop"
> >
<div i-ri:at-line /> <div i-ri:at-line />
<span v-if="!hideLabel" text-xs>{{ $t('nav.conversations') }}</span>
</NuxtLink> </NuxtLink>
</template> </template>

View file

@ -1,5 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
const model = defineModel<boolean>() const model = defineModel<boolean>()
const userSettings = useUserSettings()
const hideLabel = getPreferences(userSettings.value, 'hideBottomNavLabel')
</script> </script>
<template> <template>
@ -8,12 +11,13 @@ const model = defineModel<boolean>()
place-content-center h-full flex-1 cursor-pointer place-content-center h-full flex-1 cursor-pointer
> >
<button <button
flex items-center place-content-center h-full flex-1 class="select-none" flex flex-col items-center place-content-center h-full flex-1 class="select-none"
:class="show ? '!text-primary' : ''" :class="show ? '!text-primary' : ''"
:aria-label="$t('nav.more_menu')" :aria-label="$t('nav.more_menu')"
@click="toggleVisible" @click="toggleVisible"
> >
<span :class="show ? 'i-ri:close-fill' : 'i-ri:more-fill'" /> <span :class="show ? 'i-ri:close-fill' : 'i-ri:more-fill'" />
<span v-if="!hideLabel" text-xs>{{ $t('nav.more_menu') }}</span>
</button> </button>
</NavBottomMoreMenu> </NavBottomMoreMenu>
</template> </template>

View file

@ -6,15 +6,19 @@ defineProps<{
}>() }>()
const { notifications } = useNotifications() const { notifications } = useNotifications()
const lastAccessedNotificationRoute = useLocalStorage(STORAGE_KEY_LAST_ACCESSED_NOTIFICATION_ROUTE, '') const lastAccessedNotificationRoute = useLocalStorage(STORAGE_KEY_LAST_ACCESSED_NOTIFICATION_ROUTE, '')
const userSettings = useUserSettings()
const hideLabel = getPreferences(userSettings.value, 'hideBottomNavLabel')
</script> </script>
<template> <template>
<NuxtLink :to="`/notifications/${lastAccessedNotificationRoute}`" :aria-label="$t('nav.notifications')" :active-class="activeClass" flex flex-row items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop"> <NuxtLink :to="`/notifications/${lastAccessedNotificationRoute}`" :aria-label="$t('nav.notifications')" :active-class="activeClass" flex flex-col items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop">
<div flex relative> <div flex relative>
<div class="i-ri:notification-4-line" text-xl /> <div class="i-ri:notification-4-line" text-xl />
<div v-if="notifications" class="top-[-0.3rem] right-[-0.3rem]" absolute font-bold rounded-full h-4 w-4 text-xs bg-primary text-inverted flex items-center justify-center> <div v-if="notifications" class="top-[-0.3rem] right-[-0.3rem]" absolute font-bold rounded-full h-4 w-4 text-xs bg-primary text-inverted flex items-center justify-center>
{{ notifications < 10 ? notifications : '•' }} {{ notifications < 10 ? notifications : '•' }}
</div> </div>
</div> </div>
<span v-if="!hideLabel" text-xs>{{ $t('nav.notifications') }}</span>
</NuxtLink> </NuxtLink>
</template> </template>

View file

@ -2,10 +2,14 @@
defineProps<{ defineProps<{
activeClass: string activeClass: string
}>() }>()
const userSettings = useUserSettings()
const hideLabel = getPreferences(userSettings.value, 'hideBottomNavLabel')
</script> </script>
<template> <template>
<NuxtLink to="/search" :aria-label="$t('nav.search')" :active-class="activeClass" flex flex-row items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop"> <NuxtLink to="/search" :aria-label="$t('nav.search')" :active-class="activeClass" flex flex-col items-center place-content-center h-full flex-1 class="coarse-pointer:select-none" @click="$scrollToTop">
<div i-ri:search-line /> <div i-ri:search-line />
<span v-if="!hideLabel" text-xs>{{ $t('nav.search') }}</span>
</NuxtLink> </NuxtLink>
</template> </template>

View file

@ -2,6 +2,8 @@
import type { NavButtonName } from '~/composables/settings' import type { NavButtonName } from '~/composables/settings'
import { STORAGE_KEY_BOTTOM_NAV_BUTTONS } from '~/constants' import { STORAGE_KEY_BOTTOM_NAV_BUTTONS } from '~/constants'
const userSettings = useUserSettings()
interface NavButton { interface NavButton {
name: NavButtonName name: NavButtonName
label: string label: string
@ -136,5 +138,11 @@ function save() {
</button> </button>
</div> </div>
</form> </form>
<SettingsToggleItem
:checked="getPreferences(userSettings, 'hideBottomNavLabel')"
@click="togglePreferences('hideBottomNavLabel')"
>
{{ $t('settings.interface.bottom_nav_hide_label') }}
</SettingsToggleItem>
</section> </section>
</template> </template>

View file

@ -32,6 +32,7 @@ export interface PreferencesSettings {
experimentalGitHubCards: boolean experimentalGitHubCards: boolean
experimentalUserPicker: boolean experimentalUserPicker: boolean
experimentalEmbeddedMedia: boolean experimentalEmbeddedMedia: boolean
hideBottomNavLabel: boolean
} }
export interface UserSettings { export interface UserSettings {
@ -88,6 +89,7 @@ export const DEFAULT__PREFERENCES_SETTINGS: PreferencesSettings = {
experimentalGitHubCards: true, experimentalGitHubCards: true,
experimentalUserPicker: true, experimentalUserPicker: true,
experimentalEmbeddedMedia: false, experimentalEmbeddedMedia: false,
hideBottomNavLabel: false,
} }
export function getDefaultUserSettings(locales: string[]): UserSettings { export function getDefaultUserSettings(locales: string[]): UserSettings {

View file

@ -455,6 +455,7 @@
}, },
"interface": { "interface": {
"bottom_nav": "Bottom Navigation", "bottom_nav": "Bottom Navigation",
"bottom_nav_hide_label": "Hide bottom labels",
"bottom_nav_instructions": "Choose your favorite navigation buttons up to five for the bottom navigation. Must include the \"More menu\" button.", "bottom_nav_instructions": "Choose your favorite navigation buttons up to five for the bottom navigation. Must include the \"More menu\" button.",
"color_mode": "Color Mode", "color_mode": "Color Mode",
"dark_mode": "Dark", "dark_mode": "Dark",