Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use scrollspy on docs pages #33428

Merged
merged 5 commits into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion site/assets/scss/_syntax.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
--base05: #abb2bf;
--base06: #b6bdca;
--base07: #d19a66;
--base08: #e06c75;
--base08: #{$red-300};
--base09: #d19a66;
--base0A: #e5c07b;
--base0B: #98c379;
Expand Down
27 changes: 19 additions & 8 deletions site/assets/scss/_toc.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// stylelint-disable selector-max-type
// stylelint-disable selector-max-type, selector-no-qualifying-type, selector-max-compound-selectors

.bd-toc {
@include media-breakpoint-up(lg) {
Expand All @@ -16,23 +16,34 @@
ul {
padding-left: 0;
margin-bottom: 0;
margin-left: -.75rem;
list-style: none;

ul {
padding-left: 1rem;
margin-top: .25rem;
}
}
margin-left: -1rem;

li {
margin-bottom: .25rem;
a {
padding-left: 1.375rem;
}
}
}

a {
display: block;
padding: .125rem 0 .125rem .625rem;
color: inherit;
text-decoration: none;
border-left: .125rem solid transparent;

&:hover,
&.active {
color: var(--bd-toc-color);
border-left-color: var(--bd-toc-color);
}

&:not(:hover) {
text-decoration: none;
&.active {
font-weight: 500;
}

code {
Expand Down
3 changes: 2 additions & 1 deletion site/assets/scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ $bd-callout-variants: info, warning, danger !default;
--bd-accent-rgb: #{to-rgb($bd-accent)};
--bd-pink-rgb: #{to-rgb($pink-500)};
--bd-teal-rgb: #{to-rgb($teal-500)};

--bd-violet-bg: var(--bd-violet);
--bd-toc-color: var(--bd-violet);
--bd-sidebar-link-bg: rgba(var(--bd-violet-rgb), .1);
}

@include color-mode(dark, true) {
--bd-violet: #{mix($bd-violet, $white, 75%)};
--bd-violet-bg: #{$bd-violet};
--bd-toc-color: var(--#{$prefix}emphasis-color);
--bd-sidebar-link-bg: rgba(#{to-rgb(mix($bd-violet, $black, 75%))}, .5);
}
1 change: 1 addition & 0 deletions site/layouts/_default/docs.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{ define "body_override" }}<body data-bs-spy="scroll" tabindex="0" data-bs-target="#TableOfContents">{{ end }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that there should be a block {{ if (eq .Page.Params.toc true) }} around to avoid trigger the js when there's no need.

That said, I wonder if these attributes should be on .bd-main, .bd-content or keep it here ?

{{ define "main" }}
<div class="container-xxl bd-gutter mt-3 my-md-4 bd-layout">
<aside class="bd-sidebar">
Expand Down