Skip to content

Commit

Permalink
fixed breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Gadorek committed Jan 8, 2025
1 parent 8b0e7a8 commit 0f71b90
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v2
with:
mdbook-version: "latest"
mdbook-version: "0.4.43"

- name: Setup Pages
uses: actions/configure-pages@v4
Expand Down
2 changes: 2 additions & 0 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ language = "en"
multilingual = false
src = "src"
title = "ESP-docs mdbook theme"
description = "https://espressif.github.io/esp-docs-mdbook/"


[build]
Expand All @@ -17,3 +18,4 @@ smart-punctuation = true
git-repository-url="https://github.com/espressif/esp-docs-mdbook"
copy-theme = true
additional-files = ["theme"]
site-url = "/esp-docs-mdbook/"
124 changes: 63 additions & 61 deletions theme/book.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ function playground_text(playground, hidden = true) {

function get_theme() {
var theme;
return theme;
try {
theme = localStorage.getItem("mdbook-theme");
} catch (e) {}
Expand All @@ -361,6 +362,7 @@ function playground_text(playground, hidden = true) {
}

function set_theme(theme, store = true) {
return;
let ace_theme;

if (theme == "coal" || theme == "navy") {
Expand Down Expand Up @@ -411,36 +413,36 @@ function playground_text(playground, hidden = true) {

set_theme(theme, false);

themeToggleButton.addEventListener("click", function () {
if (themePopup.style.display === "block") {
hideThemes();
} else {
showThemes();
}
});
// themeToggleButton.addEventListener("click", function () {
// if (themePopup.style.display === "block") {
// hideThemes();
// } else {
// showThemes();
// }
// });

themePopup.addEventListener("click", function (e) {
var theme;
if (e.target.className === "theme") {
theme = e.target.id;
} else if (e.target.parentElement.className === "theme") {
theme = e.target.parentElement.id;
} else {
return;
}
set_theme(theme);
});
// themePopup.addEventListener("click", function (e) {
// var theme;
// if (e.target.className === "theme") {
// theme = e.target.id;
// } else if (e.target.parentElement.className === "theme") {
// theme = e.target.parentElement.id;
// } else {
// return;
// }
// set_theme(theme);
// });

themePopup.addEventListener("focusout", function (e) {
// e.relatedTarget is null in Safari and Firefox on macOS (see workaround below)
if (
!!e.relatedTarget &&
!themeToggleButton.contains(e.relatedTarget) &&
!themePopup.contains(e.relatedTarget)
) {
hideThemes();
}
});
// themePopup.addEventListener("focusout", function (e) {
// // e.relatedTarget is null in Safari and Firefox on macOS (see workaround below)
// if (
// !!e.relatedTarget &&
// !themeToggleButton.contains(e.relatedTarget) &&
// !themePopup.contains(e.relatedTarget)
// ) {
// hideThemes();
// }
// });

// Should not be needed, but it works around an issue on macOS & iOS: https://github.com/rust-lang/mdBook/issues/628
document.addEventListener("click", function (e) {
Expand Down Expand Up @@ -527,28 +529,28 @@ function playground_text(playground, hidden = true) {
}

// Toggle sidebar
sidebarToggleButton.addEventListener("click", function sidebarToggle() {
if (body.classList.contains("sidebar-hidden")) {
var current_width = parseInt(
document.documentElement.style.getPropertyValue("--sidebar-width"),
10
);
if (current_width < 150) {
document.documentElement.style.setProperty("--sidebar-width", "150px");
}
showSidebar();
} else if (body.classList.contains("sidebar-visible")) {
hideSidebar();
} else {
if (getComputedStyle(sidebar)["transform"] === "none") {
hideSidebar();
} else {
showSidebar();
}
}
});
// sidebarToggleButton.addEventListener("click", function sidebarToggle() {
// if (body.classList.contains("sidebar-hidden")) {
// var current_width = parseInt(
// document.documentElement.style.getPropertyValue("--sidebar-width"),
// 10
// );
// if (current_width < 150) {
// document.documentElement.style.setProperty("--sidebar-width", "150px");
// }
// showSidebar();
// } else if (body.classList.contains("sidebar-visible")) {
// hideSidebar();
// } else {
// if (getComputedStyle(sidebar)["transform"] === "none") {
// hideSidebar();
// } else {
// showSidebar();
// }
// }
// });

sidebarResizeHandle.addEventListener("mousedown", initResize, false);
// sidebarResizeHandle.addEventListener("mousedown", initResize, false);

function initResize(e) {
window.addEventListener("mousemove", resize, false);
Expand Down Expand Up @@ -692,9 +694,9 @@ function playground_text(playground, hidden = true) {
(function scrollToTop() {
var menuTitle = document.querySelector(".menu-title");

menuTitle.addEventListener("click", function () {
document.scrollingElement.scrollTo({ top: 0, behavior: "smooth" });
});
// menuTitle.addEventListener("click", function () {
// document.scrollingElement.scrollTo({ top: 0, behavior: "smooth" });
// });
})();

(function controllMenu() {
Expand All @@ -703,12 +705,12 @@ function playground_text(playground, hidden = true) {
(function controllPosition() {
var scrollTop = document.scrollingElement.scrollTop;
var prevScrollTop = scrollTop;
var minMenuY = -menu.clientHeight - 50;
// var minMenuY = -menu.clientHeight - 50;
// When the script loads, the page can be at any scroll (e.g. if you reforesh it).
menu.style.top = scrollTop + "px";
// menu.style.top = scrollTop + "px";
// Same as parseInt(menu.style.top.slice(0, -2), but faster
var topCache = menu.style.top.slice(0, -2);
menu.classList.remove("sticky");
// var topCache = menu.style.top.slice(0, -2);
// menu.classList.remove("sticky");
var stickyCache = false; // Same as menu.classList.contains('sticky'), but faster
document.addEventListener(
"scroll",
Expand Down Expand Up @@ -749,11 +751,11 @@ function playground_text(playground, hidden = true) {
})();
(function controllBorder() {
function updateBorder() {
if (menu.offsetTop === 0) {
menu.classList.remove("bordered");
} else {
menu.classList.add("bordered");
}
// if (menu.offsetTop === 0) {
// menu.classList.remove("bordered");
// } else {
// menu.classList.add("bordered");
// }
}
updateBorder();
document.addEventListener("scroll", updateBorder, { passive: true });
Expand Down
7 changes: 6 additions & 1 deletion theme/css/general.css
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ h1:visited,
h2:visited {
margin-top: 0;
color: #333;
text-decoration: none;
}

h1 a,
h2 a {
text-decoration: none;
}

.requirements-list {
Expand Down Expand Up @@ -145,7 +151,6 @@ h2:visited {
}
.main-content a {
color: #404040;
text-decoration: none; /* Optional: to remove underline from links */
}

.main-content a:hover {
Expand Down
Loading

0 comments on commit 0f71b90

Please sign in to comment.