Skip to content

Commit

Permalink
dark mode button improved
Browse files Browse the repository at this point in the history
  • Loading branch information
chaanakyaaM committed Oct 9, 2024
1 parent 2bfe9ac commit 2a36051
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
Binary file added dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<body>
<header>
<p class="title"><a href="#">Dev Profiles</a></p>
<button class="dark-btn"><img id="icon" src="Moon.png" alt="Dark"></img></button>
<button class="dark-btn"><img id="icon" src="dark.png" alt="Dark"></img></button>
</header>


Expand Down
Binary file added light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ var icon=document.getElementById("icon");
darkMode.addEventListener("click", () => {
document.body.classList.toggle("light-background");
if(document.body.classList.contains("light-background")){
icon.src="Sun.png";
icon.style.filter='invert(0%)';
icon.src="light.png";
}else{
icon.src="Moon.png";
icon.style.filter='invert(100%)';
icon.src="dark.png";
}
darkMode.classList.toggle("icon-position")
darkMode.classList.toggle("light-background");
Expand Down
29 changes: 20 additions & 9 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ body {
body,
.title,
h3,
footer,
.dark-btn {
footer{
transition: background-color 500ms ease, color 500ms ease;
}

Expand Down Expand Up @@ -340,21 +339,33 @@ header {
margin-top: 15px;
}

/* Dark Mode - Light mode Button */

.dark-btn {
width: 60px;
height: 60px;
display: flex;
align-items: center;
justify-content: center;
position: absolute;
right: 10px;
top: 10px;
padding: 5px 10px;
right: 10px;
cursor: pointer;
background-color: transparent;
transition: all 500ms;
font-size: 30px;
transition: all 0.3s;
padding: 5px 10px;
border-radius: 50%;
background-color: transparent;
border: 1px solid transparent;
transition: color 500ms ease, color 500ms ease;
}

.dark-btn:hover{
border-radius: 50%;
}

.dark-btn img {
width: 50px;
height: auto;
filter: invert(100%);
height: 30px;
}

.dark-btn #icon:hover {
Expand Down

0 comments on commit 2a36051

Please sign in to comment.