Skip to content
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
6 changes: 4 additions & 2 deletions assets/js/dark-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@
btnToActive.classList.add('active')
btnToActive.setAttribute('aria-pressed', 'true')
activeThemeIcon.setAttribute('href', svgOfActiveBtn)
const themeSwitcherLabel = `${themeSwitcherText.textContent} (${btnToActive.dataset.bsThemeValue})`
themeSwitcher.setAttribute('aria-label', themeSwitcherLabel)
if (themeSwitcherText) {
const themeSwitcherLabel = `${themeSwitcherText.textContent} (${btnToActive.dataset.bsThemeValue})`
themeSwitcher.setAttribute('aria-label', themeSwitcherLabel)
}

if (focus) {
themeSwitcher.focus()
Expand Down
23 changes: 14 additions & 9 deletions assets/scss/_nav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,20 @@
}
}

// Support for showLightDarkModeMenu:
.bi {
width: 1em;
height: 1em;
vertical-align: -.125em;
fill: currentcolor;
}
.td-navbar .dropdown-menu .active .bi {
display: block !important
.td-light-dark-menu {
.bi {
// Adapted from: https://github.com/twbs/bootstrap/blob/main/site/layouts/_default/examples.html
width: 1em;
height: 1em;
vertical-align: -.125em;
fill: currentcolor;
}

&.dropdown {
@include media-breakpoint-down(lg) {
position: unset;
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</li>
{{ end -}}
{{ if .Site.Params.ui.showLightDarkModeMenu -}}
<li class="nav-item dropdown">
<li class="td-light-dark-menu nav-item dropdown">
{{ partial "theme-toggler" . }}
</li>
{{ end -}}
Expand Down
4 changes: 3 additions & 1 deletion layouts/partials/theme-toggler.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
{{ if not $isExamples }}data-bs-display="static"{{ end }}
aria-label="Toggle theme (auto)">
<svg class="bi my-1 theme-icon-active"><use href="#circle-half"></use></svg>
<span class="{{ if $isExamples }}visually-hidden{{ else }}d-lg-none ms-2{{ end }}" id="bd-theme-text">Toggle theme</span>
{{- /* Disable menu name for Docsy:
<span class="{{ if $isExamples }}visually-hidden{{ else }}d-lg-none ms-2{{ end }}" id="bd-theme-text">Toggle theme</span>
*/}}
</button>
<ul class="dropdown-menu dropdown-menu-end{{ if $isExamples }} shadow{{ end }}" aria-labelledby="bd-theme-text">
<li>
Expand Down