Skip to content
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

feat: Implement Dark Mode Toggle for Additional Web Page #488

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Binary file added Pages/3D-Visualizations/assets/asset 45.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion Pages/3D-Visualizations/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<title>Virtuo Learn</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="media-queries.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="icon" type="image/x-icon" href="../../assets/logo.png">
<script src="https://unpkg.com/scrollreveal"></script>
</head><link
Expand All @@ -15,7 +16,7 @@
/>
<body>
<!-- nav bar -->
<nav>
<nav id="main_navbar">
<div class="container main-navi flex">
<a href="../../index.html" class="company-logo">
<img src="./assets/asset 41.png" alt="company logo">
Expand Down Expand Up @@ -44,6 +45,17 @@
<li><a href="../Doubt Engine/index.html" class="no-underline inline-block text-primary_text_color transition duration-200 ease-out hover:text-accent_color">
<i class="fa-solid fa-check-double" style="font-size:10px;"></i>
Doubt Engine</a></li>
<li>
<div class="switch-container">
<input type="checkbox" id="switch" class="switch-checkbox">
<label for="switch" class="switch-label">
<div class="switch-button">
<span class="material-icons sun-icon">wb_sunny</span>
<span class="material-icons moon-icon">brightness_2</span>
</div>
</label>
</div>
</li>
</ul>
</div>
<div class="hamburger">
Expand Down Expand Up @@ -162,6 +174,7 @@ <h2>Deoxyribonucleic acid(DNA)</h2>
})
</script>
<script src="../../scroll-reveal.js"></script>
<script src="mode-switch.js"></script>

</body>
</html>
136 changes: 136 additions & 0 deletions Pages/3D-Visualizations/mode-switch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
document.addEventListener('DOMContentLoaded', () => {
const switchCheckbox = document.getElementById('switch');
const currentTheme = localStorage.getItem('theme');

function applyDarkModeStyles() {
document.body.classList.remove('light-mode');
document.body.classList.add('dark-mode');
document.body.style.backgroundColor = "#111111";

const nav = document.querySelector("nav");
if (nav) {
nav.style.backgroundColor = "#38373743";
nav.style.backdropFilter = "blur(100px)";
}

const navLinks = document.querySelectorAll('.nav-menu li a');
navLinks.forEach(link => {
link.style.color = '#ffffff';
});

const currentPage = document.querySelector('.current-page');
if (currentPage) {
currentPage.style.color = "#ffffff";
currentPage.style.borderColor = "#6fa8dc";
}

const header = document.querySelector('.header');
if (header) {
header.style.backgroundColor = "#111111";
header.querySelector('.head-txt').style.color = "#ffffff";
}

const cards = document.querySelectorAll('.course');
cards.forEach(card => {
card.style.backgroundColor = "#242426";
card.querySelectorAll('h6, h2').forEach(textElement => {
textElement.style.color = "#ffffff";
});
});

const footer = document.querySelector('footer');
if (footer) {
footer.style.backgroundColor = "#242525";
const footerLogo = footer.querySelector('img');
if (footerLogo) {
footerLogo.src = "./assets/asset 45.png";
}
}

const companyLogo = document.querySelector('.company-logo img');
if (companyLogo) {
companyLogo.style.filter = "invert(100%)";
companyLogo.src = "./assets/asset 45.png";
}
}

function applyLightModeStyles() {
document.body.classList.remove('dark-mode');
document.body.classList.add('light-mode');
document.body.style.backgroundColor = "#ffffff";

const nav = document.querySelector("nav");
if (nav) {
nav.style.backgroundColor = "#ffffff";
}

const navLinks = document.querySelectorAll('.nav-menu li a');
navLinks.forEach(link => {
link.style.color = 'rgb(33, 28, 28)';
});

const currentPage = document.querySelector('.current-page');
if (currentPage) {
currentPage.style.color = "#4d006b";
currentPage.style.borderColor = "rgb(0, 30, 94)";
}

const header = document.querySelector('.header');
if (header) {
header.style.backgroundColor = "#ffffff";
header.querySelector('.head-txt').style.color = "#183b56";
}

const cards = document.querySelectorAll('.course');
cards.forEach(card => {
card.style.backgroundColor = "#e9ebff";
card.querySelectorAll('h6, h2').forEach(textElement => {
textElement.style.color = "#183b56";
});
});

const footer = document.querySelector('footer');
if (footer) {
footer.style.backgroundColor = "#ebf2fa";
const footerLogo = footer.querySelector('img');
if (footerLogo) {
footerLogo.src = "./assets/asset 41.png";
}
}

const companyLogo = document.querySelector('.company-logo img');
if (companyLogo) {
companyLogo.style.filter = "none";
companyLogo.src = "./assets/asset 41.png";
}

const courseHeaders = document.querySelectorAll('.course h6');
courseHeaders.forEach(header => {
header.style.color = "#ffffff"; // Change text color to white
});

const courseHeaders2 = document.querySelectorAll('.course-preview h2');
courseHeaders2.forEach(header => {
header.style.color = "#ffffff"; // Change text color to white
});
}

if (currentTheme) {
if (currentTheme === 'dark-mode') {
applyDarkModeStyles();
switchCheckbox.checked = true;
} else {
applyLightModeStyles();
}
}

switchCheckbox.addEventListener('change', () => {
if (switchCheckbox.checked) {
applyDarkModeStyles();
localStorage.setItem('theme', 'dark-mode');
} else {
applyLightModeStyles();
localStorage.setItem('theme', 'light-mode');
}
});
});
109 changes: 109 additions & 0 deletions Pages/3D-Visualizations/style.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,96 @@
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500&family=Roboto:wght@400;700&display=swap');

