Skip to content

Added Mode Toggler #572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Images/moon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions Images/sun.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
115 changes: 108 additions & 7 deletions home.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<body>
<button id="goTopBtn" title="Go to top"><i class="uil uil-arrow-up"></i></button>
<!--Navigation Bar-->
<nav class="fixed-top">
<nav class="fixed-top" style="width: 100vw;">

<h1 id="home">CSEdge</h1>
<div class="navbar-ham-switch">
Expand All @@ -68,15 +68,116 @@ <h1 id="home">CSEdge</h1>
<!-- <li class="navitem"><a href="https://learn.csedge.courses"><i class="fas fa-blog navbar-icons"></i> Blog</a></li>-->
<li class="navitem"><a href="index.html"><i class="fas fa-blog navbar-icons"></i> Blog</a></li>
<li class="navitem"><a href="#faq"><i class="fas fa-question-circle navbar-icons"></i> FAQ</a></li>
</ul>
<label class="switch">
<input type="checkbox" id="dark-mode-toggle">
<span class="slider round"></span>
</label>
<li class="navitem" id = "ham-mode-toggle-list-item" style="display: none;"><button id ="ham-mode-toggle" onclick="toggleMode()"><i class="fas fa-sun navbar-icons"></i> Toggle Mode</button></li>

<div class="toggle-container" style="top: 0px;">
<input type="checkbox" id="dark-mode-toggle" class="switch-checkbox">
<label class="theme-switch" for="dark-mode-toggle">
<div class="toggle-button">
<span class="light-mode-icon"><img src="./images/sun.svg" style = "display: block;"></span>
<span class="dark-mode-icon"><img src="./images/moon.svg"style = "display: block;"></span>
</div>
</label>
</div>
</ul>




</div>
</nav>

<script>
function toggleMode(){
document.body.classList.toggle('dark-mode');
}
</script>

<style>
.toggle-container {
transform: translate(-50%, -50%);
display: flex;
align-items: center;
justify-content: center;
margin: 30px 0 0 30px;
right: -4px;
top: 15px;
}

.light-mode .toggle-container {
right: 140px;
top: 10px;
}

/* Hidden Checkbox */
.switch-checkbox {
display: none;
}

.theme-switch {
position: relative;
width: 45px;
height: 30px;
background-color: #ccc;
border-radius: 20px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
padding: 0 5px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: background-color 0.5s ease;
}

.theme-switch .light-mode-icon,
.theme-switch .dark-mode-icon {
font-size: 19px;
position: absolute;
cursor: pointer;
top: 50%;
transform: translateY(-50%);
transition: opacity 0.5s ease, color 0.5s ease;
}

.theme-switch .light-mode-icon {
color: #f39c12;
}

.theme-switch .dark-mode-icon {
color: #bdc3c7;
opacity: 0;
}

.toggle-button {
position: absolute;
top: 3px;
left: 3px;
width: 25px;
height: 25px;
background-color: #fff;
border-radius: 50%;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
transition: transform 0.5s ease, background-color 0.5s ease;
}

/* Checkbox Checked State */
.switch-checkbox:checked + .theme-switch {
background-color: #34495e;
}

.switch-checkbox:checked + .theme-switch .light-mode-icon {
opacity: 0;
}

.switch-checkbox:checked + .theme-switch .dark-mode-icon {
opacity: 1;
}

.switch-checkbox:checked + .theme-switch .toggle-button {
transform: translateX(13px);
/* background-color: #34495e; */
}

</style>

<!--Hero Section-->

Expand Down
33 changes: 30 additions & 3 deletions navbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,29 @@ nav ul li a:hover::after {

}


/* Width at which Toggle Mode will go inside Hamburger */
@media screen and (max-width: 1100px) {

#ham-mode-toggle-list-item {
display: inline !important;
}

.navbar-ham-switch .toggle-container {
display: none;
}
}

/* Width at which hamburger will be made */

@media screen and (max-width: 1100px) {

#ham-mode-toggle {
border: none;
background-color: transparent;
cursor: pointer;
}

nav img {
display: inline-block;
padding-right: 15px;
Expand All @@ -176,21 +198,26 @@ nav ul li a:hover::after {
flex-direction: column;
text-align: center;
transition: left 0.3s ease;
justify-content: space-evenly;
}

nav ul .navitem {
margin: inherit;
}

nav ul.show {
left: 0;
}

nav ul li {
margin: 30px 0;
margin: 20px 0;
}

nav img {
nav img {
display: block;
}

nav ul a {
nav ul a, #ham-mode-toggle {
color: #000000;
font-size: 20px;
}
Expand Down