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() { - + diff --git a/src/components/calendar/CalendarButton.vue b/src/components/calendar/CalendarButton.vue new file mode 100644 index 0000000..66d5163 --- /dev/null +++ b/src/components/calendar/CalendarButton.vue @@ -0,0 +1,19 @@ + + + + + + + + + diff --git a/src/components/calendar/CalendarDay.vue b/src/components/calendar/CalendarDay.vue deleted file mode 100644 index b913c0a..0000000 --- a/src/components/calendar/CalendarDay.vue +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - {{ date.format("D") }} - - - - - diff --git a/src/components/calendar/CalendarDecade.vue b/src/components/calendar/CalendarDecade.vue deleted file mode 100644 index 48e8256..0000000 --- a/src/components/calendar/CalendarDecade.vue +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - {{ startYear }} - {{ endYear }} - - - - - {{ year.date.format("YYYY") }} - - - - - - diff --git a/src/components/calendar/CalendarDecadeView.vue b/src/components/calendar/CalendarDecadeView.vue new file mode 100644 index 0000000..863404f --- /dev/null +++ b/src/components/calendar/CalendarDecadeView.vue @@ -0,0 +1,35 @@ + + + + + + + {{ startYear }} - {{ endYear }} + + + + + {{ year.date }} + + + diff --git a/src/components/calendar/CalendarGrid.vue b/src/components/calendar/CalendarGrid.vue new file mode 100644 index 0000000..2b07311 --- /dev/null +++ b/src/components/calendar/CalendarGrid.vue @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + diff --git a/src/components/calendar/CalendarMonth.vue b/src/components/calendar/CalendarMonth.vue deleted file mode 100644 index c4a8c18..0000000 --- a/src/components/calendar/CalendarMonth.vue +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - {{ momentDate.format("MMMM YYYY") }} - - - - - - {{ day }} - - - - - - - - - - - - diff --git a/src/components/calendar/CalendarMonthButton.vue b/src/components/calendar/CalendarMonthButton.vue deleted file mode 100644 index c43ffd1..0000000 --- a/src/components/calendar/CalendarMonthButton.vue +++ /dev/null @@ -1,41 +0,0 @@ - - - - - {{ date.format("MMMM") }} - - - - diff --git a/src/components/calendar/CalendarMonthView.vue b/src/components/calendar/CalendarMonthView.vue new file mode 100644 index 0000000..b286b10 --- /dev/null +++ b/src/components/calendar/CalendarMonthView.vue @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + {{ uiDate.date }} + + + diff --git a/src/components/calendar/CalendarQuarter.vue b/src/components/calendar/CalendarQuarter.vue deleted file mode 100644 index cd0af13..0000000 --- a/src/components/calendar/CalendarQuarter.vue +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - {{ momentDate.format("YYYY") }} - - - - - {{ quarter.date.format("[Q]Q") }} - - - - - - diff --git a/src/components/calendar/CalendarQuarterButton.vue b/src/components/calendar/CalendarQuarterButton.vue deleted file mode 100644 index e82e6dc..0000000 --- a/src/components/calendar/CalendarQuarterButton.vue +++ /dev/null @@ -1,41 +0,0 @@ - - - - - {{ date.format("[Q]Q") }} - - - - diff --git a/src/components/calendar/CalendarQuarterView.vue b/src/components/calendar/CalendarQuarterView.vue new file mode 100644 index 0000000..242b95c --- /dev/null +++ b/src/components/calendar/CalendarQuarterView.vue @@ -0,0 +1,37 @@ + + + + + + + + + + + + + {{ quarter.date }} + + + + diff --git a/src/components/calendar/CalendarWeek.vue b/src/components/calendar/CalendarWeek.vue deleted file mode 100644 index eae158a..0000000 --- a/src/components/calendar/CalendarWeek.vue +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - {{ day }} - - - - - - - - - - - - diff --git a/src/components/calendar/CalendarWeekNumber.vue b/src/components/calendar/CalendarWeekNumber.vue deleted file mode 100644 index 2743a22..0000000 --- a/src/components/calendar/CalendarWeekNumber.vue +++ /dev/null @@ -1,28 +0,0 @@ - - - - - {{ date.format("[W]W") }} - - - - diff --git a/src/components/calendar/CalendarWeekdays.vue b/src/components/calendar/CalendarWeekdays.vue new file mode 100644 index 0000000..586f676 --- /dev/null +++ b/src/components/calendar/CalendarWeekdays.vue @@ -0,0 +1,26 @@ + + + + + + {{ day }} + + + + + diff --git a/src/components/calendar/CalendarYear.vue b/src/components/calendar/CalendarYear.vue deleted file mode 100644 index 95211ec..0000000 --- a/src/components/calendar/CalendarYear.vue +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - {{ momentDate.format("YYYY") }} - - - - - {{ month.date.format("MMMM") }} - - - - - - diff --git a/src/components/calendar/CalendarYearButton.vue b/src/components/calendar/CalendarYearButton.vue deleted file mode 100644 index d929cea..0000000 --- a/src/components/calendar/CalendarYearButton.vue +++ /dev/null @@ -1,41 +0,0 @@ - - - - - {{ date.format("YYYY") }} - - - - diff --git a/src/components/calendar/CalendarYearView.vue b/src/components/calendar/CalendarYearView.vue new file mode 100644 index 0000000..3397a0a --- /dev/null +++ b/src/components/calendar/CalendarYearView.vue @@ -0,0 +1,35 @@ + + + + + + + + + + + + {{ month.date }} + + + diff --git a/src/components/calendar/FormattedDate.vue b/src/components/calendar/FormattedDate.vue new file mode 100644 index 0000000..bcb7f87 --- /dev/null +++ b/src/components/calendar/FormattedDate.vue @@ -0,0 +1,23 @@ + + + + {{ momentDate.format(format) }} + + + diff --git a/src/components/modals/DatePicker.modal.vue b/src/components/modals/DatePicker.modal.vue index 1eb062c..7b356e1 100644 --- a/src/components/modals/DatePicker.modal.vue +++ b/src/components/modals/DatePicker.modal.vue @@ -1,12 +1,13 @@ - + {{ startYear }} - {{ endYear }} - + - + {{ currentDateMoment.format("YYYY") }} - + - + - {{ currentDateMoment.format("YYYY") }} + + + - + - + - {{ currentDateMoment.format("MMMM YYYY") }} + + + - + diff --git a/src/components/modals/EditDecoration.modal.vue b/src/components/modals/EditDecoration.modal.vue index 6e31f1a..829d21f 100644 --- a/src/components/modals/EditDecoration.modal.vue +++ b/src/components/modals/EditDecoration.modal.vue @@ -8,7 +8,7 @@ import type { } from "@/types/settings.types"; import ObsidianSetting from "../obsidian/ObsidianSetting.vue"; import ObsidianButton from "../obsidian/ObsidianButton.vue"; -import CalendarDecoration from "../calendar/CalendarDecoration.vue"; +import CalendarDecoration from "../notes-calendar/decorations/CalendarDecoration.vue"; import DecorationBackground from "./edit-decoration/DecorationBackground.vue"; import DecorationColor from "./edit-decoration/DecorationColor.vue"; import DecorationShape from "./edit-decoration/DecorationShape.vue"; diff --git a/src/components/notes-calendar/NotesCalendarButton.vue b/src/components/notes-calendar/NotesCalendarButton.vue new file mode 100644 index 0000000..2f78fff --- /dev/null +++ b/src/components/notes-calendar/NotesCalendarButton.vue @@ -0,0 +1,41 @@ + + + + + + + + + diff --git a/src/components/notes-calendar/NotesMonthView.vue b/src/components/notes-calendar/NotesMonthView.vue new file mode 100644 index 0000000..e3bf599 --- /dev/null +++ b/src/components/notes-calendar/NotesMonthView.vue @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + diff --git a/src/components/notes-calendar/NotesWeekView.vue b/src/components/notes-calendar/NotesWeekView.vue new file mode 100644 index 0000000..8ced4ad --- /dev/null +++ b/src/components/notes-calendar/NotesWeekView.vue @@ -0,0 +1,34 @@ + + + + + + + + + diff --git a/src/components/calendar/CalendarDecoration.vue b/src/components/notes-calendar/decorations/CalendarDecoration.vue similarity index 93% rename from src/components/calendar/CalendarDecoration.vue rename to src/components/notes-calendar/decorations/CalendarDecoration.vue index d1e759e..bc0c1e0 100644 --- a/src/components/calendar/CalendarDecoration.vue +++ b/src/components/notes-calendar/decorations/CalendarDecoration.vue @@ -1,9 +1,9 @@