Enhance cards: larger screenshots, lightbox, full-width styled vote slider

This commit is contained in:
2026-01-28 16:06:19 +01:00
parent 751cc5d2ca
commit 437b8ba3d9
3 changed files with 110 additions and 13 deletions

View File

@@ -128,7 +128,7 @@ function renderVotes() {
const footer = document.createElement("div"); const footer = document.createElement("div");
footer.className = "vote-controls"; footer.className = "vote-controls";
footer.innerHTML = ` footer.innerHTML = `
<input type="range" min="0" max="10" value="${current}" data-id="${s.id}"> <input class="full-slider" type="range" min="0" max="10" value="${current}" data-id="${s.id}">
<span class="score" id="score-${s.id}">${current}</span>`; <span class="score" id="score-${s.id}">${current}</span>`;
li.querySelector(".card-body").appendChild(footer); li.querySelector(".card-body").appendChild(footer);
list.appendChild(li); list.appendChild(li);
@@ -263,8 +263,11 @@ function buildCard(s, { showAuthor }) {
const card = document.createElement("article"); const card = document.createElement("article");
card.className = "game-card"; card.className = "game-card";
const hasImage = !!s.screenshotUrl; const hasImage = !!s.screenshotUrl;
const visual = hasImage
? `<button class="card-visual" data-img="${s.screenshotUrl}" aria-label="Open screenshot" style="background-image:url('${s.screenshotUrl}')"></button>`
: `<div class="card-visual"></div>`;
card.innerHTML = ` card.innerHTML = `
<div class="card-visual" style="${hasImage ? `background-image:url('${s.screenshotUrl}')` : ''}"></div> ${visual}
<div class="card-body"> <div class="card-body">
<div class="card-title-row"> <div class="card-title-row">
<h3>${s.name}</h3> <h3>${s.name}</h3>
@@ -275,9 +278,31 @@ function buildCard(s, { showAuthor }) {
${s.youtubeUrl ? `<a class="link" href="${s.youtubeUrl}" target="_blank" rel="noopener">YouTube ↗</a>` : ""} ${s.youtubeUrl ? `<a class="link" href="${s.youtubeUrl}" target="_blank" rel="noopener">YouTube ↗</a>` : ""}
</div> </div>
`; `;
if (hasImage) {
const btn = card.querySelector(".card-visual");
btn.addEventListener("click", () => openLightbox(s.screenshotUrl, s.name));
}
return card; return card;
} }
function openLightbox(url, title) {
const overlay = document.createElement("div");
overlay.className = "lightbox";
overlay.innerHTML = `
<div class="lightbox-content">
<button class="lightbox-close" aria-label="Close">✕</button>
<img src="${url}" alt="${title}" />
<p>${title || ""}</p>
</div>
`;
overlay.addEventListener("click", (e) => {
if (e.target.classList.contains("lightbox") || e.target.classList.contains("lightbox-close")) {
overlay.remove();
}
});
document.body.appendChild(overlay);
}
async function main() { async function main() {
setupHandlers(); setupHandlers();
try { try {

View File

@@ -16,7 +16,7 @@
<main class="grid"> <main class="grid">
<section class="card" id="actions-card"> <section class="card" id="actions-card">
<div id="suggest-view" class="phase-view hidden"> <div id="suggest-view" class="phase-view hidden">
<div class="card subcard name-box"> <div class="card subcard">
<h3>Your Name</h3> <h3>Your Name</h3>
<label class="stack"> <label class="stack">
<span class="label">Display name</span> <span class="label">Display name</span>
@@ -92,3 +92,4 @@
<script src="app.js"></script> <script src="app.js"></script>
</body> </body>
</html> </html>

View File

@@ -62,15 +62,6 @@ body {
flex-wrap: wrap; flex-wrap: wrap;
} }
.name-box {
min-width: 220px;
max-width: 260px;
background: #0b1224;
border: 1px solid #1f2937;
padding: 10px;
border-radius: 10px;
}
.stack { .stack {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -134,10 +125,15 @@ button.ghost {
} }
.card-visual { .card-visual {
height: 140px; height: 200px;
background: linear-gradient(135deg, #1d4ed8, #22c55e); background: linear-gradient(135deg, #1d4ed8, #22c55e);
background-size: cover; background-size: cover;
background-position: center; background-position: center;
cursor: pointer;
border: none;
width: 100%;
display: block;
padding: 0;
} }
.card-body { .card-body {
@@ -172,6 +168,43 @@ button.ghost {
.results-grid .game-card { border-color: #2563eb44; } .results-grid .game-card { border-color: #2563eb44; }
/* Slider */
input[type="range"].full-slider {
-webkit-appearance: none;
width: 100%;
height: 14px;
border-radius: 999px;
background: linear-gradient(90deg, #1d4ed8, #22c55e);
outline: none;
box-shadow: inset 0 0 0 1px #1f2937, 0 4px 12px rgba(0,0,0,0.25);
}
input[type="range"].full-slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 22px;
height: 22px;
border-radius: 50%;
background: #e5e7eb;
border: 2px solid #0f172a;
box-shadow: 0 4px 10px rgba(0,0,0,0.35);
}
input[type="range"].full-slider::-moz-range-thumb {
width: 22px;
height: 22px;
border-radius: 50%;
background: #e5e7eb;
border: 2px solid #0f172a;
box-shadow: 0 4px 10px rgba(0,0,0,0.35);
}
input[type="range"].full-slider::-moz-range-track {
height: 14px;
border-radius: 999px;
background: linear-gradient(90deg, #1d4ed8, #22c55e);
border: 1px solid #1f2937;
}
.score { font-weight: 700; min-width: 36px; text-align: center; }
.hidden { display: none !important; } .hidden { display: none !important; }
.toast { .toast {
@@ -213,6 +246,44 @@ button.ghost {
gap: 10px; gap: 10px;
} }
.lightbox {
position: fixed;
inset: 0;
background: rgba(0,0,0,0.75);
display: flex;
align-items: center;
justify-content: center;
z-index: 100;
}
.lightbox-content {
position: relative;
max-width: 90vw;
max-height: 90vh;
background: #0f172a;
padding: 12px;
border-radius: 12px;
box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}
.lightbox-content img {
max-width: 100%;
max-height: 80vh;
display: block;
border-radius: 8px;
}
.lightbox-close {
position: absolute;
top: 8px;
right: 8px;
background: #111827;
color: #e5e7eb;
border: 1px solid #1f2937;
border-radius: 999px;
width: 32px;
height: 32px;
font-size: 16px;
cursor: pointer;
}
.panel-header { .panel-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;