-
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Designed the dark logo * Designed the light logo * Specified logo-switcher JS file * Specified the logo-switcher script to be added in the html head * Override webpack css (pydata_sphinx_theme) * Create updateLogo func and a MutationObserver to update the mainLogo src * Specified mainLogo css file
- Loading branch information
1 parent
1921c79
commit cfe80d7
Showing
5 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,25 @@ | ||
document.addEventListener('DOMContentLoaded', () => { | ||
const logos = document.querySelectorAll('.logo__image'); | ||
|
||
logos.forEach(logo => { | ||
if (logo.classList.contains('only-light')) { | ||
logo.src = '_static/logo-light.png'; // Replacing with the light logo | ||
} else if (logo.classList.contains('only-dark')) { | ||
logo.src = '_static/logo-dark.png'; // Replacing with the dark logo | ||
} | ||
}); | ||
|
||
function updateLogo() { | ||
let mainLogo = document.querySelector(".bd-content img:not(.only-dark,.dark-light)"); // Select the image | ||
let isDarkMode = document.documentElement.getAttribute("data-theme") === "dark"; // Check theme | ||
|
||
if (mainLogo) { | ||
mainLogo.src = isDarkMode ? "_static/logo-dark.png" : "_static/logo-light.png"; // Change image source | ||
} | ||
} | ||
|
||
// Listen for attribute changes on <html> that is the root node of the document | ||
const observer = new MutationObserver(updateLogo); | ||
observer.observe(document.documentElement, { attributes: true, attributeFilter: ["data-theme"] }); | ||
updateLogo(); | ||
}); |
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,7 @@ | ||
html[data-theme=dark] .bd-content img:not(.only-dark,.dark-light) { | ||
background: transparent !important; | ||
border-radius: .25rem; | ||
} | ||
html .bd-content img:not(.only-dark,.dark-light){ | ||
padding: 1rem 0; | ||
} |