Skip to content

Commit 571df42

Browse files
committed
Sidebar: Toc styling border
1 parent e1c39d4 commit 571df42

File tree

2 files changed

+68
-25
lines changed

2 files changed

+68
-25
lines changed

assets/css/v2/style.css

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,11 +453,22 @@ nav {
453453
.sidebar-layout {
454454
display: flex;
455455
flex-direction: column;
456+
position: relative; /* required for absolute-positioned pseudo element */
456457
z-index: 2;
457-
border-right: 1px solid var(--color-divider);
458458
min-height: 100vh;
459459
}
460460

461+
/* this is the complete, corrected CSS you can directly copy/paste clearly: */
462+
.sidebar-layout::before {
463+
content: "";
464+
position: absolute;
465+
top: 0;
466+
bottom: 0;
467+
right: 0;
468+
width: 1px;
469+
background-color: var(--color-divider);
470+
}
471+
461472
#searchbox {
462473
width: 24rem;
463474
display: none;
@@ -810,6 +821,16 @@ button:has(~ .product-selector[style*="none"]) > .product-selector-button-icon {
810821
text-align: left;
811822
padding: 0.25rem 0.5rem;
812823
border-radius: 5px;
824+
font-weight: 500;
825+
826+
&:hover {
827+
background-color: oklch(var(--color-brand) / 0.06);
828+
color: oklch(var(--color-brand) / 1);
829+
}
830+
}
831+
832+
.sidebar__container button.sidebar__toggle--ancestor {
833+
font-weight: 600;
813834
}
814835

815836
.sidebar__chevron {
@@ -837,6 +858,12 @@ button:has(~ .product-selector[style*="none"]) > .product-selector-button-icon {
837858
border-radius: 5px;
838859
color: oklch(0 0 0 / 0.75);
839860
text-decoration: none;
861+
transition: background-color 0.2s ease, color 0.2s ease;
862+
863+
&:hover {
864+
background-color: oklch(var(--color-brand) / 0.08);
865+
color: oklch(var(--color-brand));
866+
}
840867
}
841868

842869
.sidebar__link--current {
@@ -848,18 +875,31 @@ button:has(~ .product-selector[style*="none"]) > .product-selector-button-icon {
848875

849876
.sidebar__toc {
850877
#TableOfContents {
851-
padding: 0.25rem 0.75rem;
852-
margin: 2px 0.5rem 2px 0;
853-
border-radius: 5px;
878+
padding: 0 0.75rem 0 0;
879+
margin: 0.5rem 0.25rem 0.5rem 0.8rem;
880+
border-left: 1px solid var(--color-divider);
854881
color: oklch(0 0 0 / 0.75);
855882

883+
a {
884+
color: oklch(0 0 0 / 0.75);
885+
text-decoration: none;
886+
}
887+
856888
&:empty {
857889
display: none;
858890
}
859891

860892
li {
861893
padding: 0.25rem 0.75rem;
862894
}
895+
896+
li:first-child {
897+
padding-top: 0;
898+
}
899+
900+
li:last-child {
901+
padding-bottom: 0;
902+
}
863903
}
864904
}
865905

layouts/partials/sidebar-list.html

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,30 @@
99
{{- $isAncestor := .IsAncestor $currentPage -}}
1010
{{- $shouldExpand := or $onPage $isAncestor -}}
1111
{{- $sectionID := printf "section-%s" (urlize .Permalink) -}}
12+
1213
{{ if eq .Kind "section" }}
13-
<li class="sidebar__section">
14-
<button
15-
class="sidebar__toggle"
16-
aria-expanded="{{ $shouldExpand }}"
17-
aria-controls="{{ $sectionID }}"
18-
>
19-
<span class="sidebar__chevron {{ if $shouldExpand }}sidebar__chevron--open{{ end }}">
20-
{{ partial "lucide" (dict "context" . "icon" "chevron-right") }}
21-
</span>
22-
<span class="sidebar__toggle-text">{{ .Title }}</span>
23-
</button>
24-
<div
25-
id="{{ $sectionID }}"
26-
class="sidebar__children"
27-
{{ if not $shouldExpand }}hidden{{ end }}
28-
>
29-
{{ partial "sidebar-list.html" (dict
30-
"firstSection" . "currentUrl" $currentUrl "currentPage" $currentPage) }}
31-
</div>
32-
</li>
14+
<li class="sidebar__section">
15+
<button
16+
class="sidebar__toggle {{ if $isAncestor }}sidebar__toggle--ancestor{{ end }}"
17+
aria-expanded="{{ $shouldExpand }}"
18+
aria-controls="{{ $sectionID }}"
19+
>
20+
<span class="sidebar__chevron {{ if $shouldExpand }}sidebar__chevron--open{{ end }}">
21+
{{ partial "lucide" (dict "context" . "icon" "chevron-right") }}
22+
</span>
23+
<span class="sidebar__toggle-text">{{ .Title }}</span>
24+
</button>
25+
<div
26+
id="{{ $sectionID }}"
27+
class="sidebar__children"
28+
{{ if not $shouldExpand }}hidden{{ end }}
29+
>
30+
{{ partial "sidebar-list.html" (dict
31+
"firstSection" . "currentUrl" $currentUrl "currentPage" $currentPage)
32+
}}
33+
</div>
34+
</li>
35+
3336
{{ else if eq .Kind "page" }}
3437
<li class="sidebar__page">
3538
<a
@@ -39,13 +42,13 @@
3942
>
4043
{{ .Title }}
4144
</a>
45+
4246
{{ if $onPage }}
4347
{{ with .TableOfContents }}
4448
<div class="sidebar__toc" id="TableOfContents">{{ . }}</div>
4549
{{ end }}
4650
{{ end }}
4751
</li>
48-
4952
{{ end }}
5053
{{ end }}
5154
</ul>

0 commit comments

Comments
 (0)