forked from ietf-tools/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Upgrade bootstrap to 5.3.0 and enable dark mode
Fixes ietf-tools#3365
- Loading branch information
1 parent
6611e31
commit e6710a2
Showing
12 changed files
with
127 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
@import "vanillajs-datepicker/sass/index-bs5"; | ||
@import "bootstrap/scss/functions"; | ||
@import "bootstrap/scss/variables"; | ||
@import "bootstrap/scss/variables-dark"; | ||
@import "bootstrap/scss/maps"; | ||
@import "bootstrap/scss/mixins"; | ||
@import "bootstrap/scss/root"; | ||
|
||
// FIXME: color.scale doesn't seem to work with CSS variables, so avoid those:` | ||
$dp-cell-focus-background-color: $dropdown-link-hover-bg !default; | ||
|
||
@import "vanillajs-datepicker/sass/datepicker-bs5"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
@import "bootstrap/scss/functions"; | ||
@import "bootstrap/scss/variables"; | ||
@import "bootstrap/scss/variables-dark"; | ||
@import "bootstrap/scss/maps"; | ||
@import "bootstrap/scss/mixins"; | ||
@import "bootstrap/scss/root"; | ||
|
||
// FIXME: bs-5.3.0 workaround from https://github.com/apalfrey/select2-bootstrap-5-theme/issues/75s | ||
$s2bs5-clear-icon: str-replace($btn-close-bg, #{$btn-close-color}, #{shade-color(red, 50%)}) !default; | ||
@import "select2/src/scss/core"; | ||
@import "select2-bootstrap-5-theme/src/include-all"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/*! | ||
* Color mode toggler for Bootstrap's docs (https://getbootstrap.com/) | ||
* Copyright 2011-2023 The Bootstrap Authors | ||
* Licensed under the Creative Commons Attribution 3.0 Unported License. | ||
*/ | ||
|
||
(() => { | ||
"use strict"; | ||
|
||
const storedTheme = localStorage.getItem("theme"); | ||
|
||
const getPreferredTheme = () => { | ||
if (storedTheme) { | ||
return storedTheme; | ||
} | ||
|
||
return window.matchMedia("(prefers-color-scheme: dark)").matches | ||
? "dark" | ||
: "light"; | ||
}; | ||
|
||
const setTheme = function (theme) { | ||
if ( | ||
theme === "auto" && | ||
window.matchMedia("(prefers-color-scheme: dark)").matches | ||
) { | ||
document.documentElement.setAttribute("data-bs-theme", "dark"); | ||
} else { | ||
document.documentElement.setAttribute("data-bs-theme", theme); | ||
} | ||
}; | ||
|
||
setTheme(getPreferredTheme()); | ||
|
||
const showActiveTheme = (theme, focus = false) => { | ||
const themeSwitcher = document.querySelector("#bd-theme"); | ||
|
||
if (!themeSwitcher) { | ||
return; | ||
} | ||
|
||
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"); | ||
|
||
document.querySelectorAll("[data-bs-theme-value]").forEach((element) => { | ||
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})`; | ||
themeSwitcher.setAttribute("aria-label", themeSwitcherLabel); | ||
|
||
if (focus) { | ||
themeSwitcher.focus(); | ||
} | ||
}; | ||
|
||
window | ||
.matchMedia("(prefers-color-scheme: dark)") | ||
.addEventListener("change", () => { | ||
if (storedTheme !== "light" || storedTheme !== "dark") { | ||
setTheme(getPreferredTheme()); | ||
} | ||
}); | ||
|
||
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); | ||
setTheme(theme); | ||
showActiveTheme(theme, true); | ||
}); | ||
}); | ||
}); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters