Skip to content

Commit 476caed

Browse files
committed
feat: add tooltip on hover for collapsed sidebar nav items
1 parent 1effce8 commit 476caed

2 files changed

Lines changed: 79 additions & 8 deletions

File tree

public/css/style.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,27 @@ cap-widget {
563563
margin-left: 60px;
564564
}
565565

566+
.sidebar-tooltip {
567+
position: fixed;
568+
z-index: 10000;
569+
background: var(--bg-card);
570+
color: var(--text-primary);
571+
padding: 6px 12px;
572+
border-radius: var(--radius-sm);
573+
font-size: 0.85rem;
574+
white-space: nowrap;
575+
pointer-events: none;
576+
opacity: 0;
577+
transform: translateY(-50%);
578+
transition: opacity 0.15s ease;
579+
box-shadow: 0 4px 12px rgba(0,0,0,0.4);
580+
border: 1px solid var(--border);
581+
}
582+
583+
.sidebar-tooltip.visible {
584+
opacity: 1;
585+
}
586+
566587
.main-content {
567588
position: relative;
568589
z-index: 1;

public/js/app.js

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ async function renderDashboard() {
469469
${window.location.hostname === 'beta.zero-host.org' ? 'Switch to Stable' : 'Switch to Beta'}
470470
</a>
471471
</nav>
472+
<div class="sidebar-tooltip" id="sidebar-tooltip"></div>
472473
<div class="sidebar-footer">
473474
<div class="user-info" id="sidebar-user-info" style="display:flex;align-items:center;justify-content:space-between;padding:8px 12px;cursor:pointer">
474475
<div style="display:flex;align-items:center;gap:10px">
@@ -544,10 +545,59 @@ async function renderDashboard() {
544545

545546
initSidebarResize();
546547

548+
initSidebarTooltip();
549+
547550
const page = window.location.pathname.replace('/', '') || 'overview';
548551
navigateTo(page);
549552
}
550553

554+
function initSidebarTooltip() {
555+
const sidebar = $('#sidebar');
556+
const sidebarNav = document.querySelector('.sidebar-nav');
557+
const tooltip = document.getElementById('sidebar-tooltip');
558+
let tooltipTimer = null;
559+
let tooltipQuickMode = false;
560+
561+
function showTooltipForItem(item) {
562+
const text = item.textContent.trim();
563+
if (!text) return;
564+
tooltip.textContent = text;
565+
const rect = item.getBoundingClientRect();
566+
tooltip.style.top = (rect.top + rect.height / 2) + 'px';
567+
tooltip.style.left = (rect.right + 10) + 'px';
568+
tooltip.classList.add('visible');
569+
}
570+
571+
function hideTooltip() {
572+
tooltip.classList.remove('visible');
573+
clearTimeout(tooltipTimer);
574+
tooltipQuickMode = false;
575+
}
576+
577+
sidebarNav.addEventListener('mouseover', (e) => {
578+
const item = e.target.closest('.nav-item');
579+
if (!item) return;
580+
if (!sidebar.classList.contains('collapsed')) return;
581+
582+
clearTimeout(tooltipTimer);
583+
584+
if (tooltipQuickMode) {
585+
showTooltipForItem(item);
586+
} else {
587+
tooltipTimer = setTimeout(() => {
588+
showTooltipForItem(item);
589+
tooltipQuickMode = true;
590+
}, 5000);
591+
}
592+
});
593+
594+
sidebarNav.addEventListener('mouseleave', () => {
595+
if (tooltip.classList.contains('visible') || tooltipTimer) {
596+
hideTooltip();
597+
}
598+
});
599+
}
600+
551601
function navigateTo(page) {
552602
if (pteroTimeout) clearTimeout(pteroTimeout);
553603
document.querySelectorAll('.page').forEach(p => p.classList.remove('active'));
@@ -1315,27 +1365,27 @@ function renderAccount() {
13151365
</div>
13161366
</div>
13171367
1318-
<div class="card account-menu-card" id="account-menu-dangerous" style="cursor:pointer">
1368+
<div class="card account-menu-card" id="account-menu-logout" style="cursor:pointer">
13191369
<div class="account-menu-item">
13201370
<div class="account-menu-icon" style="color:var(--accent-red)">
1321-
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><path d="M12 9v4"/><circle cx="12" cy="18" r="1"/></svg>
1371+
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 21H5a2 2 0 01-2-2V5a2 2 0 012-2h4M16 17l5-5-5-5M21 12H9"/></svg>
13221372
</div>
13231373
<div class="account-menu-text">
1324-
<div class="account-menu-title">Dangerous Zone & Export Account Data</div>
1325-
<div class="account-menu-desc">Delete your account or export your personal data (RGPD)</div>
1374+
<div class="account-menu-title">Sign Out</div>
1375+
<div class="account-menu-desc">Logout from your account</div>
13261376
</div>
13271377
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="color:var(--text-muted);flex-shrink:0"><path d="M9 18l6-6-6-6"/></svg>
13281378
</div>
13291379
</div>
13301380
1331-
<div class="card account-menu-card" id="account-menu-logout" style="cursor:pointer">
1381+
<div class="card account-menu-card" id="account-menu-dangerous" style="cursor:pointer">
13321382
<div class="account-menu-item">
13331383
<div class="account-menu-icon" style="color:var(--accent-red)">
1334-
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 21H5a2 2 0 01-2-2V5a2 2 0 012-2h4M16 17l5-5-5-5M21 12H9"/></svg>
1384+
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><path d="M12 9v4"/><circle cx="12" cy="18" r="1"/></svg>
13351385
</div>
13361386
<div class="account-menu-text">
1337-
<div class="account-menu-title">Sign Out</div>
1338-
<div class="account-menu-desc">Logout from your account</div>
1387+
<div class="account-menu-title">Dangerous Zone & Export Account Data</div>
1388+
<div class="account-menu-desc">Delete your account or export your personal data (RGPD)</div>
13391389
</div>
13401390
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="color:var(--text-muted);flex-shrink:0"><path d="M9 18l6-6-6-6"/></svg>
13411391
</div>

0 commit comments

Comments
 (0)