Skip to content

Commit 232953f

Browse files
committed
Added the abilitiy to toggle the theme
1 parent 1d0dbc9 commit 232953f

10 files changed

+201
-74
lines changed

about.css

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
1+
:root {
2+
--bg-color: black;
3+
--font-color: white;
4+
}
5+
.lightMode {
6+
--bg-color: white;
7+
--font-color: black;
8+
}
19
nav {
210
color: white;
311
background-color: black;
412
}
513

614
#para {
715
text-align: center;
8-
color: black;
16+
color: var(--font-color);
917
}
1018
body {
11-
background-color: white;
19+
background-color: var(--bg-color);
1220
font-family: "Righteous", cursive;
1321
}
1422
h1 {
15-
color: black;
23+
color: var(--font-color);
1624
text-align: center;
1725
margin-top: 90px;
1826
margin-bottom: 40px;
@@ -38,6 +46,7 @@ h1 {
3846

3947
.itemNav {
4048
padding: 15px;
49+
cursor: pointer;
4150
}
4251
.about-title {
4352
padding-top: 6%;

about.html

+6-2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
<li class="nav-item itemNav">
5252
<a class="nav-link" href="about.html">About</a>
5353
</li>
54+
<li class="nav-item itemNav">
55+
<p class="nav-link" id="toggle">🌞</p>
56+
</li>
5457
</ul>
5558
</div>
5659
</nav>
@@ -145,9 +148,10 @@ <h5 class="card-title">
145148
crossorigin="anonymous"
146149
></script>
147150
<script>
148-
$('.navbar-nav>li>a').on('click', function() {
149-
$('.navbar-collapse').collapse('hide');
151+
$(".navbar-nav>li>a").on("click", function () {
152+
$(".navbar-collapse").collapse("hide");
150153
});
151154
</script>
155+
<script src="about.js"></script>
152156
</body>
153157
</html>

about.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const toggle = document.querySelector("#toggle");
2+
toggle.addEventListener("click", modeSwitch);
3+
4+
let isLight = true;
5+
6+
function modeSwitch() {
7+
isLight = !isLight;
8+
let root = document.body;
9+
10+
isLight ? (toggle.innerText = "🌞") : (toggle.innerText = "🌚");
11+
12+
root.classList.toggle("lightMode");
13+
}

icons/grid-large.png

-1.77 KB
Binary file not shown.

icons/grid-large.svg

+53
Loading

icons/grid-small.png

-1.37 KB
Binary file not shown.

icons/grid-small.svg

+18
Loading

index.css

+32-23
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1+
:root {
2+
--bg-color: black;
3+
--font-color: white;
4+
}
5+
.lightMode {
6+
--bg-color: white;
7+
--font-color: black;
8+
}
19
html {
210
scroll-behavior: smooth;
311
}
412
body {
5-
color: black;
13+
color: var(--font-color);
14+
background-color: var(--bg-color);
615
font-family: "Righteous", cursive;
716
}
8-
17+
button {
18+
color: var(--font-color);
19+
}
920
#header {
1021
background: url("https://www.wallpaperup.com/uploads/wallpapers/2015/10/27/825565/a8f967ede1e1e41abc91787415e3b9ee.jpg");
1122

@@ -19,26 +30,27 @@ body {
1930
}
2031

2132
/* scale-animation-by-sudo-nick16 */
22-
.card{
33+
.card {
2334
transition: transform 0.2s;
2435
}
2536
.card:hover {
26-
transform: scale(1.05)
37+
transform: scale(1.05);
2738
}
2839

2940
.backToTop {
3041
margin-left: 49%;
3142

32-
color: #000000;
43+
color: var(--font-color);
3344
padding: 0.6%;
3445
border-radius: 50%;
3546
margin-bottom: 4%;
3647
}
3748
.card {
49+
background-color: var(--bg-color);
3850
height: 100%;
39-
-webkit-box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.25);
40-
-moz-box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.25);
41-
box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.25);
51+
-webkit-box-shadow: 0px 0px 20px 0px rgba(255, 255, 255, 0.25);
52+
-moz-box-shadow: 0px 0px 20px 0px rgba(255, 255, 255, 0.25);
53+
box-shadow: 0px 0px 20px 0px rgba(255, 255, 255, 0.25);
4254
}
4355
.card-body.hidden {
4456
display: none;
@@ -47,7 +59,7 @@ body {
4759
padding: 2rem;
4860
}
4961

50-
.btn-sm {
62+
.btn-sm {
5163
width: 100%;
5264
font-size: 15px;
5365
}
@@ -56,6 +68,7 @@ body {
5668
}
5769
.fas fa-chevron-down fa-6x gallery-icon {
5870
padding-top: 100px;
71+
color: var(--font-color);
5972
}
6073

6174
.gallery-head {
@@ -66,20 +79,21 @@ body {
6679
text-transform: uppercase;
6780
}
6881
.gallery-icon {
69-
color: #000000;
82+
color: var(--font-color);
7083
text-align: center;
7184
}
7285
.itemNav {
7386
padding: 15px;
87+
cursor: pointer;
7488
}
7589
.jumbotron {
7690
border-radius: 0;
7791
}
78-
.info{
92+
.info {
7993
display: flex;
8094
width: 100%;
8195
justify-content: center;
82-
align-items:center;
96+
align-items: center;
8397
flex-direction: column;
8498
}
8599
.lead {
@@ -88,21 +102,20 @@ body {
88102
.search-bar {
89103
justify-content: center;
90104
}
91-
92105
.search-button {
93106
max-height: 38px;
107+
margin-left: 10px;
94108
}
95109

96110
.navbar {
97111
background-color: black;
98-
color: white;
99112
}
100113
.navbar ~ * {
101114
position: relative;
102115
top: 4.45rem;
103116
}
104117
.navTitle {
105-
color: #ffffff;
118+
color: var(--font-color);
106119
padding-left: 50px;
107120
size: 50px;
108121
}
@@ -117,7 +130,7 @@ body {
117130
margin: 0 10px;
118131
border: 1px solid #dddddd;
119132
border-radius: 3px;
120-
background: #ffffff;
133+
background: var(--bg-color);
121134

122135
display: flex;
123136
align-items: center;
@@ -134,13 +147,12 @@ body {
134147
outline: 1px solid black;
135148
}
136149
@media (max-width: 900px) {
137-
138150
#header {
139151
width: 100%;
140152
}
141-
.info{
153+
.info {
142154
display: flex;
143-
align-items:center;
155+
align-items: center;
144156
justify-content: center;
145157
flex-direction: column;
146158
width: 100%;
@@ -160,17 +172,14 @@ body {
160172
/* #normal-view {
161173
margin-left: 50%;
162174
} */
163-
.view-div{
175+
.view-div {
164176
display: flex;
165177
align-items: center;
166178
justify-content: center;
167179
width: 100%;
168180
}
169181
}
170182

171-
172-
173-
174183
@media only screen and (max-width: 600px) {
175184
.display-3 {
176185
font-size: 4rem;

index.html

+5-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
<li class="nav-item itemNav">
3535
<a class="nav-link" href="about.html">About</a>
3636
</li>
37+
<li class="nav-item itemNav">
38+
<p class="nav-link" id="toggle">🌞</p>
39+
</li>
3740
</ul>
3841
</div>
3942
</nav>
@@ -66,8 +69,8 @@ <h1 class="gallery-head" id="gallery1">Pokémon gallery</h1>
6669
</button>
6770
</div>
6871
<div class="view-div">
69-
<button class="view-button" id="normal-view"><img src="icons/grid-small.png"> Normal</button>
70-
<button class="view-button" id="compact-view"><img src="icons/grid-large.png"> Compact</button>
72+
<button class="view-button" id="normal-view"><img src="icons/grid-small.svg"> Normal</button>
73+
<button class="view-button" id="compact-view"><img src="icons/grid-large.svg"> Compact</button>
7174
</div>
7275
</div>
7376
<section id="gallery">

0 commit comments

Comments
 (0)