Skip to content

Commit fb40ee2

Browse files
darkmode
1 parent 192c4f5 commit fb40ee2

File tree

1 file changed

+106
-14
lines changed

1 file changed

+106
-14
lines changed

index.html

+106-14
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,49 @@
1212
--text-color: #1a2634;
1313
--subtle-color: #6c7a89;
1414
--grid-color: rgba(0, 0, 0, 0.06);
15+
--container-bg: white;
16+
--link-hover: #2d3e50;
17+
}
18+
19+
@media (prefers-color-scheme: dark) {
20+
:root {
21+
--primary-color: #e1e1e1;
22+
--accent-color: #a8b9cc;
23+
--background-color: #1a1a1a;
24+
--text-color: #e1e1e1;
25+
--subtle-color: #888;
26+
--grid-color: rgba(255, 255, 255, 0.06);
27+
--container-bg: #1a1a1a;
28+
--link-hover: #a8b9cc;
29+
}
30+
}
31+
32+
/* Light theme (default) */
33+
:root[data-theme="light"] {
34+
--primary-color: #1a2634;
35+
--accent-color: #2d3e50;
36+
--background-color: #f8f9fa;
37+
--text-color: #1a2634;
38+
--subtle-color: #6c7a89;
39+
--grid-color: rgba(0, 0, 0, 0.06);
40+
--container-bg: white;
41+
--link-hover: #2d3e50;
42+
}
43+
44+
/* Dark theme */
45+
:root[data-theme="dark"] {
46+
--primary-color: #e1e1e1;
47+
--accent-color: #a8b9cc;
48+
--background-color: #1a1a1a;
49+
--text-color: #e1e1e1;
50+
--subtle-color: #888;
51+
--grid-color: rgba(255, 255, 255, 0.06);
52+
--container-bg: #1a1a1a;
53+
--link-hover: #a8b9cc;
1554
}
1655

1756
body {
18-
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
57+
font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace;
1958
line-height: 1.6;
2059
max-width: 700px;
2160
margin: 40px auto;
@@ -26,21 +65,23 @@
2665
linear-gradient(to right, var(--grid-color) 1px, transparent 1px),
2766
linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
2867
background-size: 16px 16px;
29-
font-size: 15px;
68+
font-size: 14px;
69+
transition: color 0.3s ease, background-color 0.3s ease;
3070
}
3171

3272
.container {
33-
background: white;
73+
background: var(--container-bg);
3474
padding: 40px;
3575
box-shadow: 0 0 40px rgba(0, 0, 0, 0.05);
36-
border: 1px solid rgba(0, 0, 0, 0.12);
76+
border: 1px solid var(--grid-color);
77+
transition: background-color 0.3s ease, border-color 0.3s ease;
3778
}
3879

3980
@media (max-width: 600px) {
4081
body {
4182
margin: 0;
4283
padding: 0;
43-
background: white;
84+
background: var(--container-bg);
4485
}
4586
.container {
4687
padding: 20px;
@@ -67,6 +108,7 @@
67108
border-bottom: 1px solid var(--grid-color);
68109
padding-bottom: 0.3em;
69110
margin-top: 1.5em;
111+
transition: border-color 0.3s ease;
70112
}
71113

72114
.company {
@@ -95,7 +137,7 @@
95137
}
96138

97139
.links a:hover {
98-
color: var(--accent-color);
140+
color: var(--link-hover);
99141
}
100142

101143
.content a, .company a {
@@ -106,7 +148,7 @@
106148
}
107149

108150
.content a:hover, .company a:hover {
109-
color: var(--accent-color);
151+
color: var(--link-hover);
110152
}
111153

112154
.tooltip {
@@ -115,7 +157,7 @@
115157
top: 50%;
116158
transform: translate(-50%, -50%);
117159
background: var(--accent-color);
118-
color: white;
160+
color: var(--container-bg);
119161
padding: 8px 16px;
120162
border-radius: 3px;
121163
font-size: 13px;
@@ -126,14 +168,26 @@
126168
white-space: nowrap;
127169
}
128170

171+
.footer {
172+
display: flex;
173+
justify-content: space-between;
174+
align-items: center;
175+
margin-top: 40px;
176+
border-top: 1px solid var(--grid-color);
177+
padding-top: 20px;
178+
transition: border-color 0.3s ease;
179+
}
180+
129181
.last-updated {
130182
color: var(--subtle-color);
131183
font-size: 0.9em;
132-
margin-top: 40px;
133-
text-align: right;
134184
font-style: italic;
135-
border-top: 1px solid var(--grid-color);
136-
padding-top: 20px;
185+
}
186+
187+
.theme-toggle {
188+
cursor: pointer;
189+
user-select: none;
190+
font-size: 1.2em;
137191
}
138192

139193
p {
@@ -172,13 +226,16 @@ <h2>Links</h2>
172226
<div><a href="resume.pdf" target="_blank">📄 Resume</a></div>
173227
</div>
174228

175-
<div class="last-updated">Last Updated: November 2024</div>
229+
<div class="footer">
230+
<div class="last-updated">Last Updated: November 2024</div>
231+
<div class="theme-toggle">☀️</div>
232+
</div>
176233
</div>
177234

178235
<div class="tooltip" id="tooltip">Copied to clipboard!</div>
179236

180237
<script>
181-
// Only handle clipboard for email
238+
// Email clipboard functionality
182239
document.querySelectorAll('a[data-clipboard]').forEach(link => {
183240
link.addEventListener('click', (e) => {
184241
e.preventDefault();
@@ -194,6 +251,41 @@ <h2>Links</h2>
194251
}, 1000);
195252
});
196253
});
254+
255+
// Theme toggle
256+
const themeToggle = document.querySelector('.theme-toggle');
257+
const root = document.documentElement;
258+
259+
// Function to check if system is in dark mode
260+
const systemPrefersDark = () =>
261+
window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
262+
263+
// Function to set theme
264+
const setTheme = (isDark) => {
265+
if (isDark) {
266+
root.setAttribute('data-theme', 'dark');
267+
themeToggle.textContent = '🌙';
268+
localStorage.setItem('theme', 'dark');
269+
} else {
270+
root.setAttribute('data-theme', 'light');
271+
themeToggle.textContent = '☀️';
272+
localStorage.setItem('theme', 'light');
273+
}
274+
};
275+
276+
// Initialize theme based on localStorage or system preference
277+
const storedTheme = localStorage.getItem('theme');
278+
if (storedTheme) {
279+
setTheme(storedTheme === 'dark');
280+
} else {
281+
setTheme(systemPrefersDark());
282+
}
283+
284+
// Toggle theme on click
285+
themeToggle.addEventListener('click', () => {
286+
const isDark = root.getAttribute('data-theme') === 'dark';
287+
setTheme(!isDark);
288+
});
197289
</script>
198290
</body>
199291
</html>

0 commit comments

Comments
 (0)