Web: Feishin-style layout and graphite default theme
Sidebar with icons and a playlist list, blurred-art detail headers with a round play toolbar, card hover play, track table with column headers and an album column, slimmer 90px player bar. Old amber default moves to graphite once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a708d28788
commit
e23311bff6
4 files changed
+183
-91
No files matched your search
+46
-13
@@ -15,6 +15,7 @@ const view = $("#view");
|
||||
// ---- appearance -------------------------------------------------------------------------------
|
||||
|
||||
const THEMES = {
|
||||
graphite: { bg: "#181819", panel: "#101010", raised: "#262628", line: "#2b2b2e", text: "#e7e7e7", muted: "#a8a8a8", accent: "#3a81ed" },
|
||||
amber: { bg: "#0d0e12", panel: "#15171d", raised: "#1d2028", line: "#262a33", text: "#eceef3", muted: "#8a8f9c", accent: "#f2b544" },
|
||||
ocean: { bg: "#0a1018", panel: "#101a26", raised: "#172434", line: "#1f2f42", text: "#e6eef7", muted: "#8698ad", accent: "#4cc2ff" },
|
||||
rose: { bg: "#120c10", panel: "#1b1218", raised: "#251922", line: "#33222e", text: "#f5e9f0", muted: "#a48b99", accent: "#ff6f9f" },
|
||||
@@ -28,7 +29,7 @@ const inkFor = hex => {
|
||||
return l > 0.6 ? "#141414" : "#ffffff";
|
||||
};
|
||||
function applyTheme() {
|
||||
const t = THEMES[S.theme] || THEMES.amber, a = S.accent || t.accent;
|
||||
const t = THEMES[S.theme] || THEMES.graphite, a = S.accent || t.accent;
|
||||
$("#theme").textContent = `:root{--bg:${t.bg};--panel:${t.panel};--raised:${t.raised};--line:${t.line};--text:${t.text};--muted:${t.muted};` +
|
||||
`--accent:${a};--accent-ink:${inkFor(a)};--glass:${t.panel}ee;--hover:${t.text}0d;--shadow:${t.light ? "#0003" : "#0009"};` +
|
||||
`--wave:${t.text}44;--wave-ghost:${t.text}14;color-scheme:${t.light ? "light" : "dark"}}`;
|
||||
@@ -592,7 +593,13 @@ function card({ href, img: src, fb, t, s = "", round, kind, srv, key }) {
|
||||
const nk = kind === "album" || kind === "artist" ? nameKey(t) : "";
|
||||
const hide = nk && !stemSets()[kind].has(nk);
|
||||
return `<a class="card ${round ? "round" : ""} ${hide ? "nostem" : ""}" href="${href}" ${kind ? `data-kind="${kind}" data-srv="${esc(srv)}" data-key="${esc(key)}"` : ""} ${nk ? `data-nk="${esc(nk)}"` : ""}>
|
||||
${src ? `<img loading="lazy" decoding="async" src="${esc(src)}" ${fb ? `data-fb="${esc(fb)}"` : ""} ${FB} alt="">` : `<div class="ph"></div>`}<div class="t">${esc(t)}</div><div class="s">${esc(s)}</div></a>`;
|
||||
<div class="art">${src ? `<img loading="lazy" decoding="async" src="${esc(src)}" ${fb ? `data-fb="${esc(fb)}"` : ""} ${FB} alt="">` : `<div class="ph"></div>`}${kind ? `<button class="cplay" data-cardplay title="Play">${ICON.play}</button>` : ""}</div><div class="t">${esc(t)}</div><div class="s">${esc(s)}</div></a>`;
|
||||
}
|
||||
// Tracks behind a card, for its play button and right-click menu.
|
||||
async function cardTracks(c) {
|
||||
const { kind, srv, key } = c.dataset;
|
||||
if (kind === "playlist") return ((await px(srv, `/playlists/${key}/items`)).Metadata || []).map(m => track(srv, m));
|
||||
return leaves(srv, key);
|
||||
}
|
||||
const albumCard = m => card({ href: `#/album/${m._srv}:${m.ratingKey}`, img: img(m._srv, m.thumb), t: m.title, s: [m.parentTitle, m.year].filter(Boolean).join(" · "), kind: "album", srv: m._srv, key: m.ratingKey });
|
||||
const artistCard = m => card({ href: `#/artist/${m._srv}:${m.ratingKey}`, img: img(m._srv, m.thumb), t: m.title, round: true, kind: "artist", srv: m._srv, key: m.ratingKey });
|
||||
@@ -600,15 +607,18 @@ const artistCard = m => card({ href: `#/artist/${m._srv}:${m.ratingKey}`, img: i
|
||||
const rowHtml = (listId, t, i, { numbers, album = true, mix } = {}) => `
|
||||
<tr data-list="${listId}" data-i="${i}" class="${Stems.find(t) ? "" : "nostem"} ${Q.cur()?.id === t.id ? "playing" : ""}">
|
||||
<td class="n">${numbers ? t.index ?? i + 1 : i + 1}</td>
|
||||
<td class="ti">${esc(t.title)}<span class="badge">${badge(t)}</span>${mix ? '<span class="tag">MIX</span>' : ""}${album ? `<small>${esc([t.artist, t.album].filter(Boolean).join(" · "))}</small>` : ""}</td>
|
||||
<td class="ti"><div class="tt">${esc(t.title)}<span class="badge">${badge(t)}</span>${mix ? '<span class="tag">MIX</span>' : ""}</div><small>${esc(t.artist || "")}</small></td>
|
||||
${album ? `<td class="al">${esc(t.album || "")}</td>` : ""}
|
||||
<td class="off">${Offline.has(t.id) ? ICON.download : ""}</td>
|
||||
<td class="d">${fmtTime(t.duration / 1000)}</td>
|
||||
<td class="acts"><button data-add title="Add to queue (shift: play next)">+</button><button data-menu title="More">${ICON.more}</button></td>
|
||||
</tr>`;
|
||||
const CLOCK = '<svg viewBox="0 0 24 24"><path d="M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20zm0 2a8 8 0 1 0 0 16 8 8 0 0 0 0-16zm-1 3h2v4.6l3.4 2-1 1.7L11 12.7V7z"/></svg>';
|
||||
const thead = (album = true) => `<thead><tr><th class="n">#</th><th class="ti">Title</th>${album ? '<th class="al">Album</th>' : ""}<th class="off"></th><th class="d">${CLOCK}</th><th class="acts"></th></tr></thead>`;
|
||||
function trackTable(listId, tracks, opts = {}) {
|
||||
lists[listId] = tracks;
|
||||
if (!tracks.length) return `<p class="empty-msg">Nothing here.</p>`;
|
||||
return `<table class="tracks"><tbody>${tracks.map((t, i) => rowHtml(listId, t, i, { ...opts, mix: listItems[listId]?.[i]?.mix })).join("")}</tbody></table>
|
||||
return `<table class="tracks">${thead(opts.album)}<tbody>${tracks.map((t, i) => rowHtml(listId, t, i, { ...opts, mix: listItems[listId]?.[i]?.mix })).join("")}</tbody></table>
|
||||
<p class="empty-msg only-stems">None of these have stems yet.</p><p class="empty-msg only-nostems">All of these have stems.</p>`;
|
||||
}
|
||||
|
||||
@@ -623,12 +633,13 @@ function sortControl(screen) {
|
||||
const bar = (title, { sort, filter = true, extra = "" } = {}) =>
|
||||
`<div class="bar"><h1>${esc(title)}</h1><span class="sub" id="count"></span><span class="grow"></span>${extra}${filter ? stemsChip() : ""}${sort ? sortControl(sort) : ""}</div>`;
|
||||
const actions = id => `<div class="actions">
|
||||
<button class="btn primary" data-play="${id}">${ICON.play} Play</button>
|
||||
<button class="btn" data-play="${id}" data-mode="shuffle">${ICON.shuffle} Shuffle</button>
|
||||
<button class="bigplay" data-play="${id}" title="Play">${ICON.play}</button>
|
||||
<button class="ibtn" data-play="${id}" data-mode="shuffle" title="Shuffle">${ICON.shuffle}</button>
|
||||
<button class="btn" data-play="${id}" data-mode="stem">Stem Now</button>
|
||||
<button class="btn icon" data-listmenu="${id}" title="More">${ICON.more}</button></div>`;
|
||||
const hero = (src, kind, title, sub, id, round, fb) => `<div class="hero">${src ? `<img src="${esc(src)}" ${fb ? `data-fb="${esc(fb)}"` : ""} ${FB} alt="" ${round ? 'class="round"' : ""}>` : `<div class="ph ${round ? "round" : ""}"></div>`}
|
||||
<div class="meta"><div class="kind">${kind}</div><h1>${esc(title)}</h1><div class="sub">${sub}</div>${id ? actions(id) : ""}</div></div>`;
|
||||
<button class="ibtn" data-listmenu="${id}" title="More">${ICON.more}</button></div>`;
|
||||
const hero = (src, kind, title, sub, id, round, fb) => `<header class="hero">${src ? `<div class="hero-bg"><img src="${esc(src)}" alt="" onerror="this.style.display='none'"></div>` : ""}
|
||||
<div class="hero-in">${src ? `<img class="art ${round ? "round" : ""}" src="${esc(src)}" ${fb ? `data-fb="${esc(fb)}"` : ""} ${FB} alt="">` : `<div class="ph ${round ? "round" : ""}"></div>`}
|
||||
<div class="meta"><div class="kind">${kind}</div><h1>${esc(title)}</h1><div class="sub">${sub}</div></div></div></header>${id ? actions(id) : ""}`;
|
||||
|
||||
function needPlex() {
|
||||
view.innerHTML = `<h1>Welcome</h1><p class="sub">Add a Plex server in <a class="link" href="#/settings">Settings</a> to browse your library, or <a class="link" href="#/stems">browse the stems</a> on their own.</p>`;
|
||||
@@ -775,7 +786,7 @@ const routes = {
|
||||
const srcs = sources();
|
||||
if (!srcs.length) return needPlex();
|
||||
view.innerHTML = bar("Songs", { sort: "songs", extra: `<button class="chip" data-shuffleall>${ICON.shuffle} Shuffle all</button>` })
|
||||
+ `<table class="tracks"><tbody></tbody></table><p class="empty-msg only-stems">No songs with stems loaded yet. Scroll for more.</p><p class="empty-msg only-nostems">Every song loaded so far has stems. Scroll for more.</p>`;
|
||||
+ `<table class="tracks">${thead()}<tbody></tbody></table><p class="empty-msg only-stems">No songs with stems loaded yet. Scroll for more.</p><p class="empty-msg only-nostems">Every song loaded so far has stems. Scroll for more.</p>`;
|
||||
lists.songs = [];
|
||||
const size = S.stemFilter ? 1000 : 150;
|
||||
await paged(my, $("tbody", view), new Pager(srcs, secPath, { type: 10, sort: sortState("songs").param }, size), size, (ms, off) => {
|
||||
@@ -814,7 +825,8 @@ const routes = {
|
||||
if (my !== seq) return;
|
||||
pls = st.random ? pls.sort(() => Math.random() - 0.5) : pls.sort(comparator(st.param));
|
||||
count(pls.length + playlists.length, "playlist");
|
||||
$("#plexpl").innerHTML = pls.length ? `<div class="grid">${pls.map(p => card({ href: `#/playlist/${p._srv}:${p.ratingKey}`, img: img(p._srv, p.thumb || p.composite), fb: p.composite && rawImg(p._srv, p.composite), t: p.title, s: plural(p.leafCount || 0, "track") })).join("")}</div>`
|
||||
navPls = [...pls].sort((a, b) => a.title.localeCompare(b.title)); navPlaylists();
|
||||
$("#plexpl").innerHTML = pls.length ? `<div class="grid">${pls.map(p => card({ href: `#/playlist/${p._srv}:${p.ratingKey}`, img: img(p._srv, p.thumb || p.composite), fb: p.composite && rawImg(p._srv, p.composite), t: p.title, s: plural(p.leafCount || 0, "track"), kind: "playlist", srv: p._srv, key: p.ratingKey })).join("")}</div>`
|
||||
: `<p class="empty-msg">No music playlists.</p>`;
|
||||
},
|
||||
async album(my, arg) {
|
||||
@@ -899,11 +911,26 @@ const routes = {
|
||||
settings: renderSettings,
|
||||
};
|
||||
|
||||
// Sidebar playlist list: stem playlists, then Plex ones (fetched at start and on the Playlists page).
|
||||
let navPls = [], navHtml = "";
|
||||
function navPlaylists() {
|
||||
const box = $("#nav-pl"), html = playlists.map(p => `<a href="#/stemplaylist/${p.id}">${esc(p.title)}</a>`).join("")
|
||||
+ navPls.map(p => `<a href="#/playlist/${p._srv}:${p.ratingKey}">${esc(p.title)}</a>`).join("");
|
||||
if (html !== navHtml) { navHtml = html; box.innerHTML = html; }
|
||||
for (const a of box.children) a.classList.toggle("on", a.getAttribute("href") === location.hash);
|
||||
}
|
||||
async function loadNavPlaylists() {
|
||||
if (!liveServers().length) return;
|
||||
try { navPls = (await everything(liveServers().map(srv => ({ srv })), "/playlists", { playlistType: "audio" })).sort((a, b) => a.title.localeCompare(b.title)); } catch {}
|
||||
navPlaylists();
|
||||
}
|
||||
|
||||
async function route() {
|
||||
const my = ++seq;
|
||||
const [, name = "home", ...rest] = (location.hash || "#/home").split("/");
|
||||
const arg = decodeURIComponent(rest.join("/"));
|
||||
$$("#nav a").forEach(a => a.classList.toggle("on", a.dataset.nav === name || (a.dataset.nav === "genres" && name === "genre") || (a.dataset.nav === "playlists" && /playlist$/.test(name))));
|
||||
navPlaylists();
|
||||
lists = {}; listItems = {}; kick = null;
|
||||
delete view.dataset.genre;
|
||||
view.scrollTop = 0;
|
||||
@@ -923,6 +950,11 @@ view.addEventListener("click", async ev => {
|
||||
const el = ev.target.closest("button, tr[data-list]");
|
||||
if (!el) return;
|
||||
const ds = el.dataset, row = ev.target.closest("tr[data-list]");
|
||||
if ("cardplay" in ds) {
|
||||
ev.preventDefault();
|
||||
const ts = await cardTracks(el.closest(".card"));
|
||||
return ts.length ? Q.playList(ts, 0, false) : toast("Nothing to play");
|
||||
}
|
||||
if (ds.stemfilter) { S.stemFilter = S.stemFilter === ds.stemfilter ? "" : ds.stemfilter; save(); applyStemFilter(); return; }
|
||||
if ("sortdir" in ds) { pickSort(ds.sortdir, sortState(ds.sortdir).i); return route(); }
|
||||
if ("reshuffle" in ds) return route();
|
||||
@@ -989,7 +1021,7 @@ view.addEventListener("change", ev => {
|
||||
view.addEventListener("contextmenu", ev => {
|
||||
const row = ev.target.closest("tr[data-list]"), c = ev.target.closest(".card[data-kind]");
|
||||
if (row) { ev.preventDefault(); trackMenu(ev.clientX, ev.clientY, row.dataset.list, +row.dataset.i); }
|
||||
else if (c) { ev.preventDefault(); listMenu(ev.clientX, ev.clientY, () => leaves(c.dataset.srv, c.dataset.key), { title: $(".t", c).textContent, href: c.getAttribute("href") }); }
|
||||
else if (c) { ev.preventDefault(); listMenu(ev.clientX, ev.clientY, () => cardTracks(c), { title: $(".t", c).textContent, href: c.getAttribute("href") }); }
|
||||
});
|
||||
|
||||
// ---- settings -----------------------------------------------------------------------------------
|
||||
@@ -1028,7 +1060,7 @@ function serverHtml(srv) {
|
||||
}
|
||||
|
||||
function renderSettings() {
|
||||
const theme = THEMES[S.theme] || THEMES.amber;
|
||||
const theme = THEMES[S.theme] || THEMES.graphite;
|
||||
view.innerHTML = `<div class="settings"><nav class="toc">${SECTIONS.map(([id, l]) => `<a href="#/settings" data-jump="${id}">${l}</a>`).join("")}</nav><div class="panes">
|
||||
<section id="set-plex"><h2>Plex</h2>
|
||||
<p class="note">Turn on the music libraries you want. Everything that's on is browsed as one library.</p>
|
||||
@@ -1210,6 +1242,7 @@ async function connect() {
|
||||
Q.restore();
|
||||
UI.all();
|
||||
route();
|
||||
loadNavPlaylists();
|
||||
Live.poll();
|
||||
setInterval(() => { if (!document.hidden) Stems.refresh(); }, 5 * 60 * 1000);
|
||||
})();
|
||||
Reference in new issue
Block a user