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): show bottom nav button labels #3120

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
17 changes: 15 additions & 2 deletions components/nav/button/Bookmark.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
<script setup lang="ts">
import { useHideBottomNavigationLabel } from '~/composables/settings'

defineProps<{
activeClass: string
}>()

const hideLabel = useHideBottomNavigationLabel()
</script>

<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">
<div i-ri:bookmark-line />
<NuxtLink
to="/bookmarks"
:aria-label="$t('nav.bookmarks')"
:active-class="activeClass"
flex flex-col items-center place-content-center h-full flex-1 min-w-0
class="coarse-pointer:select-none"
:class="hideLabel ? null : 'gap-1'"
@click="$scrollToTop"
>
<div aria-hidden="true" i-ri:bookmark-line />
<span v-if="!hideLabel" text-xs overflow-hidden text-ellipsis whitespace-nowrap>{{ $t('nav.bookmarks') }}</span>
</NuxtLink>
</template>
15 changes: 13 additions & 2 deletions components/nav/button/Compose.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@
defineProps<{
activeClass: string
}>()

const hideLabel = useHideBottomNavigationLabel()
</script>

<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">
<div i-ri:quill-pen-line />
<NuxtLink
to="/compose"
:aria-label="$t('nav.compose')"
:active-class="activeClass"
flex flex-col items-center place-content-center h-full flex-1 min-w-0
class="coarse-pointer:select-none"
:class="hideLabel ? null : 'gap-1'"
@click="$scrollToTop"
>
<div aria-hidden="true" i-ri:quill-pen-line />
<span v-if="!hideLabel" text-xs overflow-hidden text-ellipsis whitespace-nowrap>{{ $t('nav.compose') }}</span>
</NuxtLink>
</template>
16 changes: 14 additions & 2 deletions components/nav/button/Explore.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,22 @@ defineProps<{
}>()

const lastAccessedExploreRoute = useLocalStorage(STORAGE_KEY_LAST_ACCESSED_EXPLORE_ROUTE, '')

const userSettings = useUserSettings()
const hideLabel = computed(() => getPreferences(userSettings.value, 'hideBottomNavLabel'))
</script>

<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">
<div i-ri:compass-3-line />
<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 min-w-0
class="coarse-pointer:select-none"
:class="hideLabel ? null : 'gap-1'"
@click="$scrollToTop"
>
<div aria-hidden="true" i-ri:compass-3-line />
<span v-if="!hideLabel" text-xs overflow-hidden text-ellipsis whitespace-nowrap>{{ $t('nav.explore') }}</span>
</NuxtLink>
</template>
15 changes: 13 additions & 2 deletions components/nav/button/Favorite.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@
defineProps<{
activeClass: string
}>()

const hideLabel = useHideBottomNavigationLabel()
</script>

<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">
<div i-ri:heart-line />
<NuxtLink
to="/favourites"
:aria-label="$t('nav.favourites')"
:active-class="activeClass"
flex flex-col items-center place-content-center h-full flex-1 min-w-0
class="coarse-pointer:select-none"
:class="hideLabel ? null : 'gap-1'"
@click="$scrollToTop"
>
<div aria-hidden="true" i-ri:heart-line />
<span v-if="!hideLabel" text-xs overflow-hidden text-ellipsis whitespace-nowrap>{{ $t('nav.favourites') }}</span>
</NuxtLink>
</template>
17 changes: 15 additions & 2 deletions components/nav/button/Federated.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
<script setup lang="ts">
import { useHideBottomNavigationLabel } from '~/composables/settings'

defineProps<{
activeClass: string
}>()

const hideLabel = useHideBottomNavigationLabel()
</script>

<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">
<div i-ri:earth-line />
<NuxtLink
:to="`/${currentServer}/public`"
:aria-label="$t('nav.federated')"
:active-class="activeClass"
flex flex-col items-center place-content-center h-full flex-1 min-w-0
class="coarse-pointer:select-none"
:class="hideLabel ? null : 'gap-1'"
@click="$scrollToTop"
>
<div aria-hidden="true" i-ri:earth-line />
<span v-if="!hideLabel" text-xs overflow-hidden text-ellipsis whitespace-nowrap>{{ $t('nav.federated') }}</span>
</NuxtLink>
</template>
15 changes: 13 additions & 2 deletions components/nav/button/Hashtag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@
defineProps<{
activeClass: string
}>()

