Add match detail map hero image

This commit is contained in:
devRaGonSa
2026-05-20 10:39:10 +02:00
parent 8343720235
commit c4f62bbe76
22 changed files with 152 additions and 7 deletions

View File

@@ -22,15 +22,20 @@
.historical-hero__copy {
display: grid;
gap: 24px;
min-width: 0;
}
.historical-hero__layout {
display: grid;
grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
grid-template-columns: minmax(190px, 260px) minmax(0, 0.82fr) minmax(320px, 0.9fr);
align-items: center;
gap: 32px;
}
.historical-hero__layout > * {
min-width: 0;
}
.historical-logo-frame {
width: min(300px, 100%);
min-height: 220px;
@@ -42,6 +47,45 @@
.historical-hero__text {
max-width: 60ch;
overflow-wrap: anywhere;
}
.historical-map-hero {
position: relative;
overflow: hidden;
min-height: 220px;
margin: 0;
border: 1px solid rgba(210, 182, 118, 0.2);
border-radius: 18px;
background:
linear-gradient(180deg, rgba(19, 24, 16, 0.9), rgba(10, 13, 9, 0.72));
box-shadow:
inset 0 1px 0 rgba(255, 255, 255, 0.04),
0 18px 40px rgba(0, 0, 0, 0.24);
}
.historical-map-hero[hidden] {
display: none;
}
.historical-map-hero::before {
content: "";
position: absolute;
inset: 0;
z-index: 1;
border: 1px solid rgba(210, 182, 118, 0.12);
border-radius: inherit;
background:
linear-gradient(90deg, rgba(7, 9, 7, 0.24), transparent 34%),
linear-gradient(180deg, transparent 54%, rgba(7, 9, 7, 0.44));
pointer-events: none;
}
.historical-map-hero__image {
width: 100%;
height: 100%;
min-height: 220px;
object-fit: cover;
}
.historical-content {
@@ -657,7 +701,24 @@
}
.historical-hero__layout {
display: flex;
display: grid;
grid-template-columns: 1fr;
}
.historical-hero__copy,
.historical-hero__copy > div,
.historical-hero__text {
width: 100%;
max-width: 100%;
}
.historical-map-hero {
width: 100%;
min-height: 190px;
}
.historical-map-hero__image {
min-height: 190px;
}
.historical-selector {

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

View File

@@ -20,6 +20,8 @@ document.addEventListener("DOMContentLoaded", () => {
timelineNote: document.getElementById("match-detail-timeline-note"),
timelineState: document.getElementById("match-detail-timeline-state"),
timelineGrid: document.getElementById("match-detail-timeline-grid"),
mapHero: document.getElementById("match-detail-map-hero"),
mapImage: document.getElementById("match-detail-map-image"),
};
if (!serverSlug || !matchId) {
@@ -66,6 +68,7 @@ function renderMatchDetail(item, nodes) {
nodes.title.textContent = mapName;
nodes.summary.textContent = `${serverName} - ${formatDetailSubtitle(item)}`;
nodes.note.textContent = "";
renderMapHero(item, mapName, nodes);
nodes.grid.innerHTML = renderScoreboardDetail(item, { mapName, serverName });
renderPlayerSection(item, nodes);
hideTimelineSection(nodes);
@@ -74,6 +77,28 @@ function renderMatchDetail(item, nodes) {
nodes.grid.hidden = false;
}
function renderMapHero(item, mapName, nodes) {
if (!nodes.mapHero || !nodes.mapImage) {
return;
}
const mapImagePath = resolveMapImagePath(item, mapName);
if (!mapImagePath) {
nodes.mapImage.removeAttribute("src");
nodes.mapImage.alt = "";
nodes.mapHero.hidden = true;
return;
}
nodes.mapImage.src = mapImagePath;
nodes.mapImage.alt = mapName;
nodes.mapImage.onerror = () => {
nodes.mapImage.removeAttribute("src");
nodes.mapHero.hidden = true;
};
nodes.mapHero.hidden = false;
}
function renderScoreboardDetail(item, { mapName, serverName }) {
const result = item.result || {};
const alliedScore = Number.isFinite(Number(result.allied_score))
@@ -273,6 +298,36 @@ function resolveMatchFactions(item, mapName) {
};
}
function resolveMapImagePath(item, mapName) {
const normalizedMap = normalizeLookupText(
`${item.map?.name || ""} ${item.map?.pretty_name || ""} ${mapName || ""}`,
).replaceAll(" ", "");
const mapAssetByKey = {
carentan: "carentan-day.webp",
driel: "driel-day.webp",
elalamein: "elalamein-day.webp",
elsenbornridge: "elsenbornridge-day.webp",
foy: "foy-day.webp",
hill400: "hill400-day.webp",
hurtgenforest: "hurtgenforest-day.webp",
kharkov: "kharkov-day.webp",
kursk: "kursk-day.webp",
mortain: "mortain-day.webp",
omahabeach: "omahabeach-day.webp",
purpleheartlane: "purpleheartlane-rain.webp",
smolensk: "smolensk-day.webp",
stmariedumont: "stmariedumont-day.webp",
stmereeglise: "stmereeglise-day.webp",
tobrukdawn: "tobruk-dawn.webp",
tobruk: "tobruk-day.webp",
utahbeach: "utahbeach-day.webp",
};
const matchedKey = Object.keys(mapAssetByKey).find((key) =>
normalizedMap.includes(key),
);
return matchedKey ? `./assets/img/maps/${mapAssetByKey[matchedKey]}` : "";
}
function normalizeLookupText(value) {
return String(value || "")
.normalize("NFD")
@@ -284,10 +339,10 @@ function normalizeLookupText(value) {
function formatDetailSubtitle(item) {
if (item.capture_basis === "rcon-materialized-admin-log") {
return "Partida RCON materializada";
return "RCON";
}
if (item.capture_basis === "rcon-competitive-window") {
return "Partida RCON registrada";
return "RCON";
}
if (item.result_source === "public-scoreboard-match") {
return "Partida del scoreboard";

View File

@@ -44,6 +44,18 @@
</p>
</div>
</div>
<figure class="historical-map-hero" id="match-detail-map-hero" hidden>
<img
class="historical-map-hero__image"
id="match-detail-map-image"
src=""
alt=""
width="960"
height="540"
loading="eager"
decoding="async"
/>
</figure>
</div>
</div>
</header>