Skip to content

Commit 5f69956

Browse files
authored
Merge pull request #6 from vin-im/main
Update index.html
2 parents c22a750 + 59df087 commit 5f69956

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

public/index.html

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html lang="en" class="light">
2+
<html lang="en" class="dark">
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -79,10 +79,8 @@
7979
<div class="container mx-auto px-4 py-8">
8080
<div class="flex justify-center items-center mb-8 relative">
8181
<h1 class="text-4xl font-bold text-gray-800">DumbWhois</h1>
82-
<button onclick="toggleDarkMode()" class="absolute right-0 p-2 rounded-lg bg-gray-200 dark:bg-gray-700">
83-
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
84-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" />
85-
</svg>
82+
<button onclick="toggleDarkMode()" class="absolute right-0 p-2 rounded-lg text-gray-800 dark:text-gray-200">
83+
<span id="themeIcon"></span>
8684
</button>
8785
</div>
8886

@@ -110,16 +108,34 @@ <h1 class="text-4xl font-bold text-gray-800">DumbWhois</h1>
110108
</div>
111109

112110
<script>
111+
const sunIcon = `<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
112+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" />
113+
</svg>`;
114+
115+
const moonIcon = `<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
116+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" />
117+
</svg>`;
118+
119+
function updateThemeIcon() {
120+
const isDark = document.documentElement.classList.contains('dark');
121+
document.getElementById('themeIcon').innerHTML = isDark ? sunIcon : moonIcon;
122+
}
123+
113124
function toggleDarkMode() {
114125
const html = document.documentElement;
115126
const isDark = html.classList.contains('dark');
116127
html.classList.toggle('dark');
117128
localStorage.setItem('darkMode', !isDark);
129+
updateThemeIcon();
118130
}
119131

120-
if (localStorage.getItem('darkMode') === 'true') {
121-
document.documentElement.classList.add('dark');
132+
// Check local storage, default to dark mode if not set
133+
if (localStorage.getItem('darkMode') === 'false') {
134+
document.documentElement.classList.remove('dark');
122135
}
136+
137+
// Set initial icon
138+
updateThemeIcon();
123139

124140
function formatDate(dateString) {
125141
return dateString ? new Date(dateString).toLocaleString() : 'N/A';

0 commit comments

Comments
 (0)