From 8b5f8daa771ebf3a4cd0e4913c788f4e1d4baaec Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Thu, 7 Mar 2024 14:31:47 +0200 Subject: [PATCH] Use bootstrap icons in templates when possible --- docs/assets/js/color-modes.js | 11 ++--- docs/layouts/partials/icons/github.svg | 1 - .../layouts/partials/icons/opencollective.svg | 1 - docs/layouts/partials/icons/twitter.svg | 1 - docs/layouts/partials/navbar.html | 40 ++++++------------- 5 files changed, 19 insertions(+), 35 deletions(-) delete mode 100644 docs/layouts/partials/icons/github.svg delete mode 100644 docs/layouts/partials/icons/opencollective.svg delete mode 100644 docs/layouts/partials/icons/twitter.svg diff --git a/docs/assets/js/color-modes.js b/docs/assets/js/color-modes.js index 738d3641f0..be60b010bb 100644 --- a/docs/assets/js/color-modes.js +++ b/docs/assets/js/color-modes.js @@ -35,9 +35,9 @@ } 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].filter(cl => cl.startsWith('bi-')) document.querySelectorAll('[data-bs-theme-value]').forEach(element => { element.classList.remove('active') @@ -46,8 +46,9 @@ btnToActive.classList.add('active') btnToActive.setAttribute('aria-pressed', 'true') - activeThemeIcon.setAttribute('href', svgOfActiveBtn) - const themeSwitcherLabel = `${themeSwitcherText.textContent} (${btnToActive.dataset.bsThemeValue})` + const [currentIconOfActiveBtn] = [...activeThemeIcon.classList].filter(cl => cl.startsWith('bi-')) + activeThemeIcon.classList.replace(currentIconOfActiveBtn, initialIconOfActiveBtn) + const themeSwitcherLabel = `${themeSwitcherText.textContent} (${btnToActive.parentElement.dataset.bsThemeValue})` themeSwitcher.setAttribute('aria-label', themeSwitcherLabel) if (focus) { diff --git a/docs/layouts/partials/icons/github.svg b/docs/layouts/partials/icons/github.svg deleted file mode 100644 index 6f06f7722b..0000000000 --- a/docs/layouts/partials/icons/github.svg +++ /dev/null @@ -1 +0,0 @@ -{{ with .title }}{{ . }}{{ else }}GitHub{{ end }} \ No newline at end of file diff --git a/docs/layouts/partials/icons/opencollective.svg b/docs/layouts/partials/icons/opencollective.svg deleted file mode 100644 index 2896ba50ce..0000000000 --- a/docs/layouts/partials/icons/opencollective.svg +++ /dev/null @@ -1 +0,0 @@ -{{ with .title }}{{ . }}{{ else }}Open Collective{{ end }} \ No newline at end of file diff --git a/docs/layouts/partials/icons/twitter.svg b/docs/layouts/partials/icons/twitter.svg deleted file mode 100644 index 7a7fcee28b..0000000000 --- a/docs/layouts/partials/icons/twitter.svg +++ /dev/null @@ -1 +0,0 @@ -{{ with .title }}{{ . }}{{ else }}Twitter{{ end }} \ No newline at end of file diff --git a/docs/layouts/partials/navbar.html b/docs/layouts/partials/navbar.html index fbfd2d3c95..18dffc21bc 100644 --- a/docs/layouts/partials/navbar.html +++ b/docs/layouts/partials/navbar.html @@ -41,19 +41,19 @@
Bootstrap
@@ -64,20 +64,6 @@
Bootstrap