const hideLabel = useHideBottomNavigationLabel()
</script>

<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">
<div i-ri:hashtag />
<NuxtLink
to="/hashtags"
:aria-label="$t('nav.hashtags')"
:active-class="activeClass"
flex flex-col items-center place-content-center h-full flex-1 min-w-0
class="coarse-pointer:select-none"
:class="hideLabel ? null : 'gap-1'"
@click="$scrollToTop"
>
<div aria-hidden="true" i-ri:hashtag />
<span v-if="!hideLabel" text-xs overflow-hidden text-ellipsis whitespace-nowrap>{{ $t('nav.hashtags') }}</span>
</NuxtLink>
</template>
15 changes: 13 additions & 2 deletions components/nav/button/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@
defineProps<{
activeClass: string
}>()

const hideLabel = useHideBottomNavigationLabel()
</script>

<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">
<div i-ri:home-5-line />
<NuxtLink
to="/home"
:aria-label="$t('nav.home')"
:active-class="activeClass"
flex flex-col items-center place-content-center h-full flex-1 min-w-0
class="coarse-pointer:select-none"
:class="hideLabel ? null : 'gap-1'"
@click="$scrollToTop"
>
<div aria-hidden="true" i-ri:home-5-line />
<span v-if="!hideLabel" text-xs overflow-hidden text-ellipsis whitespace-nowrap>{{ $t('nav.home') }}</span>
</NuxtLink>
</template>
13 changes: 10 additions & 3 deletions components/nav/button/List.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
<script setup lang="ts">
import { useHideBottomNavigationLabel } from '~/composables/settings'

defineProps<{
activeClass: string
}>()

const hideLabel = useHideBottomNavigationLabel()
</script>

<template>
<NuxtLink
to="/lists"
:aria-label="$t('nav.lists')"
:active-class="activeClass"
flex flex-row items-center place-content-center h-full flex-1
class="coarse-pointer:select-none" @click="$scrollToTop"
flex flex-col items-center place-content-center h-full flex-1 min-w-0
class="coarse-pointer:select-none"
:class="hideLabel ? null : 'gap-1'"
@click="$scrollToTop"
>
<div i-ri:list-check />
<div aria-hidden="true" i-ri:list-check />
<span v-if="!hideLabel" text-xs overflow-hidden text-ellipsis whitespace-nowrap>{{ $t('nav.lists') }}</span>
</NuxtLink>
</template>
15 changes: 13 additions & 2 deletions components/nav/button/Local.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@
defineProps<{
activeClass: string
}>()

const hideLabel = useHideBottomNavigationLabel()
</script>

<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">
<div i-ri:group-2-line />
<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 min-w-0
class="coarse-pointer:select-none"
:class="hideLabel ? null : 'gap-1'"
@click="$scrollToTop"
>
<div aria-hidden="true" i-ri:group-2-line />
<span v-if="!hideLabel" text-xs overflow-hidden text-ellipsis whitespace-nowrap>{{ $t('nav.local') }}</span>
</NuxtLink>
</template>
17 changes: 13 additions & 4 deletions components/nav/button/Mention.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@
defineProps<{
activeClass: string
}>()

const hideLabel = useHideBottomNavigationLabel()
</script>

<template>
<NuxtLink
to="/conversations" :aria-label="$t('nav.conversations')"
:active-class="activeClass" flex flex-row items-center place-content-center h-full
flex-1 class="coarse-pointer:select-none" @click="$scrollToTop"
to="/conversations"
:aria-label="$t('nav.conversations')"
:active-class="activeClass"
flex flex-col items-center place-content-center h-full flex-1 min-w-0
class="coarse-pointer:select-none"
:class="hideLabel ? null : 'gap-1'"
@click="$scrollToTop"
>
<div i-ri:at-line />
<div aria-hidden="true" i-ri:at-line />
<span v-if="!hideLabel" text-xs overflow-hidden text-ellipsis whitespace-nowrap>
{{ $t('nav.conversations') }}
</span>
</NuxtLink>
</template>
8 changes: 6 additions & 2 deletions components/nav/button/MoreMenu.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<script setup lang="ts">
const model = defineModel<boolean>()

const hideLabel = useHideBottomNavigationLabel()
</script>

