Skip to content

Commit 1c14aa8

Browse files
committed
added dynamic theme swith to the icons preview
1 parent 829e8d5 commit 1c14aa8

File tree

1 file changed

+97
-34
lines changed

1 file changed

+97
-34
lines changed

api/templates/icon_gallery.html

Lines changed: 97 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,21 @@
1313
crossorigin="anonymous"
1414
></script>
1515
<style>
16-
@import url("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Montserrat:ital,wght@0,100..900;1,100..900&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
16+
@import url("https://fonts.googleapis.com/css2?family=Inter&family=Montserrat&family=Poppins&display=swap");
17+
1718
* {
1819
margin: 0;
1920
padding: 0;
2021
box-sizing: border-box;
2122
}
23+
2224
body {
2325
font-family: system-ui, sans-serif;
2426
background: #092635;
2527
padding: 20px;
2628
color: #ddd;
2729
}
30+
2831
nav {
2932
display: flex;
3033
align-items: center;
@@ -37,24 +40,29 @@
3740
z-index: 100;
3841
width: 100%;
3942
}
43+
4044
nav ul {
4145
display: flex;
4246
align-items: center;
4347
gap: 20px;
4448
list-style: none;
4549
}
50+
4651
nav ul a {
4752
font-size: 1.35rem;
4853
color: #5c8374;
4954
text-decoration: none;
5055
transition: 0.3s ease;
5156
}
57+
5258
nav ul a:hover {
5359
color: #9ec8b9;
5460
}
61+
5562
main {
5663
margin: 100px auto;
5764
}
65+
5866
h1 {
5967
text-align: center;
6068
font-size: 2.75rem;
@@ -65,6 +73,7 @@
6573
animation: fadeInText 0.7s ease forwards;
6674
animation-delay: 0.7s;
6775
}
76+
6877
h2 {
6978
font-family: Poppins, sans-serif;
7079
font-weight: 300;
@@ -75,16 +84,19 @@
7584
animation: fadeInText 0.7s ease forwards;
7685
animation-delay: 0.7s;
7786
}
87+
7888
.section {
7989
margin-top: 40px;
8090
}
91+
8192
.icon-grid {
8293
display: flex;
8394
flex-wrap: wrap;
8495
gap: 16px;
8596
opacity: 0;
8697
animation: fadeInPage 0.8s ease forwards;
8798
}
99+
88100
.icon-container {
89101
width: 100px;
90102
text-align: center;
@@ -98,12 +110,14 @@
98110
background: #1b4242;
99111
transition: 100ms ease-out;
100112
}
113+
101114
.icon-container img:hover {
102115
background: #9ec8b9;
103116
box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
104117
width: 60px;
105118
height: 60px;
106119
}
120+
107121
.label {
108122
font-size: 12px;
109123
margin: 6px 0;
@@ -113,24 +127,48 @@
113127
cursor: pointer;
114128
font-family: Montserrat, sans-serif;
115129
font-weight: 600;
130+
max-width: 100px;
131+
overflow: hidden;
132+
white-space: nowrap;
133+
text-overflow: ellipsis;
116134
}
135+
117136
.footer-links {
118137
margin-top: 30px;
119138
display: flex;
120139
align-items: center;
121140
justify-content: center;
141+
}
122142

123-
a {
124-
font-size: 2rem;
125-
color: #9ec8b9;
126-
}
143+
.footer-links a {
144+
font-size: 2rem;
145+
color: #9ec8b9;
146+
}
147+
148+
button.toggle-btn {
149+
margin: 30px auto;
150+
display: block;
151+
background-color: #1b4242;
152+
color: #9ec8b9;
153+
border: none;
154+
padding: 10px 20px;
155+
font-family: Inter, sans-serif;
156+
font-weight: 500;
157+
border-radius: 12px;
158+
cursor: pointer;
159+
}
160+
161+
button.toggle-btn:hover {
162+
background-color: #5c8374;
163+
color: #fff;
127164
}
128165

129166
@keyframes fadeInText {
130167
to {
131168
opacity: 1;
132169
}
133170
}
171+
134172
@keyframes fadeInPage {
135173
to {
136174
opacity: 1;
@@ -140,12 +178,13 @@
140178
</head>
141179
<body>
142180
<nav>
143-
<span
144-
><img
181+
<span>
182+
<img
145183
src="https://raw.githubusercontent.com/YuheshPandian/ICONIC/refs/heads/main/assets/Banner.svg"
146184
alt="Logo"
147185
width="150px"
148-
/></span>
186+
/>
187+
</span>
149188
<ul>
150189
<li><a href="/">Home</a></li>
151190
<li><a href="/gallery">Gallery</a></li>
@@ -156,41 +195,46 @@
156195
</li>
157196
</ul>
158197
</nav>
198+
159199
<main>
160200
<h1>Icon Gallery</h1>
161201

162-
<div class="section">
163-
<h2>Dark Theme Icons</h2>
164-
<div class="icon-grid">
165-
{% for icon in dark_icons %}
166-
<div class="icon-container">
167-
<img
168-
src="/dark/{{ icon|cut:'.svg' }}"
169-
alt="{{ icon }}"
170-
/>
171-
<div class="label" onclick="copyLabelText(this)">
172-
{{ icon|cut:'.svg' }}
173-
</div>
202+
<button class="toggle-btn" onclick="toggleTheme()">
203+
Toggle Icon Theme
204+
</button>
205+
206+
<div id="icon-section-dark" class="icon-grid">
207+
{% for icon in dark_icons %}
208+
<div class="icon-container">
209+
<img src="/dark/{{ icon|cut:'.svg' }}" alt="{{ icon }}" />
210+
<div class="label" onclick="copyLabelText(this)">
211+
{{ icon|cut:'.svg' }}
174212
</div>
175-
{% endfor %}
176213
</div>
214+
{% endfor %}
177215
</div>
178216

179-
<div class="section">
180-
<h2>Light Theme Icons</h2>
181-
<div class="icon-grid">
182-
{% for icon in light_icons %}
183-
<div class="icon-container">
184-
<img
185-
src="/light/{{ icon|cut:'.svg' }}"
186-
alt="{{ icon }}"
187-
/>
188-
<div class="label" onclick="copyLabelText(this)">
189-
{{ icon|cut:'.svg' }}
190-
</div>
217+
<div
218+
id="icon-section-light"
219+
class="icon-grid"
220+
style="display: none"
221+
>
222+
{% for icon in light_icons %}
223+
<div class="icon-container">
224+
<img
225+
src="/light/{{ icon|cut:'.svg' }}"
226+
alt="{{ icon }}"
227+
style="background: #9ec8b9"
228+
/>
229+
<div
230+
class="label"
231+
onclick="copyLabelText(this)"
232+
style="background: #9ec8b9; color: #092635"
233+
>
234+
{{ icon|cut:'.svg' }}
191235
</div>
192-
{% endfor %}
193236
</div>
237+
{% endfor %}
194238
</div>
195239
</main>
196240

@@ -212,6 +256,25 @@ <h2>Light Theme Icons</h2>
212256
console.error("Failed to copy:", err);
213257
});
214258
}
259+
260+
let isDarkTheme = true;
261+
262+
function toggleTheme() {
263+
const darkSection =
264+
document.getElementById("icon-section-dark");
265+
const lightSection =
266+
document.getElementById("icon-section-light");
267+
268+
if (isDarkTheme) {
269+
darkSection.style.display = "none";
270+
lightSection.style.display = "flex";
271+
} else {
272+
darkSection.style.display = "flex";
273+
lightSection.style.display = "none";
274+
}
275+
276+
isDarkTheme = !isDarkTheme;
277+
}
215278
</script>
216279
</body>
217280
</html>

0 commit comments

Comments
 (0)