Skip to content

Open source personal finance application

refactor: improve class order and structure, update translations for category and transaction forms

Ilya Komichevb5937813d4c3
diff --git a/app/components/app/Copyright.vue b/app/components/app/Copyright.vue
index 096a63a5..c5a58a7e 100644
--- a/app/components/app/Copyright.vue
+++ b/app/components/app/Copyright.vue
@@ -7,12 +7,12 @@ const { t } = useI18n()
<template>
<a
:class="[classes.item.rounded, classes.item.link, classes.item.center3]"
- class="px-5 py-2 text-sm text-muted"
+ class="text-muted px-5 py-2 text-sm"
href="https://ilko.me"
>
{{ t('madeBy.text') }}
<Icon
- class="mx-2 animate-[heartbeat_3s_ease-in-out_infinite] text-2xl text-alert-1"
+ class="text-alert-1 mx-2 animate-[heartbeat_3s_ease-in-out_infinite] text-2xl"
name="mdi:heart"
/>
{{ t('madeBy.name') }}
diff --git a/app/components/bottomSheet/BottomSheetClose.vue b/app/components/bottomSheet/BottomSheetClose.vue
index 953de84c..8f492235 100644
--- a/app/components/bottomSheet/BottomSheetClose.vue
+++ b/app/components/bottomSheet/BottomSheetClose.vue
@@ -6,7 +6,7 @@ const emit = defineEmits<{
<template>
<div
- class="absolute right-1 top-1 z-30 flex size-8 items-center justify-center rounded-full bg-item-3 transition ease-in-out hover:bg-[var(--item-5)]"
+ 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-[var(--item-5)]"
@click="(e: Event) => emit('onClick', e)"
>
<Icon
diff --git a/app/components/categories/Form.vue b/app/components/categories/Form.vue
index 854c3f27..047c5898 100644
--- a/app/components/categories/Form.vue
+++ b/app/components/categories/Form.vue
@@ -221,7 +221,7 @@ async function onSave() {
<template #default="{ close }">
<div class="bottomSheetContent">
<div>
- <UiTitleModal>{{ t('selectColor') }}</UiTitleModal>
+ <UiTitleModal>{{ t('categories.form.selectColor') }}</UiTitleModal>
<CategoriesItem
:categoryId="props.categoryId"
:category="categoryPlaceholder"
@@ -263,8 +263,8 @@ async function onSave() {
<template #default="{ close }">
<div class="bottomSheetContent">
- <div class="grid gap-3 pb-1 pt-3">
- <UiTitleModal>{{ t("selectIcon") }}</UiTitleModal>
+ <div class="grid gap-3 pt-3 pb-1">
+ <UiTitleModal>{{ t('categories.form.selectIcon') }}</UiTitleModal>
<CategoriesItem
:categoryId="props.categoryId"
:category="categoryPlaceholder"
@@ -272,7 +272,7 @@ async function onSave() {
</div>
<div class="scrollerBlock bottomSheetContentInside">
- <FormElement class="pb-4 pt-2">
+ <FormElement class="pt-2 pb-4">
<template #label>
{{ t('categories.form.icon.desc') }}
<a
@@ -299,7 +299,7 @@ async function onSave() {
:key="icon"
:class="[{ '!border-(--ui-primary)': icon === props.categoryForm.icon }]"
:style="{ background: props.categoryForm.color }"
- class="flex-center size-10 cursor-pointer rounded-full border-2 border-transparent text-icon-primary"
+ class="flex-center text-icon-primary size-10 cursor-pointer rounded-full border-2 border-transparent"
@click="emit('updateValue', 'icon', icon)"
>
<Icon :name="icon" size="20" />
@@ -333,7 +333,7 @@ async function onSave() {
<template #default="{ close }">
<div class="bottomSheetContent">
- <UiTitleModal>{{ t('selectParent') }}</UiTitleModal>
+ <UiTitleModal>{{ t('categories.form.selectParent') }}</UiTitleModal>
<div class="scrollerBlock bottomSheetContentInside">
<UiItem2
@@ -366,15 +366,3 @@ async function onSave() {
</BottomSheet>
</Teleport>
</template>
-
-<i18n lang="yaml">
-en:
- selectIcon: Category icon
- selectColor: Category color
- selectParent: Parent category
-
-ru:
- selectIcon: Иконка категории
- selectColor: Цвет категории
- selectParent: Родительская категория
-</i18n>
diff --git a/app/components/categories/Header.vue b/app/components/categories/Header.vue
index 75b9e676..4a4dab6e 100644
--- a/app/components/categories/Header.vue
+++ b/app/components/categories/Header.vue
@@ -25,14 +25,14 @@ function onParentClick() {
class="mt-[-2px] size-5"
/>
- <div class="@lg:text-xl text-lg font-semibold">
+ <div class="text-lg font-semibold @lg:text-xl">
{{ props.category.name }}
</div>
</div>
<div
v-if="props.parentCategory"
- class="@lg:text-base flex items-center pt-[3px] text-xs font-medium leading-none text-2"
+ class="text-2 flex items-center pt-[3px] text-xs leading-none font-medium @lg:text-base"
>
<div class="text-2xs text-4">
•
diff --git a/app/components/categories/Name.vue b/app/components/categories/Name.vue
index dc51ba1a..eaecac78 100644
--- a/app/components/categories/Name.vue
+++ b/app/components/categories/Name.vue
@@ -18,18 +18,18 @@ const props = defineProps<{
<div :class="cn('flex gap-3 items-baseline pt-0', { 'flex-col !gap-0.5': props.alt })">
<!-- Parent category name -->
<template v-if="alt && isShowParent && !props.hasChildren && props.category?.parentId">
- <div class="text-2xs leading-none text-4">
+ <div class="text-2xs text-4 leading-none">
{{ props.parentCategory?.name }}
</div>
</template>
<!-- Base name -->
- <div class="flex items-center gap-2 text-nowrap text-xs font-semibold leading-none tracking-wide">
+ <div class="text-toned flex items-center gap-2 text-sm leading-none font-medium tracking-wide text-nowrap">
{{ props.category?.name }}
<!-- Has childs -->
<div
v-if="props.isShowDots && props.hasChildren"
- class="text-xs leading-none text-4"
+ class="text-4 text-xs leading-none"
>
...
</div>
@@ -44,11 +44,11 @@ const props = defineProps<{
<!-- Parent category name -->
<template v-if="!alt && isShowParent && !props.hasChildren && props.category?.parentId">
- <div class="text-nowrap text-2xs leading-none text-4">
+ <div class="text-2xs text-4 leading-none text-nowrap">
•
</div>
- <div class="text-2xs leading-none text-4">
+ <div class="text-2xs text-4 leading-none">
{{ props.parentCategory?.name }}
</div>
</template>
diff --git a/app/components/categories/page/List.vue b/app/components/categories/page/List.vue
index ef6efe30..fea9ae36 100644
--- a/app/components/categories/page/List.vue
+++ b/app/components/categories/page/List.vue
@@ -60,7 +60,7 @@ const categoriesView = useStorage<'list' | 'grid'>('finapp.categoriesView', 'lis
lineWidth: categoriesView === 'list' ? 1 : 0,
}"
:class="{
- '@2xl/page:grid-cols-3 @sm:grid-cols-2 grid gap-1.5': categoriesView === 'grid',
+ 'grid gap-1.5 @sm:grid-cols-2 @2xl/page:grid-cols-3': categoriesView === 'grid',
}"
:insideClasses="categoriesView === 'grid' ? 'bg-item-2' : ''"
@click="(categoryId: CategoryId) => router.push(`/categories/${categoryId}`)"
diff --git a/app/components/categories/page/id/Index.vue b/app/components/categories/page/id/Index.vue
index 1109597c..fdae0ad3 100644
--- a/app/components/categories/page/id/Index.vue
+++ b/app/components/categories/page/id/Index.vue
@@ -90,7 +90,6 @@ function onEditClick(close: () => void) {
useHead({ title: category.value?.name })
-// TODO: translate
const deleteDescText = computed(() => {
if (trnsIds.value && trnsIds.value.length > 0)
return t('categories.form.delete.alertWithTrns', { trns: t('trns.plural', trnsIds.value.length) })
@@ -147,7 +146,7 @@ async function onDeleteConfirm() {
}"
:filter="{
isShow: true,
- isShowCategories: true,
+ isShowWallets: true,
}"
>
<template #title>
diff --git a/app/components/form/Input.vue b/app/components/form/Input.vue
index b78b4352..4486584f 100644
--- a/app/components/form/Input.vue
+++ b/app/components/form/Input.vue
@@ -18,7 +18,7 @@ const emit = defineEmits<{
:value="props.value"
:class="getStyles('item', ['link', 'rounded'])"
:type="props.type ?? 'text'"
- class="m-0 w-full border border-solid border-item-6 bg-item-3 px-3 py-2 text-base font-normal placeholder:text-muted hover:border-(--ui-primary) hover:bg-[var(--item-5)] hover:text-1 hover:outline-none"
+ class="border-item-6 bg-item-3 placeholder:text-muted hover:text-1 m-0 w-full border border-solid px-3 py-2 text-base font-normal hover:border-(--ui-primary) hover:bg-[var(--item-5)] hover:outline-none"
@input="(event: HTMLInputEvent) => emit('updateValue', event.target.value)"
>
</template>
diff --git a/app/components/stat/chart/View.vue b/app/components/stat/chart/View.vue
index 9d9fca39..4ea39454 100644
--- a/app/components/stat/chart/View.vue
+++ b/app/components/stat/chart/View.vue
@@ -7,8 +7,8 @@ import { SVGRenderer } from 'echarts/renderers'
import VChart from 'vue-echarts'
import type { Period } from '~/components/date/types'
-import type { PeriodNameWithAll } from '~/components/stat/filter/types'
import type { ChartType } from '~/components/stat/chart/types'
+import type { PeriodNameWithAll } from '~/components/stat/filter/types'
import { formatByLocale } from '~/components/date/utils'
import { config, lineConfig } from '~/components/stat/chart/config'
diff --git a/app/components/stat/date/Range.vue b/app/components/stat/date/Range.vue
index da07b903..75e6f24c 100644
--- a/app/components/stat/date/Range.vue
+++ b/app/components/stat/date/Range.vue
@@ -26,11 +26,11 @@ const date = computed(() => {
</script>
<template>
- <div class="flex items-center gap-1 leading-none tracking-wide text-nowrap">
+ <div class="flex items-center gap-1 leading-none text-nowrap">
{{ date }}
<data
v-if="statDate.params.value.isShowMaxRange && statDate.params.value.intervalSelected === -1"
- class="flex-inline w-auto bg-item-4 text-2xs text-4 items-center rounded-sm px-1 py-px leading-none"
+ class="flex-inline bg-item-3 text-2xs text-4 w-auto items-center rounded-sm px-1 py-px leading-none"
>max</data>
</div>
</template>
diff --git a/app/components/stat/date/Selector.vue b/app/components/stat/date/Selector.vue
index 17d86b1c..a4004e8c 100644
--- a/app/components/stat/date/Selector.vue
+++ b/app/components/stat/date/Selector.vue
@@ -1,7 +1,7 @@
<script setup lang="ts">
import type { Grouped, Range, StatDateProvider } from '~/components/date/types'
-import { getUCalendarTimedDate, getUCalendarToday, parseUCalendarDate } from '~/components/date/utils'
+import { getUCalendarToday, parseUCalendarDate } from '~/components/date/utils'
const emit = defineEmits<{
onClose: []
@@ -110,7 +110,7 @@ function onSelectRange(value: unknown) {
{{ t(`dates.${item.intervalsBy}.simple`) }}
</DateLinkItem>
- <div class="flex border border-default rounded-sm bg-default p-px gap-1">
+ <div class="border-default bg-default flex gap-1 rounded-sm border p-px">
<DateLinkItem @click="statDate.delInterval">
-
</DateLinkItem>
diff --git a/app/components/stat/sum/Item.vue b/app/components/stat/sum/Item.vue
index dca31942..6814eeb7 100644
--- a/app/components/stat/sum/Item.vue
+++ b/app/components/stat/sum/Item.vue
@@ -25,9 +25,9 @@ const currenciesStore = useCurrenciesStore()
<template>
<div
- class="@2xl/page:px-4 @2xl/page:py-2 rounded-sm border border-transparent bg-[var(--item-3)] px-2 py-2 grow flex-1 flex-wrap @2xl/page:max-w-max"
+ class="flex-1 grow flex-wrap rounded-sm border border-transparent bg-[var(--item-3)] px-2 py-2 @2xl/page:max-w-max @2xl/page:px-4 @2xl/page:py-2"
:class="{
- '!border-(--ui-primary)/40 !bg-item-2': props.isActive,
+ '!bg-item-2 !border-(--ui-primary)/40': props.isActive,
}"
@click="(e: Event) => emit('click', e)"
>
diff --git a/app/components/trnForm/EditedTrn.vue b/app/components/trnForm/EditedTrn.vue
new file mode 100644
index 00000000..680657a2
--- /dev/null
+++ b/app/components/trnForm/EditedTrn.vue
@@ -0,0 +1,119 @@
+<script lang="ts" setup>
+import { useTrnsFormStore } from '~/components/trnForm/useTrnsFormStore'
+import { useTrnsStore } from '~/components/trns/useTrnsStore'
+
+const trnsStore = useTrnsStore()
+const trnsFormStore = useTrnsFormStore()
+const { t } = useI18n()
+
+const showModalConfirm = ref(false)
+
+function handleDeleteConfirm() {
+ trnsStore.deleteTrn(JSON.parse(JSON.stringify(trnsFormStore.values.trnId)))
+ showModalConfirm.value = false
+}
+
+const items = computed(() => ({
+ duplicate: {
+ click: () => {
+ if (trnsFormStore.values.trnId) {
+ trnsFormStore.trnFormDuplicate(trnsFormStore.values.trnId)
+ trnsFormStore.values.trnId = null
+ }
+ },
+ icon: 'mdi:content-copy',
+ label: t('base.duplicate'),
+ },
+ // eslint-disable-next-line perfectionist/sort-objects
+ delete: {
+ click: () => {
+ showModalConfirm.value = true
+ },
+ icon: 'mdi:delete-empty-outline',
+ label: t('base.delete'),
+ },
+}))
+
+const actions = computed(() => ({
+ no: {
+ click: () => {
+ showModalConfirm.value = false
+ },
+ icon: 'mdi:close',
+ label: t('base.no'),
+ },
+
+ yes: {
+ click: () => {
+ handleDeleteConfirm()
+ trnsFormStore.onClose()
+ },
+ icon: 'mdi:check',
+ label: t('base.yes'),
+ },
+}))
+</script>
+
+<template>
+ <div
+ v-if="trnsFormStore.values.trnId"
+ class="relative mb-2 px-3"
+ >
+ <TrnsItem
+ :trnItem="trnsStore.computeTrnItem(trnsFormStore.values.trnId)"
+ class="group bg-item-3 rounded-lg"
+ @click="trnsFormStore.values.trnId = null"
+ />
+
+ <div
+ v-if="showModalConfirm"
+ class="absolute -bottom-4 left-0 z-20 w-full px-4"
+ >
+ <div class="text-1 z-10 grid h-full content-center gap-4 rounded-lg border border-(--ui-primary) bg-[var(--item-1)] p-3">
+ {{ t('trnForm.delete.alert') }}
+
+ <div class="flex gap-2">
+ <UiElement
+ v-for="(item, slug) in actions"
+ :key="slug"
+ :insideClasses="slug === 'yes' ? '!min-h-[44px] bg-item-4' : '!min-h-[44px] bg-item-3'"
+ class="grow"
+ @click="item.click"
+ >
+ <template #leftIcon>
+ <Icon
+ :name="item.icon"
+ size="22"
+ />
+ </template>
+
+ <div class="text-muted leading-none">
+ {{ item.label }}
+ </div>
+ </UiElement>
+ </div>
+ </div>
+ </div>
+
+ <!-- Trn actions -->
+ <div class="flex pt-2">
+ <UiItem1
+ v-for="(item, slug) in items"
+ :key="slug"
+ variant="text"
+ @click="item.click"
+ >
+ <template #leftIcon>
+ <Icon
+ :name="item.icon"
+ size="22"
+ />
+ </template>
+
+ <div class="text-muted leading-none">
+ {{ t(item.label) }}
+ </div>
+ </UiItem1>
+ </div>
+ </div>
+</template>
diff --git a/app/components/trnForm/Selection.vue b/app/components/trnForm/Selection.vue
index 01271ab7..4738bfb8 100644
--- a/app/components/trnForm/Selection.vue
+++ b/app/components/trnForm/Selection.vue
@@ -102,7 +102,7 @@ async function onSelectParentCategory(id: CategoryId) {
:style="{ height: props.maxHeight }"
class="swiper-slide"
>
- <div class="scrollerBlock h-full overflow-y-auto pb-3 grid gap-4">
+ <div class="scrollerBlock grid h-full gap-4 overflow-y-auto pb-3">
<TrnFormSelectionCategoriesFast
@onSelectCategory="id => onSelectCategory(id, close)"
@onSelectParentCategory="id => onSelectParentCategory(id)"
@@ -117,7 +117,7 @@ async function onSelectParentCategory(id: CategoryId) {
>
<div class="scrollerBlock h-full overflow-y-auto pb-3">
<UiTitle3
- class="sticky top-0 z-10 bg-[var(--item-1)] px-3 pb-3 pt-4"
+ class="sticky top-0 z-10 bg-[var(--item-1)] px-3 pt-4 pb-3"
@click="trnsFormStore.ui.catsRootModal = true"
>
{{ $t("categories.title") }}
diff --git a/app/components/ui/IconBase.vue b/app/components/ui/IconBase.vue
index e93afdd2..82a89b01 100644
--- a/app/components/ui/IconBase.vue
+++ b/app/components/ui/IconBase.vue
@@ -23,7 +23,7 @@ const emit = defineEmits<{
:class="{
[cn('rounded-full w-7 p-1.5', props.class)]: props.invert,
}"
- class="flex-center aspect-square overflow-hidden text-icon-primary"
+ class="flex-center text-icon-primary aspect-square overflow-hidden"
@click="(e: Event) => emit('click', e)"
>
<Icon
diff --git a/app/components/ui/TitleModal.vue b/app/components/ui/TitleModal.vue
index b0e661ca..8f9c9ac7 100644
--- a/app/components/ui/TitleModal.vue
+++ b/app/components/ui/TitleModal.vue
@@ -6,7 +6,7 @@ const emit = defineEmits<{
<template>
<div
- class="sticky top-0 z-20 bg-default px-4 pb-4 pt-5 font-tertiary text-lg font-semibold leading-none"
+ class="bg-default font-tertiary sticky top-0 z-20 px-4 pt-5 pb-4 text-lg leading-none font-semibold"
@click="(e: Event) => emit('click', e)"
>
<slot />
diff --git a/i18n/locales/en-US.js b/i18n/locales/en-US.js
index a54d3a4e..8bd4f64e 100644
--- a/i18n/locales/en-US.js
+++ b/i18n/locales/en-US.js
@@ -50,7 +50,7 @@ export default {
form: {
childColor: 'Apply color to all child categories',
delete: {
- alertWithTrns: `This will delete {trns} transactions`,
+ alertWithTrns: `This will delete {trns}`,
errorChilds: 'You cannot delete a category with child categories. Delete the child categories first.',
okWithoutTrns: 'Category deleted',
okWithTrns: `Category and {trns} transactions deleted`,
@@ -81,6 +81,9 @@ export default {
search: {
placeholder: 'Search categories...',
},
+ selectColor: 'Category color',
+ selectIcon: 'Category icon',
+ selectParent: 'Parent category',
title: 'Categories',
},
@@ -340,11 +343,15 @@ export default {
},
trnForm: {
- calcTrnButton: 'Calculate',
+ btnCalculate: 'Calculate',
+ btnSave: 'Save',
category: {
select: 'Select category',
},
createTrn: 'Add transaction',
+ delete: {
+ alert: 'Are you sure you want to delete this transaction?',
+ },
description: {
placeholder: 'Write...',
title: 'Description',
@@ -403,7 +410,7 @@ export default {
placeholder: 'Select currency',
},
delete: {
- alertWithTrns: `This will delete {trns} transactions`,
+ alertWithTrns: `This will delete {trns}`,
errorChilds: 'You can not delete wallet with child categories. Delete child categories first.',
okWithoutTrns: 'Wallet deleted',
okWithTrns: `Wallet deleted and {trns}`,
diff --git a/i18n/locales/ru-RU.js b/i18n/locales/ru-RU.js
index 9472eecd..e2e70812 100644
--- a/i18n/locales/ru-RU.js
+++ b/i18n/locales/ru-RU.js
@@ -73,6 +73,9 @@ export default {
},
recentCategory: 'Показывать в недавно использованных',
save: 'Сохранить',
+ selectColor: 'Цвет категории',
+ selectIcon: 'Иконка категории',
+ selectParent: 'Родительская категория',
},
name: 'Категории',
new: 'Новая категория',
@@ -341,11 +344,15 @@ export default {
},
trnForm: {
- calcTrnButton: 'Посчитать результат',
+ btnCalculate: 'Посчитать результат',
+ btnSave: 'Сохранить',
category: {
select: 'Выбрать категорию',
},
createTrn: 'Создать транзакцию',
+ delete: {
+ alert: 'Вы уверены, что хотите удалить эту транзакцию?',
+ },
description: {
placeholder: 'Напишите...',
title: 'Описание',