From 4e31fa4427037c0ffd4ad704308203639bf05df8 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 20 Apr 2026 00:12:53 +0900 Subject: [PATCH] refac --- .../calendar/CalendarSidebar.svelte | 2 +- .../components/calendar/CalendarView.svelte | 164 ---------------- src/routes/(app)/calendar/+page.svelte | 180 ++++++++++++++++-- 3 files changed, 170 insertions(+), 176 deletions(-) diff --git a/src/lib/components/calendar/CalendarSidebar.svelte b/src/lib/components/calendar/CalendarSidebar.svelte index 8ed0df4727..dc98df05e0 100644 --- a/src/lib/components/calendar/CalendarSidebar.svelte +++ b/src/lib/components/calendar/CalendarSidebar.svelte @@ -71,7 +71,7 @@
-
+
{miniMonthNames[miniMonth]} {miniYear}
- -
- {/if} - -
-
- {headerText} - - -
- -
- - - - - -
-
-
- - {#if view === 'month'}
diff --git a/src/routes/(app)/calendar/+page.svelte b/src/routes/(app)/calendar/+page.svelte index 6e7296efb3..2267c1c799 100644 --- a/src/routes/(app)/calendar/+page.svelte +++ b/src/routes/(app)/calendar/+page.svelte @@ -14,6 +14,11 @@ import CalendarEventModal from '$lib/components/calendar/CalendarEventModal.svelte'; import Spinner from '$lib/components/common/Spinner.svelte'; import Plus from '$lib/components/icons/Plus.svelte'; + import Tooltip from '$lib/components/common/Tooltip.svelte'; + import SidebarIcon from '$lib/components/icons/Sidebar.svelte'; + import Select from '$lib/components/common/Select.svelte'; + import Check from '$lib/components/icons/Check.svelte'; + import ChevronDown from '$lib/components/icons/ChevronDown.svelte'; const i18n = getContext('i18n'); @@ -29,6 +34,22 @@ let editEvent: CalendarEventModel | null = null; let defaultStartAt: number | null = null; + const MONTH_NAMES = [ + 'January', + 'February', + 'March', + 'April', + 'May', + 'June', + 'July', + 'August', + 'September', + 'October', + 'November', + 'December' + ]; + const DAY_NAMES = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; + function getVisibleRange(): { start: string; end: string } { const d = new Date(currentDate); let start: Date; @@ -128,8 +149,29 @@ showEventModal = true; } + function navigateCalendar(delta: number) { + const d = new Date(currentDate); + if (view === 'month') { + d.setDate(1); + d.setMonth(d.getMonth() + delta); + } else if (view === 'week') d.setDate(d.getDate() + delta * 7); + else d.setDate(d.getDate() + delta); + currentDate = d; + handleNavigate(); + } + + function goToToday() { + currentDate = new Date(); + handleNavigate(); + } + $: defaultCalendarId = calendars.find((c) => c.is_default)?.id || calendars[0]?.id || ''; + $: headerText = + view === 'day' + ? `${DAY_NAMES[currentDate.getDay()]}, ${MONTH_NAMES[currentDate.getMonth()]} ${currentDate.getDate()}, ${currentDate.getFullYear()}` + : `${MONTH_NAMES[currentDate.getMonth()]} ${currentDate.getFullYear()}`; + onMount(async () => { await loadCalendars(); await refresh(); @@ -157,17 +199,134 @@ : ''} max-w-full" > {#if loaded} + + +
-