From 79c8edc6cfb707f140ae78986b54f7dd593e899e Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Tue, 8 Oct 2024 13:20:06 +0200 Subject: [PATCH] makes the calendar week mode header align and highlights the week or day in the Month view depenedent if there is a week view available --- public/css/components/calendar.css | 5 ++++ public/js/components/Calendar/Header.js | 26 ++++++++-------- public/js/components/Calendar/Month/Page.js | 33 +++++++++++++++++---- public/js/components/Calendar/Week/Page.js | 4 +-- 4 files changed, 49 insertions(+), 19 deletions(-) diff --git a/public/css/components/calendar.css b/public/css/components/calendar.css index fed873a31..912161097 100755 --- a/public/css/components/calendar.css +++ b/public/css/components/calendar.css @@ -133,6 +133,11 @@ position: relative; aspect-ratio: 1; } + +.fhc-calendar-month-page-day-highlight { + background-color: #f5f5f5; +} + .fhc-calendar-sm .fhc-calendar-month-page-day.active .no, .fhc-calendar-xs .fhc-calendar-month-page-day.active .no { background-color: rgba(var(--bs-info-rgb), 0.25); diff --git a/public/js/components/Calendar/Header.js b/public/js/components/Calendar/Header.js index 127a2619a..e2f484b28 100755 --- a/public/js/components/Calendar/Header.js +++ b/public/js/components/Calendar/Header.js @@ -45,19 +45,21 @@ export default { } }, template: ` -
- -
-
- - +
+
+ +
+
+ + +
+
-
` } diff --git a/public/js/components/Calendar/Month/Page.js b/public/js/components/Calendar/Month/Page.js index f257c442c..56217ff97 100755 --- a/public/js/components/Calendar/Month/Page.js +++ b/public/js/components/Calendar/Month/Page.js @@ -1,13 +1,19 @@ import CalendarDate from '../../../composables/CalendarDate.js'; export default { + data(){ + return{ + highlightedWeek: null, + highlightedDay: null, + } + }, inject: [ 'date', 'focusDate', 'size', 'events', 'showWeeks', - 'noWeekView' + 'noWeekView', ], props: { year: Number, @@ -24,11 +30,12 @@ export default { let firstDayOfMonth = new CalendarDate(this.year, this.month, 1); let startDay = firstDayOfMonth.firstDayOfCalendarMonth; let endDay = firstDayOfMonth.lastDayOfCalendarMonth; - + let res = []; let week = {no:0,y:0,days:[]}; while (startDay <= endDay) { week.days.push(new Date(startDay)); + if (week.days.length == 7) { let d = new CalendarDate(week.days[res.length ? 0 : 6]); week.no = d.w; @@ -39,7 +46,8 @@ export default { startDay.setDate(startDay.getDate() + 1); } return res; - } + }, + }, methods: { selectDay(day) { @@ -52,17 +60,32 @@ export default { this.focusDate.set(week.days[0]); this.$emit('updateMode', 'week'); } + }, + highlight(week, day){ + this.highlightedWeek = week.no; + this.highlightedDay = day; + }, + isHighlighted(week, day) { + return this.noWeekView ? day == this.highlightedDay : week.no == this.highlightedWeek; + }, + clickEvent(day,week) { + if(this.noWeekView){ + this.selectDay(day); + }else{ + this.changeToWeek(week); + } } }, template: ` +

{{minimized}}

-
+
{{day.toLocaleString(undefined, {weekday: size < 1 ? 'narrow' : (size < 3 ? 'short' : 'long')})}}