Skip to content

Open source personal finance application

feat: enhance UI components and layout for improved user experience

Ilya Komichevfdd0214126d4
diff --git a/app/assets/css/main.css b/app/assets/css/main.css
index 82ecc259..928b4e8c 100644
--- a/app/assets/css/main.css
+++ b/app/assets/css/main.css
@@ -20,7 +20,7 @@
@layer base {
html,
body {
- @apply antialiased text-default bg-default select-none overflow-hidden;
+ @apply antialiased text-default bg-[var(--item-1)] select-none;
overscroll-behavior-y: none;
}
}
diff --git a/app/components/categories/page/id/Index.vue b/app/components/categories/page/id/Index.vue
index fdae0ad3..08d07dd4 100644
--- a/app/components/categories/page/id/Index.vue
+++ b/app/components/categories/page/id/Index.vue
@@ -136,6 +136,8 @@ async function onDeleteConfirm() {
})
}, 300)
}
+
+const categoriesIds = computed(() => categoriesStore.getChildsIds(categoryId.value))
</script>
<template>
@@ -190,6 +192,18 @@ async function onDeleteConfirm() {
@onConfirm="onDeleteConfirm"
/>
+ <div
+ class="grow px-2 lg:px-4 2xl:px-8"
+ >
+ <CategoriesList
+ :ids="categoriesIds"
+ :categoriesItemProps="{
+ class: 'group',
+ }"
+ @click="(categoryId: CategoryId) => router.push(`/categories/${categoryId}`)"
+ />
+ </div>
+
<StatWrap
:activeTab
:hasChildren="categoriesIdsOrParent.length > 1"
diff --git a/app/components/layout/Sidebar.vue b/app/components/layout/Sidebar.vue
index 947e8866..398badc2 100644
--- a/app/components/layout/Sidebar.vue
+++ b/app/components/layout/Sidebar.vue
@@ -27,113 +27,115 @@ const isShowLogoMenu = ref(false)
<template>
<aside
:class="{
- '': props.isShowTrnForm && props.isShowSidebar && width >= 767,
- 'block w-72': props.isShowSidebar && width >= 767,
+ 'w-72': props.isShowSidebar && width >= 767,
+ 'w-12': !props.isShowSidebar || width < 767,
}"
- class="fixed inset-y-0 left-0 z-10 hidden h-full w-12 overflow-hidden sm:block"
+ class="fixed inset-y-0 left-0 z-40 hidden h-dvh overflow-hidden transition-all duration-300 ease-in-out sm:block"
>
- <!-- Small menu -->
- <LayoutSidebarMenu
- :isShowText="false"
- :class="{ 'md:hidden': props.isShowSidebar }"
- class="sm:align-center hidden h-full flex-col justify-center gap-1 sm:flex"
- />
-
- <div
- v-if="width >= 768 && props.isShowSidebar"
- class="grid h-full content-start gap-8 overflow-hidden overflow-y-auto"
- >
- <div class="px-2 pt-5">
- <BottomSheetOrDropdown
- :isOpen="isShowLogoMenu"
- isShowCloseBtn
- @onOpenModal="isShowLogoMenu = true"
- @onCloseModal="isShowLogoMenu = false"
- >
- <template #trigger>
- <div
- :class="getStyles('item', ['link', 'rounded'])"
- class="group-data-[state='open']:!bg-item-4 block cursor-default px-3 py-2"
- >
- <UiLogo />
- </div>
- </template>
-
- <template #content>
- <div class="grid gap-2 px-1 py-3 md:px-3">
- <UserViewLogout isShowSignOut />
-
- <div class="flex items-center gap-2">
- <LocaleSwitcher />
- <ThemeSwitcher />
- <ThemePicker />
- </div>
- </div>
- </template>
- </BottomSheetOrDropdown>
- </div>
+ <div class="relative h-full overflow-hidden overflow-y-auto overscroll-contain">
+ <!-- Small menu -->
+ <LayoutSidebarMenu
+ :isShowText="false"
+ :class="{ 'md:hidden': props.isShowSidebar }"
+ class="sm:align-center hidden h-full flex-col justify-center gap-1 sm:flex"
+ />
<div
- v-if="isDemo"
- class="px-4"
+ v-if="width >= 768 && props.isShowSidebar"
+ class="grid h-full content-start gap-8 overflow-hidden overflow-y-auto"
>
- <UiButtonAccent @click="userStore.signOut">
- {{ t("demo.exit") }}
- </UiButtonAccent>
- </div>
+ <div class="px-2 pt-5">
+ <BottomSheetOrDropdown
+ :isOpen="isShowLogoMenu"
+ isShowCloseBtn
+ @onOpenModal="isShowLogoMenu = true"
+ @onCloseModal="isShowLogoMenu = false"
+ >
+ <template #trigger>
+ <div
+ :class="getStyles('item', ['link', 'rounded'])"
+ class="group-data-[state='open']:!bg-item-4 block cursor-default px-3 py-2"
+ >
+ <UiLogo />
+ </div>
+ </template>
- <LayoutSidebarMenu class="px-2 pb-2" />
+ <template #content>
+ <div class="grid gap-2 px-1 py-3 md:px-3">
+ <UserViewLogout isShowSignOut />
- <div class="px-2 pb-6">
- <UiTitle3 class="!text-4 pb-2 pl-3">
- {{ t('wallets.title') }}
- </UiTitle3>
+ <div class="flex items-center gap-2">
+ <LocaleSwitcher />
+ <ThemeSwitcher />
+ <ThemePicker />
+ </div>
+ </div>
+ </template>
+ </BottomSheetOrDropdown>
+ </div>
- <WalletsList
- :limit="10"
- isShowToggle
- @onClick="(id: WalletId) => router.push(`/wallets/${id}`)"
+ <div
+ v-if="isDemo"
+ class="px-4"
>
- <template #default="{ walletsIdsSorted, walletsItemsLimited }">
- <WalletsItem
- v-for="(walletItem, walletId) in walletsItemsLimited"
- :key="walletId"
- :activeItemId="(route.params.id as string)"
- :lineWidth="1"
- :wallet="walletItem"
- :walletId
- class="group"
- isShowCreditLimit
- isShowRate
- isShowIcon
- @click="() => walletId === route.params.id ? router.push('/dashboard') : router.push(`/wallets/${walletId}`)"
- />
-
- <div
- v-if="walletsIdsSorted.length === 0"
- class="px-2"
- >
- <UiButtonAccent @click="router.push('/wallets/new')">
- {{ t("wallets.new") }}
- </UiButtonAccent>
- </div>
- </template>
- </WalletsList>
+ <UiButtonAccent @click="userStore.signOut">
+ {{ t("demo.exit") }}
+ </UiButtonAccent>
+ </div>
+
+ <LayoutSidebarMenu class="px-2 pb-2" />
+
+ <div class="px-2 pb-6">
+ <UiTitle3 class="!text-4 pb-2 pl-3">
+ {{ t('wallets.title') }}
+ </UiTitle3>
+
+ <WalletsList
+ :limit="10"
+ isShowToggle
+ @onClick="(id: WalletId) => router.push(`/wallets/${id}`)"
+ >
+ <template #default="{ walletsIdsSorted, walletsItemsLimited }">
+ <WalletsItem
+ v-for="(walletItem, walletId) in walletsItemsLimited"
+ :key="walletId"
+ :activeItemId="(route.params.id as string)"
+ :lineWidth="1"
+ :wallet="walletItem"
+ :walletId
+ class="group"
+ isShowCreditLimit
+ isShowRate
+ isShowIcon
+ @click="() => walletId === route.params.id ? router.push('/dashboard') : router.push(`/wallets/${walletId}`)"
+ />
+
+ <div
+ v-if="walletsIdsSorted.length === 0"
+ class="px-2"
+ >
+ <UiButtonAccent @click="router.push('/wallets/new')">
+ {{ t("wallets.new") }}
+ </UiButtonAccent>
+ </div>
+ </template>
+ </WalletsList>
+ </div>
</div>
- </div>
- <div class="absolute bottom-1 left-1 hidden w-full items-center md:flex">
- <UTooltip
- :text="t('app.toggleSidebar')"
- :kbds="['Meta', '\\']"
- >
- <UiItem1
- class="text-4 z-10"
- @click="emit('toggleSidebar')"
+ <div class="absolute bottom-1 left-0 hidden w-full items-center md:flex">
+ <UTooltip
+ :text="t('app.toggleSidebar')"
+ :kbds="['Meta', '\\']"
>
- <Icon :name="props.isShowSidebar ? 'lucide:panel-left-close' : 'lucide:panel-left'" size="18" />
- </UiItem1>
- </UTooltip>
+ <UiItem1
+ class="text-4 z-10"
+ @click="emit('toggleSidebar')"
+ >
+ <Icon :name="props.isShowSidebar ? 'lucide:panel-left-close' : 'lucide:panel-left'" size="18" />
+ </UiItem1>
+ </UTooltip>
+ </div>
</div>
</aside>
</template>
diff --git a/app/components/trnForm/FloatOpener.vue b/app/components/trnForm/FloatOpener.vue
index 5aa25952..32b45ebd 100644
--- a/app/components/trnForm/FloatOpener.vue
+++ b/app/components/trnForm/FloatOpener.vue
@@ -6,16 +6,18 @@ const { onClose, trnFormCreate, ui } = useTrnsFormStore()
<template>
<div
+ v-if="!ui.isShow"
class="
- group absolute right-0 bottom-0 hidden h-full w-[300px] items-end
- justify-end from-transparent to-[var(--item-5)]
- transition hover:bg-gradient-to-r xl:flex
- "
+ group fixed top-0 right-0 h-full w-[300px] items-end
+ justify-end from-transparent to-[var(--item-5)]
+ transition hover:bg-gradient-to-r xl:flex
+ "
@click="ui.isShow ? onClose() : trnFormCreate()"
>
<div
class="
- text-icon-primary flex items-center
+ text-icon-primary sticky right-0
+ bottom-0 flex items-center
justify-center rounded-full
px-4 py-5 text-2xl
opacity-70
diff --git a/app/components/trnForm/Sidebar.vue b/app/components/trnForm/Sidebar.vue
index 0cb5f90b..da7d44b2 100644
--- a/app/components/trnForm/Sidebar.vue
+++ b/app/components/trnForm/Sidebar.vue
@@ -49,7 +49,7 @@ watch(isShow, (v) => {
<Transition name="fadeIn" appear>
<div
v-if="isShow"
- class="trnForm @container/trnForm absolute inset-y-0 right-0 z-50 h-full w-[360px] py-2"
+ class="trnForm @container/trnForm fixed inset-y-0 right-0 z-50 h-dvh w-[360px] py-4"
>
<div class="border-left border-item-6 border-item-4 bg-item-2 relative h-full overflow-hidden rounded-l-xl border border-r-0 shadow-2xl">
<div class="absolute top-2 right-2">
@@ -60,7 +60,7 @@ watch(isShow, (v) => {
<div class="swiper-wrapper">
<!-- Main -->
<div class="swiper-slide bg-default h-full">
- <div class="scrollerBlock grid h-full grid-rows-[auto_1fr] items-start gap-4 overflow-y-auto">
+ <div class="scrollerBlock grid h-full grid-rows-[auto_1fr] items-start gap-4 overflow-y-auto overscroll-contain">
<TrnFormMain
maxHeight="100vh"
class="!pb-0"
@@ -82,7 +82,7 @@ watch(isShow, (v) => {
class="swiper-slide bg-[var(--bg-)]"
:style="{ height: '100%' }"
>
- <div class="scrollerBlock h-full overflow-y-auto">
+ <div class="scrollerBlock h-full overflow-y-auto overscroll-contain">
<UiTitle3 class="bg-default sticky top-0 z-10 px-4 pt-5 pb-3 md:text-xl">
{{ t('trns.history') }}
</UiTitle3>
diff --git a/app/components/trns/pages/History.vue b/app/components/trns/pages/History.vue
index f43a153e..e51fd176 100644
--- a/app/components/trns/pages/History.vue
+++ b/app/components/trns/pages/History.vue
@@ -46,7 +46,7 @@ watch([filter.categoriesIds, filter.walletsIds], () => {
<template>
<UiPage>
- <UiHeader sticky>
+ <UiHeader>
<UiHeaderTitle>{{ t('trns.history') }}</UiHeaderTitle>
<template #actions>
<StatFilterSelector
diff --git a/app/components/ui/Header.vue b/app/components/ui/Header.vue
index 1b1818c3..6656f2e7 100644
--- a/app/components/ui/Header.vue
+++ b/app/components/ui/Header.vue
@@ -1,19 +1,6 @@
-<script setup lang="ts">
-import { cn } from '~~/lib/cn'
-
-const props = defineProps<{
- sticky?: boolean
-}>()
-</script>
-
<template>
- <div
- :class="cn([
- 'bg-default/90 top-0 z-20 mb-2 backdrop-blur lg:sticky',
- props.sticky && 'sticky',
- ])"
- >
- <div class="border-item-4 grid min-h-12 max-w-7xl items-center border-b px-2 py-2 lg:px-4 lg:py-4 2xl:px-8">
+ <div class="bg-default/90 sticky top-0 z-20 mb-2 backdrop-blur">
+ <div class="border-item-4 grid min-h-12 max-w-7xl items-center border-b px-2 py-2 lg:px-4 lg:py-4">
<div class="flex grow items-center gap-2">
<slot />
diff --git a/app/components/wallets/page/List.vue b/app/components/wallets/page/List.vue
index 5d67e180..4a0cc756 100644
--- a/app/components/wallets/page/List.vue
+++ b/app/components/wallets/page/List.vue
@@ -501,6 +501,10 @@ const isOpen = ref(false)
<UiHeaderTitle>{{ t('wallets.name') }}</UiHeaderTitle>
<template #actions>
+ <UiItem3 @click="router.push('/wallets/new')">
+ <Icon name="lucide:plus" size="24" />
+ </UiItem3>
+
<BottomSheetOrDropdown
:isOpen="isOpen"
isShowCloseBtn
@@ -514,7 +518,7 @@ const isOpen = ref(false)
</template>
<template #content>
- <div class="p-1 pb-3 pt-4">
+ <div class="p-1 pt-4 pb-3">
<UiHeaderLink
v-if="walletsStore.sortedIds.length > 1"
icon="lucide:arrow-down-up"
@@ -522,13 +526,6 @@ const isOpen = ref(false)
>
{{ t('wallets.sortTitle') }}
</UiHeaderLink>
-
- <UiHeaderLink
- icon="lucide:plus"
- @click="router.push('/wallets/new')"
- >
- {{ t('wallets.new') }}
- </UiHeaderLink>
</div>
</template>
</BottomSheetOrDropdown>
@@ -552,10 +549,10 @@ const isOpen = ref(false)
<!-- Content -->
<div
v-else
- class="@xl/page:grid-cols-2 @xl/page:gap-6 @3xl/page:gap-12 grid max-w-5xl grow px-2 lg:px-4 2xl:px-8"
+ class="grid max-w-5xl grow px-2 lg:px-4 2xl:px-8 @xl/page:grid-cols-2 @xl/page:gap-6 @3xl/page:gap-12"
>
<!-- Right -->
- <div class="@xl/page:order-1 @xl/page:gap-4 @xl/page:pt-1 grid content-start gap-3 @3xl/main:max-w-sm">
+ <div class="grid content-start gap-3 @xl/page:order-1 @xl/page:gap-4 @xl/page:pt-1 @3xl/main:max-w-sm">
<!-- Wallets Currencies -->
<WalletsCurrencies
v-if="walletsStore.currenciesUsed.length > 1 && groupedBy !== 'currency'"
@@ -645,7 +642,7 @@ const isOpen = ref(false)
</div>
<!-- Wallets List -->
- <div class="@xl/page:max-w-lg md:max-w-lg">
+ <div class="md:max-w-lg @xl/page:max-w-lg">
<!-- No grouping -->
<div
v-if="groupedBy === 'none'"
@@ -686,7 +683,7 @@ const isOpen = ref(false)
:isShown
@click="toggleMap(groupPrimary)"
>
- <div class="font-tertiary !text-3 text-base font-semibold leading-none">
+ <div class="font-tertiary !text-3 text-base leading-none font-semibold">
{{ groupedBy === 'type' ? t(`money.types.${groupPrimary}`) : groupPrimary }}
</div>
@@ -725,7 +722,7 @@ const isOpen = ref(false)
:isShown
@click="toggleMap(groupPrimary, groupSecondary)"
>
- <div class="font-tertiary text-base font-semibold leading-none">
+ <div class="font-tertiary text-base leading-none font-semibold">
{{ groupedBy === 'currency' ? t(`money.types.${groupSecondary}`) : groupSecondary }}
</div>
<div class="ml-auto">
diff --git a/app/composables/usePageScroll.ts b/app/composables/usePageScroll.ts
deleted file mode 100644
index d23e8ed3..00000000
--- a/app/composables/usePageScroll.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-export function usePageScroll() {
- const route = useRoute()
- const scroll = ref<Record<string, number>>({})
-
- onUpdated(() => {
- setTimeout(() => {
- document.getElementById('pageScroll')?.scrollTo(0, scroll.value[route.path] ?? 0)
- }, 1)
- })
-
- onBeforeUpdate(() => {
- scroll.value[route.path] = document.getElementById('pageScroll')?.scrollTop ?? 0
- })
-}
diff --git a/app/layouts/default.vue b/app/layouts/default.vue
index 64478a1f..eb28380d 100644
--- a/app/layouts/default.vue
+++ b/app/layouts/default.vue
@@ -58,21 +58,22 @@ defineShortcuts({
: trnsFormStore.trnFormCreate()
},
})
-
-usePageScroll()
</script>
<template>
<div
- :class="{ 'md:pr-[360px]': trnsFormStore.ui.isShow && width >= 767 }"
- class="h-dvh bg-[var(--item-1)] transition-all duration-300 ease-in-out"
+ class="min-h-dvh transition-all duration-300 ease-in-out sm:pl-12"
+ :class="{
+ 'md:pl-72': isShowSidebar && width >= 767,
+ 'md:pr-[360px]': trnsFormStore.ui.isShow && width >= 767,
+ }"
style="margin-left: env(safe-area-inset-left)"
>
- <div v-if="status === 'error'">
+ <div v-if="status === 'error'" class="p-4">
<pre>{{ error }}</pre>
</div>
- <div v-else-if="status === 'pending' || trnsStore.items === false || walletsStore.items === false">
+ <div v-else-if="status === 'pending' || trnsStore.items === false || walletsStore.items === false" class="p-4">
{{ t('base.loading') }}
</div>
@@ -83,17 +84,12 @@ usePageScroll()
@toggleSidebar="isShowSidebar = !isShowSidebar"
/>
- <div
- class="grid h-full overflow-hidden sm:pl-12 md:p-4 md:pl-12"
- :class="{
- 'sm:pl-74 md:pl-74': isShowSidebar && width >= 767,
- }"
- >
- <div class="bg-default sm:border-item-4 relative z-10 h-full max-w-5xl overflow-hidden sm:rounded-md sm:border lg:rounded-2xl">
+ <div class="md:py-4 md:pr-4">
+ <div class="bg-default sm:border-item-4 relative z-10 max-w-5xl contain-paint sm:rounded-md sm:border lg:rounded-2xl">
<main
id="pageScroll"
style="padding-bottom: calc(50px + env(safe-area-inset-bottom))"
- class="@container/main grid h-full overflow-hidden overflow-y-auto"
+ class="@container/main contain-paint"
>
<slot :keepalive="{ include: keepalive }" />
</main>
@@ -102,7 +98,6 @@ usePageScroll()
<TrnFormFloatOpener />
- <!-- Menu -->
<LayoutMenuBottom />
<LayoutMenuBottomModal v-if="isModalOpen('menu')" />
</template>