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

Added light mode feature #1818

Closed
wants to merge 1 commit 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
Binary file added assets/images/grat.avif
Binary file not shown.
10 changes: 9 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<title>CalcDiverse</title>
</head>

<body class="containers" id="home">
<body class="containers light-mode" id="home" >
<div class="circle-container">
<div class="circle"></div>
<div class="circle"></div>
Expand Down Expand Up @@ -76,6 +76,14 @@
<li class="nav-item">
<a href="./assets/contact/contact.html" class="nav-link"><i class="fa fa-phone" aria-hidden="true"></i> Contact</a>
</li>
<div class="theme-switch-wrapper">
<label class="theme-switch" for="checkbox">
<input type="checkbox" id="checkbox" />
<div class="slider round"></div>
</label>
<!-- <em>Enable Dark Mode!</em> -->
</div>


</ul>
<div class="hamburger">
Expand Down
24 changes: 24 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
// dark and light mode

const toggleSwitch = document.querySelector('#checkbox');
const currentTheme = localStorage.getItem('theme') ? localStorage.getItem('theme') : null;

if (currentTheme) {
document.documentElement.setAttribute('data-theme', currentTheme);

if (currentTheme === 'dark') {
toggleSwitch.checked = true;
document.body.classList.add('dark-mode');
}
}

toggleSwitch.addEventListener('change', (e) => {
if (e.target.checked) {
document.body.classList.add('dark-mode');
localStorage.setItem('theme', 'dark');
} else {
document.body.classList.remove('dark-mode');
localStorage.setItem('theme', 'light');
}
});

// Progress Bar
const updateProgress = () => {
const {
Expand Down
135 changes: 135 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,141 @@
background: var(--light);
border-radius: 25px;
}
/* light mode dark mode */
/* styles.css */

.theme-switch-wrapper {
display: flex;
align-items: center;
}

.theme-switch {
display: inline-block;
height: 34px;
position: relative;
width: 60px;
}

.theme-switch input {
display: none;
}

.slider {
background-color: #ccc;
bottom: 0;
cursor: pointer;
left: 0;
position: absolute;
right: 0;
top: 0;
transition: 0.4s;
}

.slider:before {
background-color: #fff;
bottom: 4px;
content: "";
height: 26px;
left: 4px;
position: absolute;
transition: 0.4s;
width: 26px;
}

input:checked + .slider {
background-color: #f493cf;
}

input:checked + .slider:before {
transform: translateX(26px);
}

.slider.round {
border-radius: 34px;
}

.slider.round:before {
border-radius: 50%;
}


/* styles.css */



/* styles.css */

body {
transition: background-color 0.3s, color 0.3s, background-image 0.3s;
justify-content: center;
align-items: center;
min-height: 100vh;
font-size: 1.4rem;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}

/* Light Mode */
.light-mode {
background-color: #ffffff;
color: #000000;
background-image: url(./assets/images/background.jpg);
}

/* Dark Mode */
.dark-mode {
background-color: #121212;
color: #ffffff;
background-image: url(./assets/images/grat.avif);
}

.dark-mode .navbar {
background-color: #f493cf;
box-shadow: 0 20px 16px 0 rgba(240, 161, 227, 0.37);
}
/* .dark-mode .navbar:: hover{
color:#000000
} */
/* .dark-mode
.comp-section .compcontainer h3 {
color: rgb(117, 109, 109);
}
.dark-mode .paragraph {
color: rgb(117, 109, 109);
} */
.dark-mode #progress-bar{
background: linear-gradient(45deg, rgb(97, 189, 229), rgb(212, 22, 208));
}
.dark-mode .circle-container{
color: pink;
}
.dark-mode .comp-section .compcontainer h1 {
/* text-shadow: 2px 2px 10px var(--light); */
}
.dark-mode .circle {
background-color: #b94bcd;
}
.dark-mode .circle::before {
content: "";
position: fixed;
width: 50px;
height: 50px;
opacity: 0.2;
transform: translate(-30%, -30%);
border-radius: 50%;
}
.dark-mode .nav-link:hover {
color: #76076d;
border-top-color: #76076d;
border-bottom-color: #76076d;
}
.dark-mode #active1 {
color: #76076d;
border-top-color: #76076d;
border-bottom-color: #76076d;
}

/* Custom Cursor Css */

Expand Down