package templates import "fmt" // CalendarSummary is one of the user's own calendars, listed on the // calendar home page. type CalendarSummary struct { Name string Color string // hex color like "#3b82f6", "" if unset } // EventSummary is a single event shown inside a month-view day cell. type EventSummary struct { ID string Summary string TimeText string // e.g. "14:00" or "" for all-day events AllDay bool } // MonthDay is one day cell in the month grid. type MonthDay struct { Date string // "YYYY-MM-DD", used for links and the "new event" date Day int // day-of-month number shown in the cell InMonth bool // false for the leading/trailing days of neighboring months IsToday bool Events []EventSummary } // MonthViewData is everything the month grid template needs to render one // month of a single calendar. type MonthViewData struct { Cal string Color string MonthLabel string // e.g. "August 2026" Weeks [][]MonthDay PrevMonthURL string NextMonthURL string TodayURL string } // EventFormData pre-fills the create/edit event form. type EventFormData struct { Cal string ID string // empty when creating a new event Summary string Description string Location string AllDay bool StartDate string // "YYYY-MM-DD" StartTime string // "HH:MM", empty when AllDay EndDate string // "YYYY-MM-DD" EndTime string // "HH:MM", empty when AllDay } templ CalendarsHome(username string, calendars []CalendarSummary) { @Layout("Calendar", username) {

Calendar

if len(calendars) == 0 {

You don't have any calendars yet — create one from the dashboard first.

} else { } } } templ MonthView(username string, data MonthViewData) { @Layout("Calendar", username) {
← Calendars

{ data.Cal }

Today { data.MonthLabel } New event
for _, wd := range weekdayLabels() {
{ wd }
} for _, week := range data.Weeks { for _, day := range week { @monthDayCell(data.Cal, day) } }
} } templ monthDayCell(cal string, day MonthDay) {
{ fmt.Sprint(day.Day) }
for _, ev := range day.Events { if !ev.AllDay && ev.TimeText != "" { { ev.TimeText } } { " " + ev.Summary } }
} templ EventForm(username string, data EventFormData, errMsg string) { @Layout("Calendar", username) { ← { data.Cal }

if data.ID == "" { New event } else { Edit event }

if errMsg != "" {

{ errMsg }

}
if data.ID != "" { }
} } func eventFormAction(data EventFormData) templ.SafeURL { if data.ID == "" { return templ.URL("/web/calendar/" + data.Cal + "/new") } return templ.URL("/web/calendar/" + data.Cal + "/" + data.ID + "/edit") } func weekdayLabels() []string { return []string{"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"} }