diff --git a/components/calendar/CalendarMenuNav.vue b/components/calendar/CalendarMenuNav.vue index 67c9402..3593ee0 100644 --- a/components/calendar/CalendarMenuNav.vue +++ b/components/calendar/CalendarMenuNav.vue @@ -16,7 +16,7 @@ interface DirectionLabels { futureFar: string } -const { currentConfig, decrementMonth, incrementMonth, decrementYear, incrementYear } = +const { currentConfig, decrementViewMonth, incrementViewMonth, decrementViewYear, incrementViewYear } = useCalendar() const activeDirectionLabels: ComputedRef = computed(() => { @@ -59,20 +59,20 @@ const activeDirectionLabels: ComputedRef = computed(() => { function toPastFar(): void { switch (currentConfig.viewType) { case 'month': - decrementYear() + decrementViewYear() break case 'year': - decrementYear(10) + decrementViewYear(10) break case 'decade': - decrementYear(100) + decrementViewYear(100) break case 'century': default: - decrementYear(1000) + decrementViewYear(1000) break } } @@ -80,20 +80,20 @@ function toPastFar(): void { function toPastNear(): void { switch (currentConfig.viewType) { case 'month': - decrementMonth() + decrementViewMonth() break case 'year': - decrementYear() + decrementViewYear() break case 'decade': - decrementYear(10) + decrementViewYear(10) break case 'century': default: - decrementYear(100) + decrementViewYear(100) break } } @@ -101,20 +101,20 @@ function toPastNear(): void { function toFutureNear(): void { switch (currentConfig.viewType) { case 'month': - incrementMonth() + incrementViewMonth() break case 'year': - incrementYear() + incrementViewYear() break case 'decade': - incrementYear(10) + incrementViewYear(10) break case 'century': default: - incrementYear(100) + incrementViewYear(100) break } } @@ -122,20 +122,20 @@ function toFutureNear(): void { function toFutureFar(): void { switch (currentConfig.viewType) { case 'month': - incrementYear() + incrementViewYear() break case 'year': - incrementYear(10) + incrementViewYear(10) break case 'decade': - incrementYear(100) + incrementViewYear(100) break case 'century': default: - incrementYear(1000) + incrementViewYear(1000) break } } diff --git a/components/calendar/state/monthly/Layout.vue b/components/calendar/state/monthly/Layout.vue index ada1c4f..a903bc9 100644 --- a/components/calendar/state/monthly/Layout.vue +++ b/components/calendar/state/monthly/Layout.vue @@ -2,7 +2,7 @@ import { useCalendar } from '@/stores/CalendarStore' import { useThrottleFn } from '@vueuse/core' -const { currentDate, decrementMonth, incrementMonth } = useCalendar() +const { currentDate, decrementViewMonth, incrementViewMonth } = useCalendar() const { currentMonthData } = storeToRefs(useCalendar()) function handleWheel(e: WheelEvent) { @@ -15,11 +15,11 @@ function handleWheel(e: WheelEvent) { } const moveCalendarLeft = useThrottleFn(() => { - decrementMonth() + decrementViewMonth() }, 100) const moveCalendarRight = useThrottleFn(() => { - incrementMonth() + incrementViewMonth() }, 100) diff --git a/components/calendar/state/yearly/Layout.vue b/components/calendar/state/yearly/Layout.vue index 3c9273d..1efcd17 100644 --- a/components/calendar/state/yearly/Layout.vue +++ b/components/calendar/state/yearly/Layout.vue @@ -2,7 +2,7 @@ import { useCalendar } from '@/stores/CalendarStore' import { useThrottleFn } from '@vueuse/core' -const { decrementYear, incrementYear } = useCalendar() +const { decrementViewYear, incrementViewYear } = useCalendar() const { sortedMonths: months } = storeToRefs(useCalendar()) function handleWheel(e: WheelEvent) { @@ -15,11 +15,11 @@ function handleWheel(e: WheelEvent) { } const moveCalendarLeft = useThrottleFn(() => { - decrementYear() + decrementViewYear() }, 100) const moveCalendarRight = useThrottleFn(() => { - incrementYear() + incrementViewYear() }, 100) diff --git a/stores/CalendarStore.ts b/stores/CalendarStore.ts index d60b970..f9f06e8 100644 --- a/stores/CalendarStore.ts +++ b/stores/CalendarStore.ts @@ -205,14 +205,14 @@ export const useCalendar = defineStore('calendar', () => { /** * Moves the current date forward one month */ - function incrementMonth(): void { + function incrementViewMonth(): void { let newValue = Number(params.month) + 1 // If the new value would exceed the max number of month per year if (newValue >= monthsPerYear.value) { newValue = 0 // Increment the year - incrementYear() + incrementViewYear() } params.month = newValue.toString() @@ -221,26 +221,26 @@ export const useCalendar = defineStore('calendar', () => { /** * Moves the current date backward one month */ - function decrementMonth(): void { + function decrementViewMonth(): void { let newValue = Number(params.month) - 1 // If the new value would go below 0 if (newValue < 0) { newValue = monthsPerYear.value - 1 // Decrement the year - decrementYear() + decrementViewYear() } params.month = newValue.toString() } /** - * Get the previous month number + * Get the previous month number of the calendar view * * @param monthNumber Initial month * @returns The previous month number in the year */ - function getPreviousMonth(monthNumber: number): number { + function getPreviousViewMonth(monthNumber: number): number { const target: number = monthNumber - 1 if (target < 0) { @@ -251,12 +251,12 @@ export const useCalendar = defineStore('calendar', () => { } /** - * Get the following month number + * Get the following month number of the calendar view * * @param monthNumber Initial month * @returns The next month number in the year */ - function getNextMonth(monthNumber: number): number { + function getNextViewMonth(monthNumber: number): number { const target: number = monthNumber + 1 if (target + 1 > monthsPerYear.value) { @@ -267,9 +267,9 @@ export const useCalendar = defineStore('calendar', () => { } /** - * Moves the current date to a particular month + * Moves the current view to a particular month */ - function setMonth(target: number): void { + function setViewMonth(target: number): void { // If the target is outside the month bounds if (target < 0 || target >= monthsPerYear.value) { return @@ -279,18 +279,18 @@ export const useCalendar = defineStore('calendar', () => { } /** - * Moves the current date forward one year + * Moves the current view forward one year */ - function incrementYear(inc: number = 1): void { + function incrementViewYear(inc: number = 1): void { const newValue = Number(params.year) + inc params.year = newValue.toString() } /** - * Moves the current date backward one year + * Moves the current view backward one year */ - function decrementYear(inc: number = 1): void { + function decrementViewYear(inc: number = 1): void { const newValue = Number(params.year) - inc params.year = newValue.toString() @@ -583,9 +583,9 @@ export const useCalendar = defineStore('calendar', () => { const currentMonth = sortedMonths.value[datePivot.month] dateAcc.day = currentMonth.days - datePivot.day if (direction === 'future') { - datePivot.month = getNextMonth(datePivot.month) + datePivot.month = getNextViewMonth(datePivot.month) } else { - datePivot.month = getPreviousMonth(datePivot.month) + datePivot.month = getPreviousViewMonth(datePivot.month) } datePivot.day = 1 @@ -914,13 +914,13 @@ export const useCalendar = defineStore('calendar', () => { selectedDate: skipHydrate(selectedDate), selectDate, params, - incrementMonth, - decrementMonth, - setMonth, - getPreviousMonth, - getNextMonth, - incrementYear, - decrementYear, + incrementViewMonth, + decrementViewMonth, + setViewMonth, + getPreviousViewMonth, + getNextViewMonth, + incrementViewYear, + decrementViewYear, jumpToDate, jumpToDefaultDate, getFormattedDateTitle,