From 8e68a2f44b195202313437e6944252726a0f51f1 Mon Sep 17 00:00:00 2001 From: Alexis <35.alexis.pele@gmail.com> Date: Wed, 3 Apr 2024 20:49:12 +0200 Subject: [PATCH] Refactored jump today button --- src/components/calendar/CalendarJumpToday.vue | 27 ++++++++++++ src/components/calendar/CalendarMenu.vue | 42 +++---------------- src/components/calendar/CalendarTile.vue | 2 +- src/stores/calendar.ts | 18 +++++++- 4 files changed, 50 insertions(+), 39 deletions(-) create mode 100644 src/components/calendar/CalendarJumpToday.vue diff --git a/src/components/calendar/CalendarJumpToday.vue b/src/components/calendar/CalendarJumpToday.vue new file mode 100644 index 0000000..15537d0 --- /dev/null +++ b/src/components/calendar/CalendarJumpToday.vue @@ -0,0 +1,27 @@ + + + + + + + + Aujourd'hui + + + + {{ defaultDateFormatted }} + + + + diff --git a/src/components/calendar/CalendarMenu.vue b/src/components/calendar/CalendarMenu.vue index 1012f2e..03e6f21 100644 --- a/src/components/calendar/CalendarMenu.vue +++ b/src/components/calendar/CalendarMenu.vue @@ -1,5 +1,4 @@ @@ -38,16 +28,7 @@ const defaultDateFormatted = computed(() => getFormattedDateTitle(defaultDate, t - - - - Aujourd'hui - - - {{ defaultDateFormatted }} - - - + @@ -105,20 +86,7 @@ const defaultDateFormatted = computed(() => getFormattedDateTitle(defaultDate, t - - - - - - - - - {{ option }} - - - - - + diff --git a/src/components/calendar/CalendarTile.vue b/src/components/calendar/CalendarTile.vue index 09a4b71..0945f58 100644 --- a/src/components/calendar/CalendarTile.vue +++ b/src/components/calendar/CalendarTile.vue @@ -44,7 +44,7 @@ const isDefaultDate = computed(() => { v-if="eventsForTheDay.length > 0" class="absolute top-12 bottom-2 inset-x-2 grid auto-rows-min gap-1" :class="{ - 'opacity-50': props.faded + 'opacity-40': props.faded }" > diff --git a/src/stores/calendar.ts b/src/stores/calendar.ts index 6e65ed6..2b8f3d9 100644 --- a/src/stores/calendar.ts +++ b/src/stores/calendar.ts @@ -158,6 +158,21 @@ export const useCalendar = defineStore('calendar', () => { period: currentPeriod.value } + const isCurrentScreenActive = computed(() => { + switch (currentConfig.value.viewType) { + case 'month': + return defaultDate.value.month === Number(currentDate.currentMonth.value) + + case 'year': + case 'decade': + case 'century': + return defaultDate.value.year === Number(currentDate.currentYear.value) + + default: + return false + } + }) + /** * Moves the current date forward one month */ @@ -304,6 +319,7 @@ export const useCalendar = defineStore('calendar', () => { getFormattedDateTitle, getMonthName, setViewType, - getViewTypeTitle + getViewTypeTitle, + isCurrentScreenActive } })
{{ defaultDateFormatted }}