Skip to content

Commit

Permalink
Merge pull request #363 from SafeEHA/new-dark-mode-patch
Browse files Browse the repository at this point in the history
Dark mode feature
  • Loading branch information
metal3-io-bot authored Sep 29, 2023
2 parents 6b168ea + 9938928 commit 80efc9a
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 10 deletions.
9 changes: 4 additions & 5 deletions _includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
<div>
<div class="mk-cncf-footer">
<p>We are a <a href="https://cncf.io/">Cloud Native Computing Foundation</a> sandbox project.</p>
<p><img src="/assets/images/cncf-color.png"/></p>
<p><img id= "cncf-image" src="/assets/images/cncf-color.png"/></p>
<p>Copyright {{ 'now' | date: "%Y" }} The Metal³ Contributors - <a href="/privacy-statement.html">Privacy Statement</a></p>
<p>Copyright {{ 'now' | date: "%Y" }} The Linux Foundation. All Rights Reserved. The Linux Foundation has registered trademarks and uses trademarks. For a list of trademarks of The Linux Foundation, please see our <a href="https://www.linuxfoundation.org/trademark-usage">Trademark Usage</a> page.</p>
</div>
<div class="mk-icons-footer">
<p>
<a href="https://twitter.com/{{ site.twitter_username }}" aria-label="Visit us on Twitter">
Expand All @@ -23,10 +26,6 @@
</a>
</p>
</div>
<p>Copyright {{ 'now' | date: "%Y" }} The Metal³ Contributors - <a href="/privacy-statement.html">Privacy Statement</a></p>
<p>Copyright {{ 'now' | date: "%Y" }} The Linux Foundation. All Rights Reserved. The Linux Foundation has registered trademarks and uses trademarks. For a list of trademarks of The Linux Foundation, please see our <a href="https://www.linuxfoundation.org/trademark-usage">Trademark Usage</a> page.</p>
</div>

</div>
</footer>
</div><!--wrapper-->
Expand Down
112 changes: 111 additions & 1 deletion _includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
</div>
<button type="submit" id = "search-button" class = "search-button" disabled = 'true' >
<img src="../assets//images/search.png" style="height: 20px;" alt="">

</button>
<div id="mode-toggle">
<img src="../assets/images/moon-outline.png" id="mode-icon" style="height: 20px; margin-left: 10px;"/>
</div>
</form>
</li>

Expand Down Expand Up @@ -157,6 +159,114 @@ <h1 class="mk-masthead__content--sub__title">Blog</h1>
});
}
</script>
<script>
document.addEventListener("DOMContentLoaded", function(){
let iconMode = document.getElementById("mode-icon")
let toggleMode = document.getElementById("mode-toggle")
let cncfImage = document.getElementById("cncf-image")
let isToggled = localStorage.getItem("currentMode") === "true";
updateMode();
toggleMode.addEventListener("click", () => {
isToggled = !isToggled;
localStorage.setItem("currentMode", isToggled);
updateMode();
});
function updateMode() {
let mastHead = document.querySelector(".mk-masthead");
let h1 = document.querySelectorAll("h1")
let h2 = document.querySelectorAll("h2")
let h3 = document.querySelectorAll("h3")
let li = document.querySelectorAll("li")
let sections = document.querySelectorAll(".mk-main__section")
let body = document.querySelector("body")
let whyCards = document.querySelectorAll(".mk-why-baremetal__card")
let blogCards = document.querySelectorAll(".mk-blog-meta__card")
let questions = document.querySelectorAll(".mk-faqs__question")
let subHeadings = document.querySelectorAll(".mk-sub-heading")
let p = document.querySelectorAll("p")
if (isToggled) {

iconMode.src = "../assets/images/moon-outline.png";
cncfImage.src = "../assets/images/cncf-white.svg";
mastHead.style.backgroundColor = "var(--mk--BackgroundColor--500)";
body.style.backgroundColor = "var(--mk--BackgroundColor--500)";
body.style.color = "var(--mk--Color--200)";
h1.forEach((eachH1)=>{
eachH1.style.color = "var(--mk--Color--200)"
})
h2.forEach((eachH2)=>{
eachH2.style.color = "var(--mk--Color--200)"
})
h3.forEach((eachH3)=>{
eachH3.style.color = "var(--mk--Color--200)"
})
li.forEach((eachLi)=>{
eachLi.style.color = "var(--mk--Color--200)"
})
sections.forEach((section)=>{
section.style.backgroundColor = "var(--mk--BackgroundColor--500)";
})
p.forEach((eachP)=>{
eachP.style.color = "var(--mk--Color--200)"
})
whyCards.forEach((whyCard)=>{
whyCard.querySelector("h3").style.color = "var(--mk--BackgroundColor--150)"
whyCard.style.backgroundColor = "var(--mk--BackgroundColor--175)"
})
blogCards.forEach((blogCard)=>{
blogCard.style.backgroundColor = "var(--mk--color-brand--400)";
})
questions.forEach((question)=>{
question.style.color = "var(--mk--Color--200)"
})
subHeadings.forEach((subHeading)=>{
subHeading.style.color = "var(--mk--Color--500)"
})
} else {
iconMode.src = "../../assets/images/moon.png";
cncfImage.src = "../assets/images/cncf-color.svg";
mastHead.style.backgroundColor = "";
body.style.backgroundColor = "";
body.style.color = "var(--mk--Color--400)";


h1.forEach((eachH1)=>{
eachH1.style.color = ""
})
h2.forEach((eachH2)=>{
eachH2.style.color = ""
})
h3.forEach((eachH3)=>{
eachH3.style.color = ""
})
sections.forEach((section)=>{
section.style.backgroundColor = "var(--mk--BackgroundColor--250)";
})
li.forEach((eachLi)=>{
eachLi.style.color = ""
})
p.forEach((eachP)=>{
eachP.style.color = ""
})
whyCards.forEach((whyCard)=>{
whyCard.querySelector("h3").style.color = ""
whyCard.style.backgroundColor = "white"
})
blogCards.forEach((blogCard)=>{
blogCard.style.backgroundColor = ""
})
questions.forEach((question)=>{
question.style.color = ""
})
subHeadings.forEach((subHeading)=>{
subHeading.style.color = "var(--mk--Color--500)"
})


}
}
})
</script>
<script>
var mykeywords = [{% for tag in site.categories %}"{{ tag[0] }}", {% endfor %}]
autocomplete(document.getElementById("search-input"), mykeywords);
Expand Down
5 changes: 4 additions & 1 deletion _sass/_footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
width: 100%;
}
}

#cncf-image{
width: 40%;
height: 40%;
}
.fa-lg {
font-size:60px ;
padding:5px ;
Expand Down
1 change: 1 addition & 0 deletions assets/images/cncf-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/moon-outline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/moon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions assets/images/sprite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 80efc9a

Please sign in to comment.