feat: future day grey.

This commit is contained in:
2025-11-11 14:42:42 +08:00
parent 9b1eb6cafd
commit d4765a5baf
2 changed files with 24 additions and 0 deletions

View File

@@ -123,6 +123,11 @@ export default class CalendarView {
dayEl.classList.add('other-month'); dayEl.classList.add('other-month');
} }
// Check if the day is in the future
if (this.isFutureDate(date)) {
dayEl.classList.add('future-day');
}
if (this.isToday(date)) { if (this.isToday(date)) {
dayEl.classList.add('today'); dayEl.classList.add('today');
} }
@@ -235,6 +240,15 @@ export default class CalendarView {
date.getDate() === today.getDate(); date.getDate() === today.getDate();
} }
// Check if a date is in the future
isFutureDate(date) {
const today = new Date();
today.setHours(0, 0, 0, 0);
const checkDate = new Date(date);
checkDate.setHours(0, 0, 0, 0);
return checkDate > today;
}
formatDate(date) { formatDate(date) {
const year = date.getFullYear(); const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); const month = String(date.getMonth() + 1).padStart(2, '0');

View File

@@ -504,6 +504,16 @@ header h1 {
background: #f9fafb; background: #f9fafb;
} }
.day.future-day {
opacity: 0.6;
background: #f3f4f6;
color: #9ca3af;
}
.day.future-day .day-number {
color: #9ca3af;
}
.day.today { .day.today {
border-color: #667eea; border-color: #667eea;
background: #f0f4ff; background: #f0f4ff;