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 my dark-light theme project #692

Open
wants to merge 1 commit into
base: master
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added Dark-Mode.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Light-Mode.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dark Mode</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="style.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="script.js" defer></script>

<script src=
"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.0/jquery.min.js">
</script>

</head>

<body>
<div class="mode">
Dark mode:
<span class="change">OFF</span>
</div>

<div>
<h1>Contribution Project</h1>
<p><i>A Contribution Project for Developers</i></p>

<h3>Light and Dark Mode</h3>
<div>
<img src="Light-Mode.png" id="lightImage" alt="Light-Mode">
</div>
<p>
Click on the switch on top-right
to move to dark mode.
</p>

</div>

</body>
</html>

<!-- https://www.geeksforgeeks.org/how-to-create-dark-light-mode-for-website-using-javascript-jquery/ -->
1 change: 1 addition & 0 deletions javascript20-projects
Submodule javascript20-projects added at 6f28e5
1 change: 1 addition & 0 deletions light-dark-mode
Submodule light-dark-mode added at 79e8a2
39 changes: 39 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
$( ".change" ).on("click", function()
{
if ( $( "body" ).hasClass( "dark" ))
{
$( "body" ).removeClass( "dark" );
$( ".change" ).text( "OFF" );
}
else
{
$( "body" ).addClass( "dark" );
$( ".change" ).text( "ON" );
}
if (lightImage.getAttribute('src') === "Light-Mode.png")
{
lightImage.setAttribute('src', "Dark-Mode.png");
lightImage.addClass("img-toggle");
}
else
{
lightImage.setAttribute('src', "Light-Mode.png");
}
});

/*
let lightImage = document.getElementById("lightImage");
let change = document.getElementById("change");

function changeToDark()
{
if (lightImage.getAttribute('src') === "Light-Mode.png")
{
lightImage.setAttribute('src', "Dark-Mode.png");
}
else
{
lightImage.setAttribute('src', "Light-Mode.png");
}
}
*/
37 changes: 37 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
body{
padding: 10% 3% 10% 3%;
text-align: center;
}

img {
height: 100%;
width: 100%;
object-fit: cover;
}

.img-toggle {
height: 140px;
width: 140px;
}

h1 {
color: #E67451;
}

.mode {
float: right;
}

.change {
cursor: pointer;
border: 1px solid #555;
border-radius: 40%;
width: 20px;
text-align: center;
padding: 5px;
margin-left: 8px;
}
.dark {
background-color: #222;
color: #e6e6e6;
}