Skip to content

Open source personal finance application

refactor: unify button components and enhance layout consistency

Ilya Komichev07f2144a53eb
diff --git a/app/components/categories/Form.vue b/app/components/categories/Form.vue
index 812ab5df..ed921a32 100644
--- a/app/components/categories/Form.vue
+++ b/app/components/categories/Form.vue
@@ -136,7 +136,7 @@ async function onSave() {
</UiFormElement>
<!-- Parent -->
- <UiItem2
+ <UiButtonWithRight
v-if="isAllowChangeParent"
@click="modals.parent = true"
>
@@ -147,10 +147,10 @@ async function onSave() {
<template #value>
{{ props.categoryForm.parentId === 0 ? t('categories.form.parent.no') : categoriesStore.items[props.categoryForm.parentId]?.name }}
</template>
- </UiItem2>
+ </UiButtonWithRight>
<!-- Icon -->
- <UiItem2 @click="modals.icon = true">
+ <UiButtonWithRight @click="modals.icon = true">
<template #label>
{{ t('categories.form.icon.label') }}
</template>
@@ -162,10 +162,10 @@ async function onSave() {
invert
/>
</template>
- </UiItem2>
+ </UiButtonWithRight>
<!-- Color -->
- <UiItem2 @click="modals.colors = true">
+ <UiButtonWithRight @click="modals.colors = true">
<template #label>
{{ t('color.label') }}
</template>
@@ -177,7 +177,7 @@ async function onSave() {
invert
/>
</template>
- </UiItem2>
+ </UiButtonWithRight>
<!-- Options -->
<div>
diff --git a/app/components/date/LinkItem.vue b/app/components/date/LinkItem.vue
index 91177465..3bf5dd8f 100644
--- a/app/components/date/LinkItem.vue
+++ b/app/components/date/LinkItem.vue
@@ -17,7 +17,7 @@ const emit = defineEmits<{
'_!bg-item-5 text-accent-1': props.isActive,
},
]"
- class="text-nowrap rounded-full font-primary text-xs leading-none"
+ class="font-primary text-nowrap rounded-full text-xs leading-none"
@click="(e: Event) => emit('click', e)"
>
<slot />
diff --git a/app/components/filter/FilterSelector.vue b/app/components/filter/FilterSelector.vue
index 04473483..9ea1f430 100644
--- a/app/components/filter/FilterSelector.vue
+++ b/app/components/filter/FilterSelector.vue
@@ -23,13 +23,14 @@ const modals = ref({
<template>
<div class="flex">
<template v-if="props.isShowCategories">
- <!-- Categories -->
+ <!-- Categories: PC -->
<UPopover
v-if="isLaptop"
+ class="group"
>
- <UiItem3>
+ <UiItem1>
<Icon name="hugeicons:folder-library" size="20" />
- </UiItem3>
+ </UiItem1>
<template #panel="{ close }">
<UiPopoverWrap
@@ -47,13 +48,13 @@ const modals = ref({
</template>
</UPopover>
- <!-- Mobile -->
+ <!-- Categories: Mobile -->
<template v-else>
- <UiItem3
+ <UiItem1
@click="modals.categories = true"
>
<Icon name="hugeicons:folder-library" size="20" />
- </UiItem3>
+ </UiItem1>
<Teleport to="body">
<BottomSheet
@@ -96,12 +97,15 @@ const modals = ref({
</template>
</template>
- <!-- Wallets -->
<template v-if=" props.isShowWallets">
- <UPopover v-if="isLaptop">
- <UiItem3>
+ <!-- Wallets: PC -->
+ <UPopover
+ v-if="isLaptop"
+ class="group"
+ >
+ <UiItem1>
<Icon name="hugeicons:wallet-01" />
- </UiItem3>
+ </UiItem1>
<template #panel="{ close }">
<UiPopoverWrap
@@ -117,13 +121,13 @@ const modals = ref({
</template>
</UPopover>
- <!-- Mobile -->
+ <!-- Wallets: Mobile -->
<template v-else>
- <UiItem3
+ <UiItem1
@click="modals.wallets = true"
>
<Icon name="hugeicons:wallet-01" />
- </UiItem3>
+ </UiItem1>
<Teleport to="body">
<BottomSheet
diff --git a/app/components/stat/CategoriesButtons.vue b/app/components/stat/CategoriesButtons.vue
index df10611a..d8b0734a 100644
--- a/app/components/stat/CategoriesButtons.vue
+++ b/app/components/stat/CategoriesButtons.vue
@@ -35,13 +35,13 @@ const grouping = {
toggle: () => {
if (statConfig.config.value.catsView === 'list') {
- statConfig.updateConfig('vertical', { isGrouped: !statConfig.config.value.catsList.isGrouped })
+ // statConfig.updateConfig('vertical', { isGrouped: !statConfig.config.value.catsList.isGrouped })
statConfig.updateConfig('catsList', { isGrouped: !statConfig.config.value.catsList.isGrouped })
return
}
if (statConfig.config.value.catsView === 'round') {
- statConfig.updateConfig('vertical', { isGrouped: !statConfig.config.value.catsRound.isGrouped })
+ // statConfig.updateConfig('vertical', { isGrouped: !statConfig.config.value.catsRound.isGrouped })
statConfig.updateConfig('catsRound', { isGrouped: !statConfig.config.value.catsRound.isGrouped })
}
},
@@ -58,14 +58,11 @@ const favorites = computed(() => ({
return false
}),
toggle: () => {
- if (statConfig.config.value.catsView === 'list') {
- statConfig.updateConfig('catsList', { isShowFavorites: !statConfig.config.value.catsList.isShowFavorites,
- })
- }
+ if (statConfig.config.value.catsView === 'list')
+ statConfig.updateConfig('catsList', { isShowFavorites: !statConfig.config.value.catsList.isShowFavorites })
- if (statConfig.config.value.catsView === 'round') {
+ if (statConfig.config.value.catsView === 'round')
statConfig.updateConfig('catsRound', { isShowFavorites: !statConfig.config.value.catsRound.isShowFavorites })
- }
},
}))
@@ -142,17 +139,6 @@ const isShow = ref(false)
<template>
<div class="relative flex rounded-md">
- <!-- Vertical -->
- <UiItem1
- v-if="props.catsLength > 1"
- @click="statConfig.updateConfig('vertical', { isShow: !statConfig.config.value.vertical.isShow })"
- >
- <Icon
- name="lucide:chart-no-axes-column-decreasing"
- size="18"
- />
- </UiItem1>
-
<UiItem1
v-if="statConfig.config.value.catsView === 'list'"
@click="emit('toggleOpened')"
@@ -200,9 +186,7 @@ const isShow = ref(false)
@onCloseModal="isShow = false"
>
<template #trigger>
- <UiItem1
- class="border border-transparent group-data-[headlessui-state='open']:!border-accent-1"
- >
+ <UiItem1>
<Icon name="lucide:circle-ellipsis" size="20" />
</UiItem1>
</template>
@@ -210,7 +194,7 @@ const isShow = ref(false)
<template #content="{ close }">
<div class="grid min-w-80 gap-4 px-1 pt-3 md:px-3">
<BottomSheetClose @click="close" />
- <div class="grid gap-4 border-b border-item-3 pb-3">
+ <div class="border-item-3 grid gap-4 border-b pb-3">
<!-- Grouping -->
<div class="grid gap-3">
<UiTitleOption>
@@ -280,7 +264,7 @@ const isShow = ref(false)
<!-- List -->
<div
v-if="statConfig.config.value.catsView === 'list'"
- class="grid gap-3 border-b border-item-3 pb-2 last:border-0"
+ class="border-item-3 grid gap-3 border-b pb-2 last:border-0"
>
<UiTitleOption>{{ t('listItemsOptions') }}</UiTitleOption>
<div class="flex gap-1">
@@ -362,7 +346,7 @@ const isShow = ref(false)
<!-- Vertical -->
<div
v-if="props.catsLength > 1"
- class="grid border-b border-item-3 pb-2 last:border-0 md:pb-0"
+ class="border-item-3 grid border-b pb-2 last:border-0 md:pb-0"
>
<UiTitleOption class="pb-2">
{{ t('stat.config.categories.vertical.label') }}
@@ -418,7 +402,7 @@ const isShow = ref(false)
<!-- TODO: use StatConfig -->
<div
v-if="false"
- class="border-b border-item-3 pb-2 last:border-0 last:pb-0"
+ class="border-item-3 border-b pb-2 last:border-0 last:pb-0"
>
<!-- Favorite -->
<UiElement
diff --git a/app/components/stat/Config.vue b/app/components/stat/Config.vue
index d0362019..d79de85c 100644
--- a/app/components/stat/Config.vue
+++ b/app/components/stat/Config.vue
@@ -30,9 +30,9 @@ const isShow = ref(false)
@onCloseModal="isShow = false"
>
<template #trigger>
- <UiItem3>
+ <UiItem1>
<Icon name="lucide:settings-2" size="20" />
- </UiItem3>
+ </UiItem1>
</template>
<template #content="{ close }">
@@ -40,9 +40,9 @@ const isShow = ref(false)
<BottomSheetClose @click="close" />
<!-- Chart -->
- <div class="border-b border-item-3 pb-3">
+ <div class="border-item-3 border-b pb-3">
<UiTitleOption class="pb-2">
- {{ t("stat.config.chartShow.title") }}
+ {{ t('stat.config.chartShow.title') }}
</UiTitleOption>
<UiCheckbox
@@ -65,7 +65,7 @@ const isShow = ref(false)
<!-- Chart: view -->
<div class="hidden gap-3 md:grid">
<UiTitleOption>
- {{ t("stat.config.chartView.label") }}
+ {{ t('stat.config.chartView.label') }}
</UiTitleOption>
<UiTabs1>
@@ -83,7 +83,7 @@ const isShow = ref(false)
<!-- Chart: type -->
<div class="grid gap-3">
<UiTitleOption>
- {{ t("stat.config.chart.type.label") }}
+ {{ t('stat.config.chart.type.label') }}
</UiTitleOption>
<UiTabs1>
@@ -108,10 +108,10 @@ const isShow = ref(false)
<!-- Showed wallets -->
<div
v-if="props.isShowWallets"
- class="border-b border-item-3 pb-3"
+ class="border-item-3 border-b pb-3"
>
<UiTitleOption class="pb-2">
- {{ t("stat.config.wallets.title") }}
+ {{ t('stat.config.wallets.title') }}
</UiTitleOption>
<UiCheckbox
:checkboxValue="statConfig.config.value.wallets.isShow"
@@ -155,7 +155,7 @@ const isShow = ref(false)
<!-- Statistics -->
<div>
<UiTitleOption class="pb-2">
- {{ t("statistics.title") }}
+ {{ t('statistics.title') }}
</UiTitleOption>
<UiCheckbox
diff --git a/app/components/stat/Header.vue b/app/components/stat/Header.vue
index ad8579c1..03a81cad 100644
--- a/app/components/stat/Header.vue
+++ b/app/components/stat/Header.vue
@@ -75,7 +75,7 @@ function onClickWallet(walletId: WalletId) {
<template #after>
<div
v-if="props.menu"
- class="px-2 sm:pb-1 md:pt-2 lg:px-4 2xl:px-8"
+ class="px-2 sm:pb-1 md:py-1 lg:px-4 2xl:px-8"
>
<StatMenu
:active="props.menu.active"
diff --git a/app/components/stat/date/Quick.vue b/app/components/stat/date/Quick.vue
index 66e8020b..3a8d5c2c 100644
--- a/app/components/stat/date/Quick.vue
+++ b/app/components/stat/date/Quick.vue
@@ -61,7 +61,7 @@ function setMaxRange(isSkipEmpty = false) {
<div class="swiper-wrapper">
<!-- Recent -->
<div class="swiper-slide">
- <div class="flex flex-wrap">
+ <div class="flex overflow-hidden">
<DateRanges @onClose="emit('onClose')" />
<div class="flex">
@@ -79,13 +79,13 @@ function setMaxRange(isSkipEmpty = false) {
</div>
<div class="swiper-slide">
- <div class="flex flex-wrap">
+ <div class="flex overflow-hidden">
<DateRanges2 @onClose="emit('onClose')" />
</div>
</div>
<div class="swiper-slide">
- <div class="flex flex-wrap">
+ <div class="flex overflow-hidden">
<DateLinkItem
:isActive="statDate.params.value.isShowMaxRange && !statDate.params.value.isSkipEmpty"
@click="() => setMaxRange(false)"
diff --git a/app/components/ui/Item2.vue b/app/components/ui/ButtonWithRight.vue
similarity index 57%
rename from app/components/ui/Item2.vue
rename to app/components/ui/ButtonWithRight.vue
index 1c48e756..c73dff73 100644
--- a/app/components/ui/Item2.vue
+++ b/app/components/ui/ButtonWithRight.vue
@@ -6,14 +6,14 @@ const emit = defineEmits<{
<template>
<UiElement
- insideClasses="w-full !min-h-[44px] bg-item-4 px-2 @xl/page:px-4 block @xl/page:flex @xl/page:flex-wrap gap-0 gap-x-2"
+ insideClasses="max-w-lg w-full !min-h-[44px] bg-item-4 px-2 @xs/element:pl-4 @xs/element:pr-3 block @xs/element:flex @xs/element:flex-wrap gap-0 gap-x-2"
@click="(e: Event) => emit('click', e)"
>
- <div class="text-sm text-2">
+ <div class="text-2 text-sm">
<slot name="label" />
</div>
- <div class="@xl/page:ml-auto flex items-center gap-1 text-base">
+ <div class="@xs/element:ml-auto flex items-center gap-1 text-base">
<slot name="value" />
<Icon
name="lucide:chevron-down"
diff --git a/app/components/ui/Element.vue b/app/components/ui/Element.vue
index a68d0465..0ef74899 100644
--- a/app/components/ui/Element.vue
+++ b/app/components/ui/Element.vue
@@ -49,7 +49,7 @@ const classes = computed(() => cn(
'ml-[48px] group-last/item:hidden': lineWidth === 4,
'group-last:hidden': lineWidth !== 3 && lineWidth !== 4,
}"
- class="mx-2 h-px bg-item-5"
+ class="bg-item-5 mx-2 h-px"
/>
</div>
</template>
diff --git a/app/components/ui/Item1.vue b/app/components/ui/Item1.vue
index 63e5cf8e..5cdc5f3d 100644
--- a/app/components/ui/Item1.vue
+++ b/app/components/ui/Item1.vue
@@ -9,7 +9,7 @@ const emit = defineEmits<{
<template>
<div
:class="getStyles('item', ['link', '_bg', 'center', 'minh2', 'minw1', 'rounded'])"
- class="justify-center text-xl"
+ class="group-data-[headlessui-state='open']:!bg-item-3 justify-center text-xl"
@click="(e: Event) => emit('click', e)"
>
<slot />
diff --git a/app/components/wallets/Form.vue b/app/components/wallets/Form.vue
index 011dbbee..783292d4 100644
--- a/app/components/wallets/Form.vue
+++ b/app/components/wallets/Form.vue
@@ -119,7 +119,7 @@ async function onSave() {
</UiFormElement>
<!-- Currencies -->
- <UiItem2 @click="modals.currencies = true">
+ <UiButtonWithRight @click="modals.currencies = true">
<template #label>
{{ t('wallets.form.currencies.label') }}
</template>
@@ -127,10 +127,10 @@ async function onSave() {
<template #value>
{{ props.walletForm.currency }}
</template>
- </UiItem2>
+ </UiButtonWithRight>
<!-- Color -->
- <UiItem2 @click="modals.colors = true">
+ <UiButtonWithRight @click="modals.colors = true">
<template #label>
{{ t('color.label') }}
</template>
@@ -142,7 +142,7 @@ async function onSave() {
class="size-6"
/>
</template>
- </UiItem2>
+ </UiButtonWithRight>
<!-- Description -->
<UiFormElement>
diff --git a/app/components/wallets/List.vue b/app/components/wallets/List.vue
index 369bd0c6..bac886d3 100644
--- a/app/components/wallets/List.vue
+++ b/app/components/wallets/List.vue
@@ -52,15 +52,15 @@ onMounted(() => stateLimit.value = props.limit)
>
<div
:class="getStyles('item', ['rounded', 'minh1', 'link', 'padding1', 'center3'])"
- class="-mt-px text-xs"
+ class="text-2 -mt-px text-xs"
@click="toggle"
>
<template v-if="stateLimit > 0">
- {{ t("showAll") }}
+ {{ t('showAll') }}
</template>
<template v-else-if="stateLimit !== limit">
- {{ t("wallets.showOnly") }} {{ limit }}
+ {{ t('wallets.showOnly') }} {{ limit }}
</template>
</div>
</slot>
diff --git a/app/components/wallets/page/List.vue b/app/components/wallets/page/List.vue
index bc76cdf0..a42e310b 100644
--- a/app/components/wallets/page/List.vue
+++ b/app/components/wallets/page/List.vue
@@ -340,24 +340,30 @@ const counts = computed(() => ({
class="@xl/page:hidden grid grid-cols-2 gap-2 pb-2"
>
<!-- Currencies -->
- <UiItem2 @click="isShowCurrencyFilter = true">
+ <UiButtonWithRight
+ isShort
+ @click="isShowCurrencyFilter = true"
+ >
<template #label>
{{ t('filterByCurrency') }}
</template>
<template #value>
{{ currencyFiltered === 'all' ? t('all') : currencyFiltered }}
</template>
- </UiItem2>
+ </UiButtonWithRight>
<!-- Base -->
- <UiItem2 @click="isShowBaseCurrencyModal = true">
+ <UiButtonWithRight
+ isShort
+ @click="isShowBaseCurrencyModal = true"
+ >
<template #label>
{{ t('currencies.base') }}
</template>
<template #value>
{{ currenciesStore.base }}
</template>
- </UiItem2>
+ </UiButtonWithRight>
</div>
<!-- Wallets Currencies -->
@@ -424,7 +430,7 @@ const counts = computed(() => ({
/>
</UiToggle2>
- <UiItem2
+ <UiButtonWithRight
class="@xl/page:grid hidden grow"
@click="isShowBaseCurrencyModal = true"
>
@@ -434,7 +440,7 @@ const counts = computed(() => ({
<template #value>
{{ currenciesStore.base }}
</template>
- </UiItem2>
+ </UiButtonWithRight>
</div>
<div>
@@ -544,7 +550,7 @@ const counts = computed(() => ({
</div>
</template>
- <div class="ml-5 -translate-x-px border-l border-item-5 pl-3">
+ <div class="border-item-5 ml-5 -translate-x-px border-l pl-3">
<template v-if="groupedOptions.currencies === 0">
<WalletsItem
v-for="walletId in walletsIds"
@@ -586,7 +592,7 @@ const counts = computed(() => ({
</div>
</template>
- <div class="ml-5 -translate-x-px border-l border-item-5 pl-3">
+ <div class="border-item-5 ml-5 -translate-x-px border-l pl-3">
<WalletsItem
v-for="walletId in groupedWalletsIds"
:key="walletId"
@@ -634,7 +640,7 @@ const counts = computed(() => ({
</div>
</template>
- <div class="ml-5 -translate-x-px border-l border-item-5 pl-3">
+ <div class="border-item-5 ml-5 -translate-x-px border-l pl-3">
<template v-if="groupedOptions.type === 0">
<WalletsItem
v-for="walletId in walletsIds"
@@ -685,7 +691,7 @@ const counts = computed(() => ({
</div>
</template>
- <div class="ml-5 -translate-x-px border-l border-item-5 pl-3">
+ <div class="border-item-5 ml-5 -translate-x-px border-l pl-3">
<WalletsItem
v-for="walletId in groupedWalletsIds"
:key="walletId"
diff --git a/app/pages/settings.vue b/app/pages/settings.vue
index 94dc8ba7..09c70def 100644
--- a/app/pages/settings.vue
+++ b/app/pages/settings.vue
@@ -39,7 +39,7 @@ function onGenerateDemoData() {
<UiHeaderTitle>{{ t('settings.title') }}</UiHeaderTitle>
</UiHeader>
- <div class="pageWrapper rounded-xl bg-foreground-1 pt-4">
+ <div class="pageWrapper bg-foreground-1 rounded-xl pt-4">
<div>
<!-- Locale -->
<div class="pb-12">
@@ -64,7 +64,7 @@ function onGenerateDemoData() {
<!-- Currency -->
<div class="pb-12">
- <UiItem2 @click="isShowBaseCurrencyModal = true">
+ <UiButtonWithRight @click="isShowBaseCurrencyModal = true">
<template #label>
{{ t('currencies.base') }}
</template>
@@ -72,7 +72,7 @@ function onGenerateDemoData() {
<template #value>
{{ currenciesStore.base }}
</template>
- </UiItem2>
+ </UiButtonWithRight>
</div>
<!-- User -->
@@ -82,12 +82,12 @@ function onGenerateDemoData() {
</UiTitle3>
<div
v-if="userStore.user"
- class="pb-4 text-item-2"
+ class="text-item-2 pb-4"
>
{{ userStore.user?.email }}
</div>
<UiElement
- insideClasses="bg-item-4 min-h-[44px]"
+ insideClasses="bg-item-4 min-h-[44px] max-w-lg"
@click="userStore.signOut"
>
<template #leftIcon>
@@ -102,7 +102,7 @@ function onGenerateDemoData() {
<UiTitle3 class="pb-2">
{{ t('settings.caution') }}
</UiTitle3>
- <div class="pb-4 text-xs leading-none text-item-2">
+ <div class="text-item-2 pb-4 text-xs leading-none">
{{ t('alerts.willDeleteEverything') }}
</div>
@@ -111,7 +111,7 @@ function onGenerateDemoData() {
v-if="isDemo"
:lineWidth="1"
class="group"
- insideClasses="min-h-[44px] bg-item-4"
+ insideClasses="min-h-[44px] bg-item-4 max-w-lg"
@click="onGenerateDemoData"
>
<template #leftIcon>
@@ -123,7 +123,7 @@ function onGenerateDemoData() {
<UiElement
:lineWidth="1"
class="group"
- insideClasses="min-h-[44px] bg-item-4"
+ insideClasses="min-h-[44px] bg-item-4 max-w-lg"
@click="confirmRemoveUserData = true"
>
<template #leftIcon>
@@ -138,7 +138,7 @@ function onGenerateDemoData() {
<!-- About -->
<div class="pb-12">
{{ t('app.about') }}
- <div class="pt-4 text-xs text-item-2">
+ <div class="text-item-2 pt-4 text-xs">
{{ t('app.version') }} {{ version }}
</div>
</div>