feat: add right sidebar with table of contents, scroll spy, and reading progress tracking

This commit is contained in:
2026-03-24 20:40:04 -04:00
parent dc2fdbe109
commit e06ae556ba
3 changed files with 674 additions and 0 deletions
+232
View File
@@ -987,6 +987,228 @@ select {
border-radius: 4px;
}
/* --- Right Sidebar Resize Handle --- */
.right-sidebar-resize-handle {
width: 5px;
cursor: ew-resize;
background: transparent;
flex-shrink: 0;
transition: background 150ms ease, opacity 300ms ease;
z-index: 10;
}
.right-sidebar-resize-handle:hover,
.right-sidebar-resize-handle.active {
background: var(--accent);
opacity: 0.5;
}
.right-sidebar-resize-handle.hidden {
width: 0;
opacity: 0;
pointer-events: none;
}
/* --- Right Sidebar (Outline/TOC) --- */
.right-sidebar {
width: 280px;
min-width: 200px;
max-width: 400px;
background: var(--bg-sidebar);
border-left: 1px solid var(--border);
display: flex;
flex-direction: column;
overflow: hidden;
transition: background 200ms ease, transform 300ms ease, width 300ms ease;
flex-shrink: 0;
}
.right-sidebar.hidden {
transform: translateX(100%);
width: 0;
min-width: 0;
border-left: none;
}
/* Right sidebar header */
.right-sidebar-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 12px 16px;
border-bottom: 1px solid var(--border);
background: var(--bg-sidebar);
flex-shrink: 0;
}
.right-sidebar-title {
font-family: 'JetBrains Mono', monospace;
font-size: 0.7rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.08em;
color: var(--text-muted);
margin: 0;
}
.right-sidebar-toggle-btn {
display: flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
padding: 0;
background: transparent;
border: 1px solid var(--border);
border-radius: 4px;
color: var(--text-secondary);
cursor: pointer;
transition: all 150ms ease;
}
.right-sidebar-toggle-btn:hover {
background: var(--bg-hover);
border-color: var(--accent);
color: var(--accent);
}
.right-sidebar-toggle-btn i {
transition: transform 200ms ease;
}
.right-sidebar.hidden .right-sidebar-toggle-btn i {
transform: rotate(180deg);
}
/* Outline panel */
.outline-panel {
flex: 1;
overflow-y: auto;
overflow-x: hidden;
padding: 8px 0;
min-height: 0;
}
.outline-panel::-webkit-scrollbar {
width: 6px;
}
.outline-panel::-webkit-scrollbar-thumb {
background: var(--scrollbar);
border-radius: 3px;
}
.outline-list {
display: flex;
flex-direction: column;
gap: 2px;
padding: 0 8px;
}
.outline-item {
display: flex;
align-items: center;
padding: 8px 12px;
border-radius: 6px;
font-family: 'JetBrains Mono', monospace;
font-size: 0.82rem;
color: var(--text-secondary);
cursor: pointer;
transition: all 150ms ease;
position: relative;
text-decoration: none;
line-height: 1.4;
word-break: break-word;
}
.outline-item:hover {
background: var(--bg-hover);
color: var(--text-primary);
}
.outline-item.active {
background: color-mix(in srgb, var(--accent) 12%, transparent);
color: var(--accent);
font-weight: 500;
}
.outline-item.active::before {
content: '';
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 3px;
background: var(--accent);
border-radius: 0 2px 2px 0;
}
/* Heading levels */
.outline-item.level-2 {
font-weight: 600;
font-size: 0.85rem;
padding-left: 12px;
}
.outline-item.level-3 {
font-weight: 400;
font-size: 0.8rem;
padding-left: 28px;
color: var(--text-muted);
}
.outline-item.level-3:hover {
color: var(--text-secondary);
}
.outline-item.level-3.active {
color: var(--accent);
}
/* Empty state */
.outline-empty {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 40px 20px;
gap: 12px;
color: var(--text-muted);
font-size: 0.85rem;
text-align: center;
}
/* Reading progress */
.reading-progress {
padding: 12px 16px;
border-top: 1px solid var(--border);
background: var(--bg-sidebar);
flex-shrink: 0;
}
.reading-progress-bar {
width: 100%;
height: 6px;
background: color-mix(in srgb, var(--border) 50%, transparent);
border-radius: 3px;
overflow: hidden;
margin-bottom: 8px;
}
.reading-progress-fill {
height: 100%;
background: var(--accent);
border-radius: 3px;
transition: width 150ms ease;
width: 0%;
}
.reading-progress-text {
font-family: 'JetBrains Mono', monospace;
font-size: 0.75rem;
font-weight: 600;
color: var(--text-muted);
text-align: center;
}
/* Welcome */
.welcome {
display: flex;
@@ -2128,6 +2350,16 @@ select {
word-wrap: break-word;
}
/* Mobile right sidebar - hide by default */
@media (max-width: 768px) {
.right-sidebar {
display: none;
}
.right-sidebar-resize-handle {
display: none;
}
}
/* Mobile help navigation */
@media (max-width: 768px) {
.help-nav {