+
+
+
+
diff --git a/site/static/docs/5.3/assets/js/color-modes.js b/site/static/docs/5.3/assets/js/color-modes.js
index 8a0dabf18164..f0a2c5c4dad0 100644
--- a/site/static/docs/5.3/assets/js/color-modes.js
+++ b/site/static/docs/5.3/assets/js/color-modes.js
@@ -19,29 +19,29 @@
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
}
- const setTheme = theme => {
+ const setTheme = (theme, element = document.documentElement) => {
if (theme === 'auto') {
- document.documentElement.setAttribute('data-bs-theme', (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'))
+ element.setAttribute('data-bs-theme', (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'))
} else {
- document.documentElement.setAttribute('data-bs-theme', theme)
+ element.setAttribute('data-bs-theme', theme)
}
}
setTheme(getPreferredTheme())
- const showActiveTheme = (theme, focus = false) => {
- const themeSwitcher = document.querySelector('#bd-theme')
-
+ const showActiveTheme = (theme, focus = false, selectedToggler = document.querySelector('#bd-theme')) => {
+ const themeSwitcher = selectedToggler.closest('.dropdown')
if (!themeSwitcher) {
return
}
+ const themeSwitcherButton = themeSwitcher.querySelector('.dropdown-toggle')
const themeSwitcherText = document.querySelector('#bd-theme-text')
- const activeThemeIcon = document.querySelector('.theme-icon-active use')
- const btnToActive = document.querySelector(`[data-bs-theme-value="${theme}"]`)
+ const activeThemeIcon = themeSwitcher.querySelector('.theme-icon-active use')
+ const btnToActive = themeSwitcher.querySelector(`[data-bs-theme-value="${theme}"]`)
const svgOfActiveBtn = btnToActive.querySelector('svg use').getAttribute('href')
- document.querySelectorAll('[data-bs-theme-value]').forEach(element => {
+ themeSwitcher.querySelectorAll('[data-bs-theme-value]').forEach(element => {
element.classList.remove('active')
element.setAttribute('aria-pressed', 'false')
})
@@ -49,11 +49,11 @@
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)
+ const themeSwitcherLabel = `${themeSwitcherText.textContent} (${btnToActive.dataset.bsThemeValue})${btnToActive.closest('.highlight-toolbar') ? ' (local)' : ''}`
+ themeSwitcherButton.setAttribute('aria-label', themeSwitcherLabel)
if (focus) {
- themeSwitcher.focus()
+ themeSwitcherButton.focus()
}
}
@@ -71,9 +71,15 @@
.forEach(toggle => {
toggle.addEventListener('click', () => {
const theme = toggle.getAttribute('data-bs-theme-value')
- setStoredTheme(theme)
- setTheme(theme)
- showActiveTheme(theme, true)
+
+ if (toggle.closest('.bd-code-snippet')) {
+ setTheme(theme, toggle.closest('.bd-code-snippet').firstElementChild)
+ showActiveTheme(theme, true, toggle.closest('.dropdown-menu').previousElementSibling)
+ } else {
+ setStoredTheme(theme)
+ setTheme(theme)
+ showActiveTheme(theme, true)
+ }
})
})
})