class TimelineSidebar extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.render(); this.setupEventListeners(); } render() { this.shadowRoot.innerHTML = `

Timeline

${Array.from({ length: 24 }, (_, i) => `
${i.toString().padStart(2, '0')}:00
`).join('')}
`; } setupEventListeners() { const toggleBtn = this.shadowRoot.querySelector('.toggle-btn'); toggleBtn.addEventListener('click', () => { this.classList.toggle('open'); const icon = toggleBtn.querySelector('svg'); if (this.classList.contains('open')) { icon.innerHTML = ''; } else { icon.innerHTML = ''; } }); // Setup drag and drop this.shadowRoot.addEventListener('dragover', (e) => { if (e.target.classList.contains('task-drop-area')) { e.preventDefault(); e.target.style.backgroundColor = '#37415170'; } }); this.shadowRoot.addEventListener('dragleave', (e) => { if (e.target.classList.contains('task-drop-area')) { e.target.style.backgroundColor = ''; } }); this.shadowRoot.addEventListener('drop', (e) => { if (e.target.classList.contains('task-drop-area')) { e.preventDefault(); e.target.style.backgroundColor = ''; const taskId = e.dataTransfer.getData('text/plain'); const hour = parseInt(e.target.dataset.hour); this.dispatchEvent(new CustomEvent('task-dropped', { detail: { taskId, hour } })); } }); } } customElements.define('timeline-sidebar', TimelineSidebar);