Open source personal finance application
refactor(stat/categories): rename Round* components and use RoundPill
Ilya Komichev5c1efbea222b
diff --git a/app/components/stat/Item.vue b/app/components/stat/Item.vueindex f8499fd6..337660a5 100644--- a/app/components/stat/Item.vue+++ b/app/components/stat/Item.vue@@ -110,7 +110,6 @@ function onClickSumItemWrap(type: SeriesSlugSelected) {<div class="@container/stat"><StatChartWrapv-if="shouldShowAmounts"- :isEmpty="selectedTrnsIds.length === 0":series="chartSeries":xAxisLabels="chartXAxisLabels"class="pb-3"@@ -124,7 +123,7 @@ function onClickSumItemWrap(type: SeriesSlugSelected) {isShowWallets/>- <StatCategoriesRoundSectionMenu+ <StatCategoriesConfigMenu:filteredCategoriesIds:preCategoriesIds="props.preCategoriesIds":selectedTrnsIds@@ -188,7 +187,7 @@ function onClickSumItemWrap(type: SeriesSlugSelected) {<div v-else class="mx-auto grid w-full max-w-150 content-start justify-items-center gap-4"><TrnsNoTrns />- <StatCategoriesRoundSectionRecent />+ <StatCategoriesRoundRecent /></div></div>diff --git a/app/components/stat/categories/RoundSectionMenu.vue b/app/components/stat/categories/ConfigMenu.vuesimilarity index 91%rename from app/components/stat/categories/RoundSectionMenu.vuerename to app/components/stat/categories/ConfigMenu.vueindex fd646988..06955f86 100644--- a/app/components/stat/categories/RoundSectionMenu.vue+++ b/app/components/stat/categories/ConfigMenu.vue@@ -136,9 +136,9 @@ function setGrouping(mode: GroupingMode) {<div class="grid gap-3"><!-- Chart --><div class="overflow-hidden rounded-sm border border-(--ui-border)">- <div class="flex items-stretch bg-(--item-4)" :class="{ 'pb-px': isExpandedChartCard }">+ <div class="bg-accented flex items-stretch" :class="{ 'pb-px': isExpandedChartCard }"><div- class="flex grow cursor-pointer items-center gap-2 rounded-tr-sm rounded-br-sm px-3 py-2 hover:bg-(--item-3)"+ class="hover:bg-elevated flex grow cursor-pointer items-center gap-2 rounded-tr-sm rounded-br-sm px-3 py-2"@click="isExpandedChartCard = !isExpandedChartCard"><Icon@@ -150,7 +150,7 @@ function setGrouping(mode: GroupingMode) {</div></div><div- class="flex shrink-0 cursor-pointer items-center rounded-tl-sm rounded-bl-sm px-3 hover:bg-(--item-3)"+ class="hover:bg-elevated flex shrink-0 cursor-pointer items-center rounded-tl-sm rounded-bl-sm px-3"@click.stop="toggleChartShow"><FormSwitch :value="isChartShow" />@@ -227,9 +227,9 @@ function setGrouping(mode: GroupingMode) {<!-- Round categories --><div class="overflow-hidden rounded-sm border border-(--ui-border)">- <div class="flex items-stretch bg-(--item-4)" :class="{ 'pb-px': isExpandedRoundCard }">+ <div class="bg-accented flex items-stretch" :class="{ 'pb-px': isExpandedRoundCard }"><div- class="flex grow cursor-pointer items-center gap-2 rounded-tr-sm rounded-br-sm px-3 py-2 hover:bg-(--item-3)"+ class="hover:bg-elevated flex grow cursor-pointer items-center gap-2 rounded-tr-sm rounded-br-sm px-3 py-2"@click="isExpandedRoundCard = !isExpandedRoundCard"><Icon@@ -241,7 +241,7 @@ function setGrouping(mode: GroupingMode) {</div></div><div- class="flex shrink-0 cursor-pointer items-center rounded-tl-sm rounded-bl-sm px-3 hover:bg-(--item-3)"+ class="hover:bg-elevated flex shrink-0 cursor-pointer items-center rounded-tl-sm rounded-bl-sm px-3"@click.stop="toggleMaster('catsRound', isCatsRoundShow)"><FormSwitch :value="isCatsRoundShow" />@@ -284,9 +284,9 @@ function setGrouping(mode: GroupingMode) {<!-- List --><div class="overflow-hidden rounded-sm border border-(--ui-border)">- <div class="flex items-stretch bg-(--item-4)" :class="{ 'pb-px': isExpandedListCard }">+ <div class="bg-accented flex items-stretch" :class="{ 'pb-px': isExpandedListCard }"><div- class="flex grow cursor-pointer items-center gap-2 rounded-tr-sm rounded-br-sm px-3 py-2 hover:bg-(--item-3)"+ class="hover:bg-elevated flex grow cursor-pointer items-center gap-2 rounded-tr-sm rounded-br-sm px-3 py-2"@click="isExpandedListCard = !isExpandedListCard"><Icon@@ -298,7 +298,7 @@ function setGrouping(mode: GroupingMode) {</div></div><div- class="flex shrink-0 cursor-pointer items-center rounded-tl-sm rounded-bl-sm px-3 hover:bg-(--item-3)"+ class="hover:bg-elevated flex shrink-0 cursor-pointer items-center rounded-tl-sm rounded-bl-sm px-3"@click.stop="toggleMaster('catsList', isCatsListShow)"><FormSwitch :value="isCatsListShow" />diff --git a/app/components/stat/categories/Round.vue b/app/components/stat/categories/Round.vuenew file mode 100644index 00000000..814523d3--- /dev/null+++ b/app/components/stat/categories/Round.vue@@ -0,0 +1,54 @@+<script setup lang="ts">+import type { CategoryId } from '~/components/categories/types'+import type { CategoryWithData } from '~/components/stat/types'++import { useCurrenciesStore } from '~/components/currencies/useCurrenciesStore'+import { useCategoryLongPress } from '~/components/stat/categories/useCategoryLongPress'+import { statConfigKey } from '~/components/stat/injectionKeys'+import { getTrnTypeByAmount } from '~/components/trns/types'++const props = defineProps<{+ isShowAmount?: boolean+ isShowParent?: boolean+ item: CategoryWithData+}>()++const emit = defineEmits<{+ click: [categoryId: CategoryId]+}>()++const currenciesStore = useCurrenciesStore()+const statConfig = inject(statConfigKey)!++const isIconBg = computed(() => statConfig.config.value.catsRound.isIconBg)++const { longPressRef } = useCategoryLongPress(+ () => props.item.id,+ () => emit('click', props.item.id),+)+</script>++<template>+ <CategoriesRoundPill+ ref="longPressRef"+ :categoryId="props.item.id"+ :isIconBg="isIconBg"+ :isShowParent="props.isShowParent"+ >+ <div+ v-if="props.isShowAmount"+ class="opacity-90"+ >+ <Amount+ :amount="props.item.value"+ :type="getTrnTypeByAmount(props.item.value)"+ :currencyCode="currenciesStore.base"+ :isShowBaseRate="false"+ :isShowSymbol="false"+ align="left"+ variant="xs"+ colorize="income"+ />+ </div>+ </CategoriesRoundPill>+</template>diff --git a/app/components/stat/categories/Round2lines.vue b/app/components/stat/categories/Round2lines.vuedeleted file mode 100644index cceea0ed..00000000--- a/app/components/stat/categories/Round2lines.vue+++ /dev/null@@ -1,96 +0,0 @@-<script setup lang="ts">-import type { CategoryId } from '~/components/categories/types'-import type { CategoryWithData } from '~/components/stat/types'--import { useCategoriesStore } from '~/components/categories/useCategoriesStore'-import { useCurrenciesStore } from '~/components/currencies/useCurrenciesStore'-import { useCategoryLongPress } from '~/components/stat/categories/useCategoryLongPress'-import { statConfigKey } from '~/components/stat/injectionKeys'-import { getTrnTypeByAmount } from '~/components/trns/types'--const props = defineProps<{- isShowAmount?: boolean- isShowParent?: boolean- item: CategoryWithData-}>()--const emit = defineEmits<{- click: [categoryId: CategoryId]-}>()--const categoriesStore = useCategoriesStore()-const currenciesStore = useCurrenciesStore()-const statConfig = inject(statConfigKey)!--const isIconBg = computed(() => statConfig.config.value.catsRound.isIconBg)--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,- () => emit('click', props.item.id),-)-</script>--<template>- <div- v-if="category"- ref="longPressRef"- class="dark:bg-item-3 relative flex items-center overflow-hidden rounded-2xl border border-transparent p-1 pr-3 hover:bg-(--item-5)"- :class="isIconBg ? 'gap-2' : 'gap-1'"- >- <div- :style="{ backgroundColor: category?.color }"- class="absolute inset-0 size-full opacity-10"- />-- <div class="size-6">- <UiIconBase- v-if="isIconBg"- :name="category?.icon"- :color="category?.color"- :size="14"- class="!w-6 p-1"- invert- />- <UiIconBase- v-else- :name="category?.icon"- :color="category?.color"- :size="14"- class="!w-6 p-1"- />- </div>-- <div>- <CategoriesName- :category- :isShowParent="props.isShowParent"- :parentCategory- stacked- size="xs"- />-- <div- v-if="props.isShowAmount"- class="opacity-90"- >- <Amount- :amount="props.item.value"- :type="getTrnTypeByAmount(props.item.value)"- :currencyCode="currenciesStore.base"- :isShowBaseRate="false"- :isShowSymbol="false"- align="left"- variant="xs"- colorize="income"- />- </div>- </div>- </div>-</template>diff --git a/app/components/stat/categories/RoundSectionRecent.vue b/app/components/stat/categories/RoundRecent.vuesimilarity index 58%rename from app/components/stat/categories/RoundSectionRecent.vuerename to app/components/stat/categories/RoundRecent.vueindex ea45d0e6..d187765c 100644--- a/app/components/stat/categories/RoundSectionRecent.vue+++ b/app/components/stat/categories/RoundRecent.vue@@ -46,35 +46,14 @@ function onClick(categoryId: CategoryId) {<template><div class="flex flex-wrap justify-center gap-1 gap-y-2">- <div+ <CategoriesRoundPillv-for="categoryId in categoryIds":key="categoryId"- class="dark:bg-item-3 relative flex cursor-default items-center gap-2 overflow-hidden rounded-2xl border border-transparent p-1 pr-3 hover:bg-(--item-5)"+ :categoryId="categoryId"+ :isShowParent="!!categoriesStore.items[categoryId]?.parentId"+ isIconBg+ class="cursor-default"@click="onClick(categoryId)"- >- <div- :style="{ backgroundColor: categoriesStore.items[categoryId]?.color }"- class="absolute inset-0 size-full opacity-10"- />-- <div class="size-6">- <UiIconBase- :name="categoriesStore.items[categoryId]?.icon ?? ''"- :color="categoriesStore.items[categoryId]?.color"- :size="14"- class="!w-6 p-1"- invert- />- </div>-- <CategoriesName- v-if="categoriesStore.items[categoryId]"- :category="categoriesStore.items[categoryId]!"- :isShowParent="!!categoriesStore.items[categoryId]?.parentId"- :parentCategory="categoriesStore.items[categoryId]?.parentId ? categoriesStore.items[categoriesStore.items[categoryId]!.parentId] : undefined"- stacked- size="xs"- />- </div>+ /></div></template>diff --git a/app/components/stat/categories/RoundSection.vue b/app/components/stat/categories/RoundSection.vueindex d809c8b0..e460691c 100644--- a/app/components/stat/categories/RoundSection.vue+++ b/app/components/stat/categories/RoundSection.vue@@ -69,7 +69,7 @@ const filteredSet = computed(() => new Set(props.filteredCategoriesIds))<template><div class="flex min-w-0 flex-wrap justify-start gap-1 gap-y-2">- <StatCategoriesRound2lines+ <StatCategoriesRoundv-for="item in visibleCategories":key="item.id":item="item"