Skip to content

Open source personal finance application

fix: improve button accessibility with semantic HTML and aria-labels

Ilya Komichev48eefa35c956
diff --git a/app/components/bottomSheet/BottomSheetClose.vue b/app/components/bottomSheet/BottomSheetClose.vue
index 61b385fe..be2c4aa6 100644
--- a/app/components/bottomSheet/BottomSheetClose.vue
+++ b/app/components/bottomSheet/BottomSheetClose.vue
@@ -5,8 +5,10 @@ const emit = defineEmits<{
</script>
<template>
- <div
- class="bg-item-3 absolute top-1 right-1 z-30 flex size-8 items-center justify-center rounded-full transition ease-in-out hover:bg-(--item-5)"
+ <button
+ type="button"
+ :aria-label="$t('base.close')"
+ class="bg-item-3 absolute top-1 right-1 z-30 flex size-8 cursor-default items-center justify-center rounded-full transition ease-in-out hover:bg-(--item-5)"
@click="(e: Event) => emit('click', e)"
>
<Icon
@@ -14,5 +16,5 @@ const emit = defineEmits<{
color="text-muted"
size="22"
/>
- </div>
+ </button>
</template>
diff --git a/app/components/categories/page/List.vue b/app/components/categories/page/List.vue
index a974bfd9..879e1043 100644
--- a/app/components/categories/page/List.vue
+++ b/app/components/categories/page/List.vue
@@ -78,14 +78,14 @@ const { getCategoryContextMenuItems } = useCategoryContextMenu({
<UiHeader>
<UiHeaderTitle>{{ t('categories.name') }}</UiHeaderTitle>
<template #actions>
- <UiActionButton @click="categoriesView = categoriesView === 'list' ? 'grid' : 'list'">
+ <UiActionButton :ariaLabel="$t('base.toggleView')" @click="categoriesView = categoriesView === 'list' ? 'grid' : 'list'">
<Icon
:name="categoriesView === 'list' ? 'lucide:layout-grid' : 'lucide:list'"
size="20"
/>
</UiActionButton>
- <UiActionButton @click="router.push('/categories/new')">
+ <UiActionButton :ariaLabel="$t('categories.new')" @click="router.push('/categories/new')">
<Icon name="lucide:plus" size="24" />
</UiActionButton>
</template>
diff --git a/app/components/currencies/page/List.vue b/app/components/currencies/page/List.vue
index c0f69b05..1bc39ad9 100644
--- a/app/components/currencies/page/List.vue
+++ b/app/components/currencies/page/List.vue
@@ -67,7 +67,7 @@ const list = computed(() => {
<UiHeader>
<UiHeaderTitle>{{ t('currencies.page.title') }}</UiHeaderTitle>
<template #actions>
- <UiActionButton @click="showAll = !showAll">
+ <UiActionButton :ariaLabel="$t('currencies.ariaFilter')" @click="showAll = !showAll">
<Icon
:name="showAll ? 'lucide:filter' : 'lucide:globe'"
size="20"
diff --git a/app/components/date/Nav.vue b/app/components/date/Nav.vue
index 49bfc905..6a43afcf 100644
--- a/app/components/date/Nav.vue
+++ b/app/components/date/Nav.vue
@@ -15,12 +15,14 @@ const emit = defineEmits<{
<div class="flex items-center gap-1">
<UiActionButton
v-if="position === 'left' && isShowNavHome"
+ :ariaLabel="$t('base.today')"
@click="emit('changeDate', 'today')"
>
<Icon name="lucide:undo-2" size="20" />
</UiActionButton>
<UiActionButton
+ :ariaLabel="$t('base.previous')"
:class="cn('bg-item-3', isStart && 'hover:transparent opacity-30')"
@click="emit('changeDate', 'prev')"
>
@@ -28,6 +30,7 @@ const emit = defineEmits<{
</UiActionButton>
<UiActionButton
+ :ariaLabel="$t('base.next')"
:class="cn('bg-item-3', isEnd && 'hover:transparent opacity-30')"
@click="emit('changeDate', 'next')"
>
@@ -36,6 +39,7 @@ const emit = defineEmits<{
<UiActionButton
v-if="position === 'right' && isShowNavHome"
+ :ariaLabel="$t('base.today')"
@click="emit('changeDate', 'today')"
>
<Icon name="lucide:undo-2" size="20" />
diff --git a/app/components/layout/Sidebar.vue b/app/components/layout/Sidebar.vue
index d9b7fb31..eccdaa7a 100644
--- a/app/components/layout/Sidebar.vue
+++ b/app/components/layout/Sidebar.vue
@@ -129,6 +129,7 @@ const { getWalletContextMenuItems } = useWalletContextMenu()
:kbds="['Meta', '\\']"
>
<UiActionButton
+ :ariaLabel="t('app.toggleSidebar')"
class="text-4 z-10"
@click="emit('toggleSidebar')"
>
diff --git a/app/components/stat/CategoriesButtons.vue b/app/components/stat/CategoriesButtons.vue
index e74b435f..fc2c4c79 100644
--- a/app/components/stat/CategoriesButtons.vue
+++ b/app/components/stat/CategoriesButtons.vue
@@ -71,6 +71,7 @@ function onChangeViewOptions(newViewOptions: Pick<DeepPartial<MiniItemConfig>, '
</UiChipButton>
<UiChipButton
+ :ariaLabel="$t('base.togglePresets')"
class="!grow-0"
@click="isShowMorePresets = !isShowMorePresets"
>
diff --git a/app/components/stat/categories/Section.vue b/app/components/stat/categories/Section.vue
index e0f9a273..214f1eb5 100644
--- a/app/components/stat/categories/Section.vue
+++ b/app/components/stat/categories/Section.vue
@@ -51,6 +51,7 @@ const filteredSet = computed(() => new Set(props.filteredCategoriesIds))
<UiTabsBar>
<UiActionButton
v-if="roundCategories.length > visibleCategoriesLimit"
+ :ariaLabel="$t('base.toggleExpand')"
size="sm"
@click="isExpanded = !isExpanded"
>
@@ -61,6 +62,7 @@ const filteredSet = computed(() => new Set(props.filteredCategoriesIds))
</UiActionButton>
<UiActionButton
+ :ariaLabel="$t('base.toggleGrouping')"
size="sm"
@click="statConfig.config.value.catsRound.isGrouped = !statConfig.config.value.catsRound.isGrouped"
>
diff --git a/app/components/stat/categories/Section2.vue b/app/components/stat/categories/Section2.vue
index 61024777..cf583bbf 100644
--- a/app/components/stat/categories/Section2.vue
+++ b/app/components/stat/categories/Section2.vue
@@ -132,6 +132,7 @@ function toggleRoot(id: CategoryId) {
class="flex items-center"
>
<UiActionButton
+ :ariaLabel="$t('base.toggleGrouping')"
:isActive="statConfig.config.value.vertical.isGrouped"
@click="statConfig.config.value.vertical.isGrouped = !statConfig.config.value.vertical.isGrouped"
>
@@ -179,6 +180,7 @@ function toggleRoot(id: CategoryId) {
>
<UiActionButton
v-if="statConfig.config.value.catsView === 'list' && !props.isOneCategory && statConfig.config.value.catsList.isGrouped"
+ :ariaLabel="$t('base.toggleFolders')"
@click="toggleOpened"
>
<Icon
@@ -200,6 +202,7 @@ function toggleRoot(id: CategoryId) {
<UiActionButton
v-if="!props.isOneCategory"
+ :ariaLabel="$t('base.toggleGrouping')"
:isActive="statConfig.config.value.catsList.isGrouped"
@click="statConfig.config.value.catsList.isGrouped = !statConfig.config.value.catsList.isGrouped"
>
diff --git a/app/components/stat/date/Nav.vue b/app/components/stat/date/Nav.vue
index 49bfc905..6a43afcf 100644
--- a/app/components/stat/date/Nav.vue
+++ b/app/components/stat/date/Nav.vue
@@ -15,12 +15,14 @@ const emit = defineEmits<{
<div class="flex items-center gap-1">
<UiActionButton
v-if="position === 'left' && isShowNavHome"
+ :ariaLabel="$t('base.today')"
@click="emit('changeDate', 'today')"
>
<Icon name="lucide:undo-2" size="20" />
</UiActionButton>
<UiActionButton
+ :ariaLabel="$t('base.previous')"
:class="cn('bg-item-3', isStart && 'hover:transparent opacity-30')"
@click="emit('changeDate', 'prev')"
>
@@ -28,6 +30,7 @@ const emit = defineEmits<{
</UiActionButton>
<UiActionButton
+ :ariaLabel="$t('base.next')"
:class="cn('bg-item-3', isEnd && 'hover:transparent opacity-30')"
@click="emit('changeDate', 'next')"
>
@@ -36,6 +39,7 @@ const emit = defineEmits<{
<UiActionButton
v-if="position === 'right' && isShowNavHome"
+ :ariaLabel="$t('base.today')"
@click="emit('changeDate', 'today')"
>
<Icon name="lucide:undo-2" size="20" />
diff --git a/app/components/trnForm/main/AmountTransfer.vue b/app/components/trnForm/main/AmountTransfer.vue
index 05514ea1..942eb3df 100644
--- a/app/components/trnForm/main/AmountTransfer.vue
+++ b/app/components/trnForm/main/AmountTransfer.vue
@@ -134,11 +134,11 @@ function copyAmount() {
v-if="item.transferType === 'expense'"
class="flex justify-center gap-1 pt-3 pb-1"
>
- <UiActionButton @click="switchWallets">
+ <UiActionButton :ariaLabel="$t('wallets.ariaSwitch')" @click="switchWallets">
<Icon name="lucide:arrow-up-down" size="24" />
</UiActionButton>
- <UiActionButton @click="copyAmount">
+ <UiActionButton :ariaLabel="$t('trnForm.ariaCopyAmount')" @click="copyAmount">
<Icon name="lucide:clipboard-paste" size="24" />
</UiActionButton>
</div>
diff --git a/app/components/ui/ActionButton.vue b/app/components/ui/ActionButton.vue
index 6b231903..cea0320d 100644
--- a/app/components/ui/ActionButton.vue
+++ b/app/components/ui/ActionButton.vue
@@ -1,5 +1,6 @@
<script setup lang="ts">
-const { isActive = false, size = 'md', variant = 'icon' } = defineProps<{
+const { ariaLabel, isActive = false, size = 'md', variant = 'icon' } = defineProps<{
+ ariaLabel?: string
isActive?: boolean
size?: 'sm' | 'md'
variant?: 'icon' | 'text'
@@ -11,9 +12,11 @@ const emit = defineEmits<{
</script>
<template>
- <div
+ <button
+ type="button"
+ :aria-label="ariaLabel"
:class="cn(
- 'interactive data-[state=open]:!bg-item-4 flex min-w-[42px] items-center justify-center rounded-sm',
+ 'interactive data-[state=open]:!bg-item-4 flex min-w-[42px] cursor-default items-center justify-center rounded-sm',
size === 'md' ? 'min-h-[38px]' : 'min-h-[32px]',
variant === 'icon' && 'text-muted text-xl',
variant === 'text' && 'text-1 px-3 text-sm',
@@ -22,5 +25,5 @@ const emit = defineEmits<{
@click="(e: Event) => emit('click', e)"
>
<slot />
- </div>
+ </button>
</template>
diff --git a/app/components/ui/ChipButton.vue b/app/components/ui/ChipButton.vue
index 23d0d4b2..62381b83 100644
--- a/app/components/ui/ChipButton.vue
+++ b/app/components/ui/ChipButton.vue
@@ -1,14 +1,20 @@
<script setup lang="ts">
+const { ariaLabel } = defineProps<{
+ ariaLabel?: string
+}>()
+
const emit = defineEmits<{
click: [e: Event]
}>()
</script>
<template>
- <div
- class="interactive bg-item-3 flex min-h-[38px] min-w-[42px] grow items-center justify-center rounded-sm px-2 py-1.5 text-sm"
+ <button
+ type="button"
+ :aria-label="ariaLabel"
+ class="interactive bg-item-3 flex min-h-[38px] min-w-[42px] grow cursor-default items-center justify-center rounded-sm px-2 py-1.5 text-sm"
@click="(e: Event) => emit('click', e)"
>
<slot />
- </div>
+ </button>
</template>
diff --git a/app/components/wallets/page/List.vue b/app/components/wallets/page/List.vue
index 29ec1faf..62453e9e 100644
--- a/app/components/wallets/page/List.vue
+++ b/app/components/wallets/page/List.vue
@@ -69,7 +69,7 @@ function hasGroups(groups: Record<string, unknown> | undefined) {
<UiHeaderTitle>{{ t('wallets.name') }}</UiHeaderTitle>
<template #actions>
- <UiActionButton @click="router.push('/wallets/new')">
+ <UiActionButton :ariaLabel="$t('wallets.new')" @click="router.push('/wallets/new')">
<Icon name="lucide:plus" size="24" />
</UiActionButton>
@@ -80,7 +80,7 @@ function hasGroups(groups: Record<string, unknown> | undefined) {
@openModal="isOpen = true"
>
<template #trigger>
- <UiActionButton>
+ <UiActionButton :ariaLabel="$t('base.moreOptions')">
<Icon name="lucide:ellipsis-vertical" size="20" />
</UiActionButton>
</template>
@@ -176,6 +176,7 @@ function hasGroups(groups: Record<string, unknown> | undefined) {
class="ml-auto flex items-center gap-1"
>
<UiActionButton
+ :ariaLabel="$t('base.toggleGrouping')"
@click="toggleSecondaryGrouping"
>
<Icon
@@ -184,7 +185,7 @@ function hasGroups(groups: Record<string, unknown> | undefined) {
/>
</UiActionButton>
- <UiActionButton @click="toggleOpened">
+ <UiActionButton :ariaLabel="$t('base.toggleFolders')" @click="toggleOpened">
<Icon
v-if="typeGroupsStatus.isAllOpen"
name="lucide:folder-open"
diff --git a/i18n/locales/en-US.js b/i18n/locales/en-US.js
index 7e6d41c0..e362ba26 100644
--- a/i18n/locales/en-US.js
+++ b/i18n/locales/en-US.js
@@ -37,10 +37,19 @@ export default {
duplicate: 'Duplicate',
edit: 'Edit',
loading: 'Loading...',
+ moreOptions: 'More options',
+ next: 'Next',
no: 'No',
noData: 'No data',
+ previous: 'Previous',
save: 'Save',
sure: 'Confirm action',
+ today: 'Today',
+ toggleExpand: 'Toggle expand',
+ toggleFolders: 'Toggle folders',
+ toggleGrouping: 'Toggle grouping',
+ togglePresets: 'Toggle presets',
+ toggleView: 'Toggle view',
yes: 'Yes',
},
@@ -111,6 +120,7 @@ export default {
},
currencies: {
+ ariaFilter: 'Filter currencies',
base: 'Base currency',
list: {
all: 'All',
@@ -345,6 +355,7 @@ export default {
trnForm: {
adjustmentTitle: 'Adjustment',
+ ariaCopyAmount: 'Copy amount',
category: {
select: 'Select category',
},
@@ -399,6 +410,7 @@ export default {
userLogout: 'Logout',
wallets: {
+ ariaSwitch: 'Switch wallets',
createNewTitle: 'New wallet',
errors: {
deleteFailed: 'Failed to delete wallet',
diff --git a/i18n/locales/ru-RU.js b/i18n/locales/ru-RU.js
index b0ba7097..b4456a99 100644
--- a/i18n/locales/ru-RU.js
+++ b/i18n/locales/ru-RU.js
@@ -37,10 +37,19 @@ export default {
duplicate: 'Дублировать',
edit: 'Редактировать',
loading: 'Загрузка...',
+ moreOptions: 'Ещё',
+ next: 'Вперёд',
no: 'Нет',
noData: 'Нет данных',
+ previous: 'Назад',
save: 'Сохранить',
sure: 'Удалить?',
+ today: 'Сегодня',
+ toggleExpand: 'Развернуть/свернуть',
+ toggleFolders: 'Папки',
+ toggleGrouping: 'Группировка',
+ togglePresets: 'Пресеты',
+ toggleView: 'Вид',
yes: 'Да',
},
@@ -111,6 +120,7 @@ export default {
},
currencies: {
+ ariaFilter: 'Фильтр валют',
base: 'Основная валюта',
list: {
all: 'Все',
@@ -345,6 +355,7 @@ export default {
trnForm: {
adjustmentTitle: 'Корректировка',
+ ariaCopyAmount: 'Копировать сумму',
category: {
select: 'Выбрать категорию',
},
@@ -399,6 +410,7 @@ export default {
userLogout: 'Выйти из аккаунта',
wallets: {
+ ariaSwitch: 'Поменять кошельки',
createNewTitle: 'Добавление кошелька',
errors: {
deleteFailed: 'Не удалось удалить кошелек',