Skip to content

Commit

Permalink
Merge pull request #17 from Anushka-Pote/master
Browse files Browse the repository at this point in the history
[FEAT]: Implement Dark and Light Modes for the webpage #13
  • Loading branch information
nitendra2211 authored Oct 23, 2024
2 parents 93c0db5 + aaa29fd commit f90cb6f
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 91 deletions.
44 changes: 14 additions & 30 deletions forgot_password.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,23 @@
}
</style>
</head>
<body>

<div>
<body class="light">

<div class="container light">
<div class="theme-switch">
<label class="theme-switch">
<i class="fa-solid fa-sun" id="sun-icon"></i>
<input type="checkbox" id="theme-toggle">
<span class="slider"></span>
<i class="fa-solid fa-moon" id="moon-icon"></i>
</label>
</div>

<p class="cross">
<i class="fa-solid fa-xmark" style="color: #FFD43B; font-size: xx-large;"></i>
</p>

<h1 class="forgot-password">Forgot Password</h1>
<h1 class="login">Forgot Password</h1>
<br><br>
<p class="para">Verification code will be sent to your email</p>
<br>
Expand All @@ -41,31 +50,6 @@ <h1 class="forgot-password">Forgot Password</h1>
<img src="google-icon-1.png">
</div>
</div>

<script>
function submitEmail() {
const email = document.getElementById('email').value;
if (email) {
// Here, you can add logic to send the email to the backend for verification

// After email submission, show the password input section
document.getElementById('passwordSection').classList.remove('hidden');
document.getElementById('emailSubmit').classList.add('hidden'); // Hide email submit button
} else {
alert('Please enter your email.');
}
}

function submitPassword() {
const password = document.getElementById('password').value;
if (password) {
// Here, you can add logic to handle password submission to the backend
alert('Password submitted!');
} else {
alert('Please enter your password.');
}
}
</script>

<script src="script.js"></script>
</body>
</html>
52 changes: 29 additions & 23 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,36 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css">
</head>
<body>

<div>
<p class="cross"> <i class="fa-solid fa-xmark" style=" color: #FFD43B;
font-size: xx-large;"></i> </p>
<div class="container">
<label class="theme-switch">
<i class="fa-solid fa-sun" id="sun-icon"></i>
<input type="checkbox" id="theme-toggle">
<span class="slider"></span>
<i class="fa-solid fa-moon" id="moon-icon"></i>
</label>

<h1 class="login">
Sign In
</h1>
<br>
<br>
<p class="para">Please enter your username and password</p>
<br>
<input class="input1" type="username" placeholder="Username" required>
<br>
<br>
<br>
<input class="input2" placeholder="Password" type="password" required>
<br>
<p class="para2" >Forgot<span> <a href="forgot_password.html">password?</a></span></p>
<br>
<button class="button" type="submit" >Sign In</button>
<p>Or Sign In with</p>
<img src="google-icon-1.png">
<p class="cross">
<i class="fa-solid fa-xmark" style="color: #FFD43B; font-size: xx-large;"></i>
</p>

<h1 class="login">Sign In</h1>
<br>
<br>
<p class="para">Please enter your username and password</p>
<br>
<input class="input1" type="username" placeholder="Username" required>
<br>
<br>
<br>
<input class="input2" placeholder="Password" type="password" required>
<br>
<p class="para2">Forgot<span> <a href="forgot_password.html">password?</a></span></p>
<br>
<button class="button" type="submit">Sign In</button>
<p>Or Sign In with</p>
<img src="google-icon-1.png">
</div>

<script src="script.js"></script>
</body>
</html>
</html>
57 changes: 57 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const toggleSwitch = document.getElementById('theme-toggle');

toggleSwitch.addEventListener('change', () => {
if (toggleSwitch.checked) {
document.body.classList.add('dark');
document.body.classList.remove('light');
document.querySelector('.container').classList.add('dark');
document.querySelector('.container').classList.remove('light');
} else {
document.body.classList.add('light');
document.body.classList.remove('dark');
document.querySelector('.container').classList.add('light');
document.querySelector('.container').classList.remove('dark');
}
});

