|
| 1 | +<script> |
| 2 | + import { onMount } from 'svelte'; |
| 3 | +
|
| 4 | + let theme = 'light'; |
| 5 | +
|
| 6 | + onMount(() => { |
| 7 | + const saved = localStorage.getItem('devcard-theme'); |
| 8 | + if (saved) { |
| 9 | + theme = saved; |
| 10 | + } else if (window.matchMedia('(prefers-color-scheme: dark)').matches) { |
| 11 | + theme = 'dark'; |
| 12 | + } |
| 13 | + document.documentElement.classList.toggle('dark', theme === 'dark'); |
| 14 | + }); |
| 15 | +
|
| 16 | + function toggleTheme() { |
| 17 | + theme = theme === 'light' ? 'dark' : 'light'; |
| 18 | + document.documentElement.classList.toggle('dark', theme === 'dark'); |
| 19 | + localStorage.setItem('devcard-theme', theme); |
| 20 | + } |
| 21 | +</script> |
| 22 | + |
1 | 23 | <svelte:head> |
2 | 24 | <title>DevCard — One Tap. Every Profile. Every Platform.</title> |
3 | 25 | <meta |
|
8 | 30 |
|
9 | 31 | <main class="landing"> |
10 | 32 | <section class="hero"> |
| 33 | + <button |
| 34 | + id="theme-toggle" |
| 35 | + class="theme-toggle" |
| 36 | + on:click={toggleTheme} |
| 37 | + aria-label="Toggle theme" |
| 38 | + > |
| 39 | + {theme === 'light' ? '🌙' : '☀️'} |
| 40 | + </button> |
11 | 41 | <div class="logo">⚡</div> |
12 | 42 | <h1>DevCard</h1> |
13 | 43 | <p class="tagline">One Tap. Every Profile. Every Platform.</p> |
|
92 | 122 | </main> |
93 | 123 |
|
94 | 124 | <style> |
| 125 | + /* ── Theme toggle button ────────────────────────────────────────── */ |
| 126 | + .theme-toggle { |
| 127 | + position: absolute; |
| 128 | + top: 1.25rem; |
| 129 | + right: 1.25rem; |
| 130 | + background: var(--bg-card); |
| 131 | + border: 1px solid var(--border); |
| 132 | + border-radius: 50%; |
| 133 | + width: 2.75rem; |
| 134 | + height: 2.75rem; |
| 135 | + font-size: 1.3rem; |
| 136 | + cursor: pointer; |
| 137 | + display: flex; |
| 138 | + align-items: center; |
| 139 | + justify-content: center; |
| 140 | + transition: |
| 141 | + background 0.3s ease, |
| 142 | + border-color 0.3s ease, |
| 143 | + transform 0.2s ease, |
| 144 | + box-shadow 0.2s ease; |
| 145 | + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); |
| 146 | + line-height: 1; |
| 147 | + } |
| 148 | +
|
| 149 | + .theme-toggle:hover { |
| 150 | + transform: scale(1.12) rotate(15deg); |
| 151 | + border-color: var(--primary); |
| 152 | + box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3); |
| 153 | + } |
| 154 | +
|
| 155 | + .theme-toggle:focus-visible { |
| 156 | + outline: 2px solid var(--primary); |
| 157 | + outline-offset: 3px; |
| 158 | + } |
| 159 | +
|
95 | 160 | .landing { |
96 | 161 | max-width: 960px; |
97 | 162 | margin: 0 auto; |
98 | 163 | padding: 2rem; |
| 164 | + position: relative; |
99 | 165 | } |
100 | 166 |
|
101 | 167 | .hero { |
|
0 commit comments