|
1 | 1 | .menu { |
2 | 2 | /* Sidebar "guide line" (vertical tree line) color */ |
3 | 3 | --doc-sidebar-guide-line-color: var(--ifm-toc-border-color); |
| 4 | + /* Single source of truth for the tree-line X position (used by lines + selected highlight) */ |
| 5 | + --doc-sidebar-line-x: 1.6rem; |
| 6 | + /* Selected item background tint (fallback first, then color-mix for nicer tinting) */ |
| 7 | + --doc-sidebar-selected-bg: rgba(186, 242, 74, 0.10); |
| 8 | + --doc-sidebar-selected-bg: color-mix(in srgb, var(--ifm-color-primary) 14%, transparent); |
| 9 | + |
| 10 | + @include bp('tablet') { |
| 11 | + --doc-sidebar-line-x: 2.4rem; |
| 12 | + } |
4 | 13 |
|
5 | 14 | &.thin-scrollbar { |
6 | 15 | padding: 1rem 0 0; |
|
16 | 25 | } |
17 | 26 |
|
18 | 27 | &__list { |
| 28 | + /* The tree line is positioned relative to the list's padding box. |
| 29 | + * We store the current list padding-left so selected-row highlights can |
| 30 | + * compute a matching x-offset in the row coordinate space. */ |
| 31 | + --doc-sidebar-list-padding-left: 0px; |
| 32 | + |
19 | 33 | padding-top: 0; |
20 | 34 | padding-bottom: 0; |
21 | 35 |
|
|
26 | 40 |
|
27 | 41 | .theme-doc-sidebar-item-category-level-1 & { |
28 | 42 | padding-left: calc(var(--ifm-menu-link-padding-horizontal) / 4); |
| 43 | + --doc-sidebar-list-padding-left: calc(var(--ifm-menu-link-padding-horizontal) / 4); |
29 | 44 |
|
30 | 45 | @include bp('tablet') { |
31 | 46 | padding-left: var(--ifm-menu-link-padding-horizontal); |
| 47 | + --doc-sidebar-list-padding-left: var(--ifm-menu-link-padding-horizontal); |
32 | 48 | } |
33 | 49 | } |
34 | 50 |
|
|
38 | 54 | .theme-doc-sidebar-item-category-level-5 &, |
39 | 55 | .theme-doc-sidebar-item-category-level-6 & { |
40 | 56 | padding-left: calc(var(--ifm-menu-link-padding-horizontal) / 4); |
| 57 | + --doc-sidebar-list-padding-left: calc(var(--ifm-menu-link-padding-horizontal) / 4); |
41 | 58 |
|
42 | 59 | @include bp('tablet') { |
43 | 60 | padding-left: calc(var(--ifm-menu-link-padding-horizontal) / 2); |
| 61 | + --doc-sidebar-list-padding-left: calc(var(--ifm-menu-link-padding-horizontal) / 2); |
44 | 62 | padding-top: 0; |
45 | 63 | padding-bottom: 0; |
46 | 64 | } |
|
51 | 69 | padding-bottom: 0rem; |
52 | 70 | margin-bottom: 0.25rem; |
53 | 71 | padding-left: var(--ifm-menu-link-padding-horizontal); |
| 72 | + --doc-sidebar-list-padding-left: var(--ifm-menu-link-padding-horizontal); |
54 | 73 | } |
55 | 74 |
|
56 | 75 | /* Vertical guide lines (tree lines) for expanded category trees (level 1+). */ |
|
67 | 86 | position: absolute; |
68 | 87 | top: 0; |
69 | 88 | bottom: 0; |
70 | | - left: 1.6rem; /* align with default link text start */ |
| 89 | + left: var(--doc-sidebar-line-x); |
71 | 90 | width: 1px; |
72 | 91 | background: var(--doc-sidebar-guide-line-color); |
73 | 92 | pointer-events: none; |
74 | 93 | opacity: 0; |
75 | 94 | } |
76 | | - |
77 | | - @include bp('tablet') { |
78 | | - &::before { |
79 | | - left: 2.4rem; /* align with tablet link text start */ |
80 | | - } |
81 | | - } |
82 | 95 | } |
83 | 96 |
|
84 | 97 | .menu__list-item.theme-doc-sidebar-item-category-level-1:not(.menu__list-item--collapsed) > .menu__list::before, |
|
100 | 113 | &__list-item { |
101 | 114 | position: relative; |
102 | 115 | z-index: 1; |
| 116 | + width: 100%; |
103 | 117 |
|
104 | 118 | /* Reduce top-level nav emphasis (level 1). */ |
105 | 119 | &.theme-doc-sidebar-item-category-level-1 > .menu__list-item-collapsible > .menu__link { |
|
113 | 127 | font-weight: 400; |
114 | 128 | } |
115 | 129 |
|
116 | | - /* Active page + active ancestor path: bold for clearer orientation. */ |
117 | | - &.menu__list-item--active > .menu__list-item-collapsible > .menu__link, |
118 | | - &.menu__list-item--active > .menu__link { |
119 | | - color: var(--ifm-menu-color-active); |
120 | | - /* Parent/ancestor path: keep it emphasized, but less prominent than the active page */ |
121 | | - font-weight: 600 !important; |
122 | | - } |
| 130 | + /* Only the active page should be bold; keep ancestor path normal weight. */ |
123 | 131 |
|
124 | 132 | &-collapsible { |
125 | 133 | border-radius: 0; |
|
185 | 193 | line-height: 124%; |
186 | 194 | text-decoration: none; |
187 | 195 | font-weight: 500; |
| 196 | + /* Ensure background fills the full row */ |
| 197 | + display: flex; |
| 198 | + width: 100%; |
| 199 | + box-sizing: border-box; |
188 | 200 | padding: 0.6rem 1.6rem; |
189 | 201 | border-radius: 0; |
190 | 202 | text-decoration: none !important; |
|
195 | 207 |
|
196 | 208 | &--active { |
197 | 209 | color: var(--ifm-menu-color-active); |
198 | | - font-weight: 700 !important; |
199 | | - /* Ensure it still *looks* bold even if the font doesn't ship a true 700 weight */ |
200 | | - text-shadow: 0 0 0 currentColor; |
| 210 | + /* Docusaurus applies `menu__link--active` to the active page *and* its ancestor |
| 211 | + * categories. Keep active color, but don't bold the whole ancestor path. */ |
| 212 | + font-weight: inherit; |
| 213 | + text-shadow: none; |
201 | 214 | /* Selected item: no bar / no filled background */ |
202 | 215 | background-image: none !important; |
203 | 216 | background-color: transparent !important; |
|
207 | 220 | } |
208 | 221 | } |
209 | 222 |
|
| 223 | + /* Only the actual selected page link should be bold. */ |
| 224 | + &[aria-current='page'] { |
| 225 | + /* Selected page: keep the *normal* text color (no green), rely on highlight only */ |
| 226 | + font-weight: inherit; |
| 227 | + text-shadow: none; |
| 228 | + color: var(--ifm-menu-color) !important; |
| 229 | + |
| 230 | + &:hover, |
| 231 | + &:focus-visible { |
| 232 | + color: var(--ifm-menu-color) !important; |
| 233 | + text-shadow: none; |
| 234 | + } |
| 235 | + } |
| 236 | + |
210 | 237 | /* Hover: slight contrast, no "highlight bar" */ |
211 | | - &:hover, |
212 | | - &:focus-visible { |
| 238 | + &:hover:not([aria-current='page']), |
| 239 | + &:focus-visible:not([aria-current='page']) { |
213 | 240 | background-image: none !important; |
214 | 241 | background-color: transparent !important; |
215 | 242 | background: transparent !important; /* override Infima `background:` shorthand */ |
|
219 | 246 | } |
220 | 247 | } |
221 | 248 |
|
| 249 | + /* Selected item highlight: apply to the *row header only* (not the whole <li>), |
| 250 | + * otherwise expanded categories would tint their entire subtree. We also avoid |
| 251 | + * relying on `:has()` by using `data-current-page` (stamped by our swizzled components). */ |
| 252 | + |
| 253 | + /* Link items: the row is the direct <a> child. */ |
| 254 | + .menu__list-item[data-current-page='true'] > a.menu__link { |
| 255 | + position: relative; |
| 256 | + } |
| 257 | + .menu__list-item[data-current-page='true'] > a.menu__link::before { |
| 258 | + content: ''; |
| 259 | + position: absolute; |
| 260 | + top: 0; |
| 261 | + bottom: 0; |
| 262 | + /* Convert list-space line position to row-space by subtracting the list padding-left. */ |
| 263 | + left: calc(var(--doc-sidebar-line-x) - var(--doc-sidebar-list-padding-left) + 0.5px); |
| 264 | + right: 0; |
| 265 | + background: var(--doc-sidebar-selected-bg); |
| 266 | + pointer-events: none; |
| 267 | + z-index: 0; |
| 268 | + } |
| 269 | + |
| 270 | + /* Top-level link items (level 1): no meaningful tree line on the row, so let the |
| 271 | + * selected highlight run full-width. */ |
| 272 | + .menu__list-item.theme-doc-sidebar-item-link-level-1[data-current-page='true'] > a.menu__link::before { |
| 273 | + left: 0; |
| 274 | + } |
| 275 | + .menu__list-item[data-current-page='true'] > a.menu__link > * { |
| 276 | + position: relative; |
| 277 | + z-index: 1; |
| 278 | + } |
| 279 | + |
| 280 | + /* Category items: the row header is the collapsible wrapper. */ |
| 281 | + .menu__list-item[data-current-page='true'] > .menu__list-item-collapsible { |
| 282 | + position: relative; |
| 283 | + } |
| 284 | + .menu__list-item[data-current-page='true'] > .menu__list-item-collapsible::before { |
| 285 | + content: ''; |
| 286 | + position: absolute; |
| 287 | + top: 0; |
| 288 | + bottom: 0; |
| 289 | + left: calc(var(--doc-sidebar-line-x) - var(--doc-sidebar-list-padding-left) + 0.5px); |
| 290 | + right: 0; |
| 291 | + background: var(--doc-sidebar-selected-bg); |
| 292 | + pointer-events: none; |
| 293 | + z-index: 0; |
| 294 | + } |
| 295 | + .menu__list-item[data-current-page='true'] > .menu__list-item-collapsible > * { |
| 296 | + position: relative; |
| 297 | + z-index: 1; |
| 298 | + } |
| 299 | + |
222 | 300 | &__caret { |
223 | 301 | padding: 1rem 2rem 1rem 1rem; |
224 | 302 | opacity: 0.25; |
|
247 | 325 | /* Dark mode: make tree lines more subtle */ |
248 | 326 | [data-theme='dark'] .menu { |
249 | 327 | --doc-sidebar-guide-line-color: rgba(255, 255, 255, 0.12); |
| 328 | + --doc-sidebar-selected-bg: rgba(186, 242, 74, 0.14); |
250 | 329 | } |
251 | 330 |
|
252 | 331 | .theme-doc-sidebar-container { |
|
0 commit comments