Skip to content

Open source personal finance application

refactor: unify CategoriesName with size prop, rename alt to stacked, add i18n keys

Ilya Komichevb57af18c6b27
diff --git a/app/components/categories/Name.vue b/app/components/categories/Name.vue
index 1d764bf0..836a3ffd 100644
--- a/app/components/categories/Name.vue
+++ b/app/components/categories/Name.vue
@@ -2,42 +2,43 @@
import type { CategoryItem } from '~/components/categories/types'
const props = defineProps<{
- alt?: boolean
category: CategoryItem
- hasChildren?: boolean
- isShowDots?: boolean
+ childrenCount?: number
isShowParent?: boolean
parentCategory?: CategoryItem
- showChildrenCount?: number
+ size?: 'default' | 'xs'
+ stacked?: boolean
}>()
+
+const hasChildren = computed(() => (props.childrenCount ?? 0) > 0)
+
+const nameClass = computed(() =>
+ props.size === 'xs'
+ ? 'text-xs leading-none text-nowrap'
+ : 'text-toned text-sm leading-none font-medium tracking-wide text-nowrap',
+)
</script>
<template>
- <div :class="cn('flex gap-3 items-baseline pt-0', props.alt && 'flex-col gap-0.5')">
- <template v-if="alt && isShowParent && !props.hasChildren && props.category?.parentId">
- <div class="text-2xs text-4 leading-none">
- {{ props.parentCategory?.name }}
- </div>
- </template>
-
- <div class="text-toned flex items-center gap-2 text-sm leading-none font-medium tracking-wide text-nowrap">
+ <div :class="cn('flex gap-3 items-baseline pt-0', props.stacked && 'flex-col gap-0.5')">
+ <div class="flex items-center gap-2" :class="[nameClass]">
{{ props.category?.name }}
- <div
- v-if="props.isShowDots && props.hasChildren"
- class="text-4 text-xs leading-none"
- >
- ...
- </div>
<div
- v-if="showChildrenCount && showChildrenCount > 0"
+ v-if="hasChildren && childrenCount"
class="text-4"
>
- {{ showChildrenCount }}
+ {{ childrenCount }}
</div>
</div>
- <template v-if="!alt && isShowParent && !props.hasChildren && props.category?.parentId">
+ <template v-if="stacked && isShowParent && !hasChildren && props.category?.parentId">
+ <div class="text-2xs text-4 leading-none">
+ {{ props.parentCategory?.name }}
+ </div>
+ </template>
+
+ <template v-if="!stacked && isShowParent && !hasChildren && props.category?.parentId">
<div class="text-2xs text-4 leading-none text-nowrap">
•
</div>
diff --git a/app/components/stat/categories/Line.vue b/app/components/stat/categories/Line.vue
index 283b0b10..ccc00ba2 100644
--- a/app/components/stat/categories/Line.vue
+++ b/app/components/stat/categories/Line.vue
@@ -99,11 +99,10 @@ const { longPressRef } = useCategoryLongPress(
<CategoriesName
:category
+ :childrenCount="props.item.categories?.length"
:class="{ '!pb-2': isLines }"
- :hasChildren="categoriesStore.getChildrenIds(props.item.id).length > 0"
:isShowParent="props.isShowParent"
:parentCategory
- :showChildrenCount="props.item.categories?.length"
/>
<div
diff --git a/app/components/stat/categories/Round2lines.vue b/app/components/stat/categories/Round2lines.vue
index e8ead044..aee4c02e 100644
--- a/app/components/stat/categories/Round2lines.vue
+++ b/app/components/stat/categories/Round2lines.vue
@@ -9,6 +9,7 @@ import { getTrnTypeByAmount } from '~/components/trns/types'
const props = defineProps<{
isShowAmount?: boolean
+ isShowParent?: boolean
item: CategoryWithData
}>()
@@ -20,6 +21,11 @@ const categoriesStore = useCategoriesStore()
const currenciesStore = useCurrenciesStore()
const category = computed(() => categoriesStore.items[props.item.id])
+const parentCategory = computed(() => {
+ if (!category.value?.parentId)
+ return undefined
+ return categoriesStore.items[category.value.parentId]
+})
const { longPressRef } = useCategoryLongPress(
() => props.item.id,
@@ -49,9 +55,13 @@ const { longPressRef } = useCategoryLongPress(
</div>
<div>
- <div class="text-xs">
- {{ category.name }}
- </div>
+ <CategoriesName
+ :category
+ :isShowParent="props.isShowParent"
+ :parentCategory
+ stacked
+ size="xs"
+ />
<div
v-if="props.isShowAmount"
diff --git a/app/components/stat/sum/Item.vue b/app/components/stat/sum/Item.vue
index 37600dde..675f661a 100644
--- a/app/components/stat/sum/Item.vue
+++ b/app/components/stat/sum/Item.vue
@@ -21,7 +21,7 @@ const currenciesStore = useCurrenciesStore()
<template>
<div
- :class="cn('flex-1 flex-wrap rounded-sm border border-transparent bg-(--item-3) px-2 py-2 @2xl/page:max-w-max @2xl/page:px-4 @2xl/page:py-2',
+ :class="cn('flex-1 flex-wrap rounded-sm border border-transparent bg-(--item-3) px-3 py-2 @2xl/stat:max-w-max',
props.isActive && 'bg-item-2 border-(--ui-primary)/40',
)"
@click="(e: Event) => emit('click', e)"
diff --git a/app/components/stat/sum/Wrap.vue b/app/components/stat/sum/Wrap.vue
index ad272af0..d1ce7d03 100644
--- a/app/components/stat/sum/Wrap.vue
+++ b/app/components/stat/sum/Wrap.vue
@@ -27,7 +27,7 @@ const statConfig = inject(statConfigKey)!
const isShowAverage = computed(() => statConfig.config.value.statAverage.isShow)
const className = computed(() => cn(
- 'min-w-min rounded-sm min-h-[42px] flex items-center px-3',
+ 'min-w-min min-h-[42px] flex items-center',
{
interactive: props.type === 'summary',
},
@@ -42,7 +42,7 @@ function onClick(type: SeriesSlugSelected) {
<div class="overflow-x-auto">
<div
v-if="props.type === 'summary'"
- class="flex flex-wrap gap-2 @2xl/page:justify-start"
+ class="flex flex-wrap gap-2 @2xl/stat:justify-start"
>
<StatSumItem
:amount="-total.expense"
diff --git a/i18n/locales/en-US.js b/i18n/locales/en-US.js
index 1f06a8bd..7ca59dfe 100644
--- a/i18n/locales/en-US.js
+++ b/i18n/locales/en-US.js
@@ -37,6 +37,7 @@ export default {
duplicate: 'Duplicate',
edit: 'Edit',
loading: 'Loading...',
+ menu: 'Menu',
moreOptions: 'More options',
next: 'Next',
no: 'No',
@@ -255,6 +256,12 @@ export default {
introWallets: 'Start tracking your finances by adding your first wallet',
},
+ search: {
+ noResults: 'Nothing found',
+ placeholder: 'Search categories, wallets, transactions...',
+ title: 'Search',
+ },
+
settings: {
caution: 'With caution',
deleteButton: 'Delete my data',
@@ -284,6 +291,9 @@ export default {
title: 'List categories',
},
rounds: {
+ groupByParent: 'Group by parent',
+ showFavorites: 'Show favorites',
+ showRecent: 'Show recent',
title: 'Rounds categories',
},
vertical: {
diff --git a/i18n/locales/ru-RU.js b/i18n/locales/ru-RU.js
index b43aec7d..b8bc55a9 100644
--- a/i18n/locales/ru-RU.js
+++ b/i18n/locales/ru-RU.js
@@ -37,6 +37,7 @@ export default {
duplicate: 'Дублировать',
edit: 'Редактировать',
loading: 'Загрузка...',
+ menu: 'Меню',
moreOptions: 'Ещё',
next: 'Вперёд',
no: 'Нет',
@@ -255,6 +256,12 @@ export default {
introWallets: 'Начните учёт финансов, добавив первый кошелёк',
},
+ search: {
+ noResults: 'Ничего не найдено',
+ placeholder: 'Поиск категорий, кошельков, транзакций...',
+ title: 'Поиск',
+ },
+
settings: {
caution: 'C осторожностью',
deleteButton: 'Удалить все мои данные',
@@ -284,6 +291,9 @@ export default {
title: 'Список категорий',
},
rounds: {
+ groupByParent: 'Группировать по родителю',
+ showFavorites: 'Показывать избранные',
+ showRecent: 'Показывать недавние',
title: 'Круглые категории',
},
vertical: {
@@ -417,7 +427,7 @@ export default {
orderFailed: 'Не удалось сохранить порядок кошельков',
saveFailed: 'Не удалось сохранить кошелек',
},
- filter: 'Фильтровать кошельки',
+ filter: 'Фильтр по кошелькам',
filterByCurrency: 'Валюты кошельков',
form: {
credit: {