diff options
| -rw-r--r-- | static/deck.css | 16 | ||||
| -rw-r--r-- | static/modules/music.js | 35 |
2 files changed, 36 insertions, 15 deletions
diff --git a/static/deck.css b/static/deck.css index 2f81b94..0757cdb 100644 --- a/static/deck.css +++ b/static/deck.css @@ -715,8 +715,20 @@ select { .dash-music .music .controls button { min-height: 38px; min-width: 40px; font-size: 1rem; padding: 0; } .dash-music .music .vol { min-width: 0; } .music[hidden], .music [hidden] { display: none; } /* .art.empty sets display: flex */ -.music.game .times { display: block; color: var(--udt-subtext0); } -.dash-music .music.game .art { width: 72px; height: 96px; } +/* The game: its cover as tall as the card, platform glyph, name, times. */ +.music.game:not([hidden]) { display: flex; gap: 16px; align-items: center; height: 100%; } +.music.game .cover { height: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 12px; + flex: none; background: var(--udt-surface1); } +.music.game .cover.sq { aspect-ratio: 1; } +.music.game .cover.empty:not([hidden]) { display: flex; align-items: center; justify-content: center; + font-size: 3rem; color: var(--udt-overlay0); } +.music.game .meta { min-width: 0; display: flex; flex-direction: column; gap: 8px; } +.music.game .plat { font-size: 2.4rem; line-height: 1; color: var(--udt-accent); } +.music.game .plat small { font-family: inherit; font-size: 1rem; font-weight: 700; margin-left: 2px; } +.music.game .title { font-size: 1.3rem; font-weight: 600; white-space: normal; display: -webkit-box; + -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; } +.music.game .stat:not([hidden]) { display: flex; gap: 8px; align-items: center; color: var(--udt-subtext0); } +.music.game .stat .nf { color: var(--udt-accent); width: 1.2em; text-align: center; } .dash .prog { display: flex; flex-direction: column; gap: 6px; } .dash .prog header { display: flex; align-items: baseline; gap: 10px; } 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) { |
