@@ -4,9 +4,12 @@ import allLocales from "@fullcalendar/core/locales-all";
44import dayGridPlugin from "@fullcalendar/daygrid" ;
55import interactionPlugin from "@fullcalendar/interaction" ;
66import listPlugin from "@fullcalendar/list" ;
7+ import timeGridPlugin from "@fullcalendar/timegrid" ;
78import { ResizeController } from "@lit-labs/observers/resize-controller" ;
89import {
10+ mdiCalendarClock ,
911 mdiPlus ,
12+ mdiTimetable ,
1013 mdiViewAgenda ,
1114 mdiViewDay ,
1215 mdiViewModule ,
@@ -56,12 +59,14 @@ declare global {
5659
5760const defaultFullCalendarConfig : CalendarOptions = {
5861 headerToolbar : false ,
59- plugins : [ dayGridPlugin , listPlugin , interactionPlugin ] ,
62+ plugins : [ dayGridPlugin , listPlugin , interactionPlugin , timeGridPlugin ] ,
6063 initialView : "dayGridMonth" ,
6164 dayMaxEventRows : true ,
6265 height : "parent" ,
6366 handleWindowResize : false ,
6467 locales : allLocales ,
68+ nowIndicator : true ,
69+ scrollTime : "06:00:00" ,
6570 views : {
6671 listWeek : {
6772 type : "list" ,
@@ -86,6 +91,8 @@ export class HAFullCalendar extends LitElement {
8691 "dayGridMonth" ,
8792 "dayGridWeek" ,
8893 "dayGridDay" ,
94+ "timeGridWeek" ,
95+ "timeGridDay" ,
8996 "listWeek" ,
9097 ] ;
9198
@@ -325,6 +332,8 @@ export class HAFullCalendar extends LitElement {
325332 selectedDate :
326333 this . _activeView === "dayGridWeek" ||
327334 this . _activeView === "dayGridDay" ||
335+ this . _activeView === "timeGridWeek" ||
336+ this . _activeView === "timeGridDay" ||
328337 ( this . _activeView === "dayGridMonth" &&
329338 this . calendar ! . view . currentStart . getMonth ( ) !== new Date ( ) . getMonth ( ) )
330339 ? this . calendar ! . view . currentStart
@@ -359,8 +368,11 @@ export class HAFullCalendar extends LitElement {
359368 if ( info . view . type !== "dayGridMonth" ) {
360369 return ;
361370 }
362- this . _activeView = "dayGridDay" ;
363- this . calendar ! . changeView ( "dayGridDay" ) ;
371+ const dayView = this . views . includes ( "timeGridDay" )
372+ ? "timeGridDay"
373+ : "dayGridDay" ;
374+ this . _activeView = dayView ;
375+ this . calendar ! . changeView ( dayView ) ;
364376 this . calendar ! . gotoDate ( info . dateStr ) ;
365377 this . _fireViewChanged ( ) ;
366378 }
@@ -473,6 +485,16 @@ export class HAFullCalendar extends LitElement {
473485 value : "dayGridDay" ,
474486 iconPath : mdiViewDay ,
475487 } ,
488+ {
489+ label : localize ( "ui.components.calendar.views.timeGridWeek" ) ,
490+ value : "timeGridWeek" ,
491+ iconPath : mdiTimetable ,
492+ } ,
493+ {
494+ label : localize ( "ui.components.calendar.views.timeGridDay" ) ,
495+ value : "timeGridDay" ,
496+ iconPath : mdiCalendarClock ,
497+ } ,
476498 {
477499 label : localize ( "ui.components.calendar.views.listWeek" ) ,
478500 value : "listWeek" ,
@@ -767,6 +789,64 @@ export class HAFullCalendar extends LitElement {
767789 scrollbar-color : var (--scrollbar-thumb-color ) transparent;
768790 scrollbar-width : thin;
769791 }
792+
793+ /* timeGrid (week/day) view styles */
794+ .fc-timegrid-slot-label {
795+ font-size : var (--ha-font-size-xs );
796+ color : var (--secondary-text-color );
797+ }
798+
799+ .fc-timegrid-axis {
800+ font-size : var (--ha-font-size-xs );
801+ color : var (--secondary-text-color );
802+ }
803+
804+ .fc .fc-timegrid-col .fc-day-today {
805+ background : var (--primary-color-alpha-10 , rgba (0 , 0 , 0 , 0.04 ));
806+ }
807+
808+ .fc-timegrid-now-indicator-line {
809+ border-color : var (--primary-color );
810+ }
811+
812+ .fc-timegrid-now-indicator-arrow {
813+ border-top-color : var (--primary-color );
814+ border-bottom-color : var (--primary-color );
815+ }
816+
817+ .fc-timegrid-event {
818+ border-radius : var (--ha-border-radius-sm );
819+ }
820+
821+ .fc-timegrid-event .fc-event-main {
822+ padding : 2px 4px ;
823+ }
824+
825+ .fc-timegrid-event .fc-event-title-container {
826+ order : -1 ;
827+ }
828+
829+ /* Compact styling for short events via container query */
830+ .fc-timegrid-event-harness {
831+ container-type : size;
832+ }
833+
834+ @container (max-height : 30px ) {
835+ .fc-v-event {
836+ border-top-width : 0 ;
837+ border-bottom-width : 0 ;
838+ }
839+ .fc-v-event .fc-event-main {
840+ padding-top : 0 ;
841+ padding-bottom : 0 ;
842+ }
843+ .fc-v-event .fc-event-main .fc-event-main-frame {
844+ line-height : 14px ;
845+ }
846+ .fc-v-event .fc-event-time {
847+ display : none;
848+ }
849+ }
770850 ` ,
771851 ] ;
772852 }
0 commit comments