2025-07-24 22:17:38 +02:00
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html lang="en">
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
|
<title>Calendar Week View - POC</title>
|
|
|
|
|
<style>
|
|
|
|
|
/* Base CSS */
|
|
|
|
|
* {
|
|
|
|
|
margin: 0;
|
|
|
|
|
padding: 0;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:root {
|
|
|
|
|
/* Grid measurements */
|
|
|
|
|
--hour-height: 60px;
|
|
|
|
|
--minute-height: 1px;
|
|
|
|
|
--snap-interval: 15;
|
|
|
|
|
|
|
|
|
|
/* Time boundaries */
|
|
|
|
|
--day-start-hour: 7;
|
|
|
|
|
--day-end-hour: 19;
|
|
|
|
|
--work-start-hour: 8;
|
|
|
|
|
--work-end-hour: 17;
|
|
|
|
|
|
|
|
|
|
/* Colors */
|
|
|
|
|
--color-primary: #2196f3;
|
|
|
|
|
--color-grid-line: #e0e0e0;
|
|
|
|
|
--color-grid-line-light: rgba(0, 0, 0, 0.03);
|
|
|
|
|
--color-work-hours: rgba(0, 100, 0, 0.02);
|
|
|
|
|
--color-current-time: #ff0000;
|
|
|
|
|
|
|
|
|
|
/* Event colors */
|
|
|
|
|
--color-event-meeting: #e3f2fd;
|
|
|
|
|
--color-event-meeting-border: #2196f3;
|
|
|
|
|
--color-event-meal: #fff3e0;
|
|
|
|
|
--color-event-meal-border: #ff9800;
|
|
|
|
|
--color-event-work: #f3e5f5;
|
|
|
|
|
--color-event-work-border: #9c27b0;
|
|
|
|
|
|
|
|
|
|
/* UI colors */
|
|
|
|
|
--color-background: #ffffff;
|
|
|
|
|
--color-surface: #f5f5f5;
|
|
|
|
|
--color-text: #333333;
|
|
|
|
|
--color-text-secondary: #666666;
|
|
|
|
|
--color-border: #e0e0e0;
|
|
|
|
|
|
|
|
|
|
/* Shadows */
|
|
|
|
|
--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
|
|
|
--shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
body {
|
|
|
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
line-height: 1.5;
|
|
|
|
|
color: var(--color-text);
|
|
|
|
|
background-color: var(--color-surface);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Custom elements default display */
|
|
|
|
|
swp-calendar,
|
|
|
|
|
swp-calendar-nav,
|
|
|
|
|
swp-calendar-container,
|
|
|
|
|
swp-time-axis,
|
2025-08-07 00:15:44 +02:00
|
|
|
swp-calendar-header,
|
2025-07-24 22:17:38 +02:00
|
|
|
swp-scrollable-content,
|
|
|
|
|
swp-time-grid,
|
|
|
|
|
swp-day-columns,
|
|
|
|
|
swp-day-column,
|
|
|
|
|
swp-events-layer,
|
|
|
|
|
swp-event,
|
|
|
|
|
swp-loading-overlay {
|
|
|
|
|
display: block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Main calendar container */
|
|
|
|
|
swp-calendar {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
height: 100vh;
|
|
|
|
|
background: var(--color-background);
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Navigation bar */
|
|
|
|
|
swp-calendar-nav {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: auto 1fr auto auto;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 20px;
|
|
|
|
|
padding: 12px 16px;
|
|
|
|
|
background: var(--color-background);
|
|
|
|
|
border-bottom: 1px solid var(--color-border);
|
|
|
|
|
box-shadow: var(--shadow-sm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-nav-group {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 4px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-nav-button {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
padding: 8px 16px;
|
|
|
|
|
border: 1px solid var(--color-border);
|
|
|
|
|
background: var(--color-background);
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
font-size: 0.875rem;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
transition: all 150ms ease;
|
|
|
|
|
min-width: 40px;
|
|
|
|
|
height: 36px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-nav-button:hover {
|
|
|
|
|
background: var(--color-surface);
|
|
|
|
|
border-color: var(--color-text-secondary);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Search container */
|
|
|
|
|
swp-search-container {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
position: relative;
|
|
|
|
|
justify-self: end;
|
|
|
|
|
|
|
|
|
|
swp-search-icon {
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: 12px;
|
|
|
|
|
pointer-events: none;
|
|
|
|
|
color: var(--color-text-secondary);
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
svg {
|
|
|
|
|
width: 16px;
|
|
|
|
|
height: 16px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
input[type="search"] {
|
|
|
|
|
padding: 8px 36px 8px 36px;
|
|
|
|
|
border: 1px solid var(--color-border);
|
|
|
|
|
border-radius: 20px;
|
|
|
|
|
background: var(--color-surface);
|
|
|
|
|
font-size: 0.875rem;
|
|
|
|
|
width: 200px;
|
|
|
|
|
transition: all 150ms ease;
|
|
|
|
|
|
|
|
|
|
&::-webkit-search-cancel-button {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&:focus {
|
|
|
|
|
outline: none;
|
|
|
|
|
border-color: var(--color-primary);
|
|
|
|
|
background: var(--color-background);
|
|
|
|
|
width: 250px;
|
|
|
|
|
box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&::placeholder {
|
|
|
|
|
color: var(--color-text-secondary);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-search-clear {
|
|
|
|
|
position: absolute;
|
|
|
|
|
right: 8px;
|
|
|
|
|
width: 24px;
|
|
|
|
|
height: 24px;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
transition: all 150ms ease;
|
|
|
|
|
color: var(--color-text-secondary);
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
background: rgba(0, 0, 0, 0.1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
svg {
|
|
|
|
|
width: 12px;
|
|
|
|
|
height: 12px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&[hidden] {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-view-button {
|
|
|
|
|
padding: 8px 16px;
|
|
|
|
|
border: none;
|
|
|
|
|
background: transparent;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
font-size: 0.875rem;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
transition: all 150ms ease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-view-button:not(:last-child) {
|
|
|
|
|
border-right: 1px solid var(--color-border);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-view-button[data-active="true"] {
|
|
|
|
|
background: var(--color-primary);
|
|
|
|
|
color: white;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Calendar container grid */
|
|
|
|
|
swp-calendar-container {
|
|
|
|
|
flex: 1;
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: 60px 1fr;
|
|
|
|
|
grid-template-rows: 1fr;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Week container for sliding */
|
2025-08-07 00:15:44 +02:00
|
|
|
swp-grid-container {
|
2025-07-24 22:17:38 +02:00
|
|
|
grid-column: 2;
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-rows: auto 1fr;
|
|
|
|
|
position: relative;
|
|
|
|
|
width: 100%;
|
|
|
|
|
transition: transform 400ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-07 00:15:44 +02:00
|
|
|
swp-grid-container.slide-out-left {
|
2025-07-24 22:17:38 +02:00
|
|
|
transform: translateX(-100%);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-07 00:15:44 +02:00
|
|
|
swp-grid-container.slide-out-right {
|
2025-07-24 22:17:38 +02:00
|
|
|
transform: translateX(100%);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-07 00:15:44 +02:00
|
|
|
swp-grid-container.slide-in-left {
|
2025-07-24 22:17:38 +02:00
|
|
|
transform: translateX(-100%);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-07 00:15:44 +02:00
|
|
|
swp-grid-container.slide-in-right {
|
2025-07-24 22:17:38 +02:00
|
|
|
transform: translateX(100%);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Time axis */
|
|
|
|
|
swp-time-axis {
|
|
|
|
|
grid-column: 1;
|
|
|
|
|
grid-row: 1;
|
|
|
|
|
background: var(--color-surface);
|
|
|
|
|
border-right: 1px solid var(--color-border);
|
|
|
|
|
position: sticky;
|
|
|
|
|
left: 0;
|
|
|
|
|
z-index: 4;
|
|
|
|
|
padding-top: 80px; /* Match header height */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-hour-marker {
|
|
|
|
|
height: var(--hour-height);
|
|
|
|
|
padding: 0 8px 8px 8px;
|
|
|
|
|
font-size: 0.75rem;
|
|
|
|
|
color: var(--color-text-secondary);
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: flex-start;
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-hour-marker::after {
|
|
|
|
|
content: '';
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 100%;
|
|
|
|
|
width: 100vw;
|
|
|
|
|
height: 1px;
|
|
|
|
|
background: var(--color-grid-line);
|
|
|
|
|
pointer-events: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Week header */
|
2025-08-07 00:15:44 +02:00
|
|
|
swp-calendar-header {
|
2025-07-24 22:17:38 +02:00
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(7, 1fr);
|
|
|
|
|
background: var(--color-surface);
|
|
|
|
|
border-bottom: 1px solid var(--color-border);
|
|
|
|
|
position: sticky;
|
|
|
|
|
top: 0;
|
|
|
|
|
z-index: 3;
|
|
|
|
|
height: 80px; /* Fixed height */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-day-header {
|
|
|
|
|
padding: 12px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
border-right: 1px solid var(--color-grid-line);
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-day-header:last-child {
|
|
|
|
|
border-right: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-day-name {
|
|
|
|
|
display: block;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
font-size: 0.875rem;
|
|
|
|
|
color: var(--color-text-secondary);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-day-date {
|
|
|
|
|
display: block;
|
|
|
|
|
font-size: 1.25rem;
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
margin-top: 4px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-day-header[data-today="true"] swp-day-date {
|
|
|
|
|
color: var(--color-primary);
|
|
|
|
|
background: rgba(33, 150, 243, 0.1);
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
width: 36px;
|
|
|
|
|
height: 36px;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
margin: 4px auto 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Scrollable content */
|
|
|
|
|
swp-scrollable-content {
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
overflow-x: hidden;
|
|
|
|
|
scroll-behavior: smooth;
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Time grid */
|
|
|
|
|
swp-time-grid {
|
|
|
|
|
position: relative;
|
|
|
|
|
height: calc(12 * var(--hour-height));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-time-grid::before {
|
|
|
|
|
content: '';
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: calc((var(--work-start-hour) - var(--day-start-hour)) * var(--hour-height));
|
|
|
|
|
height: calc((var(--work-end-hour) - var(--work-start-hour)) * var(--hour-height));
|
|
|
|
|
left: 0;
|
|
|
|
|
right: 0;
|
|
|
|
|
background: var(--color-work-hours);
|
|
|
|
|
pointer-events: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Grid lines */
|
|
|
|
|
swp-grid-lines {
|
|
|
|
|
position: absolute;
|
|
|
|
|
inset: 0;
|
|
|
|
|
pointer-events: none;
|
|
|
|
|
background-image: repeating-linear-gradient(
|
|
|
|
|
to bottom,
|
|
|
|
|
transparent,
|
|
|
|
|
transparent calc(var(--hour-height) / 4 - 1px),
|
|
|
|
|
rgba(0, 0, 0, 0.03) calc(var(--hour-height) / 4 - 1px),
|
|
|
|
|
rgba(0, 0, 0, 0.03) calc(var(--hour-height) / 4)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Day columns */
|
|
|
|
|
swp-day-columns {
|
|
|
|
|
position: absolute;
|
|
|
|
|
inset: 0;
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(7, 1fr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-day-column {
|
|
|
|
|
position: relative;
|
|
|
|
|
border-right: 1px solid var(--color-grid-line);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-day-column:last-child {
|
|
|
|
|
border-right: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-events-layer {
|
|
|
|
|
position: absolute;
|
|
|
|
|
inset: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Events */
|
|
|
|
|
swp-event {
|
|
|
|
|
position: absolute;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
cursor: move;
|
|
|
|
|
transition: box-shadow 150ms ease, transform 150ms ease;
|
|
|
|
|
z-index: 10;
|
|
|
|
|
left: 1px;
|
|
|
|
|
right: 1px;
|
|
|
|
|
padding: 8px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-event[data-type="meeting"] {
|
|
|
|
|
background: var(--color-event-meeting);
|
|
|
|
|
border-left: 4px solid var(--color-event-meeting-border);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-event[data-type="meal"] {
|
|
|
|
|
background: var(--color-event-meal);
|
|
|
|
|
border-left: 4px solid var(--color-event-meal-border);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-event[data-type="work"] {
|
|
|
|
|
background: var(--color-event-work);
|
|
|
|
|
border-left: 4px solid var(--color-event-work-border);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-event:hover {
|
|
|
|
|
box-shadow: var(--shadow-md);
|
|
|
|
|
transform: scale(1.02);
|
|
|
|
|
z-index: 20;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-event-time {
|
|
|
|
|
display: block;
|
|
|
|
|
font-size: 0.875rem;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
opacity: 0.8;
|
|
|
|
|
margin-bottom: 4px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-event-title {
|
|
|
|
|
display: block;
|
|
|
|
|
font-size: 0.875rem;
|
|
|
|
|
line-height: 1.3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Loading */
|
|
|
|
|
swp-loading-overlay {
|
|
|
|
|
position: absolute;
|
|
|
|
|
inset: 0;
|
|
|
|
|
background: rgba(255, 255, 255, 0.9);
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
z-index: 200;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-loading-overlay[hidden] {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swp-spinner {
|
|
|
|
|
width: 40px;
|
|
|
|
|
height: 40px;
|
|
|
|
|
border: 3px solid #f3f3f3;
|
|
|
|
|
border-top: 3px solid var(--color-primary);
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
animation: spin 1s linear infinite;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@keyframes spin {
|
|
|
|
|
0% { transform: rotate(0deg); }
|
|
|
|
|
100% { transform: rotate(360deg); }
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<swp-calendar data-view="week" data-week-days="7" data-snap-interval="15">
|
|
|
|
|
<!-- Navigation Bar -->
|
|
|
|
|
<swp-calendar-nav>
|
|
|
|
|
<swp-nav-group>
|
|
|
|
|
<swp-nav-button data-action="prev">←</swp-nav-button>
|
|
|
|
|
<swp-nav-button data-action="next">→</swp-nav-button>
|
|
|
|
|
<swp-nav-button data-action="today">Today</swp-nav-button>
|
|
|
|
|
</swp-nav-group>
|
|
|
|
|
|
|
|
|
|
<swp-week-info>
|
|
|
|
|
<swp-week-number>Week 3</swp-week-number>
|
|
|
|
|
<swp-date-range>Jan 15 - Jan 21, 2024</swp-date-range>
|
|
|
|
|
</swp-week-info>
|
|
|
|
|
|
|
|
|
|
<swp-search-container>
|
|
|
|
|
<swp-search-icon>
|
|
|
|
|
<svg width="16" height="16" viewBox="0 0 16 16">
|
|
|
|
|
<circle cx="6" cy="6" r="5" stroke="currentColor" fill="none" stroke-width="1.5"/>
|
|
|
|
|
<path d="M10 10l4 4" stroke="currentColor" stroke-width="1.5"/>
|
|
|
|
|
</svg>
|
|
|
|
|
</swp-search-icon>
|
|
|
|
|
<input type="search" placeholder="Search events..." />
|
|
|
|
|
<swp-search-clear hidden>
|
|
|
|
|
<svg width="14" height="14" viewBox="0 0 16 16">
|
|
|
|
|
<path d="M5 5l6 6M11 5l-6 6" stroke="currentColor" stroke-width="2"/>
|
|
|
|
|
</svg>
|
|
|
|
|
</swp-search-clear>
|
|
|
|
|
</swp-search-container>
|
|
|
|
|
|
|
|
|
|
<swp-view-selector>
|
|
|
|
|
<swp-view-button data-view="day">Day</swp-view-button>
|
|
|
|
|
<swp-view-button data-view="week" data-active="true">Week</swp-view-button>
|
|
|
|
|
<swp-view-button data-view="month" disabled>Month</swp-view-button>
|
|
|
|
|
</swp-view-selector>
|
|
|
|
|
<swp-view-button data-view="day">Day</swp-view-button>
|
|
|
|
|
<swp-view-button data-view="week" data-active="true">Week</swp-view-button>
|
|
|
|
|
<swp-view-button data-view="month" disabled>Month</swp-view-button>
|
|
|
|
|
</swp-view-selector>
|
|
|
|
|
</swp-calendar-nav>
|
|
|
|
|
|
|
|
|
|
<!-- Calendar Grid -->
|
|
|
|
|
<swp-calendar-container>
|
|
|
|
|
<swp-time-axis></swp-time-axis>
|
|
|
|
|
|
2025-08-07 00:15:44 +02:00
|
|
|
<swp-grid-container>
|
|
|
|
|
<swp-calendar-header></swp-calendar-header>
|
2025-07-24 22:17:38 +02:00
|
|
|
|
|
|
|
|
<swp-scrollable-content>
|
|
|
|
|
<swp-time-grid>
|
|
|
|
|
<swp-grid-lines></swp-grid-lines>
|
|
|
|
|
<swp-day-columns></swp-day-columns>
|
|
|
|
|
</swp-time-grid>
|
|
|
|
|
</swp-scrollable-content>
|
2025-08-07 00:15:44 +02:00
|
|
|
</swp-grid-container>
|
2025-07-24 22:17:38 +02:00
|
|
|
</swp-calendar-container>
|
|
|
|
|
|
|
|
|
|
<swp-loading-overlay hidden>
|
|
|
|
|
<swp-spinner></swp-spinner>
|
|
|
|
|
</swp-loading-overlay>
|
|
|
|
|
</swp-calendar>
|
|
|
|
|
|
|
|
|
|
<script type="module">
|
|
|
|
|
// Simple proof of concept implementation
|
|
|
|
|
class CalendarPOC {
|
|
|
|
|
constructor() {
|
|
|
|
|
this.currentWeek = this.getWeekStart(new Date());
|
|
|
|
|
this.targetWeek = new Date(this.currentWeek); // Track where we're heading
|
|
|
|
|
this.animationQueue = 0; // Track pending animations
|
|
|
|
|
this.init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
init() {
|
|
|
|
|
this.renderTimeAxis();
|
|
|
|
|
this.renderWeekHeaders();
|
|
|
|
|
this.renderDayColumns();
|
|
|
|
|
this.updateWeekInfo();
|
|
|
|
|
this.setupEventListeners();
|
|
|
|
|
this.loadMockEvents();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateWeekInfo() {
|
|
|
|
|
const weekNumber = this.getWeekNumber(this.currentWeek);
|
|
|
|
|
const weekEnd = new Date(this.currentWeek);
|
|
|
|
|
weekEnd.setDate(weekEnd.getDate() + 6);
|
|
|
|
|
|
|
|
|
|
const monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
|
|
|
|
|
|
|
|
const startMonth = monthNames[this.currentWeek.getMonth()];
|
|
|
|
|
const endMonth = monthNames[weekEnd.getMonth()];
|
|
|
|
|
const startDay = this.currentWeek.getDate();
|
|
|
|
|
const endDay = weekEnd.getDate();
|
|
|
|
|
const year = this.currentWeek.getFullYear();
|
|
|
|
|
|
|
|
|
|
let dateRange;
|
|
|
|
|
if (startMonth === endMonth) {
|
|
|
|
|
dateRange = `${startMonth} ${startDay} - ${endDay}, ${year}`;
|
|
|
|
|
} else if (this.currentWeek.getFullYear() !== weekEnd.getFullYear()) {
|
|
|
|
|
dateRange = `${startMonth} ${startDay}, ${this.currentWeek.getFullYear()} - ${endMonth} ${endDay}, ${weekEnd.getFullYear()}`;
|
|
|
|
|
} else {
|
|
|
|
|
dateRange = `${startMonth} ${startDay} - ${endMonth} ${endDay}, ${year}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
document.querySelector('swp-week-number').textContent = `Week ${weekNumber}`;
|
|
|
|
|
document.querySelector('swp-date-range').textContent = dateRange;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getWeekNumber(date) {
|
|
|
|
|
const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
|
|
|
const dayNum = d.getUTCDay() || 7;
|
|
|
|
|
d.setUTCDate(d.getUTCDate() + 4 - dayNum);
|
|
|
|
|
const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
|
|
|
|
|
return Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderTimeAxis() {
|
|
|
|
|
const timeAxis = document.querySelector('swp-time-axis');
|
|
|
|
|
const startHour = 7;
|
|
|
|
|
const endHour = 19;
|
|
|
|
|
|
|
|
|
|
for (let hour = startHour; hour <= endHour; hour++) {
|
|
|
|
|
const marker = document.createElement('swp-hour-marker');
|
|
|
|
|
const period = hour >= 12 ? 'PM' : 'AM';
|
|
|
|
|
const displayHour = hour > 12 ? hour - 12 : (hour === 0 ? 12 : hour);
|
|
|
|
|
marker.textContent = `${displayHour} ${period}`;
|
|
|
|
|
timeAxis.appendChild(marker);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderWeekHeaders() {
|
2025-08-07 00:15:44 +02:00
|
|
|
const weekHeader = document.querySelector('swp-calendar-header');
|
2025-07-24 22:17:38 +02:00
|
|
|
const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
|
|
|
|
|
|
|
|
weekHeader.innerHTML = ''; // Clear any existing content
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < 7; i++) {
|
|
|
|
|
const date = new Date(this.currentWeek);
|
|
|
|
|
date.setDate(date.getDate() + i);
|
|
|
|
|
|
|
|
|
|
const header = document.createElement('swp-day-header');
|
|
|
|
|
if (this.isToday(date)) {
|
|
|
|
|
header.dataset.today = 'true';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
header.innerHTML = `
|
|
|
|
|
<swp-day-name>${days[date.getDay()]}</swp-day-name>
|
|
|
|
|
<swp-day-date>${date.getDate()}</swp-day-date>
|
|
|
|
|
`;
|
|
|
|
|
header.dataset.date = this.formatDate(date);
|
|
|
|
|
|
|
|
|
|
weekHeader.appendChild(header);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderDayColumns() {
|
|
|
|
|
const dayColumns = document.querySelector('swp-day-columns');
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < 7; i++) {
|
|
|
|
|
const column = document.createElement('swp-day-column');
|
|
|
|
|
const date = new Date(this.currentWeek);
|
|
|
|
|
date.setDate(date.getDate() + i);
|
|
|
|
|
column.dataset.date = this.formatDate(date);
|
|
|
|
|
|
|
|
|
|
const eventsLayer = document.createElement('swp-events-layer');
|
|
|
|
|
column.appendChild(eventsLayer);
|
|
|
|
|
|
|
|
|
|
dayColumns.appendChild(column);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadMockEvents() {
|
|
|
|
|
const events = [
|
|
|
|
|
{
|
|
|
|
|
title: 'Team Standup',
|
|
|
|
|
type: 'meeting',
|
|
|
|
|
day: 1,
|
|
|
|
|
startTime: '09:00',
|
|
|
|
|
duration: 30
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Client Meeting',
|
|
|
|
|
type: 'meeting',
|
|
|
|
|
day: 1,
|
|
|
|
|
startTime: '14:00',
|
|
|
|
|
duration: 90
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Lunch',
|
|
|
|
|
type: 'meal',
|
|
|
|
|
day: 1,
|
|
|
|
|
startTime: '12:00',
|
|
|
|
|
duration: 60
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Deep Work Session',
|
|
|
|
|
type: 'work',
|
|
|
|
|
day: 2,
|
|
|
|
|
startTime: '10:00',
|
|
|
|
|
duration: 120
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Team Standup',
|
|
|
|
|
type: 'meeting',
|
|
|
|
|
day: 2,
|
|
|
|
|
startTime: '09:00',
|
|
|
|
|
duration: 30
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Lunch',
|
|
|
|
|
type: 'meal',
|
|
|
|
|
day: 2,
|
|
|
|
|
startTime: '12:30',
|
|
|
|
|
duration: 60
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Project Review',
|
|
|
|
|
type: 'meeting',
|
|
|
|
|
day: 3,
|
|
|
|
|
startTime: '15:00',
|
|
|
|
|
duration: 60
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Lunch',
|
|
|
|
|
type: 'meal',
|
|
|
|
|
day: 3,
|
|
|
|
|
startTime: '12:00',
|
|
|
|
|
duration: 60
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Sprint Planning',
|
|
|
|
|
type: 'meeting',
|
|
|
|
|
day: 4,
|
|
|
|
|
startTime: '10:00',
|
|
|
|
|
duration: 120
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Coffee Break',
|
|
|
|
|
type: 'meal',
|
|
|
|
|
day: 4,
|
|
|
|
|
startTime: '15:00',
|
|
|
|
|
duration: 30
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Documentation',
|
|
|
|
|
type: 'work',
|
|
|
|
|
day: 5,
|
|
|
|
|
startTime: '13:00',
|
|
|
|
|
duration: 180
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
events.forEach(event => {
|
|
|
|
|
this.renderEvent(event);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderEvent(eventData) {
|
|
|
|
|
const column = document.querySelectorAll('swp-day-column')[eventData.day];
|
|
|
|
|
if (!column) return;
|
|
|
|
|
|
|
|
|
|
const eventsLayer = column.querySelector('swp-events-layer');
|
|
|
|
|
const event = document.createElement('swp-event');
|
|
|
|
|
event.dataset.type = eventData.type;
|
|
|
|
|
|
|
|
|
|
// Calculate position
|
|
|
|
|
const [hours, minutes] = eventData.startTime.split(':').map(Number);
|
|
|
|
|
const startMinutes = (hours - 7) * 60 + minutes; // 7 is start hour
|
|
|
|
|
|
|
|
|
|
event.style.setProperty('--start-minutes', startMinutes);
|
|
|
|
|
event.style.setProperty('--duration-minutes', eventData.duration);
|
|
|
|
|
event.style.top = `${startMinutes}px`;
|
|
|
|
|
event.style.height = `${eventData.duration}px`;
|
|
|
|
|
|
|
|
|
|
event.innerHTML = `
|
|
|
|
|
<swp-event-time>${this.formatTime(hours, minutes)}</swp-event-time>
|
|
|
|
|
<swp-event-title>${eventData.title}</swp-event-title>
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
eventsLayer.appendChild(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setupEventListeners() {
|
|
|
|
|
// Navigation buttons
|
|
|
|
|
document.querySelector('[data-action="prev"]').addEventListener('click', () => {
|
|
|
|
|
// Calculate from targetWeek, not currentWeek
|
|
|
|
|
this.targetWeek.setDate(this.targetWeek.getDate() - 7);
|
|
|
|
|
const weekToShow = new Date(this.targetWeek);
|
|
|
|
|
this.animationQueue++;
|
|
|
|
|
this.animateTransition('prev', weekToShow);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
document.querySelector('[data-action="next"]').addEventListener('click', () => {
|
|
|
|
|
// Calculate from targetWeek, not currentWeek
|
|
|
|
|
this.targetWeek.setDate(this.targetWeek.getDate() + 7);
|
|
|
|
|
const weekToShow = new Date(this.targetWeek);
|
|
|
|
|
this.animationQueue++;
|
|
|
|
|
this.animateTransition('next', weekToShow);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
document.querySelector('[data-action="today"]').addEventListener('click', () => {
|
|
|
|
|
const today = new Date();
|
|
|
|
|
const todayWeekStart = this.getWeekStart(today);
|
|
|
|
|
|
|
|
|
|
// Reset to today
|
|
|
|
|
this.targetWeek = new Date(todayWeekStart);
|
|
|
|
|
|
|
|
|
|
const currentTime = this.currentWeek.getTime();
|
|
|
|
|
const targetTime = todayWeekStart.getTime();
|
|
|
|
|
|
|
|
|
|
if (currentTime < targetTime) {
|
|
|
|
|
this.animationQueue++;
|
|
|
|
|
this.animateTransition('next', todayWeekStart);
|
|
|
|
|
} else if (currentTime > targetTime) {
|
|
|
|
|
this.animationQueue++;
|
|
|
|
|
this.animateTransition('prev', todayWeekStart);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Simple drag functionality
|
|
|
|
|
let draggedEvent = null;
|
|
|
|
|
|
|
|
|
|
document.addEventListener('mousedown', (e) => {
|
|
|
|
|
const event = e.target.closest('swp-event');
|
|
|
|
|
if (event) {
|
|
|
|
|
draggedEvent = event;
|
|
|
|
|
event.style.opacity = '0.5';
|
|
|
|
|
event.style.cursor = 'grabbing';
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
document.addEventListener('mouseup', () => {
|
|
|
|
|
if (draggedEvent) {
|
|
|
|
|
draggedEvent.style.opacity = '1';
|
|
|
|
|
draggedEvent.style.cursor = 'move';
|
|
|
|
|
draggedEvent = null;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
animateTransition(direction, targetWeek) {
|
|
|
|
|
const container = document.querySelector('swp-calendar-container');
|
2025-08-07 00:15:44 +02:00
|
|
|
const currentWeek = document.querySelector('swp-grid-container');
|
2025-07-24 22:17:38 +02:00
|
|
|
|
|
|
|
|
// Create new week container
|
2025-08-07 00:15:44 +02:00
|
|
|
const newWeek = document.createElement('swp-grid-container');
|
2025-07-24 22:17:38 +02:00
|
|
|
newWeek.innerHTML = `
|
2025-08-07 00:15:44 +02:00
|
|
|
<swp-calendar-header></swp-calendar-header>
|
2025-07-24 22:17:38 +02:00
|
|
|
<swp-scrollable-content>
|
|
|
|
|
<swp-time-grid>
|
|
|
|
|
<swp-grid-lines></swp-grid-lines>
|
|
|
|
|
<swp-day-columns></swp-day-columns>
|
|
|
|
|
</swp-time-grid>
|
|
|
|
|
</swp-scrollable-content>
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
// Position new week off-screen
|
|
|
|
|
newWeek.style.position = 'absolute';
|
|
|
|
|
newWeek.style.top = '0';
|
|
|
|
|
newWeek.style.left = '0';
|
|
|
|
|
newWeek.style.width = '100%';
|
|
|
|
|
newWeek.style.height = '100%';
|
|
|
|
|
newWeek.style.transform = direction === 'next' ? 'translateX(100%)' : 'translateX(-100%)';
|
|
|
|
|
|
|
|
|
|
// Add to container
|
|
|
|
|
container.appendChild(newWeek);
|
|
|
|
|
|
|
|
|
|
// Render new content in the new container using targetWeek
|
2025-08-07 00:15:44 +02:00
|
|
|
const tempHeader = newWeek.querySelector('swp-calendar-header');
|
2025-07-24 22:17:38 +02:00
|
|
|
const tempColumns = newWeek.querySelector('swp-day-columns');
|
|
|
|
|
|
|
|
|
|
// Clear any existing content
|
|
|
|
|
tempHeader.innerHTML = '';
|
|
|
|
|
tempColumns.innerHTML = '';
|
|
|
|
|
|
|
|
|
|
// Render headers for target week
|
|
|
|
|
for (let i = 0; i < 7; i++) {
|
|
|
|
|
const date = new Date(targetWeek);
|
|
|
|
|
date.setDate(date.getDate() + i);
|
|
|
|
|
|
|
|
|
|
const header = document.createElement('swp-day-header');
|
|
|
|
|
if (this.isToday(date)) {
|
|
|
|
|
header.dataset.today = 'true';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
header.innerHTML = `
|
|
|
|
|
<swp-day-name>${['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][date.getDay()]}</swp-day-name>
|
|
|
|
|
<swp-day-date>${date.getDate()}</swp-day-date>
|
|
|
|
|
`;
|
|
|
|
|
header.dataset.date = this.formatDate(date);
|
|
|
|
|
|
|
|
|
|
tempHeader.appendChild(header);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Render columns for target week
|
|
|
|
|
for (let i = 0; i < 7; i++) {
|
|
|
|
|
const column = document.createElement('swp-day-column');
|
|
|
|
|
const date = new Date(targetWeek);
|
|
|
|
|
date.setDate(date.getDate() + i);
|
|
|
|
|
column.dataset.date = this.formatDate(date);
|
|
|
|
|
|
|
|
|
|
const eventsLayer = document.createElement('swp-events-layer');
|
|
|
|
|
column.appendChild(eventsLayer);
|
|
|
|
|
|
|
|
|
|
tempColumns.appendChild(column);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Load events into new container
|
|
|
|
|
this.loadMockEventsIntoContainer(newWeek);
|
|
|
|
|
|
|
|
|
|
// Animate transition
|
|
|
|
|
requestAnimationFrame(() => {
|
|
|
|
|
// Slide out current week
|
|
|
|
|
currentWeek.style.transform = direction === 'next' ? 'translateX(-100%)' : 'translateX(100%)';
|
|
|
|
|
currentWeek.style.opacity = '0.5';
|
|
|
|
|
|
|
|
|
|
// Slide in new week
|
|
|
|
|
newWeek.style.transform = 'translateX(0)';
|
|
|
|
|
|
|
|
|
|
// Clean up after animation
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
currentWeek.remove();
|
|
|
|
|
newWeek.style.position = 'relative';
|
|
|
|
|
// Update currentWeek only after animation is complete
|
|
|
|
|
this.currentWeek = new Date(targetWeek);
|
|
|
|
|
this.animationQueue--;
|
|
|
|
|
|
|
|
|
|
// If this was the last queued animation, ensure we're in sync
|
|
|
|
|
if (this.animationQueue === 0) {
|
|
|
|
|
this.currentWeek = new Date(this.targetWeek);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update week info
|
|
|
|
|
this.updateWeekInfo();
|
|
|
|
|
}, 400);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadMockEventsIntoContainer(container) {
|
|
|
|
|
const events = [
|
|
|
|
|
{
|
|
|
|
|
title: 'Team Standup',
|
|
|
|
|
type: 'meeting',
|
|
|
|
|
day: 1,
|
|
|
|
|
startTime: '09:00',
|
|
|
|
|
duration: 30
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Client Meeting',
|
|
|
|
|
type: 'meeting',
|
|
|
|
|
day: 1,
|
|
|
|
|
startTime: '14:00',
|
|
|
|
|
duration: 90
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Lunch',
|
|
|
|
|
type: 'meal',
|
|
|
|
|
day: 1,
|
|
|
|
|
startTime: '12:00',
|
|
|
|
|
duration: 60
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Deep Work Session',
|
|
|
|
|
type: 'work',
|
|
|
|
|
day: 2,
|
|
|
|
|
startTime: '10:00',
|
|
|
|
|
duration: 120
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Team Standup',
|
|
|
|
|
type: 'meeting',
|
|
|
|
|
day: 2,
|
|
|
|
|
startTime: '09:00',
|
|
|
|
|
duration: 30
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Lunch',
|
|
|
|
|
type: 'meal',
|
|
|
|
|
day: 2,
|
|
|
|
|
startTime: '12:30',
|
|
|
|
|
duration: 60
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Project Review',
|
|
|
|
|
type: 'meeting',
|
|
|
|
|
day: 3,
|
|
|
|
|
startTime: '15:00',
|
|
|
|
|
duration: 60
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Lunch',
|
|
|
|
|
type: 'meal',
|
|
|
|
|
day: 3,
|
|
|
|
|
startTime: '12:00',
|
|
|
|
|
duration: 60
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Sprint Planning',
|
|
|
|
|
type: 'meeting',
|
|
|
|
|
day: 4,
|
|
|
|
|
startTime: '10:00',
|
|
|
|
|
duration: 120
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Coffee Break',
|
|
|
|
|
type: 'meal',
|
|
|
|
|
day: 4,
|
|
|
|
|
startTime: '15:00',
|
|
|
|
|
duration: 30
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Documentation',
|
|
|
|
|
type: 'work',
|
|
|
|
|
day: 5,
|
|
|
|
|
startTime: '13:00',
|
|
|
|
|
duration: 180
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const columns = container.querySelectorAll('swp-day-column');
|
|
|
|
|
events.forEach(event => {
|
|
|
|
|
this.renderEventInColumn(event, columns[event.day]);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderEventInColumn(eventData, column) {
|
|
|
|
|
if (!column) return;
|
|
|
|
|
|
|
|
|
|
const eventsLayer = column.querySelector('swp-events-layer');
|
|
|
|
|
const event = document.createElement('swp-event');
|
|
|
|
|
event.dataset.type = eventData.type;
|
|
|
|
|
|
|
|
|
|
// Calculate position
|
|
|
|
|
const [hours, minutes] = eventData.startTime.split(':').map(Number);
|
|
|
|
|
const startMinutes = (hours - 7) * 60 + minutes; // 7 is start hour
|
|
|
|
|
|
|
|
|
|
event.style.setProperty('--start-minutes', startMinutes);
|
|
|
|
|
event.style.setProperty('--duration-minutes', eventData.duration);
|
|
|
|
|
event.style.top = `${startMinutes}px`;
|
|
|
|
|
event.style.height = `${eventData.duration}px`;
|
|
|
|
|
|
|
|
|
|
event.innerHTML = `
|
|
|
|
|
<swp-event-time>${this.formatTime(hours, minutes)}</swp-event-time>
|
|
|
|
|
<swp-event-title>${eventData.title}</swp-event-title>
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
eventsLayer.appendChild(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateCalendar() {
|
|
|
|
|
// This method is now only used for initial render
|
2025-08-07 00:15:44 +02:00
|
|
|
document.querySelector('swp-calendar-header').innerHTML = '';
|
2025-07-24 22:17:38 +02:00
|
|
|
document.querySelector('swp-day-columns').innerHTML = '';
|
|
|
|
|
this.renderWeekHeaders();
|
|
|
|
|
this.renderDayColumns();
|
|
|
|
|
this.loadMockEvents();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Utility functions
|
|
|
|
|
getWeekStart(date) {
|
|
|
|
|
const d = new Date(date);
|
|
|
|
|
const day = d.getDay();
|
|
|
|
|
d.setDate(d.getDate() - day);
|
|
|
|
|
d.setHours(0, 0, 0, 0);
|
|
|
|
|
return d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
formatDate(date) {
|
|
|
|
|
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
formatTime(hours, minutes) {
|
|
|
|
|
const period = hours >= 12 ? 'PM' : 'AM';
|
|
|
|
|
const displayHours = hours % 12 || 12;
|
|
|
|
|
return `${displayHours}:${String(minutes).padStart(2, '0')} ${period}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isToday(date) {
|
|
|
|
|
const today = new Date();
|
|
|
|
|
return date.toDateString() === today.toDateString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Initialize calendar
|
|
|
|
|
const calendar = new CalendarPOC();
|
|
|
|
|
</script>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|