diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-18 16:56:00 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-18 16:56:00 +0100 |
| commit | 656486e22e8ee22af88a79d56778025825946cf8 (patch) | |
| tree | 47f0fb20f82703f5b801ae80bebbb73c72c9b978 /static/modules | |
| parent | 21c07e04daedac6ae8dbed3813e09c8737cf10a8 (diff) | |
| download | deck-it-656486e22e8ee22af88a79d56778025825946cf8.tar.gz deck-it-656486e22e8ee22af88a79d56778025825946cf8.zip | |
feat(dashboard): game card with a full-height cover and icons
The cover now fills the card's height (2:3 box art, square for Xbox
Live's art), the platform is a Nerd Font glyph (Steam, PlayStation with
a 1/2 tag, Xbox) and the session and total times sit behind clock and
history glyphs instead of a line of text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'static/modules')
| -rw-r--r-- | static/modules/music.js | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/static/modules/music.js b/static/modules/music.js index 4a4ce05..393087c 100644 --- a/static/modules/music.js +++ b/static/modules/music.js @@ -36,7 +36,10 @@ export function pickGame(pc, xbox) { session: xbox.session }; } -const PLATFORM = { steam: "Steam", ps1: "PlayStation", ps2: "PlayStation 2", xbox: "Xbox" }; +// Platform -> [Nerd Font glyph, label]: nf-md-steam, sony_playstation, microsoft_xbox. +// A PlayStation's generation is a small tag beside the glyph. +const PLATFORM = { steam: ["\u{f04d3}", "Steam"], ps1: ["\u{f0414}", "PlayStation", "1"], + ps2: ["\u{f0414}", "PlayStation 2", "2"], xbox: ["\u{f05b9}", "Xbox"] }; async function post(action, body = {}) { try { @@ -90,13 +93,12 @@ export default { </div> </div> <div class="music game" hidden> - <div class="top"> - <img class="art" alt="" hidden><div class="art empty nf"></div> - <div class="meta"> - <div class="artist plat muted"></div> - <div class="title"></div> - <div class="album times num"></div> - </div> + <img class="cover" alt="" hidden><div class="cover empty nf">\uf11b</div> + <div class="meta"> + <div class="plat nf"></div> + <div class="title"></div> + <div class="stat num" title="This session"><i class="nf">\uf017</i><span class="now"></span></div> + <div class="stat num" title="Total"><i class="nf">\u{f02da}</i><span class="total"></span></div> </div> </div>`; el.querySelector(".controls").prepend( @@ -121,15 +123,22 @@ export default { musicEl.hidden = Boolean(game); gameEl.hidden = !game; if (game) { - const img = gameEl.querySelector("img.art"); + const img = gameEl.querySelector("img.cover"); img.hidden = !game.cover; - gameEl.querySelector(".art.empty").hidden = Boolean(game.cover); + img.classList.toggle("sq", game.platform === "xbox"); // Xbox Live's art is square + gameEl.querySelector(".cover.empty").hidden = Boolean(game.cover); if (game.cover && img.getAttribute("src") !== game.cover) img.src = game.cover; - gameEl.querySelector(".plat").textContent = PLATFORM[game.platform] ?? ""; + const [glyph, label, tag] = PLATFORM[game.platform] ?? ["", ""]; + const plat = gameEl.querySelector(".plat"); + plat.textContent = glyph; + if (tag) plat.append(Object.assign(document.createElement("small"), { textContent: tag })); + plat.title = label; + plat.setAttribute("aria-label", label); gameEl.querySelector(".title").textContent = game.name ?? ""; const session = game.session ? (Date.now() / 1000 - game.session) / 60 : 0; - gameEl.querySelector(".times").textContent = game.minutes != null - ? `${hours(session)} now · ${hours(game.minutes + session)} total` : `${hours(session)} now`; + gameEl.querySelector(".now").textContent = hours(session); + gameEl.querySelector(".total").parentElement.hidden = game.minutes == null; + gameEl.querySelector(".total").textContent = hours((game.minutes ?? 0) + session); return; } if (st.art) { |