/* Switch Container */
.switch-container {
position: absolute;
transform: translate(-50%, -50%);
display: flex;
align-items: center;
justify-content: center;
}

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

/* Switch Label */
.switch-label {
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;
}

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

.switch-label .sun-icon {
color: #f39c12;
left: 2px;
}

.switch-label .moon-icon {
color: #bdc3c7;
opacity: 0;
left: 5px;
}

/* Switch Button */
.switch-button {
position: absolute;
top: 3px;
left: 3px;
width: 25px;
height: 25px;
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+.switch-label {
background-color: #111111;
}

.switch-checkbox:checked+.switch-label .sun-icon {
opacity: 0;
}

.switch-checkbox:checked+.switch-label .moon-icon {
opacity: 1;
}

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

/* CSS for dark mode */
.dark-mode .nav-menu li a:hover {
color: #2294ed !important;
}

/* CSS for light mode */
.light-mode .nav-menu li a:hover {
color: #2294ed !important;
}

/* resets */


Expand Down Expand Up @@ -142,6 +233,24 @@ ul {

/* nav bar */

#main_navbar {
/* given same padding to top and bottom */
padding-top: 10px;
padding-bottom: 10px;
background-color: rgba(237, 225, 225, 0.144);
/* Adjust the color and opacity as needed */
backdrop-filter: blur(70px);
-webkit-backdrop-filter: blur(50px);
border: 1px solid rgba(236, 235, 255, 0.3);
}

.nav-menu {
display: flex;
align-items: center;
column-gap: 15px;
width: max-content;
}

.main-navi {
margin-top: 20px;
justify-content: space-between;
Expand Down
Binary file added Pages/About-Us/assets/asset 45.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion Pages/About-Us/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<title>Virtuo Learn</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="media-queries.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="icon" type="image/x-icon" href="../../assets/logo.png">
<script src="https://unpkg.com/scrollreveal"></script>
<script src="https://cdn.tailwindcss.com"></script>
Expand Down Expand Up @@ -44,7 +45,7 @@

<body class="text-primary_text_color overflow-x-hidden font-poppins">
<!-- nav bar -->
<nav>
<nav id="main_navbar">
<div
class="container main-navi max-w-[1180px] overflow-hidden m-auto px-[20px] lg:px-[10px] justify-between mt-5 flex items-center">
<a class="no-underline inline-block company-logo" href="../../index.html">
Expand Down Expand Up @@ -81,6 +82,17 @@
class="no-underline inline-block text-primary_text_color transition duration-200 ease-out hover:text-accent_color">
<i class="fa-solid fa-check-double" style="font-size:10px;"></i>
Doubt Engine</a></li>
<li>
<div class="switch-container">
<input type="checkbox" id="switch" class="switch-checkbox">
<label for="switch" class="switch-label">
<div class="switch-button">
<span class="material-icons sun-icon">wb_sunny</span>
<span class="material-icons moon-icon">brightness_2</span>
</div>
</label>
</div>
</li>
</ul>
</div>
<div class="hamburger cursor-pointer">
Expand Down Expand Up @@ -176,6 +188,7 @@ <h1 class="text-[2rem] font-bold text-center mt-[4vh] md:text-[2rem] lg:text-5xl
});
</script>
<script src="../../scroll-reveal.js"></script>
<script src="mode-switch.js"></script>

</body>

Expand Down
Loading
Loading