Karan Adhikari commited on
Commit
dcda553
Β·
unverified Β·
1 Parent(s): c0e78ac
Files changed (1) hide show
  1. Backend/fastapi/templates/base.html +113 -11
Backend/fastapi/templates/base.html CHANGED
@@ -1,5 +1,5 @@
1
  <!DOCTYPE html>
2
- <html lang="en" class="dark">
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -10,6 +10,7 @@
10
 
11
  <style>
12
  :root {
 
13
  --primary: {{ theme.colors.primary }};
14
  --secondary: {{ theme.colors.secondary }};
15
  --accent: {{ theme.colors.accent }};
@@ -88,7 +89,7 @@ body {
88
  .toast.info { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
89
 
90
  .toast-title { font-weight: 800; font-size: 0.9rem; line-height: 1.2; }
91
- .toast-message { margin-top: 0.15rem; font-size: 0.82rem; color: var(--text-secondary); line-height: 1.35; }
92
 
93
  @keyframes toast-in { from { opacity: 0; transform: translateY(-10px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
94
  @keyframes toast-out { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(-8px) scale(0.98); } }
@@ -109,6 +110,87 @@ body {
109
  cursor: pointer;
110
  }
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  #overlay {
113
  backdrop-filter: blur(8px);
114
  background: rgba(0,0,0,0.4);
@@ -184,7 +266,7 @@ tailwind.config = {
184
  <i class="fa-solid fa-user"></i>
185
  </button>
186
 
187
- <div id="user-dropdown" class="absolute right-0 top-14 w-64 glass-panel rounded-2xl p-4 opacity-0 scale-95 pointer-events-none transition-all duration-200 origin-top-right z-50">
188
  <div class="mb-3 border-b border-white/10 pb-3">
189
  <p class="text-sm font-bold text-text">{{ current_user }}</p>
190
  <p class="text-[10px] text-green-400 font-bold uppercase tracking-wider flex items-center gap-1">
@@ -192,16 +274,28 @@ tailwind.config = {
192
  </p>
193
  </div>
194
 
195
- <form method="post" action="/set-theme" class="mb-4">
196
- <label class="text-[10px] uppercase text-text-secondary font-bold mb-1 block ml-2">App Theme</label>
197
- <select name="theme" onchange="this.form.submit()" class="theme-select w-full">
198
  {% for theme_key, theme_data in themes.items() %}
199
- <option value="{{ theme_key }}" {% if current_theme==theme_key %}selected{% endif %}>
200
- {{ theme_data.name }}
201
- </option>
 
 
 
 
 
 
 
 
 
202
  {% endfor %}
203
- </select>
204
- </form>
 
 
 
205
 
206
  <a href="/admin/settings"
207
  class="flex items-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold mb-2 transition-all"
@@ -348,6 +442,14 @@ function escapeHtml(str) {
348
  .replace(/'/g, '&#039;');
349
  }
350
 
 
 
 
 
 
 
 
 
351
  if(btn) btn.onclick = toggleMenu;
352
  if(userBtn) userBtn.onclick = toggleUser;
353
  overlay.onclick = () => { closeMenu(); closeUser(); };
 
1
  <!DOCTYPE html>
2
+ <html lang="en" class="{{ 'dark' if theme.is_dark else 'light' }}">
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
 
10
 
11
  <style>
12
  :root {
13
+ color-scheme: {{ 'dark' if theme.is_dark else 'light' }};
14
  --primary: {{ theme.colors.primary }};
15
  --secondary: {{ theme.colors.secondary }};
16
  --accent: {{ theme.colors.accent }};
 
89
  .toast.info { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
90
 
91
  .toast-title { font-weight: 800; font-size: 0.9rem; line-height: 1.2; }
92
+ .toast-message { margin-top: 0.15rem; font-size: 0.82rem; color: var(--text-sec); line-height: 1.35; }
93
 
94
  @keyframes toast-in { from { opacity: 0; transform: translateY(-10px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
95
  @keyframes toast-out { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(-8px) scale(0.98); } }
 
110
  cursor: pointer;
111
  }
112
 
113
+ input, select, textarea, button {
114
+ font-family: inherit;
115
+ }
116
+ input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
117
+ select,
118
+ textarea {
119
+ color: var(--text);
120
+ }
121
+ input::placeholder,
122
+ textarea::placeholder {
123
+ color: color-mix(in srgb, var(--text-sec) 78%, transparent);
124
+ opacity: 1;
125
+ }
126
+ select option,
127
+ select optgroup {
128
+ background-color: var(--card);
129
+ color: var(--text);
130
+ }
131
+ /* Autofill no longer paints white-on-white in dark themes */
132
+ input:-webkit-autofill,
133
+ input:-webkit-autofill:hover,
134
+ input:-webkit-autofill:focus,
135
+ textarea:-webkit-autofill {
136
+ -webkit-text-fill-color: var(--text);
137
+ -webkit-box-shadow: 0 0 0 1000px color-mix(in srgb, var(--card) 92%, transparent) inset;
138
+ caret-color: var(--text);
139
+ transition: background-color 9999s ease-in-out 0s;
140
+ }
141
+
142
+ /* ── Modern theme picker (nav) ──────────────────────────────────────────────*/
143
+ .theme-grid {
144
+ display: grid;
145
+ grid-template-columns: 1fr 1fr;
146
+ gap: 0.5rem;
147
+ }
148
+ .theme-chip {
149
+ --sw-bg: var(--bg);
150
+ --sw-primary: var(--primary);
151
+ --sw-accent: var(--accent);
152
+ --sw-text: var(--text);
153
+ display: flex;
154
+ align-items: center;
155
+ gap: 0.5rem;
156
+ padding: 0.5rem 0.6rem;
157
+ border-radius: 0.85rem;
158
+ border: 1px solid color-mix(in srgb, var(--sw-text) 18%, transparent);
159
+ background: var(--sw-bg);
160
+ cursor: pointer;
161
+ position: relative;
162
+ overflow: hidden;
163
+ transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
164
+ }
165
+ .theme-chip:hover {
166
+ transform: translateY(-1px);
167
+ border-color: var(--sw-primary);
168
+ }
169
+ .theme-chip.active {
170
+ border-color: var(--sw-primary);
171
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--sw-primary) 55%, transparent);
172
+ }
173
+ .theme-chip-dots { display: flex; gap: 3px; flex-shrink: 0; }
174
+ .theme-chip-dots .dot {
175
+ width: 0.7rem; height: 0.7rem; border-radius: 9999px;
176
+ box-shadow: 0 0 6px color-mix(in srgb, var(--sw-primary) 70%, transparent);
177
+ }
178
+ .theme-chip-name {
179
+ font-size: 0.7rem;
180
+ font-weight: 700;
181
+ color: var(--sw-text);
182
+ white-space: nowrap;
183
+ overflow: hidden;
184
+ text-overflow: ellipsis;
185
+ line-height: 1.1;
186
+ }
187
+ .theme-chip .chip-check {
188
+ position: absolute;
189
+ top: 0.3rem; right: 0.4rem;
190
+ font-size: 0.6rem;
191
+ color: var(--sw-primary);
192
+ }
193
+
194
  #overlay {
195
  backdrop-filter: blur(8px);
196
  background: rgba(0,0,0,0.4);
 
266
  <i class="fa-solid fa-user"></i>
267
  </button>
268
 
269
+ <div id="user-dropdown" class="absolute right-0 top-14 w-72 glass-panel rounded-2xl p-4 opacity-0 scale-95 pointer-events-none transition-all duration-200 origin-top-right z-50">
270
  <div class="mb-3 border-b border-white/10 pb-3">
271
  <p class="text-sm font-bold text-text">{{ current_user }}</p>
272
  <p class="text-[10px] text-green-400 font-bold uppercase tracking-wider flex items-center gap-1">
 
274
  </p>
275
  </div>
276
 
277
+ <div class="mb-4">
278
+ <label class="text-[10px] uppercase text-text-secondary font-bold mb-2 block ml-1">App Theme</label>
279
+ <div class="theme-grid">
280
  {% for theme_key, theme_data in themes.items() %}
281
+ <button type="button"
282
+ onclick="selectTheme('{{ theme_key }}')"
283
+ class="theme-chip {% if current_theme==theme_key %}active{% endif %}"
284
+ title="{{ theme_data.name }}"
285
+ style="--sw-bg:{{ theme_data.colors.background }};--sw-primary:{{ theme_data.colors.primary }};--sw-accent:{{ theme_data.colors.accent }};--sw-text:{{ theme_data.colors.text }}">
286
+ <span class="theme-chip-dots">
287
+ <span class="dot" style="background:{{ theme_data.colors.primary }}"></span>
288
+ <span class="dot" style="background:{{ theme_data.colors.accent }}"></span>
289
+ </span>
290
+ <span class="theme-chip-name">{{ theme_data.name }}</span>
291
+ {% if current_theme==theme_key %}<i class="fa-solid fa-check chip-check"></i>{% endif %}
292
+ </button>
293
  {% endfor %}
294
+ </div>
295
+ <form id="theme-form" method="post" action="/set-theme" class="hidden">
296
+ <input type="hidden" name="theme" id="theme-input">
297
+ </form>
298
+ </div>
299
 
300
  <a href="/admin/settings"
301
  class="flex items-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold mb-2 transition-all"
 
442
  .replace(/'/g, '&#039;');
443
  }
444
 
445
+ function selectTheme(key) {
446
+ const input = document.getElementById('theme-input');
447
+ const form = document.getElementById('theme-form');
448
+ if (!input || !form) return;
449
+ input.value = key;
450
+ form.submit();
451
+ }
452
+
453
  if(btn) btn.onclick = toggleMenu;
454
  if(userBtn) userBtn.onclick = toggleUser;
455
  overlay.onclick = () => { closeMenu(); closeUser(); };