// Check the user's preference and apply it
if (localStorage.getItem('theme') === 'dark') {
toggleSwitch.checked = true;
document.body.classList.add('dark');
document.body.classList.remove('light');
document.querySelector('.container').classList.add('dark');
document.querySelector('.container').classList.remove('light');
} else {
document.body.classList.add('light');
document.body.classList.remove('dark');
document.querySelector('.container').classList.add('light');
document.querySelector('.container').classList.remove('dark');
}

// Store the user's preference
toggleSwitch.addEventListener('change', () => {
localStorage.setItem('theme', toggleSwitch.checked ? 'dark' : 'light');
});

function submitEmail() {
const email = document.getElementById('email').value;
if (email) {
// Here, you can add logic to send the email to the backend for verification

// After email submission, show the password input section
document.getElementById('passwordSection').classList.remove('hidden');
document.getElementById('emailSubmit').classList.add('hidden'); // Hide email submit button
} else {
alert('Please enter your email.');
}
}

function submitPassword() {
const password = document.getElementById('password').value;
if (password) {
// Here, you can add logic to handle password submission to the backend
alert('Password submitted!');
} else {
alert('Please enter your password.');
}
}
126 changes: 88 additions & 38 deletions style.css
Original file line number Diff line number Diff line change
@@ -1,67 +1,117 @@
div{
height:650px;
width:400px;
background-color: White;
text-align: center;
color:white;
background-color: black;
body {
background-image: url("mountains.webp");
background-size: cover;
transition: background-color 0.3s ease;
}

body.dark {
background-color: #121212;
color: #ffffff;
}

.container {
height: 650px;
width: 400px;
margin: auto;
border-radius: 2%;
text-align: center;
transition: background-color 0.3s ease, opacity 0.3s ease;
}
body{
background-image: url("mountains.webp");
background-size: cover;

.container.dark {
background-color: black;
color: white;
}

body.light {
background-color: #ffffff;
color: #000000;
}
.login{

.container.light {
background-color: white;
}

.login {
font-size: 40px;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
}
.input1{
font-size:18px;

.input1, .input2 {
font-size: 18px;
text-align: center;
height:50px;
width: 70%;
border-radius: 100px;
border: 3px solid gold;
cursor:pointer;
color: darkgreen;
}
.input2{
font-size:18px;
text-align: center;
height:50px;
height: 50px;
width: 70%;
border-radius: 100px;
border: 3px solid gold;
cursor: pointer;
color: darkgreen;
}
.button{

.button {
height: 40px;
width:40%;
width: 40%;
border-radius: 100px;
font-size: large;
background-color: blue;
color:wheat;
cursor:pointer;
color: wheat;
cursor: pointer;
}
.para2{

.para2 {
text-align: right;
margin-right: 30px;
}
span{
color:blueviolet;

span {
color: blueviolet;
}
.cross{

.cross {
text-align: right;
margin-right: 10px;
}
img{
height:25px;
width:25px;

img {
height: 25px;
width: 25px;
margin-bottom: 2px;
}
.imx{
height:60px;
width:60px;

/* Theme switch styles */
.theme-switch {
position: absolute;
top: 20px;
right: 20px;
display: flex;
align-items: center;
}
.theme-switch input {
display: none;
}
.slider {
cursor: pointer;
height: 24px;
width: 48px;
background-color: #ccc;
border-radius: 50px;
position: relative;
transition: background-color 0.3s;
}
.slider:before {
position: absolute;
content: "";
height: 20px;
width: 20px;
left: 4px;
bottom: 2px;
background-color: white;
border-radius: 50%;
transition: transform 0.3s;
}
input:checked + .slider {
background-color: #4CAF50;
}
input:checked + .slider:before {
transform: translateX(24px);
}

0 comments on commit f90cb6f

Please sign in to comment.