@@ -221,6 +221,9 @@ function initializeEventCalendar(events) {
221221 const newMonth = `${ currentMonthDate . getFullYear ( ) } -${ String ( currentMonthDate . getMonth ( ) + 1 ) . padStart ( 2 , '0' ) } ` ;
222222 updateDisplayedMonth ( newMonth ) ;
223223
224+ // Update Today button disabled state
225+ updateTodayButtonState ( currentMonthDate ) ;
226+
224227 // Scroll current day into view if needed
225228 setTimeout ( ( ) => scrollCurrentDayIntoView ( ) , 100 ) ;
226229 }
@@ -365,12 +368,16 @@ function hideModal() {
365368
366369function setupEventHandlers ( ) {
367370 // Today
368- document . getElementById ( 'todayBtn' ) ?. addEventListener ( 'click' , ( ) => {
369- if ( calendar ) {
371+ const todayBtn = document . getElementById ( 'todayBtn' ) ;
372+ todayBtn ?. addEventListener ( 'click' , ( ) => {
373+ if ( calendar && ! todayBtn . disabled ) {
370374 calendar . setOption ( 'date' , new Date ( ) ) ;
371375 }
372376 } ) ;
373377
378+ // Set initial state of Today button
379+ updateTodayButtonState ( new Date ( ) ) ;
380+
374381 // Prev / next navigation
375382 document . getElementById ( 'prevBtn' ) ?. addEventListener ( 'click' , ( ) => {
376383 if ( calendar && typeof calendar . prev === 'function' ) {
@@ -390,6 +397,29 @@ function setupEventHandlers() {
390397 } ) ;
391398}
392399
400+ // Update Today button disabled state based on whether we're viewing the current month
401+ function updateTodayButtonState ( displayedDate ) {
402+ const todayBtn = document . getElementById ( 'todayBtn' ) ;
403+ if ( ! todayBtn ) return ;
404+
405+ const now = new Date ( ) ;
406+ const isCurrentMonth =
407+ displayedDate . getFullYear ( ) === now . getFullYear ( ) &&
408+ displayedDate . getMonth ( ) === now . getMonth ( ) ;
409+
410+ todayBtn . disabled = isCurrentMonth ;
411+
412+ if ( isCurrentMonth ) {
413+ // Disabled styling - match recap page disabled buttons
414+ todayBtn . classList . remove ( 'bg-primary-600' , 'hover:bg-primary-700' , 'text-white' ) ;
415+ todayBtn . classList . add ( 'bg-gray-100' , 'dark:bg-dark-800' , 'text-gray-400' , 'dark:text-dark-400' , 'cursor-not-allowed' ) ;
416+ } else {
417+ // Enabled styling - primary color
418+ todayBtn . classList . add ( 'bg-primary-600' , 'hover:bg-primary-700' , 'text-white' ) ;
419+ todayBtn . classList . remove ( 'bg-gray-100' , 'dark:bg-dark-800' , 'text-gray-400' , 'dark:text-dark-400' , 'cursor-not-allowed' ) ;
420+ }
421+ }
422+
393423// Update monthly statistics for the given month/year (preferring pre-calculated stats when available)
394424function updateMonthlyStats ( currentDate ) {
395425 if ( ! currentDate ) return ;
0 commit comments