Skip to content

Open source personal finance application

refactor: reorder date navigation - arrows, reset, then slot for date content

Ilya Komichevbac6c6e78297
diff --git a/app/components/date/Nav.vue b/app/components/date/Nav.vue
index 6a43afcf..ad34f6f7 100644
--- a/app/components/date/Nav.vue
+++ b/app/components/date/Nav.vue
@@ -1,9 +1,8 @@
<script setup lang="ts">
-const { isEnd, isShowNavHome, isStart, position = 'left' } = defineProps<{
+const { isEnd, isShowNavHome, isStart } = defineProps<{
isEnd: boolean
isShowNavHome: boolean
isStart: boolean
- position?: 'left' | 'right'
}>()
const emit = defineEmits<{
@@ -13,14 +12,6 @@ const emit = defineEmits<{
<template>
<div class="flex items-center gap-1">
- <UiActionButton
- v-if="position === 'left' && isShowNavHome"
- :ariaLabel="$t('base.today')"
- @click="emit('changeDate', 'today')"
- >
- <Icon name="lucide:undo-2" size="20" />
- </UiActionButton>
-
<UiActionButton
:ariaLabel="$t('base.previous')"
:class="cn('bg-item-3', isStart && 'hover:transparent opacity-30')"
@@ -38,11 +29,13 @@ const emit = defineEmits<{
</UiActionButton>
<UiActionButton
- v-if="position === 'right' && isShowNavHome"
+ v-if="isShowNavHome"
:ariaLabel="$t('base.today')"
@click="emit('changeDate', 'today')"
>
<Icon name="lucide:undo-2" size="20" />
</UiActionButton>
+
+ <slot />
</div>
</template>
diff --git a/app/components/stat/date/Navigation.vue b/app/components/stat/date/Navigation.vue
index 762bf03d..acbea17c 100644
--- a/app/components/stat/date/Navigation.vue
+++ b/app/components/stat/date/Navigation.vue
@@ -51,21 +51,41 @@ function changeDate(way: 'next' | 'prev' | 'today') {
<template>
<div class="items-top bg-default/90 sticky top-0 z-20 -my-2 flex grow items-center gap-2 overflow-x-auto py-2 backdrop-blur lg:top-[87px]">
- <div
- v-if="!statDate.params.value.customDate"
- class="flex gap-1"
+ <DateNav
+ v-if="isShowNav && !statDate.params.value.customDate"
+ :isEnd
+ :isShowNavHome
+ :isStart
+ @changeDate="changeDate"
>
- <DateNav
- v-if="isShowNav"
- :isEnd
- :isShowNavHome
- :isStart
- position="right"
- @changeDate="changeDate"
- />
- </div>
+ <BottomSheetOrDropdown
+ :title="t('dates.select')"
+ :isOpen="statDate.modal.value.dateSelector"
+ class="flex grow-0 gap-1"
+ isShowCloseBtn
+ @openModal="statDate.modal.value.dateSelector = true"
+ @closeModal="statDate.modal.value.dateSelector = false"
+ >
+ <template #trigger>
+ <UiTitleCollapse
+ class="_bg-item-4 text-md !grow-0"
+ isShown
+ >
+ <StatDateRange />
+ </UiTitleCollapse>
+ </template>
+
+ <template #content="{ close }">
+ <StatDateSelector
+ class="min-w-[362px] pb-2 md:px-3"
+ @close="close"
+ />
+ </template>
+ </BottomSheetOrDropdown>
+ </DateNav>
<BottomSheetOrDropdown
+ v-else
:title="t('dates.select')"
:isOpen="statDate.modal.value.dateSelector"
class="flex grow-0 gap-1"