Skip to content

Commit 83af7e8

Browse files
committed
refactor(site): use .js- prefix pattern for theme toggle
Replace inline onclick handler with addEventListener pattern to match existing .js-copy-command convention
1 parent 44ceccf commit 83af7e8

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

site/index.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,7 @@
289289
</head>
290290
<body class="min-h-screen text-slate-800 dark:text-slate-200 antialiased overflow-x-hidden bg-pattern">
291291
<!-- Theme Toggle Button -->
292-
<button id="theme-toggle" onclick="toggleTheme()"
293-
class="fixed top-6 right-6 z-50 p-3 rounded-2xl bg-white/70 dark:bg-slate-800/70 backdrop-blur-lg border border-slate-200 dark:border-slate-700 shadow-lg hover:shadow-xl transition-all duration-300"
292+
<button class="js-theme-toggle fixed top-6 right-6 z-50 p-3 rounded-2xl bg-white/70 dark:bg-slate-800/70 backdrop-blur-lg border border-slate-200 dark:border-slate-700 shadow-lg hover:shadow-xl transition-all duration-300"
294293
aria-label="Toggle dark mode">
295294
<svg class="w-5 h-5 text-slate-600 dark:text-slate-300 hidden dark:block" fill="none" stroke="currentColor" viewBox="0 0 24 24">
296295
<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"/>
@@ -555,12 +554,12 @@ <h2 class="text-3xl md:text-4xl font-bold mb-4 text-slate-900 dark:text-white">I
555554

556555
setTheme(getThemePreference());
557556

558-
window.toggleTheme = function() {
557+
document.querySelector('.js-theme-toggle').addEventListener('click', () => {
559558
const current = document.documentElement.classList.contains('dark') ? 'dark' : 'light';
560559
const next = current === 'dark' ? 'light' : 'dark';
561560
localStorage.setItem(STORAGE_KEY, next);
562561
setTheme(next);
563-
};
562+
});
564563

565564
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => {
566565
if (!localStorage.getItem(STORAGE_KEY)) {

0 commit comments

Comments
 (0)