diff --git a/src/components/CalendarHeader.vue b/src/components/CalendarHeader.vue index afacf15..b3fde2b 100644 --- a/src/components/CalendarHeader.vue +++ b/src/components/CalendarHeader.vue @@ -12,10 +12,10 @@ const props = defineProps({ const calendarStore = useCalendarStore() -// Emits: year-change -> { year, scrollTop } +// Emits year-change events const emit = defineEmits(['year-change']) -const baseDate = new Date(1970, 0, 4 + calendarStore.config.first_day) +const baseDate = computed(() => new Date(1970, 0, 4 + calendarStore.config.first_day)) const WEEK_MS = 7 * 24 * 60 * 60 * 1000 const topVirtualWeek = computed(() => { @@ -24,9 +24,9 @@ const topVirtualWeek = computed(() => { }) const currentYear = computed(() => { - const weekStart = new Date(baseDate) + const weekStart = new Date(baseDate.value) weekStart.setDate(weekStart.getDate() + topVirtualWeek.value * 7) - // ISO anchor: Thursday of current calendar week + // ISO anchor Thursday const anchor = new Date(weekStart) anchor.setDate(anchor.getDate() + ((4 - anchor.getDay() + 7) % 7)) return isoWeekInfo(anchor).year @@ -36,11 +36,10 @@ function virtualWeekOf(d) { const o = (d.getDay() - calendarStore.config.first_day + 7) % 7 const fd = new Date(d) fd.setDate(d.getDate() - o) - return Math.floor((fd - baseDate) / WEEK_MS) + return Math.floor((fd - baseDate.value) / WEEK_MS) } function isoWeekMonday(isoYear, isoWeek) { - // Monday of ISO week 1 const jan4 = new Date(isoYear, 0, 4) const week1Mon = new Date(jan4) week1Mon.setDate(week1Mon.getDate() - ((week1Mon.getDay() + 6) % 7)) @@ -54,16 +53,16 @@ function changeYear(y) { y = Math.round(Math.max(calendarStore.minYear, Math.min(calendarStore.maxYear, y))) if (y === currentYear.value) return const vw = topVirtualWeek.value - // Fraction within current row for smooth vertical position preservation + // Fraction within current row const weekStartScroll = (vw - props.minVirtualWeek) * props.rowHeight const frac = Math.max(0, Math.min(1, (props.scrollTop - weekStartScroll) / props.rowHeight)) - // Derive current ISO week via anchor Thursday - const curCalWeekStart = new Date(baseDate) + // Anchor Thursday of current calendar week + const curCalWeekStart = new Date(baseDate.value) curCalWeekStart.setDate(curCalWeekStart.getDate() + vw * 7) const curAnchorThu = new Date(curCalWeekStart) curAnchorThu.setDate(curAnchorThu.getDate() + ((4 - curAnchorThu.getDay() + 7) % 7)) let { week: isoW } = isoWeekInfo(curAnchorThu) - // Build Monday of that ISO week in target year; fallback if week absent (53) + // Build Monday of ISO week let weekMon = isoWeekMonday(y, isoW) if (isoWeekInfo(weekMon).year !== y) { isoW-- @@ -80,7 +79,7 @@ function changeYear(y) { } const weekdayNames = computed(() => { - // Get Monday-first names, then reorder by first day, then add weekend info + // Reorder names & weekend flags const mondayFirstNames = getLocalizedWeekdayNames() const sundayFirstNames = [mondayFirstNames[6], ...mondayFirstNames.slice(0, 6)] const reorderedNames = reorderByFirstDay(sundayFirstNames, calendarStore.config.first_day) diff --git a/src/components/CalendarView.vue b/src/components/CalendarView.vue index 4ccf351..9abf190 100644 --- a/src/components/CalendarView.vue +++ b/src/components/CalendarView.vue @@ -1,5 +1,5 @@ diff --git a/src/components/SettingsDialog.vue b/src/components/SettingsDialog.vue index b1dc311..30b0cd9 100644 --- a/src/components/SettingsDialog.vue +++ b/src/components/SettingsDialog.vue @@ -1,33 +1,28 @@ @@ -48,23 +43,12 @@ defineExpose({ open }) Weekend days - - - {{ ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'][i] }} - - + @@ -90,26 +74,7 @@ select { padding: 0.4rem 0.5rem; border-radius: 0.4rem; } -.weekday-pills { - display: flex; - gap: 0.35rem; - flex-wrap: wrap; -} -.pill { - border: 1px solid var(--muted); - background: var(--panel-alt, transparent); - color: var(--ink); - padding: 0.35rem 0.6rem; - border-radius: 0.5rem; - font-size: 0.7rem; - cursor: pointer; -} -.pill.active { - background: var(--today); - color: #000; - border-color: var(--today); - font-weight: 600; -} +/* WeekdaySelector display tweaks */ .footer-row { display: flex; justify-content: flex-end; @@ -124,10 +89,25 @@ select { border-radius: 0.4rem; cursor: pointer; } -.ec-btn.save-btn { - background: var(--today); - color: #000; - border-color: transparent; +.ec-btn.close-btn { + background: var(--panel-alt); + border-color: var(--muted); font-weight: 500; } + +/* Adjust WeekdaySelector size inside settings */ +::v-deep(.weekgrid) { + margin-top: 0.25rem; +} +::v-deep(.day) { + font-size: 0.6rem; + padding: 0.45rem 0.25rem; +} +::v-deep(.workday-weekend div.workday) { + background: var(--muted); +} +::v-deep(.workday-weekend div.weekend) { + background: var(--strong); +} +