Skip to content

Commit 632ce37

Browse files
committed
feat: add session header styles and button for adding new sessions
1 parent 7de932d commit 632ce37

File tree

2 files changed

+146
-0
lines changed

2 files changed

+146
-0
lines changed

src/managers/navigation-manager.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,16 +1045,28 @@ export class NavigationManager {
10451045

10461046
const offsetX = e.clientX - sessionRect.left;
10471047

1048+
// Create drag time tooltip
1049+
const dragTooltip = this.createDragTimeTooltip();
1050+
document.body.appendChild(dragTooltip);
1051+
10481052
const handleMouseMove = (e) => {
10491053
const x = e.clientX - timelineRect.left - offsetX;
10501054
const percentage = Math.max(0, Math.min(100, (x / timelineRect.width) * 100));
10511055
sessionElement.style.left = `${percentage}%`;
1056+
1057+
// Update tooltip with current time
1058+
this.updateDragTooltip(dragTooltip, e, percentage, session);
10521059
};
10531060

10541061
const handleMouseUp = () => {
10551062
sessionElement.classList.remove('dragging');
10561063
document.removeEventListener('mousemove', handleMouseMove);
10571064
document.removeEventListener('mouseup', handleMouseUp);
1065+
1066+
// Remove tooltip
1067+
if (dragTooltip && dragTooltip.parentNode) {
1068+
dragTooltip.parentNode.removeChild(dragTooltip);
1069+
}
10581070

10591071
// Update session time based on new position
10601072
this.updateSessionTimeFromPosition(sessionElement, session);
@@ -1071,6 +1083,10 @@ export class NavigationManager {
10711083
const timeline = document.getElementById('timeline-track');
10721084
const timelineRect = timeline.getBoundingClientRect();
10731085

1086+
// Create resize time tooltip
1087+
const resizeTooltip = this.createDragTimeTooltip();
1088+
document.body.appendChild(resizeTooltip);
1089+
10741090
const handleMouseMove = (e) => {
10751091
const x = e.clientX - timelineRect.left;
10761092
const percentage = Math.max(0, Math.min(100, (x / timelineRect.width) * 100));
@@ -1088,12 +1104,20 @@ export class NavigationManager {
10881104
const newWidth = Math.max(2, percentage - currentLeft); // Minimum 2% width
10891105
sessionElement.style.width = `${newWidth}%`;
10901106
}
1107+
1108+
// Update tooltip with current time range
1109+
this.updateResizeTooltip(resizeTooltip, e, sessionElement);
10911110
};
10921111

10931112
const handleMouseUp = () => {
10941113
sessionElement.classList.remove('resizing');
10951114
document.removeEventListener('mousemove', handleMouseMove);
10961115
document.removeEventListener('mouseup', handleMouseUp);
1116+
1117+
// Remove tooltip
1118+
if (resizeTooltip && resizeTooltip.parentNode) {
1119+
resizeTooltip.parentNode.removeChild(resizeTooltip);
1120+
}
10971121

10981122
// Update session time based on new size and position
10991123
this.updateSessionTimeFromPosition(sessionElement, session);
@@ -1263,6 +1287,82 @@ export class NavigationManager {
12631287
this.currentTooltip = null;
12641288
}
12651289

1290+
createDragTimeTooltip() {
1291+
const tooltip = document.createElement('div');
1292+
tooltip.className = 'drag-time-tooltip';
1293+
tooltip.style.cssText = `
1294+
position: fixed;
1295+
background: var(--shared-text);
1296+
color: var(--card-bg);
1297+
padding: 8px 12px;
1298+
border-radius: 6px;
1299+
font-size: 0.85rem;
1300+
font-weight: 600;
1301+
white-space: nowrap;
1302+
z-index: 10000;
1303+
pointer-events: none;
1304+
box-shadow: 0 4px 12px var(--shared-border);
1305+
opacity: 0;
1306+
transition: opacity 0.2s ease;
1307+
`;
1308+
return tooltip;
1309+
}
1310+
1311+
updateDragTooltip(tooltip, mouseEvent, percentage, session) {
1312+
// Calculate time from percentage
1313+
const timelineStartMinutes = 6 * 60; // 6 AM
1314+
const timelineRangeMinutes = 16 * 60; // 16 hours (6 AM to 10 PM)
1315+
const widthPercent = parseFloat(session.duration) / timelineRangeMinutes * 100;
1316+
1317+
const startMinutes = timelineStartMinutes + (percentage / 100) * timelineRangeMinutes;
1318+
const endMinutes = startMinutes + (session.duration || 25); // Default 25 min if no duration
1319+
1320+
const startHour = Math.floor(startMinutes / 60);
1321+
const startMin = Math.round(startMinutes % 60);
1322+
const endHour = Math.floor(endMinutes / 60);
1323+
const endMin = Math.round(endMinutes % 60);
1324+
1325+
const startTime = `${startHour.toString().padStart(2, '0')}:${startMin.toString().padStart(2, '0')}`;
1326+
const endTime = `${endHour.toString().padStart(2, '0')}:${endMin.toString().padStart(2, '0')}`;
1327+
1328+
tooltip.textContent = `${startTime} - ${endTime}`;
1329+
1330+
// Position tooltip near mouse
1331+
tooltip.style.left = `${mouseEvent.clientX + 15}px`;
1332+
tooltip.style.top = `${mouseEvent.clientY - 35}px`;
1333+
tooltip.style.opacity = '1';
1334+
}
1335+
1336+
updateResizeTooltip(tooltip, mouseEvent, sessionElement) {
1337+
const leftPercent = parseFloat(sessionElement.style.left);
1338+
const widthPercent = parseFloat(sessionElement.style.width);
1339+
const rightPercent = leftPercent + widthPercent;
1340+
1341+
// Convert percentages to time (6 AM to 10 PM range)
1342+
const timelineStartMinutes = 6 * 60; // 6 AM
1343+
const timelineRangeMinutes = 16 * 60; // 16 hours
1344+
1345+
const startMinutes = timelineStartMinutes + (leftPercent / 100) * timelineRangeMinutes;
1346+
const endMinutes = timelineStartMinutes + (rightPercent / 100) * timelineRangeMinutes;
1347+
const durationMinutes = endMinutes - startMinutes;
1348+
1349+
const startHour = Math.floor(startMinutes / 60);
1350+
const startMin = Math.round(startMinutes % 60);
1351+
const endHour = Math.floor(endMinutes / 60);
1352+
const endMin = Math.round(endMinutes % 60);
1353+
1354+
const startTime = `${startHour.toString().padStart(2, '0')}:${startMin.toString().padStart(2, '0')}`;
1355+
const endTime = `${endHour.toString().padStart(2, '0')}:${endMin.toString().padStart(2, '0')}`;
1356+
const duration = `${Math.round(durationMinutes)}min`;
1357+
1358+
tooltip.textContent = `${startTime} - ${endTime} (${duration})`;
1359+
1360+
// Position tooltip near mouse
1361+
tooltip.style.left = `${mouseEvent.clientX + 15}px`;
1362+
tooltip.style.top = `${mouseEvent.clientY - 35}px`;
1363+
tooltip.style.opacity = '1';
1364+
}
1365+
12661366
calculateSessionOffset(session, allSessions) {
12671367
if (!allSessions || allSessions.length <= 1) return 0;
12681368

src/styles/calendar.css

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,4 +572,50 @@
572572
font-weight: 600;
573573
}
574574

575+
/* Sessions Header Styles */
576+
.sessions-header {
577+
display: flex;
578+
align-items: center;
579+
justify-content: space-between;
580+
margin-bottom: 0.75rem;
581+
}
582+
583+
.sessions-header h4 {
584+
margin: 0;
585+
color: var(--accent-color);
586+
font-size: 0.95rem;
587+
font-weight: 600;
588+
}
589+
590+
.add-session-btn {
591+
width: 32px;
592+
height: 32px;
593+
border: none;
594+
border-radius: 50%;
595+
background: var(--accent-color);
596+
color: var(--text-on-focus);
597+
cursor: pointer;
598+
display: flex;
599+
align-items: center;
600+
justify-content: center;
601+
transition: all 0.3s ease;
602+
box-shadow: 0 2px 4px var(--shared-border);
603+
}
604+
605+
.add-session-btn:hover {
606+
background: var(--focus-timer-color);
607+
transform: scale(1.1);
608+
box-shadow: 0 4px 8px var(--shared-border);
609+
}
610+
611+
.add-session-btn:active {
612+
transform: scale(0.95);
613+
}
614+
615+
.add-session-btn svg {
616+
width: 16px;
617+
height: 16px;
618+
stroke-width: 2.5;
619+
}
620+
575621
/* Theme support is now handled through CSS variables in individual theme files */

0 commit comments

Comments
 (0)