Skip to content

Commit e29f5e5

Browse files
committed
Added day night mode;
1 parent 50fd19f commit e29f5e5

File tree

3 files changed

+52
-16
lines changed

3 files changed

+52
-16
lines changed

Clock/bhatshakran/index.html

+2-13
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,14 @@
1111
<body>
1212
<div class="main__wrapper">
1313
<div class="heading">Tim<span>eon</span></div>
14+
<div class="switch">Day</div>
1415
<div class="row">
1516
<div class="three columns left__wrapper">
1617
<div class="menu">
1718
<div class="digital">Digital
18-
<!-- <svg
19-
width="24"
20-
height="24"
21-
viewBox="0 0 24 24"
22-
fill="none"
23-
xmlns="http://www.w3.org/2000/svg"
24-
>
25-
<path
26-
d="M15.0378 6.34317L13.6269 7.76069L16.8972 11.0157L3.29211 11.0293L3.29413 13.0293L16.8619 13.0157L13.6467 16.2459L15.0643 17.6568L20.7079 11.9868L15.0378 6.34317Z"
27-
fill="currentColor"
28-
/>
29-
</svg>-->
3019
</div>
3120
<div class="analog">Analog</div>
32-
<div class="stopwatch">Stopwatch</div>
21+
<!-- <div class="stopwatch">Stopwatch</div> -->
3322
</div>
3423
</div>
3524
<div class="nine columns right__wrapper">

Clock/bhatshakran/main.js

+26
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const analogBtn = document.querySelector(".analog");
77
const stopwatchBtn = document.querySelector(".stopwatch");
88
const digitalClock = document.querySelector(".digital__clock");
99
const analogClock = document.querySelector(".clock");
10+
const switchBtn = document.querySelector(".switch");
1011

1112
function setDate() {
1213
const now = new Date();
@@ -33,10 +34,35 @@ setDate();
3334

3435
digitalBtn.addEventListener("click", () => {
3536
digitalClock.style.display = "block";
37+
digitalBtn.style.color = "#fff";
38+
analogBtn.style.color = "#d5d5d569";
3639
analogClock.style.display = "none";
3740
});
3841

3942
analogBtn.addEventListener("click", () => {
4043
digitalClock.style.display = "none";
44+
analogBtn.style.color = "#fff";
45+
digitalBtn.style.color = "#d5d5d569";
4146
analogClock.style.display = "block";
4247
});
48+
49+
switchBtn.addEventListener("click", () => {
50+
if (
51+
window
52+
.getComputedStyle(document.documentElement)
53+
.getPropertyValue("--main--color") == "#1F441E"
54+
) {
55+
document.documentElement.style.setProperty("--main--color", "black");
56+
document.documentElement.style.setProperty("--primary-color", "#fff");
57+
document.documentElement.style.setProperty(
58+
"--secondary-color",
59+
"lightgrey"
60+
);
61+
switchBtn.textContent = "Night";
62+
} else {
63+
document.documentElement.style.setProperty("--main--color", "#1F441E");
64+
document.documentElement.style.setProperty("--primary-color", "#CEE6B4");
65+
document.documentElement.style.setProperty("--secondary-color", "#9ECCA4");
66+
switchBtn.textContent = "Day";
67+
}
68+
});

Clock/bhatshakran/style.css

+24-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
box-sizing: border-box;
55
}
66
:root{
7-
--main--color:#053742;
8-
--primary-color:#a2dbfa8c;
9-
--secondary-color:#4f808a;
7+
--main--color:#1F441E;
8+
--primary-color:#CEE6B4;
9+
--secondary-color:#9ECCA4;
1010
}
1111
body{
1212
background: var(--main--color);
@@ -30,6 +30,22 @@ span{
3030
font-size: 8rem !important;
3131
}
3232

33+
.switch{
34+
border: 1px solid var(--primary-color);
35+
width: 80px;
36+
text-align: center;
37+
font-family: 'Gill Sans';
38+
font-size: 3rem;
39+
margin-left: 4rem;
40+
color:#fff;
41+
cursor: pointer;
42+
-webkit-user-select: none;
43+
-webkit-touch-callout: none;
44+
-moz-user-select: none;
45+
-ms-user-select: none;
46+
user-select: none;
47+
}
48+
3349
.left__wrapper{
3450
height: 80vh;
3551
position: relative;
@@ -55,6 +71,11 @@ span{
5571

5672
}
5773

74+
75+
.menu .analog{
76+
color: #fff;
77+
}
78+
5879
.menu > div:hover{
5980
color: white;
6081
transition: all 0.25s ease-in-out;

0 commit comments

Comments
 (0)