botserver/ui/suite/calendar/calendar.html
Rodrigo Rodriguez (Pragmatismo) 48c1ae0b51 , dt.month, dt.hour, dt.is_weekend, etc.)
- Add startup wizard module for first-run configuration
- Add white-label branding system with .product file support
- Add bot manager for lifecycle, MinIO buckets, and templates
- Add version tracking registry for component updates
- Create comparison doc: BASIC vs n8n/Zapier/Make/Copilot
- Add WhatsApp-style sample dialogs to template documentation
- Add data traceability SVG diagram ```
2025-11-30 15:07:29 -03:00

1762 lines
50 KiB
HTML

<!-- Calendar - Event Management -->
<div class="calendar-container" id="calendar-app">
<!-- Sidebar -->
<aside class="calendar-sidebar" id="calendar-sidebar">
<div class="sidebar-header">
<h2>Calendar</h2>
<button class="btn-icon" id="toggle-cal-sidebar" title="Collapse">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="11 17 6 12 11 7"></polyline>
</svg>
</button>
</div>
<!-- Quick Actions -->
<div class="sidebar-actions">
<button class="btn-primary-full" id="new-event-btn"
hx-get="/api/calendar/event/new"
hx-target="#event-modal-content"
hx-swap="innerHTML">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="12" y1="5" x2="12" y2="19"></line>
<line x1="5" y1="12" x2="19" y2="12"></line>
</svg>
<span>New Event</span>
</button>
</div>
<!-- Mini Calendar -->
<div class="mini-calendar" id="mini-calendar">
<div class="mini-calendar-header">
<button class="btn-icon-sm" id="prev-month">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="15 18 9 12 15 6"></polyline>
</svg>
</button>
<span class="mini-calendar-title" id="mini-cal-title">January 2025</span>
<button class="btn-icon-sm" id="next-month">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="9 18 15 12 9 6"></polyline>
</svg>
</button>
</div>
<div class="mini-calendar-grid">
<div class="mini-calendar-weekdays">
<span>Su</span><span>Mo</span><span>Tu</span><span>We</span><span>Th</span><span>Fr</span><span>Sa</span>
</div>
<div class="mini-calendar-days" id="mini-cal-days">
<!-- Days generated by JS</span> -->
</div>
</div>
</div>
<!-- Calendars List -->
<div class="sidebar-section">
<div class="section-header">
<h3>My Calendars</h3>
<button class="btn-icon-sm" title="Add Calendar"
hx-get="/api/calendar/new"
hx-target="#calendar-modal-content">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="12" y1="5" x2="12" y2="19"></line>
<line x1="5" y1="12" x2="19" y2="12"></line>
</svg>
</button>
</div>
<div class="calendars-list" id="calendars-list"
hx-get="/api/calendar/list"
hx-trigger="load"
hx-swap="innerHTML">
<!-- Calendars loaded here -->
</div>
</div>
<!-- Upcoming Events -->
<div class="sidebar-section">
<h3>Upcoming</h3>
<div class="upcoming-events" id="upcoming-events"
hx-get="/api/calendar/upcoming"
hx-trigger="load"
hx-swap="innerHTML">
<!-- Upcoming events loaded here -->
</div>
</div>
</aside>
<!-- Main Calendar -->
<main class="calendar-main">
<!-- Calendar Header -->
<div class="calendar-header">
<div class="header-left">
<button class="btn-today" id="today-btn">Today</button>
<div class="nav-buttons">
<button class="btn-icon" id="prev-period">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="15 18 9 12 15 6"></polyline>
</svg>
</button>
<button class="btn-icon" id="next-period">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="9 18 15 12 9 6"></polyline>
</svg>
</button>
</div>
<h2 class="current-period" id="current-period">January 2025</h2>
</div>
<div class="header-right">
<div class="view-selector">
<button class="view-btn" data-view="day">Day</button>
<button class="view-btn active" data-view="week">Week</button>
<button class="view-btn" data-view="month">Month</button>
</div>
<button class="btn-icon" id="calendar-settings" title="Settings">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="3"></circle>
<path d="M19.4 15a1.65 1.65 0 00.33 1.82l.06.06a2 2 0 010 2.83 2 2 0 01-2.83 0l-.06-.06a1.65 1.65 0 00-1.82-.33 1.65 1.65 0 00-1 1.51V21a2 2 0 01-2 2 2 2 0 01-2-2v-.09A1.65 1.65 0 009 19.4a1.65 1.65 0 00-1.82.33l-.06.06a2 2 0 01-2.83 0 2 2 0 010-2.83l.06-.06a1.65 1.65 0 00.33-1.82 1.65 1.65 0 00-1.51-1H3a2 2 0 01-2-2 2 2 0 012-2h.09A1.65 1.65 0 004.6 9a1.65 1.65 0 00-.33-1.82l-.06-.06a2 2 0 010-2.83 2 2 0 012.83 0l.06.06a1.65 1.65 0 001.82.33H9a1.65 1.65 0 001-1.51V3a2 2 0 012-2 2 2 0 012 2v.09a1.65 1.65 0 001 1.51 1.65 1.65 0 001.82-.33l.06-.06a2 2 0 012.83 0 2 2 0 010 2.83l-.06.06a1.65 1.65 0 00-.33 1.82V9a1.65 1.65 0 001.51 1H21a2 2 0 012 2 2 2 0 01-2 2h-.09a1.65 1.65 0 00-1.51 1z"></path>
</svg>
</button>
</div>
</div>
<!-- Calendar Grid -->
<div class="calendar-grid-container" id="calendar-grid">
<!-- Day View -->
<div class="day-view hidden" id="day-view">
<div class="day-header">
<div class="time-gutter"></div>
<div class="day-column-header">
<span class="day-name" id="day-view-name">Monday</span>
<span class="day-number" id="day-view-number">13</span>
</div>
</div>
<div class="day-body">
<div class="time-slots" id="day-time-slots">
<!-- Time slots generated by JS -->
</div>
<div class="day-events" id="day-events">
<!-- Events positioned here -->
</div>
</div>
</div>
<!-- Week View -->
<div class="week-view" id="week-view">
<div class="week-header">
<div class="time-gutter"></div>
<div class="week-days-header" id="week-days-header">
<!-- Week day headers generated by JS -->
</div>
</div>
<div class="week-body">
<div class="time-column">
<div class="time-slots" id="week-time-slots">
<!-- Time slots generated by JS -->
</div>
</div>
<div class="week-grid" id="week-grid">
<!-- 7 day columns with events -->
</div>
</div>
</div>
<!-- Month View -->
<div class="month-view hidden" id="month-view">
<div class="month-header">
<div class="month-weekdays">
<span>Sunday</span>
<span>Monday</span>
<span>Tuesday</span>
<span>Wednesday</span>
<span>Thursday</span>
<span>Friday</span>
<span>Saturday</span>
</div>
</div>
<div class="month-grid" id="month-grid">
<!-- Month days generated by JS -->
</div>
</div>
</div>
<!-- Current Time Indicator -->
<div class="current-time-indicator" id="current-time-indicator"></div>
</main>
<!-- Event Modal -->
<div class="modal hidden" id="event-modal">
<div class="modal-content modal-lg">
<div class="modal-header">
<h3 id="event-modal-title">New Event</h3>
<button class="btn-icon close-modal">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="18" y1="6" x2="6" y2="18"></line>
<line x1="6" y1="6" x2="18" y2="18"></line>
</svg>
</button>
</div>
<div class="modal-body" id="event-modal-content">
<!-- Event form loaded here -->
<form class="event-form" id="event-form"
hx-post="/api/calendar/event/save"
hx-target="#calendar-grid"
hx-swap="innerHTML">
<div class="form-group">
<input type="text" name="title" placeholder="Add title" class="input-title" required>
</div>
<div class="form-row">
<div class="form-group">
<label>Start</label>
<input type="datetime-local" name="start" required>
</div>
<div class="form-group">
<label>End</label>
<input type="datetime-local" name="end" required>
</div>
</div>
<div class="form-group">
<label class="checkbox-label">
<input type="checkbox" name="all_day">
<span>All day</span>
</label</label>>
</div>
<div class="form-group">
<label>Location</label>
<div class="input-with-icon">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0118 0z"></path>
<circle cx="12" cy="10" r="3"></circle>
</svg>
<input type="text" name="location" placeholder="Add location">
</div>
</div>
<div class="form-group">
<label>Description</label>
<textarea name="description" placeholder="Add description" rows="3"></textarea>
</div>
<div class="form-row">
<div class="form-group">
<label>Calendar</label>
<select name="calendar_id">
<option value="personal">Personal</option>
<option value="work">Work</option>
<option value="family">Family</option>
</select>
</div>
<div class="form-group">
<label>Color</label>
<div class="color-options">
<label class="color-option">
<input type="radio" name="color" value="blue" checked>
<span class="color-dot" style="background: #3b82f6;"></span>
</label>
<label class="color-option">
<input type="radio" name="color" value="green">
<span class="color-dot" style="background: #22c55e;"></span>
</label>
<label class="color-option">
<input type="radio" name="color" value="red">
<span class="color-dot" style="background: #ef4444;"></span>
</label>
<label class="color-option">
<input type="radio" name="color" value="purple">
<span class="color-dot" style="background: #a855f7;"></span>
</label>
<label class="color-option">
<input type="radio" name="color" value="orange">
<span class="color-dot" style="background: #f97316;"></span>
</label>
</div>
</div>
</div>
<div class="form-group">
<label>Reminder</label>
<select name="reminder">
<option value="none">No reminder</option>
<option value="5m">5 minutes before</option>
<option value="15m">15 minutes before</option>
<option value="30m" selected>30 minutes before</option>
<option value="1h">1 hour before</option>
<option value="1d">1 day before</option>
</select>
</div>
<div class="form-group">
<label>Repeat</label>
<select name="repeat">
<option value="none">Does not repeat</option>
<option value="daily">Daily</option>
<option value="weekly">Weekly</option>
<option value="monthly">Monthly</option>
<option value="yearly">Yearly</option>
</select>
</div>
<div class="form-actions">
<button type="button" class="btn-secondary close-modal">Cancel</button>
<button type="submit" class="btn-primary">Save Event</button>
</div>
</form>
</div>
</div>
</div>
<!-- Event Details Popup -->
<div class="event-popup hidden" id="event-popup">
<div class="event-popup-header">
<div class="event-popup-color" id="popup-color"></div>
<h4 id="popup-title">Event Title</h4>
<div class="event-popup-actions">
<button class="btn-icon-sm" id="edit-event" title="Edit">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"></path>
<path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"></path>
</svg>
</button>
<button class="btn-icon-sm" id="delete-event" title="Delete">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="3 6 5 6 21 6"></polyline>
<path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"></path>
</svg>
</button>
<button class="btn-icon-sm close-popup">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="18" y1="6" x2="6" y2="18"></line>
<line x1="6" y1="6" x2="18" y2="18"></line>
</svg>
</button>
</div>
</div>
<div class="event-popup-body">
<div class="popup-detail">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"></circle>
<polyline points="12 6 12 12 16 14"></polyline>
</svg>
<span id="popup-time">10:00 AM - 11:00 AM</span>
</div>
<div class="popup-detail" id="popup-location-row">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0118 0z"></path>
<circle cx="12" cy="10" r="3"></circle>
</svg>
<span id="popup-location">Conference Room A</span>
</div>
<div class="popup-detail" id="popup-description-row">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="17" y1="10" x2="3" y2="10"></line>
<line x1="21" y1="6" x2="3" y2="6"></line>
<line x1="21" y1="14" x2="3" y2="14"></line>
<line x1="17" y1="18" x2="3" y2="18"></line>
</svg>
<span id="popup-description">Event description</span>
</div>
<div class="popup-detail">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect>
<line x1="16" y1="2" x2="16" y2="6"></line>
<line x1="8" y1="2" x2="8" y2="6"></line>
<line x1="3" y1="10" x2="21" y2="10"></line>
</svg>
<span id="popup-calendar">Personal</span>
</div>
</div>
</div>
</div>
<style>
/* Calendar Container */
.calendar-container {
display: flex;
height: calc(100vh - 60px);
background: var(--background);
color: var(--foreground);
}
/* Sidebar */
.calendar-sidebar {
width: 260px;
border-right: 1px solid var(--border);
background: var(--card);
display: flex;
flex-direction: column;
overflow-y: auto;
}
.calendar-sidebar.collapsed {
width: 0;
overflow: hidden;
}
.sidebar-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px;
border-bottom: 1px solid var(--border);
}
.sidebar-header h2 {
font-size: 18px;
font-weight: 600;
margin: 0;
}
.sidebar-actions {
padding: 16px;
}
.btn-primary-full {
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
width: 100%;
padding: 12px 16px;
border: none;
border-radius: 8px;
background: var(--primary);
color: var(--primary-foreground);
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: opacity 0.15s;
}
.btn-primary-full:hover {
opacity: 0.9;
}
/* Mini Calendar */
.mini-calendar {
padding: 16px;
border-bottom: 1px solid var(--border);
}
.mini-calendar-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
}
.mini-calendar-title {
font-size: 14px;
font-weight: 600;
}
.mini-calendar-weekdays {
display: grid;
grid-template-columns: repeat(7, 1fr);
gap: 2px;
margin-bottom: 4px;
}
.mini-calendar-weekdays span {
text-align: center;
font-size: 11px;
font-weight: 500;
color: var(--muted-foreground);
padding: 4px 0;
}
.mini-calendar-days {
display: grid;
grid-template-columns: repeat(7, 1fr);
gap: 2px;
}
.mini-day {
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
border-radius: 50%;
font-size: 12px;
cursor: pointer;
transition: all 0.15s;
}
.mini-day:hover {
background: var(--accent);
}
.mini-day.other-month {
color: var(--muted-foreground);
}
.mini-day.today {
background: var(--primary);
color: var(--primary-foreground);
}
.mini-day.selected {
background: var(--accent);
border: 2px solid var(--primary);
}
.mini-day.has-events::after {
content: '';
position: absolute;
bottom: 2px;
width: 4px;
height: 4px;
border-radius: 50%;
background: var(--primary);
}
/* Sidebar Sections */
.sidebar-section {
padding: 16px;
border-bottom: 1px solid var(--border);
}
.sidebar-section h3 {
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
color: var(--muted-foreground);
margin: 0 0 12px 0;
}
.section-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
}
.section-header h3 {
margin: 0;
}
/* Calendars List */
.calendars-list {
display: flex;
flex-direction: column;
gap: 4px;
}
.calendar-item {
display: flex;
align-items: center;
gap: 10px;
padding: 8px;
border-radius: 6px;
cursor: pointer;
transition: background 0.15s;
}
.calendar-item:hover {
background: var(--accent);
}
.calendar-checkbox {
width: 16px;
height: 16px;
border: 2px solid;
border-radius: 4px;
cursor: pointer;
}
.calendar-checkbox.checked::after {
content: '✓';
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 10px;
}
.calendar-name {
flex: 1;
font-size: 13px;
}
/* Upcoming Events */
.upcoming-events {
display: flex;
flex-direction: column;
gap: 8px;
}
.upcoming-event {
display: flex;
gap: 10px;
padding: 8px;
border-radius: 6px;
cursor: pointer;
transition: background 0.15s;
}
.upcoming-event:hover {
background: var(--accent);
}
.upcoming-color {
width: 4px;
border-radius: 2px;
flex-shrink: 0;
}
.upcoming-info {
flex: 1;
min-width: 0;
}
.upcoming-title {
font-size: 13px;
font-weight: 500;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.upcoming-time {
font-size: 11px;
color: var(--muted-foreground);
}
/* Main Calendar */
.calendar-main {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
position: relative;
}
/* Calendar Header */
.calendar-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 12px 20px;
border-bottom: 1px solid var(--border);
background: var(--card);
}
.header-left {
display: flex;
align-items: center;
gap: 12px;
}
.btn-today {
padding: 8px 16px;
border: 1px solid var(--border);
border-radius: 6px;
background: var(--background);
color: var(--foreground);
font-size: 13px;
font-weight: 500;
cursor: pointer;
transition: all 0.15s;
}
.btn-today:hover {
background: var(--accent);
}
.nav-buttons {
display: flex;
gap: 4px;
}
.current-period {
font-size: 18px;
font-weight: 600;
margin: 0;
}
.header-right {
display: flex;
align-items: center;
gap: 12px;
}
.view-selector {
display: flex;
border: 1px solid var(--border);
border-radius: 6px;
overflow: hidden;
}
.view-btn {
padding: 8px 16px;
border: none;
background: var(--background);
color: var(--foreground);
font-size: 13px;
cursor: pointer;
transition: all 0.15s;
}
.view-btn:not(:last-child) {
border-right: 1px solid var(--border);
}
.view-btn:hover {
background: var(--accent);
}
.view-btn.active {
background: var(--primary);
color: var(--primary-foreground);
}
/* Calendar Grid */
.calendar-grid-container {
flex: 1;
overflow: auto;
position: relative;
}
/* Day/Week Views */
.day-view,
.week-view {
display: flex;
flex-direction: column;
height: 100%;
}
.day-view.hidden,
.week-view.hidden,
.month-view.hidden {
display: none;
}
.day-header,
.week-header {
display: flex;
border-bottom: 1px solid var(--border);
background: var(--card);
position: sticky;
top: 0;
z-index: 10;
}
.time-gutter {
width: 60px;
flex-shrink: 0;
}
.day-column-header {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
padding: 8px;
}
.day-name {
font-size: 11px;
color: var(--muted-foreground);
text-transform: uppercase;
}
.day-number {
font-size: 24px;
font-weight: 600;
}
.day-number.today {
display: flex;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
border-radius: 50%;
background: var(--primary);
color: var(--primary-foreground);
}
.week-days-header {
flex: 1;
display: grid;
grid-template-columns: repeat(7, 1fr);
}
.week-day-header {
display: flex;
flex-direction: column;
align-items: center;
padding: 8px;
border-left: 1px solid var(--border);
}
.day-body,
.week-body {
flex: 1;
display: flex;
overflow-y: auto;
}
.time-column {
width: 60px;
flex-shrink: 0;
}
.time-slots {
position: relative;
}
.time-slot {
height: 48px;
display: flex;
align-items: flex-start;
justify-content: flex-end;
padding-right: 8px;
font-size: 11px;
color: var(--muted-foreground);
}
.week-grid {
flex: 1;
display: grid;
grid-template-columns: repeat(7, 1fr);
position: relative;
}
.day-column {
border-left: 1px solid var(--border);
position: relative;
}
.hour-row {
height: 48px;
border-bottom: 1px solid var(--border);
}
.hour-row:nth-child(even) {
border-bottom-style: dashed;
}
/* Month View */
.month-view {
display: flex;
flex-direction: column;
height: 100%;
}
.month-header {
border-bottom: 1px solid var(--border);
background: var(--card);
}
.month-weekdays {
display: grid;
grid-template-columns: repeat(7, 1fr);
}
.month-weekdays span {
padding: 12px;
text-align: center;
font-size: 12px;
font-weight: 600;
color: var(--muted-foreground);
text-transform: uppercase;
}
.month-grid {
flex: 1;
display: grid;
grid-template-columns: repeat(7, 1fr);
grid-template-rows: repeat(6, 1fr);
}
.month-day {
border-right: 1px solid var(--border);
border-bottom: 1px solid var(--border);
padding: 4px;
min-height: 100px;
cursor: pointer;
transition: background 0.15s;
}
.month-day:hover {
background: var(--accent);
}
.month-day:nth-child(7n) {
border-right: none;
}
.month-day.other-month {
background: var(--muted);
}
.month-day.other-month .month-day-number {
color: var(--muted-foreground);
}
.month-day-number {
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
font-size: 13px;
font-weight: 500;
border-radius: 50%;
}
.month-day.today .month-day-number {
background: var(--primary);
color: var(--primary-foreground);
}
.month-day-events {
margin-top: 4px;
display: flex;
flex-direction: column;
gap: 2px;
}
.month-event {
padding: 2px 6px;
border-radius: 3px;
font-size: 11px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
cursor: pointer;
}
.month-event.blue { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.month-event.green { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.month-event.red { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.month-event.purple { background: rgba(168, 85, 247, 0.2); color: #a855f7; }
.month-event.orange { background: rgba(249, 115, 22, 0.2); color: #f97316; }
.more-events {
font-size: 11px;
color: var(--muted-foreground);
padding: 2px 6px;
cursor: pointer;
}
.more-events:hover {
color: var(--primary);
}
/* Event in Week/Day View */
.calendar-event {
position: absolute;
left: 2px;
right: 2px;
padding: 4px 6px;
border-radius: 4px;
font-size: 11px;
overflow: hidden;
cursor: pointer;
z-index: 5;
}
.calendar-event.blue { background: rgba(59, 130, 246, 0.9); color: white; }
.calendar-event.green { background: rgba(34, 197, 94, 0.9); color: white; }
.calendar-event.red { background: rgba(239, 68, 68, 0.9); color: white; }
.calendar-event.purple { background: rgba(168, 85, 247, 0.9); color: white; }
.calendar-event.orange { background: rgba(249, 115, 22, 0.9); color: white; }
.event-title {
font-weight: 500;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.event-time {
font-size: 10px;
opacity: 0.9;
}
/* Current Time Indicator */
.current-time-indicator {
position: absolute;
left: 60px;
right: 0;
height: 2px;
background: var(--destructive);
z-index: 20;
pointer-events: none;
}
.current-time-indicator::before {
content: '';
position: absolute;
left: -5px;
top: -4px;
width: 10px;
height: 10px;
border-radius: 50%;
background: var(--destructive);
}
/* Modal */
.modal {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 200;
}
.modal.hidden {
display: none;
}
.modal-content {
width: 90%;
max-width: 480px;
max-height: 90vh;
background: var(--card);
border-radius: 12px;
overflow: hidden;
display: flex;
flex-direction: column;
}
.modal-lg {
max-width: 560px;
}
.modal-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 20px;
border-bottom: 1px solid var(--border);
}
.modal-header h3 {
margin: 0;
font-size: 18px;
}
.modal-body {
padding: 20px;
overflow-y: auto;
}
/* Event Form */
.event-form {
display: flex;
flex-direction: column;
gap: 16px;
}
.form-group {
display: flex;
flex-direction: column;
gap: 6px;
}
.form-group label {
font-size: 12px;
font-weight: 500;
color: var(--muted-foreground);
}
.form-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
}
.input-title {
font-size: 20px;
font-weight: 600;
border: none;
background: transparent;
color: var(--foreground);
padding: 8px 0;
outline: none;
}
.input-title::placeholder {
color: var(--muted-foreground);
}
.event-form input[type="text"],
.event-form input[type="datetime-local"],
.event-form select,
.event-form textarea {
padding: 10px 12px;
border: 1px solid var(--border);
border-radius: 6px;
background: var(--background);
color: var(--foreground);
font-size: 14px;
}
.event-form textarea {
resize: vertical;
}
.input-with-icon {
display: flex;
align-items: center;
gap: 10px;
padding: 0 12px;
border: 1px solid var(--border);
border-radius: 6px;
background: var(--background);
}
.input-with-icon svg {
color: var(--muted-foreground);
flex-shrink: 0;
}
.input-with-icon input {
flex: 1;
border: none;
background: transparent;
padding: 10px 0;
outline: none;
}
.checkbox-label {
display: flex;
align-items: center;
gap: 8px;
font-size: 14px;
cursor: pointer;
}
.checkbox-label input {
width: 16px;
height: 16px;
}
.color-options {
display: flex;
gap: 8px;
}
.color-option {
cursor: pointer;
}
.color-option input {
display: none;
}
.color-dot {
display: block;
width: 24px;
height: 24px;
border-radius: 50%;
transition: transform 0.15s;
}
.color-option input:checked + .color-dot {
transform: scale(1.2);
box-shadow: 0 0 0 3px var(--background), 0 0 0 5px currentColor;
}
.form-actions {
display: flex;
justify-content: flex-end;
gap: 12px;
padding-top: 16px;
border-top: 1px solid var(--border);
}
.btn-secondary {
padding: 10px 20px;
border: 1px solid var(--border);
border-radius: 6px;
background: var(--background);
color: var(--foreground);
font-size: 14px;
cursor: pointer;
transition: background 0.15s;
}
.btn-secondary:hover {
background: var(--accent);
}
.btn-primary {
padding: 10px 20px;
border: none;
border-radius: 6px;
background: var(--primary);
color: var(--primary-foreground);
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: opacity 0.15s;
}
.btn-primary:hover {
opacity: 0.9;
}
/* Event Popup */
.event-popup {
position: absolute;
width: 300px;
background: var(--card);
border: 1px solid var(--border);
border-radius: 8px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
z-index: 100;
}
.event-popup.hidden {
display: none;
}
.event-popup-header {
display: flex;
align-items: center;
gap: 12px;
padding: 16px;
border-bottom: 1px solid var(--border);
}
.event-popup-color {
width: 12px;
height: 12px;
border-radius: 3px;
flex-shrink: 0;
}
.event-popup-header h4 {
flex: 1;
margin: 0;
font-size: 16px;
font-weight: 600;
}
.event-popup-actions {
display: flex;
gap: 4px;
}
.event-popup-body {
padding: 16px;
display: flex;
flex-direction: column;
gap: 12px;
}
.popup-detail {
display: flex;
align-items: flex-start;
gap: 12px;
font-size: 13px;
}
.popup-detail svg {
color: var(--muted-foreground);
flex-shrink: 0;
margin-top: 2px;
}
/* Button Icons */
.btn-icon {
display: flex;
align-items: center;
justify-content: center;
width: 36px;
height: 36px;
border: none;
border-radius: 6px;
background: transparent;
color: var(--foreground);
cursor: pointer;
transition: background 0.15s;
}
.btn-icon:hover {
background: var(--accent);
}
.btn-icon-sm {
width: 28px;
height: 28px;
border: none;
border-radius: 4px;
background: transparent;
color: var(--muted-foreground);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
}
.btn-icon-sm:hover {
background: var(--accent);
color: var(--foreground);
}
/* Responsive */
@media (max-width: 768px) {
.calendar-sidebar {
position: absolute;
left: 0;
top: 0;
bottom: 0;
z-index: 60;
transform: translateX(-100%);
}
.calendar-sidebar.open {
transform: translateX(0);
}
.view-selector {
display: none;
}
.month-weekdays span {
font-size: 10px;
padding: 8px 4px;
}
.month-day {
min-height: 60px;
}
.event-popup {
width: calc(100% - 32px);
left: 16px !important;
right: 16px !important;
}
}
</style>
<script>
(function() {
// State
let currentDate = new Date();
let currentView = 'week';
let selectedDate = new Date();
let events = [];
// Elements
const miniCalDays = document.getElementById('mini-cal-days');
const miniCalTitle = document.getElementById('mini-cal-title');
const currentPeriod = document.getElementById('current-period');
const dayView = document.getElementById('day-view');
const weekView = document.getElementById('week-view');
const monthView = document.getElementById('month-view');
const eventModal = document.getElementById('event-modal');
const eventPopup = document.getElementById('event-popup');
// Initialize
init();
function init() {
generateTimeSlots();
renderMiniCalendar();
renderCurrentView();
updateCurrentTimeIndicator();
setInterval(updateCurrentTimeIndicator, 60000);
bindEvents();
}
function generateTimeSlots() {
const dayTimeSlots = document.getElementById('day-time-slots');
const weekTimeSlots = document.getElementById('week-time-slots');
let html = '';
for (let i = 0; i < 24; i++) {
const hour = i === 0 ? '12 AM' : i < 12 ? `${i} AM` : i === 12 ? '12 PM' : `${i - 12} PM`;
html += `<div class="time-slot">${hour}</div>`;
}
if (dayTimeSlots) dayTimeSlots.innerHTML = html;
if (weekTimeSlots) weekTimeSlots.innerHTML = html;
// Generate week grid columns
const weekGrid = document.getElementById('week-grid');
if (weekGrid) {
let gridHtml = '';
for (let d = 0; d < 7; d++) {
gridHtml += '<div class="day-column">';
for (let h = 0; h < 24; h++) {
gridHtml += '<div class="hour-row"></div>';
}
gridHtml += '</div>';
}
weekGrid.innerHTML = gridHtml;
}
}
function renderMiniCalendar() {
const year = currentDate.getFullYear();
const month = currentDate.getMonth();
miniCalTitle.textContent = new Date(year, month).toLocaleDateString('en-US', {
month: 'long',
year: 'numeric'
});
const firstDay = new Date(year, month, 1);
const lastDay = new Date(year, month + 1, 0);
const startDay = firstDay.getDay();
const daysInMonth = lastDay.getDate();
let html = '';
const today = new Date();
// Previous month days
const prevMonthLastDay = new Date(year, month, 0).getDate();
for (let i = startDay - 1; i >= 0; i--) {
html += `<button class="mini-day other-month" data-date="${year}-${month - 1}-${prevMonthLastDay - i}">${prevMonthLastDay - i}</button>`;
}
// Current month days
for (let d = 1; d <= daysInMonth; d++) {
const isToday = today.getDate() === d && today.getMonth() === month && today.getFullYear() === year;
const isSelected = selectedDate.getDate() === d && selectedDate.getMonth() === month && selectedDate.getFullYear() === year;
const classes = ['mini-day'];
if (isToday) classes.push('today');
if (isSelected) classes.push('selected');
html += `<button class="${classes.join(' ')}" data-date="${year}-${month + 1}-${d}">${d}</button>`;
}
// Next month days
const remainingDays = 42 - (startDay + daysInMonth);
for (let i = 1; i <= remainingDays; i++) {
html += `<button class="mini-day other-month" data-date="${year}-${month + 2}-${i}">${i}</button>`;
}
miniCalDays.innerHTML = html;
}
function renderCurrentView() {
switch (currentView) {
case 'day':
renderDayView();
break;
case 'week':
renderWeekView();
break;
case 'month':
renderMonthView();
break;
}
updatePeriodTitle();
}
function renderDayView() {
dayView.classList.remove('hidden');
weekView.classList.add('hidden');
monthView.classList.add('hidden');
const dayName = document.getElementById('day-view-name');
const dayNumber = document.getElementById('day-view-number');
dayName.textContent = selectedDate.toLocaleDateString('en-US', { weekday: 'long' });
dayNumber.textContent = selectedDate.getDate();
const today = new Date();
if (selectedDate.toDateString() === today.toDateString()) {
dayNumber.classList.add('today');
} else {
dayNumber.classList.remove('today');
}
}
function renderWeekView() {
dayView.classList.add('hidden');
weekView.classList.remove('hidden');
monthView.classList.add('hidden');
const weekDaysHeader = document.getElementById('week-days-header');
const weekStart = getWeekStart(selectedDate);
let html = '';
const today = new Date();
for (let i = 0; i < 7; i++) {
const day = new Date(weekStart);
day.setDate(weekStart.getDate() + i);
const isToday = day.toDateString() === today.toDateString();
html += `
<div class="week-day-header">
<span class="day-name">${day.toLocaleDateString('en-US', { weekday: 'short' })}</span>
<span class="day-number ${isToday ? 'today' : ''}">${day.getDate()}</span>
</div>
`;
}
weekDaysHeader.innerHTML = html;
}
function renderMonthView() {
dayView.classList.add('hidden');
weekView.classList.add('hidden');
monthView.classList.remove('hidden');
const monthGrid = document.getElementById('month-grid');
const year = currentDate.getFullYear();
const month = currentDate.getMonth();
const firstDay = new Date(year, month, 1);
const lastDay = new Date(year, month + 1, 0);
const startDay = firstDay.getDay();
const daysInMonth = lastDay.getDate();
let html = '';
const today = new Date();
// Previous month days
const prevMonthLastDay = new Date(year, month, 0).getDate();
for (let i = startDay - 1; i >= 0; i--) {
html += `
<div class="month-day other-month">
<span class="month-day-number">${prevMonthLastDay - i}</span>
<div class="month-day-events"></div>
</div>
`;
}
// Current month days
for (let d = 1; d <= daysInMonth; d++) {
const isToday = today.getDate() === d && today.getMonth() === month && today.getFullYear() === year;
html += `
<div class="month-day ${isToday ? 'today' : ''}" data-date="${year}-${month + 1}-${d}">
<span class="month-day-number">${d}</span>
<div class="month-day-events"></div>
</div>
`;
}
// Next month days
const totalCells = Math.ceil((startDay + daysInMonth) / 7) * 7;
const remainingDays = totalCells - (startDay + daysInMonth);
for (let i = 1; i <= remainingDays; i++) {
html += `
<div class="month-day other-month">
<span class="month-day-number">${i}</span>
<div class="month-day-events"></div>
</div>
`;
}
monthGrid.innerHTML = html;
}
function updatePeriodTitle() {
let title = '';
switch (currentView) {
case 'day':
title = selectedDate.toLocaleDateString('en-US', {
weekday: 'long',
month: 'long',
day: 'numeric',
year: 'numeric'
});
break;
case 'week':
const weekStart = getWeekStart(selectedDate);
const weekEnd = new Date(weekStart);
weekEnd.setDate(weekStart.getDate() + 6);
if (weekStart.getMonth() === weekEnd.getMonth()) {
title = `${weekStart.toLocaleDateString('en-US', { month: 'long' })} ${weekStart.getDate()} - ${weekEnd.getDate()}, ${weekStart.getFullYear()}`;
} else {
title = `${weekStart.toLocaleDateString('en-US', { month: 'short' })} ${weekStart.getDate()} - ${weekEnd.toLocaleDateString('en-US', { month: 'short' })} ${weekEnd.getDate()}, ${weekEnd.getFullYear()}`;
}
break;
case 'month':
title = currentDate.toLocaleDateString('en-US', {
month: 'long',
year: 'numeric'
});
break;
}
currentPeriod.textContent = title;
}
function getWeekStart(date) {
const d = new Date(date);
const day = d.getDay();
d.setDate(d.getDate() - day);
return d;
}
function updateCurrentTimeIndicator() {
const indicator = document.getElementById('current-time-indicator');
const now = new Date();
const minutes = now.getHours() * 60 + now.getMinutes();
const top = (minutes / 60) * 48; // 48px per hour
indicator.style.top = `${top + 52}px`; // Offset for header
// Only show in day/week view
if (currentView === 'month') {
indicator.style.display = 'none';
} else {
indicator.style.display = 'block';
}
}
function bindEvents() {
// View selector
document.querySelectorAll('.view-btn').forEach(btn => {
btn.addEventListener('click', function() {
document.querySelectorAll('.view-btn').forEach(b => b.classList.remove('active'));
this.classList.add('active');
currentView = this.dataset.view;
renderCurrentView();
});
});
// Today button
document.getElementById('today-btn').addEventListener('click', () => {
currentDate = new Date();
selectedDate = new Date();
renderMiniCalendar();
renderCurrentView();
});
// Navigation
document.getElementById('prev-period').addEventListener('click', () => navigate(-1));
document.getElementById('next-period').addEventListener('click', () => navigate(1));
document.getElementById('prev-month').addEventListener('click', () => {
currentDate.setMonth(currentDate.getMonth() - 1);
renderMiniCalendar();
});
document.getElementById('next-month').addEventListener('click', () => {
currentDate.setMonth(currentDate.getMonth() + 1);
renderMiniCalendar();
});
// Mini calendar day click
miniCalDays.addEventListener('click', (e) => {
if (e.target.classList.contains('mini-day')) {
const dateParts = e.target.dataset.date.split('-');
selectedDate = new Date(dateParts[0], dateParts[1] - 1, dateParts[2]);
currentDate = new Date(selectedDate);
renderMiniCalendar();
renderCurrentView();
}
});
// New event button
document.getElementById('new-event-btn').addEventListener('click', () => {
eventModal.classList.remove('hidden');
});
// Close modal
document.querySelectorAll('.close-modal').forEach(btn => {
btn.addEventListener('click', () => {
eventModal.classList.add('hidden');
});
});
// Close modal on backdrop click
eventModal.addEventListener('click', (e) => {
if (e.target === eventModal) {
eventModal.classList.add('hidden');
}
});
// Close popup
document.querySelector('.close-popup')?.addEventListener('click', () => {
eventPopup.classList.add('hidden');
});
// Toggle sidebar
document.getElementById('toggle-cal-sidebar').addEventListener('click', () => {
document.getElementById('calendar-sidebar').classList.toggle('collapsed');
});
// Month day click (create event)
document.getElementById('month-grid')?.addEventListener('click', (e) => {
const monthDay = e.target.closest('.month-day');
if (monthDay && !monthDay.classList.contains('other-month')) {
const dateParts = monthDay.dataset.date?.split('-');
if (dateParts) {
selectedDate = new Date(dateParts[0], dateParts[1] - 1, dateParts[2]);
eventModal.classList.remove('hidden');
// Pre-fill date in form
const startInput = document.querySelector('input[name="start"]');
const endInput = document.querySelector('input[name="end"]');
if (startInput && endInput) {
const dateStr = selectedDate.toISOString().slice(0, 10);
startInput.value = `${dateStr}T09:00`;
endInput.value = `${dateStr}T10:00`;
}
}
}
});
// Event form submit
document.getElementById('event-form')?.addEventListener('submit', (e) => {
e.preventDefault();
// Form is handled by HTMX, but we can add validation here
eventModal.classList.add('hidden');
});
// Keyboard shortcuts
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
eventModal.classList.add('hidden');
eventPopup.classList.add('hidden');
}
// Only handle if not in input
if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return;
switch (e.key) {
case 't':
document.getElementById('today-btn').click();
break;
case 'd':
document.querySelector('[data-view="day"]').click();
break;
case 'w':
document.querySelector('[data-view="week"]').click();
break;
case 'm':
document.querySelector('[data-view="month"]').click();
break;
case 'ArrowLeft':
navigate(-1);
break;
case 'ArrowRight':
navigate(1);
break;
case 'n':
document.getElementById('new-event-btn').click();
break;
}
});
}
function navigate(direction) {
switch (currentView) {
case 'day':
selectedDate.setDate(selectedDate.getDate() + direction);
break;
case 'week':
selectedDate.setDate(selectedDate.getDate() + (direction * 7));
break;
case 'month':
currentDate.setMonth(currentDate.getMonth() + direction);
break;
}
currentDate = new Date(selectedDate);
renderMiniCalendar();
renderCurrentView();
}
})();
</script>