agrega toggle de modo claro/oscuro con persistencia en localStorage

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-23 18:20:08 -04:00
parent 36a40938c7
commit ca021cc3f7
5 changed files with 67 additions and 19 deletions
+2 -2
View File
@@ -197,7 +197,7 @@ function clearEmoji(id) {
.emoji-picker { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .35rem; } .emoji-picker { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .35rem; }
.emoji-opt { .emoji-opt {
background: var(--surface); background: var(--surface);
border: 1px solid #333; border: 1px solid var(--border2);
border-radius: 6px; border-radius: 6px;
font-size: 1.15rem; font-size: 1.15rem;
width: 34px; height: 34px; width: 34px; height: 34px;
@@ -205,7 +205,7 @@ function clearEmoji(id) {
display: flex; align-items: center; justify-content: center; display: flex; align-items: center; justify-content: center;
transition: background .12s, transform .1s; transition: background .12s, transform .1s;
} }
.emoji-opt:hover { background: #333; transform: scale(1.15); } .emoji-opt:hover { background: var(--surface3); transform: scale(1.15); }
.emoji-thumb { font-size: 1.6rem; } .emoji-thumb { font-size: 1.6rem; }
+1 -1
View File
@@ -162,7 +162,7 @@
.result-info { flex: 1; display: flex; flex-direction: column; gap: .3rem; } .result-info { flex: 1; display: flex; flex-direction: column; gap: .3rem; }
.result-name { font-size: .9rem; font-weight: 500; display: flex; align-items: center; gap: .5rem; } .result-name { font-size: .9rem; font-weight: 500; display: flex; align-items: center; gap: .5rem; }
.winner-badge { background: rgba(255,215,0,.15); color: gold; font-size: .75rem; padding: 1px 6px; border-radius: 10px; border: 1px solid rgba(255,215,0,.3); } .winner-badge { background: rgba(255,215,0,.15); color: gold; font-size: .75rem; padding: 1px 6px; border-radius: 10px; border: 1px solid rgba(255,215,0,.3); }
.result-bar-wrap { height: 6px; background: #333; border-radius: 3px; overflow: hidden; } .result-bar-wrap { height: 6px; background: var(--surface3); border-radius: 3px; overflow: hidden; }
.result-bar { height: 100%; background: var(--green); border-radius: 3px; transition: width .4s; } .result-bar { height: 100%; background: var(--green); border-radius: 3px; transition: width .4s; }
.result-count { display: flex; flex-direction: column; align-items: flex-end; min-width: 50px; } .result-count { display: flex; flex-direction: column; align-items: flex-end; min-width: 50px; }
.result-count strong { font-size: 1.1rem; } .result-count strong { font-size: 1.1rem; }
+17 -1
View File
@@ -1,9 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="es"> <html lang="es" data-theme="dark">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}Spotify Cantina{% endblock %}</title> <title>{% block title %}Spotify Cantina{% endblock %}</title>
<script>(function(){var t=localStorage.getItem('theme')||'dark';document.documentElement.setAttribute('data-theme',t);})()</script>
<link rel="stylesheet" href="/static/style.css"> <link rel="stylesheet" href="/static/style.css">
</head> </head>
<body> <body>
@@ -13,6 +14,7 @@
<a href="/">Reproductor</a> <a href="/">Reproductor</a>
<a href="/stats/">Estadísticas</a> <a href="/stats/">Estadísticas</a>
<a id="admin-nav-btn" href="/admin/login" class="btn-sm">Admin</a> <a id="admin-nav-btn" href="/admin/login" class="btn-sm">Admin</a>
<button id="theme-toggle" class="theme-toggle" onclick="toggleTheme()" title="Cambiar tema">☀️</button>
</div> </div>
</nav> </nav>
<script> <script>
@@ -23,6 +25,20 @@
btn.href = '/admin/playlists'; btn.href = '/admin/playlists';
} }
}).catch(() => {}); }).catch(() => {});
function toggleTheme() {
const current = document.documentElement.getAttribute('data-theme') || 'dark';
const next = current === 'dark' ? 'light' : 'dark';
document.documentElement.setAttribute('data-theme', next);
localStorage.setItem('theme', next);
document.getElementById('theme-toggle').textContent = next === 'dark' ? '☀️' : '🌙';
}
(function syncToggleIcon() {
const t = document.documentElement.getAttribute('data-theme') || 'dark';
const btn = document.getElementById('theme-toggle');
if (btn) btn.textContent = t === 'dark' ? '☀️' : '🌙';
})();
</script> </script>
<main> <main>
{% block content %}{% endblock %} {% block content %}{% endblock %}
+7 -7
View File
@@ -456,7 +456,7 @@ setInterval(fetchVotingStatus, 5000);
.vote-bar-wrap { .vote-bar-wrap {
width: 100%; width: 100%;
height: 4px; height: 4px;
background: #333; background: var(--surface3);
border-radius: 2px; border-radius: 2px;
overflow: hidden; overflow: hidden;
margin-top: 4px; margin-top: 4px;
@@ -498,7 +498,7 @@ setInterval(fetchVotingStatus, 5000);
} }
.vote-btn:hover:not(:disabled) { background: var(--green-dark); } .vote-btn:hover:not(:disabled) { background: var(--green-dark); }
.vote-btn:disabled { .vote-btn:disabled {
background: #333; background: var(--surface3);
color: var(--text-muted); color: var(--text-muted);
cursor: not-allowed; cursor: not-allowed;
opacity: .8; opacity: .8;
@@ -516,8 +516,8 @@ setInterval(fetchVotingStatus, 5000);
padding: 1rem; padding: 1rem;
} }
.modal-box { .modal-box {
background: #1a1a1a; background: var(--modal-bg);
border: 1px solid #333; border: 1px solid var(--border2);
border-radius: 12px; border-radius: 12px;
width: 100%; width: 100%;
max-width: 520px; max-width: 520px;
@@ -531,7 +531,7 @@ setInterval(fetchVotingStatus, 5000);
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
padding: 1rem 1.2rem; padding: 1rem 1.2rem;
border-bottom: 1px solid #2a2a2a; border-bottom: 1px solid var(--surface2);
gap: .8rem; gap: .8rem;
} }
.modal-title-wrap { .modal-title-wrap {
@@ -574,7 +574,7 @@ setInterval(fetchVotingStatus, 5000);
border-radius: 4px; border-radius: 4px;
flex-shrink: 0; flex-shrink: 0;
} }
.modal-close:hover { color: #fff; background: #2a2a2a; } .modal-close:hover { color: var(--text); background: var(--surface2); }
.modal-track-list { .modal-track-list {
overflow-y: auto; overflow-y: auto;
padding: .4rem 0; padding: .4rem 0;
@@ -587,7 +587,7 @@ setInterval(fetchVotingStatus, 5000);
cursor: pointer; cursor: pointer;
transition: background .12s; transition: background .12s;
} }
.modal-track-row:hover { background: #2a2a2a; } .modal-track-row:hover { background: var(--surface2); }
.modal-track-num { .modal-track-num {
font-size: .8rem; font-size: .8rem;
color: var(--text-muted); color: var(--text-muted);
+40 -8
View File
@@ -5,12 +5,30 @@
--bg: #121212; --bg: #121212;
--surface: #1e1e1e; --surface: #1e1e1e;
--surface2: #2a2a2a; --surface2: #2a2a2a;
--surface3: #333333;
--green: #1db954; --green: #1db954;
--green-dark: #17a349; --green-dark: #17a349;
--text: #e0e0e0; --text: #e0e0e0;
--text-muted: #888; --text-muted: #888;
--red: #e74c3c; --red: #e74c3c;
--radius: 10px; --radius: 10px;
--nav-bg: #000000;
--border: #444444;
--border2: #333333;
--modal-bg: #1a1a1a;
}
[data-theme="light"] {
--bg: #f4f4f4;
--surface: #ffffff;
--surface2: #f0f0f0;
--surface3: #e4e4e4;
--text: #111111;
--text-muted: #666666;
--nav-bg: #f8f8f8;
--border: #d8d8d8;
--border2: #cccccc;
--modal-bg: #ffffff;
} }
body { body {
@@ -28,12 +46,12 @@ a:hover { text-decoration: underline; }
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
background: #000; background: var(--nav-bg);
padding: 0.75rem 1.5rem; padding: 0.75rem 1.5rem;
position: sticky; position: sticky;
top: 0; top: 0;
z-index: 100; z-index: 100;
border-bottom: 1px solid #333; border-bottom: 1px solid var(--border2);
} }
.brand { font-size: 1.1rem; font-weight: 700; color: var(--green); letter-spacing: 1px; } .brand { font-size: 1.1rem; font-weight: 700; color: var(--green); letter-spacing: 1px; }
.nav-links { display: flex; gap: 1.5rem; } .nav-links { display: flex; gap: 1.5rem; }
@@ -154,7 +172,7 @@ a:hover { text-decoration: underline; }
flex: 1; flex: 1;
background: var(--surface2); background: var(--surface2);
color: var(--text); color: var(--text);
border: 1px solid #444; border: 1px solid var(--border);
border-radius: 6px; border-radius: 6px;
padding: 0.45rem 0.6rem; padding: 0.45rem 0.6rem;
font-size: 0.875rem; font-size: 0.875rem;
@@ -246,7 +264,7 @@ a:hover { text-decoration: underline; }
.input { .input {
background: var(--surface2); background: var(--surface2);
color: var(--text); color: var(--text);
border: 1px solid #444; border: 1px solid var(--border);
border-radius: 6px; border-radius: 6px;
padding: 0.55rem 0.75rem; padding: 0.55rem 0.75rem;
font-size: 0.9rem; font-size: 0.9rem;
@@ -265,9 +283,9 @@ a:hover { text-decoration: underline; }
text-transform: uppercase; text-transform: uppercase;
letter-spacing: 0.4px; letter-spacing: 0.4px;
padding: 0.5rem 0.6rem; padding: 0.5rem 0.6rem;
border-bottom: 1px solid #333; border-bottom: 1px solid var(--border2);
} }
.table td { padding: 0.6rem; border-bottom: 1px solid #2a2a2a; vertical-align: middle; } .table td { padding: 0.6rem; border-bottom: 1px solid var(--surface2); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; } .table tr:last-child td { border-bottom: none; }
.table-thumb { .table-thumb {
@@ -308,14 +326,14 @@ a:hover { text-decoration: underline; }
.btn-sm { .btn-sm {
background: var(--surface2); background: var(--surface2);
color: var(--text); color: var(--text);
border: 1px solid #444; border: 1px solid var(--border);
border-radius: 6px; border-radius: 6px;
padding: 0.4rem 0.7rem; padding: 0.4rem 0.7rem;
cursor: pointer; cursor: pointer;
font-size: 0.82rem; font-size: 0.82rem;
transition: background 0.15s; transition: background 0.15s;
} }
.btn-sm:hover { background: #333; } .btn-sm:hover { background: var(--surface3); }
.btn-danger { background: transparent; color: var(--red); border-color: var(--red); } .btn-danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; } .btn-danger:hover { background: var(--red); color: #fff; }
@@ -346,3 +364,17 @@ a:hover { text-decoration: underline; }
/* Misc */ /* Misc */
.empty-msg { color: var(--text-muted); font-size: 0.9rem; } .empty-msg { color: var(--text-muted); font-size: 0.9rem; }
/* ── Theme toggle ── */
.theme-toggle {
background: none;
border: none;
cursor: pointer;
font-size: 1.1rem;
padding: 0.3rem 0.4rem;
border-radius: 6px;
line-height: 1;
transition: background 0.15s;
color: var(--text-muted);
}
.theme-toggle:hover { background: var(--surface2); }