<template>
Expand All @@ -8,12 +10,14 @@ const model = defineModel<boolean>()
place-content-center h-full flex-1 cursor-pointer
>
<button
flex items-center place-content-center h-full flex-1 class="select-none"
:class="show ? '!text-primary' : ''"
flex flex-col items-center place-content-center h-full flex-1 min-w-0
class="select-none"
:class="[show ? '!text-primary' : null, hideLabel ? null : 'gap-1'].filter(Boolean).join(' ')"
:aria-label="$t('nav.more_menu')"
@click="toggleVisible"
>
<span :class="show ? 'i-ri:close-fill' : 'i-ri:more-fill'" />
<span v-if="!hideLabel" text-xs overflow-hidden text-ellipsis whitespace-nowrap>{{ $t('nav.more_menu') }}</span>
</button>
</NavBottomMoreMenu>
</template>
16 changes: 14 additions & 2 deletions components/nav/button/Notification.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
<script setup lang="ts">
import { useHideBottomNavigationLabel } from '~/composables/settings'
import { STORAGE_KEY_LAST_ACCESSED_NOTIFICATION_ROUTE } from '~/constants'

defineProps<{
activeClass: string
}>()
const { notifications } = useNotifications()
const lastAccessedNotificationRoute = useLocalStorage(STORAGE_KEY_LAST_ACCESSED_NOTIFICATION_ROUTE, '')

const hideLabel = useHideBottomNavigationLabel()
</script>

<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 min-w-0
class="coarse-pointer:select-none"
:class="hideLabel ? null : 'gap-1'"
@click="$scrollToTop"
>
<div flex relative>
<div class="i-ri:notification-4-line" text-xl />
<div aria-hidden="true" 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>
{{ notifications < 10 ? notifications : '•' }}
</div>
</div>
<span v-if="!hideLabel" text-xs overflow-hidden text-ellipsis whitespace-nowrap>{{ $t('nav.notifications') }}</span>
</NuxtLink>
</template>
15 changes: 13 additions & 2 deletions components/nav/button/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@
defineProps<{
activeClass: string
}>()

const hideLabel = useHideBottomNavigationLabel()
</script>

<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">
<div i-ri:search-line />
<NuxtLink
to="/search"
:aria-label="$t('nav.search')"
:active-class="activeClass"
flex flex-col items-center place-content-center h-full flex-1 min-w-0
class="coarse-pointer:select-none"
:class="hideLabel ? null : 'gap-1'"
@click="$scrollToTop"
>
<div aria-hidden="true" i-ri:search-line />
<span v-if="!hideLabel" text-xs overflow-hidden text-ellipsis whitespace-nowrap>{{ $t('nav.search') }}</span>
</NuxtLink>
</template>
15 changes: 12 additions & 3 deletions components/settings/SettingsBottomNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,34 @@ function reset() {
function save() {
navButtonNamesSetting.value = selectedNavButtonNames.value
}

const hideLabel = useHideBottomNavigationLabel()
</script>

<template>
<section space-y-2>
<h2 id="interface-bn" font-medium>
{{ $t('settings.interface.bottom_nav') }}
</h2>
<SettingsToggleItem
:checked="hideLabel"
@click="togglePreferences('hideBottomNavLabel')"
>
{{ $t('settings.interface.bottom_nav_hide_label') }}
</SettingsToggleItem>
<form aria-labelledby="interface-bn" aria-describedby="interface-bn-desc" @submit.prevent="save">
<p id="interface-bn-desc" pb-2>
{{ $t('settings.interface.bottom_nav_instructions') }}
</p>
<!-- preview -->
<div aria-hidden="true" flex="~ gap4 wrap" items-center select-settings h-14>
<div aria-hidden="true" flex="~ wrap" items-center select-settings p-0 pt-1 h-auto>
<nav
v-for="availableNavButton in selectedNavButtons" :key="availableNavButton.name"
flex="~ 1" items-center justify-center text-xl
flex="~ col 1" items-center justify-center text-xl
scrollbar-hide overscroll-none
>
<span :class="availableNavButton.icon" />
<span v-if="!hideLabel" text-2.5 text-center>{{ $t(availableNavButton.label) }}</span>
</nav>
</div>

Expand All @@ -103,7 +112,7 @@ function save() {
:aria-checked="isAdded(name)"
@click="isAdded(name) ? remove(name) : append(name)"
>
<span :class="icon" />
<span aria-hidden="true" :class="icon" />
{{ label ? $t(label) : 'More menu' }}
</button>
</div>
Expand Down
Loading
Loading