Open source personal finance application
refactor: improve component styles and structure across various files
Ilya Komichevf79691095e24
diff --git a/app/components/categories/Form.vue b/app/components/categories/Form.vueindex d7422894..9c9d4f8f 100644--- a/app/components/categories/Form.vue+++ b/app/components/categories/Form.vue@@ -309,7 +309,7 @@ async function onSave() {:key="icon":class="[{ '!border-accent-1': icon === props.categoryForm.icon }]":style="{ background: props.categoryForm.color }"- class="flex-center text-icon-primary size-10 cursor-pointer rounded-full border-2 border-transparent"+ class="flex-center size-10 cursor-pointer rounded-full border-2 border-transparent text-icon-primary"@click="emit('updateValue', 'icon', icon)"><Icon :name="icon" size="20" />diff --git a/app/components/categories/Selector.vue b/app/components/categories/Selector.vueindex 41ab8bd5..38061d46 100644--- a/app/components/categories/Selector.vue+++ b/app/components/categories/Selector.vue@@ -66,9 +66,9 @@ onMounted(() => {:key="categoryId"class="group/item":class="{- 'bg-item-3 relative mb-2 rounded-md': opened.includes(categoryId),- 'bg-item-3 rounded-md': isChildsSelected(categoryId),- '!border-accent-1/60 border': isEveryChildsSelected(categoryId),+ 'relative mb-2 rounded-md bg-item-3': opened.includes(categoryId),+ 'rounded-md bg-item-3': isChildsSelected(categoryId),+ 'border !border-accent-1/60': isEveryChildsSelected(categoryId),}"><CategoriesItemdiff --git a/app/components/stat/CategoriesButtons.vue b/app/components/stat/CategoriesButtons.vueindex c7b2c3f5..d71e9711 100644--- a/app/components/stat/CategoriesButtons.vue+++ b/app/components/stat/CategoriesButtons.vue@@ -98,7 +98,7 @@ function onChangeViewOptions(newViewOptions: any) {<template><div class=""><!-- List -->- <div class="border-item-4 grid gap-3 border-b pb-2 last:border-0">+ <div class="grid gap-3 border-b border-item-4 pb-2 last:border-0"><UiTitleOption>{{ t('listItemsOptions') }}</UiTitleOption><div class="flex gap-1"><UiItem2@@ -152,7 +152,7 @@ function onChangeViewOptions(newViewOptions: any) {<!-- TODO: use StatConfig --><divv-if="false"- class="border-item-4 border-b pb-2 last:border-0 last:pb-0"+ class="border-b border-item-4 pb-2 last:border-0 last:pb-0"><!-- Favorite --><UiElement@@ -190,7 +190,7 @@ function onChangeViewOptions(newViewOptions: any) {</div><div- class="border-item-4 grid gap-3 border-b pb-2 pt-3 last:border-0"+ class="grid gap-3 border-b border-item-4 pb-2 pt-3 last:border-0"><UiTitleOption>{{ t('elements') }}</UiTitleOption><div class="">diff --git a/app/components/stat/Config.vue b/app/components/stat/Config.vueindex b7570385..6a466a9e 100644--- a/app/components/stat/Config.vue+++ b/app/components/stat/Config.vue@@ -47,7 +47,7 @@ function updateStatAverage(value: number) {<BottomSheetClose @click="close" /><!-- Chart -->- <div class="border-item-3 border-b pb-3">+ <div class="border-b border-item-3 pb-3"><UiTitleOption class="pb-2">{{ t('stat.config.chartShow.title') }}</UiTitleOption>@@ -116,7 +116,7 @@ function updateStatAverage(value: number) {<!-- Showed wallets --><divv-if="props.isShowWallets"- class="border-item-3 border-b pb-3"+ class="border-b border-item-3 pb-3"><UiTitleOption class="pb-2">{{ t('stat.config.wallets.title') }}@@ -163,7 +163,7 @@ function updateStatAverage(value: number) {<!-- Statistics --><div- class="border-item-3 border-b pb-3"+ class="border-b border-item-3 pb-3"><UiTitleOption class="pb-2">{{ t('statistics.title') }}diff --git a/app/components/stat/Item.vue b/app/components/stat/Item.vueindex a0d0d7c5..172f9d65 100644--- a/app/components/stat/Item.vue+++ b/app/components/stat/Item.vue@@ -51,9 +51,10 @@ const selectedTypesMapping = computed(() => {income: [1, 2],netIncome: [0, 1, 2],summary: [0, 1, 2],+ trns: [0, 1, 2],} as const- const trnsTypes = typeMapping[props.type === 'netIncome' ? selectedType.value : props.type]+ const trnsTypes = typeMapping[(props.type === 'netIncome' || props.type === 'trns') ? selectedType.value : props.type]if (trnsTypes)return trnsTypes@@ -131,7 +132,7 @@ const typesToShow = computed(() => {const isAnyExpense = rangeTrnsIds.value.some(id => trnsStore.items?.[id]?.type === 0)const isAnyIncome = rangeTrnsIds.value.some(id => trnsStore.items?.[id]?.type === 1)- return props.type === 'netIncome' || props.type === 'periods'+ return props.type === 'netIncome' || props.type === 'periods' || props.type === 'trns'? [...(isAnyIncome ? ['income'] : []),...(isAnyExpense ? ['expense'] : []),@@ -228,7 +229,6 @@ function getIntervalsData(trnsIds: TrnId[], intervalsInRange: Range[]) {:total="rangeTotal":type="props.type":isShowAverage="statConfig.config.value.statAverage.isShow"- class="@2xl/page:bg-item-2 @2xl/page:my-2 @2xl/page:rounded-xl @2xl/page:p-2 mb-2"@click="onClickSumItem"@clickAverage="statConfig.updateConfig('statAverage', { isShow: !statConfig.config.value.statAverage.isShow })">@@ -279,13 +279,13 @@ function getIntervalsData(trnsIds: TrnId[], intervalsInRange: Range[]) {</StatSumWrap><div- class="@3xl/page:pt-3 grid w-full gap-2 pt-1"+ class="@3xl/page:pt-3 grid w-full items-start gap-2 pt-1":class="{'@3xl/page:grid-cols-[1.2fr,1fr] @3xl/page:gap-8': props.activeTab !== 'summary',}"><StatCategoriesSection- v-if="props.hasChildren || (props.preCategoriesIds ?? []).length > 0"+ v-if="(props.hasChildren || (props.preCategoriesIds ?? []).length > 0) && props.type !== 'trns'":isOneCategory="props.isOneCategory":preCategoriesIds="props.preCategoriesIds":selectedTrnsIdsdiff --git a/app/components/stat/ItemWrap.vue b/app/components/stat/ItemWrap.vueindex 88ad4661..fb5a53cc 100644--- a/app/components/stat/ItemWrap.vue+++ b/app/components/stat/ItemWrap.vue@@ -74,7 +74,7 @@ const incomeTrnsIds = computed(() => trnsStore.getStoreTrnsIds({<divv-else- class="min-h-dvh max-w-7xl px-2 lg:px-4 xl:py-2 2xl:px-8"+ class="min-h-dvh max-w-7xl p-2 lg:px-4 2xl:px-8"><StatItem:activeTab="props.activeTab"diff --git a/app/components/stat/Menu.vue b/app/components/stat/Menu.vueindex 42a057b0..07a1bea0 100644--- a/app/components/stat/Menu.vue+++ b/app/components/stat/Menu.vue@@ -27,6 +27,9 @@ const menu = computed(() => {}, {id: 'income',name: t('money.income'),+ }, {+ id: 'trns',+ name: t('trns.history'),}]if (width.value > 766) {@@ -43,17 +46,18 @@ function onClickStatMenu(tabName: StatTabSlug) {emit('click', tabName)}-onMounted(() => {- if (!menu.value.find(i => i.id === props.active)) {- onClickStatMenu(menu.value[0].id)- }-})-watch(() => props.active, () => {if (!menu.value.find(i => i.id === props.active)) {onClickStatMenu(menu.value[0].id)}-})+}, { immediate: true })++function getClasses(id?: StatTabSlug) {+ return [{+ '!border-accent-1 text-1 rounded-none border-b-2': id === props.active,+ 'text-2 hover:bg-item-5': id !== props.active,+ }, 'text-nowrap rounded-lg px-3 py-1.5 text-sm font-medium']+}</script><template>@@ -61,12 +65,7 @@ watch(() => props.active, () => {<divv-for="item in menu":key="item.id"- class="text-nowrap rounded-lg px-3 py-1.5 text-sm font-medium"- :class="[{- 'rounded-none border-b-2 !border-accent-1 text-1': item.id === props.active,- 'text-2 hover:bg-item-5': item.id !== props.active,- },- ]"+ :class="getClasses(item.id)"@click="onClickStatMenu(item.id)">{{ item.name }}diff --git a/app/components/stat/categories/Section.vue b/app/components/stat/categories/Section.vueindex 50654eac..7fc7027f 100644--- a/app/components/stat/categories/Section.vue+++ b/app/components/stat/categories/Section.vue@@ -174,13 +174,16 @@ function updateState(</script><template>- <div v-if="categoriesWithData.length > 0">+ <div+ v-if="categoriesWithData.length > 0"+ class="@3xl/page:gap-4 grid"+ ><!-- Vertical --><UiTogglev-if="statConfig.config.value.vertical.isShow":storageKey="`${storageKey}-${type}-vertical`":initStatus="true"- class="bg-item-2 @3xl/page:p-3 mb-4 rounded-xl p-2 md:max-w-lg"+ class="@3xl/page:p-3 mb-4 rounded-xl bg-item-2 p-2 md:max-w-lg"><template #header="{ toggle, isShown }"><div class="flex items-center justify-between md:max-w-lg">@@ -269,7 +272,7 @@ function updateState(v-if="statConfig.config.value.catsRound.isShow":storageKey="`${storageKey}-${type}-rounds`":initStatus="true"- class="bg-item-2 @3xl/page:p-3 mb-4 rounded-xl p-2 md:max-w-lg"+ class="@3xl/page:p-3 mb-4 rounded-xl bg-item-2 p-2 md:max-w-lg"><template #header="{ toggle, isShown }"><div class="flex items-center justify-between md:max-w-lg">@@ -351,7 +354,7 @@ function updateState(v-if="statConfig.config.value.catsList.isShow":storageKey="`${storageKey}-${type}-list`":initStatus="true"- class="bg-item-2 @3xl/page:p-3 mb-4 rounded-xl p-2 md:max-w-lg"+ class="@3xl/page:p-3 mb-4 rounded-xl bg-item-2 p-2 md:max-w-lg"><template #header="{ toggle, isShown }"><div class="flex items-center justify-between md:max-w-lg">@@ -479,7 +482,7 @@ function updateState(</template><!-- Inside -->- <div class="border-item-4 ml-5 mt-[-2px] -translate-x-px border-l pl-3">+ <div class="ml-5 mt-[-2px] -translate-x-px border-l border-item-4 pl-3"><divv-if="!item.categories || item.categories.length === 0"class="mb-3 ml-11"@@ -550,7 +553,7 @@ function updateState(</template><!-- Inside -->- <div class="border-item-4 ml-5 mt-[-2px] -translate-x-px border-l pl-14">+ <div class="ml-5 mt-[-2px] -translate-x-px border-l border-item-4 pl-14"><TrnsList:trnsIds="itemInside.trnsIds":size="5"diff --git a/app/components/stat/chart/Wrap.vue b/app/components/stat/chart/Wrap.vueindex 80613b42..e2fab5bd 100644--- a/app/components/stat/chart/Wrap.vue+++ b/app/components/stat/chart/Wrap.vue@@ -50,6 +50,7 @@ function onChangePeriod(period: Period) {:class="{'md:max-w-lg': props.chartView === 'half',}"+ class="mb-3 rounded-xl bg-item-2 p-2"><divv-if="statConfig.config.value?.chartShow"diff --git a/app/components/stat/date/Quick.vue b/app/components/stat/date/Quick.vueindex 43b65711..6b53bfe2 100644--- a/app/components/stat/date/Quick.vue+++ b/app/components/stat/date/Quick.vue@@ -8,7 +8,6 @@ const emit = defineEmits<{onClose: []}>()-const { t } = useI18n()const statDate = inject('statDate') as StatDateProviderconst sliderRef = ref<any>(null)diff --git a/app/components/stat/date/Selector.vue b/app/components/stat/date/Selector.vueindex 0e05a5ca..6ca37686 100644--- a/app/components/stat/date/Selector.vue+++ b/app/components/stat/date/Selector.vue@@ -17,11 +17,6 @@ const tabs = {selected: ref('presets'),}-function setMaxRange(isSkipEmpty = false) {- emit('onClose')- statDate.setMaxRange(isSkipEmpty)-}-const intervals = computed<Grouped[]>(() => [{intervalsBy: 'day',intervalsDuration: 1,diff --git a/app/components/stat/sum/Item.vue b/app/components/stat/sum/Item.vueindex f902178d..3f37f0cc 100644--- a/app/components/stat/sum/Item.vue+++ b/app/components/stat/sum/Item.vue@@ -24,7 +24,7 @@ const currenciesStore = useCurrenciesStore()<template><div- class="grid gap-1 border border-transparent px-3 pt-2"+ class="@2xl/page:px-4 @2xl/page:pt-3 @2xl/page:pb-2 grid gap-1 border border-transparent bg-item-2 px-3 pt-2":class="{'!border-accent-1/40 !bg-item-2': props.isActive,}"diff --git a/app/components/stat/sum/Wrap.vue b/app/components/stat/sum/Wrap.vueindex e776575f..c0fed4fb 100644--- a/app/components/stat/sum/Wrap.vue+++ b/app/components/stat/sum/Wrap.vue@@ -37,10 +37,10 @@ function onClick(type: StatTabSlug) {</script><template>- <div class="overflow-x-auto">+ <div class="@2xl/page:my-2 mb-2 overflow-x-auto"><div- v-if="props.type === 'netIncome'"- class="@2xl/page:justify-start @2xl/page:gap-x-4 flex flex-wrap justify-stretch"+ v-if="props.type === 'netIncome' || props.type === 'trns'"+ class="@2xl/page:justify-start @2xl/page:gap-x-4 flex flex-wrap justify-stretch gap-2"><StatSumItemv-if="props.isShowExpense"diff --git a/app/components/stat/trns/Section.vue b/app/components/stat/trns/Section.vueindex c0750c54..6ebd6407 100644--- a/app/components/stat/trns/Section.vue+++ b/app/components/stat/trns/Section.vue@@ -15,7 +15,7 @@ defineProps<{v-if="selectedTrnsIds.length > 0":storageKey="`${storageKey}-${type}trns-all`":initStatus="true"- class="md:max-w-lg"+ class="@3xl/page:p-3 mb-4 rounded-xl bg-item-2 p-2 md:max-w-lg"><template #header="{ toggle, isShown }"><div class="flex items-center justify-between">diff --git a/app/components/stat/types.ts b/app/components/stat/types.tsindex 8328a6ee..e1349758 100644--- a/app/components/stat/types.ts+++ b/app/components/stat/types.ts@@ -5,7 +5,7 @@ import type { ChartType } from '~/components/stat/chart/types'import type { TrnId } from '~/components/trns/types'export type MoneyTypeSlug = 'expense' | 'income'-export type StatTabSlug = 'income' | 'expense' | 'netIncome' | 'summary' | 'periods'+export type StatTabSlug = 'income' | 'expense' | 'netIncome' | 'summary' | 'periods' | 'trns'export type MoneyTypeNumber = 0 | 1 | 3export type TotalCategories = {diff --git a/app/components/trnForm/Categories.vue b/app/components/trnForm/Categories.vueindex 07738276..4eadbd19 100644--- a/app/components/trnForm/Categories.vue+++ b/app/components/trnForm/Categories.vue@@ -46,7 +46,7 @@ onMounted(() => {<!-- Recent --><div class="swiper-slide h-full"><div- class="scrollerBlock bg-item-1 font-primary rounded-t-2xl px-3 py-4 text-center text-xl font-semibold"+ class="scrollerBlock rounded-t-2xl bg-item-1 px-3 py-4 text-center font-primary text-xl font-semibold">{{ $t('categories.recentCategories') }}</div>@@ -63,7 +63,7 @@ onMounted(() => {<!-- Main --><div class="swiper-slide h-full"><div- class="scrollerBlock bg-item-1 font-primary rounded-t-2xl px-3 py-4 text-center text-xl font-semibold"+ class="scrollerBlock rounded-t-2xl bg-item-1 px-3 py-4 text-center font-primary text-xl font-semibold">{{ $t("categories.title") }}</div>@@ -79,7 +79,7 @@ onMounted(() => {<!-- Favorite --><div class="swiper-slide h-full">- <div class="scrollerBlock bg-item-1 font-primary rounded-t-2xl px-3 py-4 text-center text-xl font-semibold">+ <div class="scrollerBlock rounded-t-2xl bg-item-1 px-3 py-4 text-center font-primary text-xl font-semibold">{{ $t('categories.favoriteCategories') }}</div><div class="px-3 pb-1">diff --git a/app/components/trnForm/Main.vue b/app/components/trnForm/Main.vueindex fdab5629..9c0240a7 100644--- a/app/components/trnForm/Main.vue+++ b/app/components/trnForm/Main.vue@@ -96,7 +96,7 @@ const actions = computed(() => ({/><UiTitle3- class="bg-item-1 sticky top-0 z-10 px-3 pb-3 pt-4 md:text-xl"+ class="sticky top-0 z-10 bg-item-1 px-3 pb-3 pt-4 md:text-xl"@click="trnsFormStore.values.trnId = null">{{ trnsFormStore.values.trnId ? t("trnForm.titleEditTrn") : t("trnForm.createTrn") }}@@ -108,7 +108,7 @@ const actions = computed(() => ({><TrnsItem:trnItem="trnsStore.computeTrnItem(trnsFormStore.values.trnId)"- class="bg-item-3 group rounded-lg"+ class="group rounded-lg bg-item-3"@click="trnsFormStore.values.trnId = null"/>@@ -116,7 +116,7 @@ const actions = computed(() => ({v-if="showModalConfirm"class="absolute -bottom-4 left-0 z-10 w-full px-4">- <div class="border-accent-1 bg-item-1 text-1 z-10 grid h-full content-center gap-4 rounded-lg border p-3">+ <div class="z-10 grid h-full content-center gap-4 rounded-lg border border-accent-1 bg-item-1 p-3 text-1">{{ t('base.sure') }}<div class="flex gap-2">@@ -134,7 +134,7 @@ const actions = computed(() => ({/></template>- <div class="text-2 leading-none">+ <div class="leading-none text-2">{{ item.label }}</div></UiElement>@@ -157,7 +157,7 @@ const actions = computed(() => ({/></template>- <div class="text-2 leading-none">+ <div class="leading-none text-2">{{ t(item.label) }}</div></UiItem1>diff --git a/app/components/trnForm/SelectionCategoriesFast.vue b/app/components/trnForm/SelectionCategoriesFast.vueindex 1e554c91..fab95000 100644--- a/app/components/trnForm/SelectionCategoriesFast.vue+++ b/app/components/trnForm/SelectionCategoriesFast.vue@@ -22,7 +22,7 @@ const trnsFormStore = useTrnsFormStore()class="pb-6"><UiTitle3- class="bg-item-1 sticky top-0 z-20 px-3 pb-3 pt-4"+ class="sticky top-0 z-20 bg-item-1 px-3 pb-3 pt-4"@click="trnsFormStore.ui.catsRootModal = true">{{ t('categories.favoriteCategories') }}@@ -40,7 +40,7 @@ const trnsFormStore = useTrnsFormStore()<!-- Recent categories --><div v-if="categoriesStore.recentCategoriesIds.length > 0"><UiTitle3- class="bg-item-1 sticky top-0 z-20 px-3 pb-3 pt-4"+ class="sticky top-0 z-20 bg-item-1 px-3 pb-3 pt-4"@click="trnsFormStore.ui.catsRootModal = true">{{ t('categories.recentCategories') }}diff --git a/app/components/trns/List.vue b/app/components/trns/List.vueindex b3d38cdb..2f7ba911 100644--- a/app/components/trns/List.vue+++ b/app/components/trns/List.vue@@ -208,7 +208,7 @@ const groupedTrns = computed(() => paginatedTrnsIds.value<!-- Group Sum --><divv-if="isShowGroupSum && paginatedTrnsIds.length > 1"- class="border-item-4 border-b pb-2 pr-3"+ class="border-b border-item-4 pb-2 pr-3"><Amountv-if="getTotalOfTrnsIds(paginatedTrnsIds).income !== 0"@@ -246,12 +246,12 @@ const groupedTrns = computed(() => paginatedTrnsIds.value<!-- With dates --><divv-if="isShowDates"- class="grid gap-3"+ class="grid gap-1"><divv-for="(groupTrnsIds, date) in groupedTrns":key="date"- class="bg-item-2 overflow-hidden rounded-lg"+ class="_bg-item-2 _rounded-lg overflow-hidden border-b border-item-4 pb-2"><div:class="{ 'border-item-4': isShowGroupSum && groupTrnsIds.length > 1 }"@@ -310,7 +310,7 @@ const groupedTrns = computed(() => paginatedTrnsIds.valueclass="flex-center pt-1"><div- class="flex-center bg-item-5 text-2 hocus:bg-item-6 rounded-full px-5 py-2 text-sm"+ class="flex-center rounded-full bg-item-5 px-5 py-2 text-sm text-2 hocus:bg-item-6"@click="pageNumber = ++pageNumber">{{ t("trns.more") }} {{ paginatedTrnsIds.length }} /diff --git a/app/components/ui/Item1.vue b/app/components/ui/Item1.vueindex 6611b34c..b22ab59a 100644--- a/app/components/ui/Item1.vue+++ b/app/components/ui/Item1.vue@@ -13,13 +13,13 @@ const emit = defineEmits<{<template><div- class="group-data-[headlessui-state=open]:!bg-item-4 justify-center" :class="[+ class="justify-center group-data-[headlessui-state=open]:!bg-item-4" :class="[getStyles('item', ['link', 'center', 'minh2', 'minw1', 'rounded']),{- 'text-2 text-xl': variant === 'icon',+ 'text-xl text-2': variant === 'icon',},{- 'text-1 px-3 text-sm': variant === 'text',+ 'px-3 text-sm text-1': variant === 'text',},{'!bg-item-3': isActive,diff --git a/app/components/ui/TabsItem1.vue b/app/components/ui/TabsItem1.vueindex 5812dbf5..bd1e3b4f 100644--- a/app/components/ui/TabsItem1.vue+++ b/app/components/ui/TabsItem1.vue@@ -13,7 +13,7 @@ const emit = defineEmits(['click']):class="[getStyles('item', ['minh2']), {'!bg-item-4': isActive,}]"- class="text-3 hocus:bg-item-5 flex flex-1 grow select-none items-center justify-center gap-1 text-nowrap rounded-lg px-2 text-sm"+ class="flex flex-1 grow select-none items-center justify-center gap-1 text-nowrap rounded-lg px-2 text-sm text-3 hocus:bg-item-5"@click="emit('click')"><slot />