diff --git a/src/calendar-view/CalendarView.vue b/src/calendar-view/CalendarView.vue index 506e1a8..98dfca6 100644 --- a/src/calendar-view/CalendarView.vue +++ b/src/calendar-view/CalendarView.vue @@ -2,18 +2,16 @@ import { computed, ref } from "vue"; import ObsidianIconButton from "../components/obsidian/ObsidianIconButton.vue"; import ObsidianButton from "../components/obsidian/ObsidianButton.vue"; -import CalendarMonth from "../components/calendar/CalendarMonth.vue"; import DatePickerModal from "../components/modals/DatePicker.modal.vue"; import { VueModal } from "../components/modals/vue-modal"; import { today, date_from_string } from "../calendar"; import { openDate } from "@/journals/open-date"; -import CalendarMonthButton from "@/components/calendar/CalendarMonthButton.vue"; -import CalendarYearButton from "@/components/calendar/CalendarYearButton.vue"; -import CalendarQuarterButton from "@/components/calendar/CalendarQuarterButton.vue"; import { ShelfSuggestModal } from "@/components/suggests/shelf-suggest"; import { useShelfProvider } from "@/composables/use-shelf"; import { useApp } from "@/composables/use-app"; import { usePlugin } from "@/composables/use-plugin"; +import NotesMonthView from "@/components/notes-calendar/NotesMonthView.vue"; +import NotesCalendarButton from "@/components/notes-calendar/NotesCalendarButton.vue"; const app = useApp(); const plugin = usePlugin(); @@ -38,13 +36,6 @@ const shouldShowShelf = computed(() => { const { journals } = useShelfProvider(selectedShelf); -const daysClickable = computed(() => { - return journals.day.value.length > 0; -}); -const weeksClickable = computed(() => { - return journals.week.value.length > 0; -}); - function selectShelf() { new ShelfSuggestModal( app, @@ -97,38 +88,6 @@ function openDay(date: string, event: MouseEvent) { event, ).catch(console.error); } -function openWeek(date: string, event: MouseEvent) { - openDate( - plugin, - date, - journals.week.value.map((journal) => journal.name), - event, - ).catch(console.error); -} -function openMonth(event: MouseEvent) { - openDate( - plugin, - refDate.value, - journals.month.value.map((journal) => journal.name), - event, - ).catch(console.error); -} -function openQuarter(event: MouseEvent) { - openDate( - plugin, - refDate.value, - journals.quarter.value.map((journal) => journal.name), - event, - ).catch(console.error); -} -function openYear(event: MouseEvent) { - openDate( - plugin, - refDate.value, - journals.year.value.map((journal) => journal.name), - event, - ).catch(console.error); -} // TODO slim header to avoid scroll @@ -141,44 +100,35 @@ function openYear(event: MouseEvent) { Today - + - + diff --git a/src/calendar.ts b/src/calendar.ts index 7099dfe..8b20cdd 100644 --- a/src/calendar.ts +++ b/src/calendar.ts @@ -1,7 +1,6 @@ import { moment } from "obsidian"; import { extractCurrentlocaleData } from "./utils/moment"; import type { MomentDate } from "./types/date.types"; -import { computed } from "vue"; const CUSTOM_LOCALE = "custom-journal-locale"; let initialWeekSettings: { dow: number; doy: number } | undefined; @@ -47,18 +46,15 @@ export function today(): MomentDate { return md.startOf("day"); } -export const weekdayNames = computed(() => { - const weekdayNames: string[] = []; - const week = today().startOf("week"); - const weekEnd = today().endOf("week"); - - while (week.isSameOrBefore(weekEnd)) { - weekdayNames.push(week.format("ddd")); - week.add(1, "day"); - } - - return weekdayNames; -}); +export function isSamePeriod( + period: moment.unitOfTime.StartOf, + a: string | MomentDate, + b: string | MomentDate, +): boolean { + const date1 = typeof a === "string" ? date_from_string(a) : a; + const date2 = typeof b === "string" ? date_from_string(b) : b; + return date1.isSame(date2, period); +} export function dateDistance(fromDate: string, toDate: string): number { const from = date_from_string(fromDate); diff --git a/src/code-blocks/timeline/TimelineCalendar.vue b/src/code-blocks/timeline/TimelineCalendar.vue index 8b441c3..cb070e8 100644 --- a/src/code-blocks/timeline/TimelineCalendar.vue +++ b/src/code-blocks/timeline/TimelineCalendar.vue @@ -3,10 +3,7 @@ import { date_from_string, today } from "@/calendar"; import type { JournalNoteData } from "@/types/journal.types"; import { computed } from "vue"; -import CalendarMonth from "@/components/calendar/CalendarMonth.vue"; -import CalendarMonthButton from "@/components/calendar/CalendarMonthButton.vue"; -import CalendarQuarterButton from "@/components/calendar/CalendarQuarterButton.vue"; -import CalendarYearButton from "@/components/calendar/CalendarYearButton.vue"; +import NotesMonthView from "@/components/notes-calendar/NotesMonthView.vue"; const props = defineProps<{ noteData: JournalNoteData | null; @@ -29,13 +26,7 @@ const list = computed(() => { diff --git a/src/code-blocks/timeline/TimelineMonth.vue b/src/code-blocks/timeline/TimelineMonth.vue index 4f17297..d412368 100644 --- a/src/code-blocks/timeline/TimelineMonth.vue +++ b/src/code-blocks/timeline/TimelineMonth.vue @@ -1,34 +1,21 @@ diff --git a/src/code-blocks/timeline/TimelineQuarter.vue b/src/code-blocks/timeline/TimelineQuarter.vue index 12ff7db..e5e9081 100644 --- a/src/code-blocks/timeline/TimelineQuarter.vue +++ b/src/code-blocks/timeline/TimelineQuarter.vue @@ -3,11 +3,7 @@ import { date_from_string, today } from "@/calendar"; import type { JournalNoteData } from "@/types/journal.types"; import { computed } from "vue"; -import CalendarMonth from "@/components/calendar/CalendarMonth.vue"; -import CalendarMonthButton from "@/components/calendar/CalendarMonthButton.vue"; -import CalendarQuarterButton from "@/components/calendar/CalendarQuarterButton.vue"; -import CalendarYearButton from "@/components/calendar/CalendarYearButton.vue"; - +import NotesMonthView from "@/components/notes-calendar/NotesMonthView.vue"; const props = defineProps<{ noteData: JournalNoteData | null; }>(); @@ -29,13 +25,7 @@ const list = computed(() => { diff --git a/src/code-blocks/timeline/TimelineWeek.vue b/src/code-blocks/timeline/TimelineWeek.vue index faee266..df16e62 100644 --- a/src/code-blocks/timeline/TimelineWeek.vue +++ b/src/code-blocks/timeline/TimelineWeek.vue @@ -1,8 +1,8 @@ diff --git a/src/components/CollapsibleBlock.vue b/src/components/CollapsibleBlock.vue index 0a53103..9201803 100644 --- a/src/components/CollapsibleBlock.vue +++ b/src/components/CollapsibleBlock.vue @@ -16,7 +16,7 @@ function toggle() {