Skip to content

Commit ad223bc

Browse files
committed
feat: enhance timeline display with dynamic height and grid lines
1 parent c2412c7 commit ad223bc

File tree

3 files changed

+51
-33
lines changed

3 files changed

+51
-33
lines changed

src/managers/navigation-manager.js

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,9 @@ export class NavigationManager {
687687
this.createTimelineSession(session, date, timelineTrack, allSessions);
688688
});
689689

690+
// Calculate and set timeline height after all sessions are added
691+
this.updateTimelineHeight(timelineTrack, allSessions.length);
692+
690693
// Initialize timeline interactions
691694
this.initializeTimelineInteractions();
692695

@@ -843,6 +846,41 @@ export class NavigationManager {
843846
return TimeUtils.formatTime(seconds);
844847
}
845848

849+
updateTimelineHeight(timelineTrack, totalSessions) {
850+
const rowHeight = 20; // 15px session height + 5px spacing
851+
const baseHeight = 25; // Base padding
852+
const minHeight = 60; // Minimum height even with no sessions
853+
const requiredHeight = Math.max(minHeight, baseHeight + (totalSessions * rowHeight));
854+
855+
timelineTrack.style.height = `${requiredHeight}px`;
856+
857+
// Add vertical grid lines
858+
this.addTimelineGridLines(timelineTrack);
859+
}
860+
861+
addTimelineGridLines(timelineTrack) {
862+
// Remove existing grid lines
863+
const existingLines = timelineTrack.querySelectorAll('.timeline-grid-line');
864+
existingLines.forEach(line => line.remove());
865+
866+
// Add grid lines for major hours: 0, 4, 8, 12, 16, 20
867+
const majorHours = [0, 4, 8, 12, 16, 20];
868+
const timelineStartHour = 0;
869+
const timelineRangeHours = 24;
870+
871+
majorHours.forEach(hour => {
872+
const line = document.createElement('div');
873+
line.className = 'timeline-grid-line';
874+
875+
// Calculate position percentage
876+
const hoursFromStart = hour - timelineStartHour;
877+
const percentage = (hoursFromStart / timelineRangeHours) * 100;
878+
line.style.left = `${percentage}%`;
879+
880+
timelineTrack.appendChild(line);
881+
});
882+
}
883+
846884
setupTimelineHours(timelineHours) {
847885
timelineHours.innerHTML = '';
848886

@@ -936,18 +974,6 @@ export class NavigationManager {
936974
sessionElement.classList.add('session-stacked');
937975
}
938976

939-
// Calculate required height for all sessions
940-
const totalSessions = allSessions.length;
941-
const rowHeight = 20; // 15px session height + 5px spacing
942-
const baseHeight = 20; // Base padding
943-
const requiredHeight = baseHeight + (totalSessions * rowHeight);
944-
945-
// Update timeline track height
946-
const currentHeight = parseInt(timelineTrack.style.height) || 50;
947-
if (requiredHeight > currentHeight) {
948-
timelineTrack.style.height = `${requiredHeight}px`;
949-
}
950-
951977
timelineTrack.appendChild(sessionElement);
952978
}
953979

@@ -1045,7 +1071,6 @@ export class NavigationManager {
10451071

10461072
contextMenu.innerHTML = `
10471073
<div class="context-menu-item edit-item">${isHistorical ? 'Convert to Manual & Edit' : 'Edit Session'}</div>
1048-
<div class="context-menu-item duplicate-item">Duplicate</div>
10491074
${isHistorical ? '' : '<div class="context-menu-item danger delete-item">Delete</div>'}
10501075
`;
10511076

@@ -1084,7 +1109,7 @@ export class NavigationManager {
10841109
const deleteItem = contextMenu.querySelector('.delete-item');
10851110
if (deleteItem) {
10861111
deleteItem.addEventListener('click', () => {
1087-
if (window.sessionManager && confirm('Are you sure you want to delete this session?')) {
1112+
if (window.sessionManager) {
10881113
window.sessionManager.currentEditingSession = session;
10891114
window.sessionManager.selectedDate = date;
10901115
window.sessionManager.deleteCurrentSession();
@@ -1093,12 +1118,6 @@ export class NavigationManager {
10931118
});
10941119
}
10951120

1096-
contextMenu.querySelector('.duplicate-item').addEventListener('click', () => {
1097-
// TODO: Implement session duplication
1098-
console.log('Duplicate session:', session);
1099-
contextMenu.remove();
1100-
});
1101-
11021121
document.body.appendChild(contextMenu);
11031122
}
11041123

src/managers/session-manager.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,6 @@ export class SessionManager {
308308
async deleteCurrentSession() {
309309
if (!this.currentEditingSession) return;
310310

311-
if (!confirm('Are you sure you want to delete this session?')) return;
312-
313311
try {
314312
const dateString = this.selectedDate.toDateString();
315313

src/styles/timeline.css

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,7 @@
3232
}
3333

3434
.timeline-hour::after {
35-
content: '';
36-
position: absolute;
37-
top: 12px;
38-
left: 50%;
39-
transform: translateX(-50%);
40-
width: 1px;
41-
height: calc(100vh - 200px);
42-
max-height: 500px;
43-
background: #e5e7eb;
44-
z-index: 1;
35+
display: none;
4536
}
4637

4738
.timeline-track {
@@ -55,6 +46,16 @@
5546
transition: height 0.3s ease;
5647
}
5748

49+
.timeline-grid-line {
50+
position: absolute;
51+
top: 0;
52+
bottom: 0;
53+
width: 1px;
54+
background: #e5e7eb;
55+
z-index: 1;
56+
pointer-events: none;
57+
}
58+
5859
.timeline-session {
5960
position: absolute;
6061
height: 15px;
@@ -70,7 +71,7 @@
7071
user-select: none;
7172
transition: all 0.2s ease;
7273
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
73-
z-index: 5;
74+
z-index: 10;
7475
}
7576

7677
.timeline-session-content {

0 commit comments

Comments
 (0)