diff --git a/docs/assets/js/color-modes.js b/docs/assets/js/color-modes.js index f14a3be9d5..19d45cc7c6 100644 --- a/docs/assets/js/color-modes.js +++ b/docs/assets/js/color-modes.js @@ -1,6 +1,6 @@ /*! * Color mode toggler for Bootstrap's docs (https://getbootstrap.com/) - * Copyright 2011-2023 The Bootstrap Authors + * Copyright 2011-2024 The Bootstrap Authors * Licensed under the Creative Commons Attribution 3.0 Unported License. */ @@ -35,19 +35,20 @@ } 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 svgOfActiveBtn = btnToActive.querySelector('svg use').getAttribute('href') + const activeThemeIcon = document.querySelector('.theme-icon-active') + const btnToActive = document.querySelector(`[data-bs-theme-value="${theme}"] i`) + const initialIconOfActiveBtn = [...btnToActive.classList].find(cl => cl.startsWith('bi-')) - document.querySelectorAll('[data-bs-theme-value]').forEach(element => { + for (const element of document.querySelectorAll('[data-bs-theme-value]')) { element.classList.remove('active') element.setAttribute('aria-pressed', 'false') - }) + } btnToActive.classList.add('active') btnToActive.setAttribute('aria-pressed', 'true') - activeThemeIcon.setAttribute('href', svgOfActiveBtn) - const themeSwitcherLabel = `${themeSwitcherText.textContent} (${btnToActive.dataset.bsThemeValue})` + const currentIconOfActiveBtn = [...activeThemeIcon.classList].find(cl => cl.startsWith('bi-')) + activeThemeIcon.classList.replace(currentIconOfActiveBtn, initialIconOfActiveBtn) + const themeSwitcherLabel = `${themeSwitcherText.textContent} (${btnToActive.parentElement.dataset.bsThemeValue})` themeSwitcher.setAttribute('aria-label', themeSwitcherLabel) if (focus) { @@ -65,15 +66,14 @@ window.addEventListener('DOMContentLoaded', () => { showActiveTheme(getPreferredTheme()) - document.querySelectorAll('[data-bs-theme-value]') - .forEach(toggle => { - toggle.addEventListener('click', () => { - const theme = toggle.getAttribute('data-bs-theme-value') - localStorage.setItem('theme', theme) - setStoredTheme(theme) - setTheme(theme) - showActiveTheme(theme, true) - }) + for (const toggle of document.querySelectorAll('[data-bs-theme-value]')) { + toggle.addEventListener('click', () => { + const theme = toggle.getAttribute('data-bs-theme-value') + localStorage.setItem('theme', theme) + setStoredTheme(theme) + setTheme(theme) + showActiveTheme(theme, true) }) + } }) })() diff --git a/docs/content/_index.md b/docs/content/_index.md index 0976b40dba..5108bcb55f 100644 --- a/docs/content/_index.md +++ b/docs/content/_index.md @@ -35,7 +35,7 @@ composer require twbs/bootstrap-icons Include the icon fonts stylesheet—in your website `
` or via `@import` in CSS—from jsDelivr and get started in seconds. [See icon font docs](#icon-font) for examples. {{< highlight html >}} - + {{< /highlight >}} {{< highlight css >}} diff --git a/docs/layouts/partials/favicons.html b/docs/layouts/partials/favicons.html index 520b61a127..58fd96db51 100644 --- a/docs/layouts/partials/favicons.html +++ b/docs/layouts/partials/favicons.html @@ -1,4 +1,3 @@ -{{ "" | safeHTML }} diff --git a/docs/layouts/partials/footer.html b/docs/layouts/partials/footer.html index e340df5b1f..8ec9af27f7 100644 --- a/docs/layouts/partials/footer.html +++ b/docs/layouts/partials/footer.html @@ -2,13 +2,14 @@