Skip to content

Commit 43d9219

Browse files
mdoGeoSot
authored andcommitted
Redesign the toc for scrollspy
1 parent 8503aa0 commit 43d9219

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

site/assets/scss/_toc.scss

+18-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// stylelint-disable selector-max-type
2-
31
.bd-toc {
42
@include media-breakpoint-up(lg) {
53
position: sticky;
@@ -10,29 +8,35 @@
108
overflow-y: auto;
119
}
1210

13-
nav {
11+
.nav {
1412
@include font-size(.875rem);
1513

16-
ul ul {
14+
ul {
1715
padding-left: 1rem;
18-
margin-top: .25rem;
1916
}
2017

21-
li {
22-
margin-bottom: .25rem;
23-
24-
> .nav-link.active {
25-
background-color: $bd-purple-light;
18+
.nav-link {
19+
padding: .125rem 0 .125rem .9rem;
20+
margin-left: -1rem;
21+
border-left: .1rem solid transparent;
22+
@include border-radius(0);
23+
24+
&:hover,
25+
&.active {
26+
font-weight: 500;
27+
color: $bd-purple;
28+
background-color: transparent;
29+
border-left-color: $bd-purple-light;
30+
}
31+
&.active {
32+
padding-left: .8em;
33+
border-left-width: .2em;
2634
}
2735
}
2836

2937
a {
3038
color: inherit;
3139

32-
&:hover:not(.active) {
33-
text-decoration: underline;
34-
}
35-
3640
code {
3741
font: inherit;
3842
}

site/layouts/_default/docs.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ <h1 class="bd-title" id="content">{{ .Title | markdownify }}</h1>
2020
{{ if (eq .Page.Params.toc true) }}
2121
<div class="bd-toc mt-4 mb-5 my-md-0 ps-xl-3 mb-lg-5 text-muted">
2222
<strong class="d-block h6 my-2 pb-2 border-bottom">On this page</strong>
23-
{{ .Page.TableOfContents | replaceRE "(<li>)" "<li class=\"nav-item\">" | replaceRE "(<ul>)" "<ul class=\"nav nav-pills flex-column\">" | replaceRE "(?s:href)" "class=\"nav-link py-0 px-1\" href" | safeHTML }}
23+
{{ .Page.TableOfContents | replaceRE "(<li>)" "<li class=\"nav-item\">" | replaceRE "(<ul>)" "<ul class=\"nav nav-pills flex-column\">" | replaceRE "(?s:href)" "class=\"nav-link\" href" | safeHTML }}
2424
</div>
2525
{{ end }}
2626

0 commit comments

Comments
 (0)