fix: double TOC in published view and broken collapsible sections
Browse files- Add missing mobile TOC styles (display:none defaults, sidebar panel,
backdrop, toggle button) extracted from TableOfContents.astro
- Add overflow:hidden + transition for toc-collapsible sub-sections
Made-with: Cursor
frontend/src/styles/components/_toc.css
CHANGED
|
@@ -4,6 +4,18 @@
|
|
| 4 |
/* Shared between editor and publisher. */
|
| 5 |
/* ============================================================================ */
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
.table-of-contents {
|
| 8 |
position: sticky;
|
| 9 |
top: 32px;
|
|
@@ -53,3 +65,159 @@
|
|
| 53 |
.table-of-contents nav a.active {
|
| 54 |
text-decoration: underline;
|
| 55 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
/* Shared between editor and publisher. */
|
| 5 |
/* ============================================================================ */
|
| 6 |
|
| 7 |
+
/* Loading state */
|
| 8 |
+
.table-of-contents.toc-loading,
|
| 9 |
+
.toc-mobile-sidebar.toc-loading {
|
| 10 |
+
opacity: 0;
|
| 11 |
+
transition: opacity 0.3s ease-in-out;
|
| 12 |
+
}
|
| 13 |
+
.table-of-contents.toc-loaded,
|
| 14 |
+
.toc-mobile-sidebar.toc-loaded {
|
| 15 |
+
opacity: 1;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
/* Desktop TOC */
|
| 19 |
.table-of-contents {
|
| 20 |
position: sticky;
|
| 21 |
top: 32px;
|
|
|
|
| 65 |
.table-of-contents nav a.active {
|
| 66 |
text-decoration: underline;
|
| 67 |
}
|
| 68 |
+
|
| 69 |
+
/* Collapsible sub-sections (JS adds class toc-collapsible and inline height) */
|
| 70 |
+
.toc-collapsible li > ul {
|
| 71 |
+
overflow: hidden;
|
| 72 |
+
transition: height 200ms ease;
|
| 73 |
+
}
|
| 74 |
+
.toc-collapsible li.collapsed > ul {
|
| 75 |
+
display: block;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
/* ============================================================================ */
|
| 79 |
+
/* Mobile TOC - toggle button */
|
| 80 |
+
/* Hidden on desktop, shown via _layout.css @media (--bp-content-collapse) */
|
| 81 |
+
/* ============================================================================ */
|
| 82 |
+
|
| 83 |
+
.toc-mobile-toggle {
|
| 84 |
+
display: none;
|
| 85 |
+
position: fixed;
|
| 86 |
+
top: var(--spacing-4);
|
| 87 |
+
right: var(--spacing-4);
|
| 88 |
+
z-index: var(--z-overlay);
|
| 89 |
+
width: 40px;
|
| 90 |
+
height: 40px;
|
| 91 |
+
border-radius: 50%;
|
| 92 |
+
border: 1px solid var(--border-color);
|
| 93 |
+
background: var(--page-bg);
|
| 94 |
+
box-shadow: 0 2px 12px rgba(0,0,0,.08);
|
| 95 |
+
align-items: center;
|
| 96 |
+
justify-content: center;
|
| 97 |
+
padding: 0;
|
| 98 |
+
cursor: pointer;
|
| 99 |
+
color: var(--text-color);
|
| 100 |
+
transition: transform 150ms ease, box-shadow 150ms ease;
|
| 101 |
+
}
|
| 102 |
+
.toc-mobile-toggle:active {
|
| 103 |
+
transform: scale(0.92);
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
/* ============================================================================ */
|
| 107 |
+
/* Mobile TOC - backdrop */
|
| 108 |
+
/* ============================================================================ */
|
| 109 |
+
|
| 110 |
+
.toc-mobile-backdrop {
|
| 111 |
+
display: none;
|
| 112 |
+
position: fixed;
|
| 113 |
+
inset: 0;
|
| 114 |
+
z-index: var(--z-overlay);
|
| 115 |
+
background: rgba(0,0,0,.4);
|
| 116 |
+
opacity: 0;
|
| 117 |
+
pointer-events: none;
|
| 118 |
+
transition: opacity 250ms ease;
|
| 119 |
+
}
|
| 120 |
+
.toc-mobile-backdrop.open {
|
| 121 |
+
opacity: 1;
|
| 122 |
+
pointer-events: auto;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
/* ============================================================================ */
|
| 126 |
+
/* Mobile TOC - sidebar panel */
|
| 127 |
+
/* ============================================================================ */
|
| 128 |
+
|
| 129 |
+
.toc-mobile-sidebar {
|
| 130 |
+
display: none;
|
| 131 |
+
position: fixed;
|
| 132 |
+
top: 0;
|
| 133 |
+
right: 0;
|
| 134 |
+
bottom: 0;
|
| 135 |
+
z-index: calc(var(--z-overlay) + 1);
|
| 136 |
+
width: min(320px, 85vw);
|
| 137 |
+
background: var(--page-bg);
|
| 138 |
+
border-left: 1px solid var(--border-color);
|
| 139 |
+
transform: translateX(100%);
|
| 140 |
+
transition: transform 300ms cubic-bezier(.4,0,.2,1);
|
| 141 |
+
flex-direction: column;
|
| 142 |
+
}
|
| 143 |
+
.toc-mobile-sidebar.open {
|
| 144 |
+
transform: translateX(0);
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
.toc-mobile-sidebar__header {
|
| 148 |
+
display: flex;
|
| 149 |
+
align-items: center;
|
| 150 |
+
justify-content: space-between;
|
| 151 |
+
padding: 16px;
|
| 152 |
+
border-bottom: 1px solid var(--border-color);
|
| 153 |
+
flex-shrink: 0;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
.toc-mobile-sidebar__title {
|
| 157 |
+
font-weight: 700;
|
| 158 |
+
font-size: 15px;
|
| 159 |
+
color: var(--text-color);
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
.toc-mobile-sidebar__actions {
|
| 163 |
+
display: flex;
|
| 164 |
+
align-items: center;
|
| 165 |
+
gap: 4px;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
.toc-mobile-sidebar__close,
|
| 169 |
+
.toc-mobile-sidebar__theme {
|
| 170 |
+
background: none;
|
| 171 |
+
border: none;
|
| 172 |
+
color: var(--muted-color);
|
| 173 |
+
cursor: pointer;
|
| 174 |
+
padding: 4px;
|
| 175 |
+
border-radius: 6px;
|
| 176 |
+
width: 32px;
|
| 177 |
+
height: 32px;
|
| 178 |
+
display: flex;
|
| 179 |
+
align-items: center;
|
| 180 |
+
justify-content: center;
|
| 181 |
+
transition: color 150ms ease, background 150ms ease;
|
| 182 |
+
}
|
| 183 |
+
.toc-mobile-sidebar__close:hover,
|
| 184 |
+
.toc-mobile-sidebar__theme:hover {
|
| 185 |
+
color: var(--text-color);
|
| 186 |
+
background: var(--surface-bg);
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
.toc-mobile-sidebar__body {
|
| 190 |
+
flex: 1;
|
| 191 |
+
overflow-y: auto;
|
| 192 |
+
-webkit-overflow-scrolling: touch;
|
| 193 |
+
padding: 16px;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
/* TOC styles inside mobile sidebar */
|
| 197 |
+
.toc-mobile-sidebar nav ul {
|
| 198 |
+
margin: 0 0 6px;
|
| 199 |
+
padding-left: 1em;
|
| 200 |
+
}
|
| 201 |
+
.toc-mobile-sidebar nav li {
|
| 202 |
+
list-style: none;
|
| 203 |
+
margin: 0.35em 0;
|
| 204 |
+
}
|
| 205 |
+
.toc-mobile-sidebar nav a,
|
| 206 |
+
.toc-mobile-sidebar nav a:link,
|
| 207 |
+
.toc-mobile-sidebar nav a:visited {
|
| 208 |
+
color: var(--text-color);
|
| 209 |
+
text-decoration: none;
|
| 210 |
+
border-bottom: none;
|
| 211 |
+
font-size: 14px;
|
| 212 |
+
line-height: 1.5;
|
| 213 |
+
}
|
| 214 |
+
.toc-mobile-sidebar nav > ul > li > a {
|
| 215 |
+
font-weight: 700;
|
| 216 |
+
}
|
| 217 |
+
.toc-mobile-sidebar nav a:hover {
|
| 218 |
+
text-decoration: underline solid var(--muted-color);
|
| 219 |
+
}
|
| 220 |
+
.toc-mobile-sidebar nav a.active {
|
| 221 |
+
color: var(--primary-color);
|
| 222 |
+
text-decoration: underline;
|
| 223 |
+
}
|