mirror of
https://github.com/pvrzz/atmosphere.git
synced 2026-11-29 05:22:26 +00:00
Fix artist photo search, artist placeholders and mini player controls
- Artist photo search: thumbnails are fetched by the app and embedded, so they always show (lazy-loaded web images never started loading) - Artists without a photo show the person placeholder instead of an album cover - Mini player: lyrics centre inside their own box instead of scrolling the whole window, and only the cover shrinks when space is tight, so the controls always show
This commit is contained in:
@@ -95,10 +95,10 @@ function toast(message, kind = "") {
|
||||
}, kind === "err" ? 6500 : 3000);
|
||||
}
|
||||
|
||||
function art(url, cls, alt = "") {
|
||||
if (!url) return h("div", { class: `${cls} ph` }, icon("music"));
|
||||
function art(url, cls, alt = "", ph = "music") {
|
||||
if (!url) return h("div", { class: `${cls} ph` }, icon(ph));
|
||||
const img = h("img", { class: cls, src: url, alt, loading: "lazy", draggable: "false", referrerpolicy: "no-referrer" });
|
||||
img.addEventListener("error", () => img.replaceWith(h("div", { class: `${cls} ph` }, icon("music"))), { once: true });
|
||||
img.addEventListener("error", () => img.replaceWith(h("div", { class: `${cls} ph` }, icon(ph))), { once: true });
|
||||
return img;
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -130,10 +130,10 @@ async function loadLibrary() {
|
||||
if (typeof updateCommit === "function") updateCommit();
|
||||
}
|
||||
|
||||
const artistImage = (ar) => ar?.meta?.image || ar?.albums.find((a) => a.art)?.art || ar?.tracks.find((t) => t.art)?.art || null;
|
||||
const artistImage = (ar) => ar?.meta?.image || null;
|
||||
|
||||
function cover(key, cls, alt = "") {
|
||||
return art(artUrl(key), cls, alt);
|
||||
function cover(key, cls, alt = "", ph = "music") {
|
||||
return art(artUrl(key), cls, alt, ph);
|
||||
}
|
||||
|
||||
/* routing */
|
||||
@@ -668,7 +668,7 @@ async function searchArtistOnline(ar) {
|
||||
if (!r) return;
|
||||
photos.replaceChildren(...r.photos.map((p) => {
|
||||
const el = h("button", { class: "pick-photo", type: "button", title: `${p.name} · ${fans(p.fans)}`, onclick: () => { pick.photo = pick.photo === p.full ? null : p.full; $$(".pick-photo", photos).forEach((x) => x.classList.toggle("on", x === el && !!pick.photo)); } },
|
||||
h("img", { src: p.thumb, alt: "", referrerpolicy: "no-referrer", loading: "lazy" }), h("span", {}, p.name), h("small", {}, fans(p.fans)));
|
||||
h("img", { src: p.thumb, alt: "" }), h("span", {}, p.name), h("small", {}, fans(p.fans)));
|
||||
return el;
|
||||
}));
|
||||
pages.replaceChildren(...r.pages.map((p) => {
|
||||
@@ -892,7 +892,7 @@ function albumView(root, key) {
|
||||
|
||||
function artistCard(ar) {
|
||||
return h("div", { class: "card-tile artist", role: "button", tabindex: "0", "data-artist": ar.key, onclick: () => openLib("artist", ar.key), onkeydown: (e) => { if (e.key === "Enter") openLib("artist", ar.key); } },
|
||||
h("div", { class: "tile-art round" }, cover(artistImage(ar), "tile-img", ar.name)),
|
||||
h("div", { class: "tile-art round" }, cover(artistImage(ar), "tile-img", ar.name, "user")),
|
||||
h("div", { class: "tile-title" }, ar.name),
|
||||
h("div", { class: "tile-sub" }, ar.albums.length ? plural(ar.albums.length, "release") : plural(ar.tracks.length, "song")));
|
||||
}
|
||||
@@ -916,7 +916,7 @@ function artistView(root, key) {
|
||||
root.append(
|
||||
h("header", { class: "hero artist-hero" },
|
||||
h("div", { class: "hero-bg", style: img ? `background-image:url("${artUrl(img)}")` : "" }),
|
||||
cover(img, "avatar", ar.name),
|
||||
cover(img, "avatar", ar.name, "user"),
|
||||
h("div", { class: "hero-meta" },
|
||||
h("div", { class: "kind-line" }, h("span", { class: "kind-btn", style: "cursor:default" }, icon("user"), "Artist")),
|
||||
ar.meta?.logo ? h("h1", { class: "hero-title big has-logo" }, h("img", { class: `artist-logo ${ar.meta.logoDark ? "dark" : ""}`, src: artUrl(ar.meta.logo), alt: ar.name })) : h("h1", { class: "hero-title big" }, ar.name),
|
||||
|
||||
+13
-1
@@ -155,6 +155,18 @@ function renderLyricsAll() {
|
||||
if (typeof Mini !== "undefined" && Mini.on) renderMiniPanel();
|
||||
}
|
||||
|
||||
function centerLine(el) {
|
||||
let box = el.parentElement;
|
||||
while (box && box !== document.body) {
|
||||
const style = getComputedStyle(box);
|
||||
if (/(auto|scroll)/.test(style.overflowY) && box.scrollHeight > box.clientHeight) break;
|
||||
box = box.parentElement;
|
||||
}
|
||||
if (!box || box === document.body) return;
|
||||
const target = el.getBoundingClientRect().top - box.getBoundingClientRect().top + box.scrollTop - (box.clientHeight - el.offsetHeight) / 2;
|
||||
box.scrollTo({ top: Math.max(0, target), behavior: reduced.matches ? "auto" : "smooth" });
|
||||
}
|
||||
|
||||
function tick() {
|
||||
Lyr.raf = 0;
|
||||
const visible = !$("#lyricsPanel").hidden || Lyr.tv || (typeof Mini !== "undefined" && Mini.on && Mini.panelShown && Mini.prefs.panel === "lyrics");
|
||||
@@ -177,7 +189,7 @@ function tick() {
|
||||
});
|
||||
if (box.classList.contains("depth")) setDepth(box, idx);
|
||||
const cur = box.querySelector(".lyr-line.on");
|
||||
if (cur) cur.scrollIntoView({ block: "center", behavior: reduced.matches ? "auto" : "smooth" });
|
||||
if (cur) centerLine(cur);
|
||||
}
|
||||
}
|
||||
const line = l.lines[idx];
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ const Mini = {
|
||||
|
||||
const MINI_MIN = { w: 260, h: 96 };
|
||||
const MINI_MAX = { w: 900, h: 900 };
|
||||
const MINI_CORE = 168;
|
||||
const MINI_CORE = 196;
|
||||
const MINI_STRIP = 112;
|
||||
const MINI_PANEL = 232;
|
||||
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ function qsResults(raw) {
|
||||
const add = (group, list, n, make) => list.slice(0, n).forEach(([, x], i) => out.push({ group: i === 0 ? group : null, ...make(x) }));
|
||||
const songItem = (t) => ({ kind: "song", title: t.title, sub: [t.artist, t.album].filter(Boolean).join(" · "), art: t.art, run: () => playList([t]), alt: () => Player.playNext([t]) });
|
||||
const albumItem = (a) => ({ kind: "album", title: a.title, sub: `${albumKind(a)} · ${a.artist}`, art: a.art, run: () => openLib("album", a.key), alt: () => playList(a.tracks) });
|
||||
const artistItem = (a) => ({ kind: "artist", title: a.name, sub: `Artist · ${plural(a.tracks.length, "song")}`, art: a.meta?.image || a.albums[0]?.art, round: true, run: () => openLib("artist", a.key), alt: () => playList(a.tracks, 0, true) });
|
||||
const artistItem = (a) => ({ kind: "artist", title: a.name, sub: `Artist · ${plural(a.tracks.length, "song")}`, art: a.meta?.image || null, icon: "user", round: true, run: () => openLib("artist", a.key), alt: () => playList(a.tracks, 0, true) });
|
||||
const listItem = (p) => ({ kind: "playlist", title: p.name, sub: `Playlist · ${plural(p.order.length, "song")}`, icon: p.linked ? "folder" : "playlist", run: () => openLib("playlist", p.name), alt: () => playList(p.order.map((id) => Lib.byId.get(id)).filter(Boolean)) });
|
||||
if (top && top[0] >= 60) {
|
||||
const x = top[1];
|
||||
|
||||
+1
-1
@@ -116,7 +116,7 @@ function statsView(root) {
|
||||
const artistRows = a.artists.slice(0, 8).map((e, i) => {
|
||||
const ar = Lib.artists.get(e.key);
|
||||
return h("div", { class: "rank-row", role: "button", tabindex: "0", onclick: () => ar && openLib("artist", ar.key) },
|
||||
h("span", { class: "rank" }, String(i + 1)), cover(ar ? artistImage(ar) : null, "lt-cover round"),
|
||||
h("span", { class: "rank" }, String(i + 1)), cover(ar ? artistImage(ar) : null, "lt-cover round", "", "user"),
|
||||
h("div", { class: "lt-main" }, h("span", { class: "lt-title" }, e.name), h("span", { class: "lt-sub" }, `${plural(e.plays, "play")} · ${fmtHours(e.ms)}`)));
|
||||
});
|
||||
body.append(h("div", { class: "stat-split" },
|
||||
|
||||
@@ -1183,3 +1183,11 @@ body.mini-mode > *:not(#mini):not(.toasts):not(.modal-wrap):not(script) { displa
|
||||
.keep-audio { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s3); align-items: start; margin-top: var(--s3); cursor: pointer; }
|
||||
.keep-audio span { display: grid; gap: 2px; }
|
||||
.keep-audio small { color: var(--text-3); font-size: 11.5px; line-height: 1.4; }
|
||||
|
||||
/* mini player: the cover gives way first, the controls never do */
|
||||
.mini.portrait .mini-body { flex: 0 1 auto; min-height: 0; }
|
||||
.mini.portrait .mini-art { flex: 0 1 auto; min-height: 0; width: auto; aspect-ratio: 1; max-width: calc(100% - 40px); }
|
||||
.mini.portrait .mini-art img, .mini.portrait .mini-art-empty { width: 100%; height: 100%; }
|
||||
.mini .mini-info, .mini .mini-ctl, .mini .mini-top { flex-shrink: 0; }
|
||||
.mini.has-panel .mini-panel { min-height: 96px; }
|
||||
.mini.tiny.has-panel .mini-panel { display: none; }
|
||||
|
||||
Reference in New Issue
Block a user