diff --git a/src/_components/facets/grid.vto b/src/_components/facets/grid.vto index 4fecfdfb..59ad6863 100644 --- a/src/_components/facets/grid.vto +++ b/src/_components/facets/grid.vto @@ -18,7 +18,9 @@
  • diff --git a/src/_data/facets.yaml b/src/_data/facets.yaml index 3cec433b..8c7ca7eb 100644 --- a/src/_data/facets.yaml +++ b/src/_data/facets.yaml @@ -10,6 +10,13 @@ featured: true desc: > Automatically put tracks into the queue. +- url: "facets/scrobble/index.html" + title: "Scrobble" + kind: "prelude" + category: Misc + featured: true + desc: > + Enable scrobbling, keep track of what you're listening to. - url: "facets/scrobble/last.fm/index.html" title: "Scrobble / Last.fm" category: Misc diff --git a/src/common/facets/foundation.js b/src/common/facets/foundation.js index a938b83e..4976e5b4 100644 --- a/src/common/facets/foundation.js +++ b/src/common/facets/foundation.js @@ -82,7 +82,7 @@ async function fillQueueAutomatically() { } async function playAudioFromQueue() { - const [a, q, ms, qa, sca] = await Promise.all([ + const [a, q, ms, qa] = await Promise.all([ // engine audio(), queue(), @@ -90,7 +90,6 @@ async function playAudioFromQueue() { // orchestrator mediaSession(), queueAudio(), - scrobbleAudio(), ]); return { @@ -101,7 +100,6 @@ async function playAudioFromQueue() { orchestrator: { mediaSession: ms, queueAudio: qa, - scrobbleAudio: sca, }, }; } diff --git a/src/common/facets/utils.js b/src/common/facets/utils.js index ffa39666..d5fc1541 100644 --- a/src/common/facets/utils.js +++ b/src/common/facets/utils.js @@ -10,10 +10,13 @@ import * as CID from "../cid.js"; */ /** - * @param {{ name: string; uri: string }} _args + * @param {{ description?: string; kind: string | undefined; name: string; uri: string }} _args * @param {{ fetchHTML: boolean }} options */ -export async function facetFromURI({ name, uri }, { fetchHTML }) { +export async function facetFromURI( + { description, kind, name, uri }, + { fetchHTML }, +) { const html = fetchHTML ? await loadURI(uri) : undefined; const cid = html ? await CID.create(0x55, new TextEncoder().encode(html)) @@ -26,8 +29,10 @@ export async function facetFromURI({ name, uri }, { fetchHTML }) { createdAt: timestamp, id: TID.now(), cid, + description, html, name, + kind: kind === "interactive" || kind === "prelude" ? kind : undefined, updatedAt: timestamp, uri, }; diff --git a/src/facets/common/build.js b/src/facets/common/build.js index 47b042f9..7f878374 100644 --- a/src/facets/common/build.js +++ b/src/facets/common/build.js @@ -105,7 +105,8 @@ async (event) => { const cid = await CID.create(0x55, new TextEncoder().encode(html)); const name = nameEl?.value ?? "nameless"; const description = descriptionEl?.value ?? ""; - const kind = /** @type {"interactive" | "prelude"} */ (kindEl?.value ?? "interactive"); + const kind = + /** @type {"interactive" | "prelude"} */ (kindEl?.value ?? "interactive"); /** @type {Facet} */ const facet = $editingFacet.value @@ -231,9 +232,13 @@ export function listenForExamplesEdit() { const name = target.closest("li")?.getAttribute("data-name"); if (!name) return; + const kind = target.closest("li")?.getAttribute("data-kind") ?? undefined; + switch (rel) { case "edit": { - const facet = await facetFromURI({ name, uri }, { fetchHTML: true }); + const facet = await facetFromURI({ kind, name, uri }, { + fetchHTML: true, + }); editFacet(facet); document.querySelector("#build")?.scrollIntoView(); break; diff --git a/src/facets/common/grid.js b/src/facets/common/grid.js index cd3178f0..4996d46f 100644 --- a/src/facets/common/grid.js +++ b/src/facets/common/grid.js @@ -26,6 +26,9 @@ export function insertToggleButtons() { const uri = li.getAttribute("data-uri"); const name = li.getAttribute("data-name"); + const kind = li.getAttribute("data-kind") ?? undefined; + const description = li.getAttribute("data-description") ?? undefined; + if (!uri || !name) return; const out = await foundation.orchestrator.output(); @@ -35,7 +38,9 @@ export function insertToggleButtons() { if (isActive) { out.facets.save(collection.filter((f) => f.uri !== uri)); } else { - const facet = await facetFromURI({ name, uri }, { fetchHTML: false }); + const facet = await facetFromURI({ description, kind, name, uri }, { + fetchHTML: false, + }); out.facets.save([...collection, facet]); } }); diff --git a/src/facets/common/you.js b/src/facets/common/you.js index 8b7ea9b5..8c89b6d4 100644 --- a/src/facets/common/you.js +++ b/src/facets/common/you.js @@ -86,6 +86,13 @@ function openAddFromURIModal() { autocomplete="off" />
    +
    + + +
    { e.preventDefault(); + const nameEl = /** @type {HTMLInputElement} */ ( dialog?.querySelector("#add-uri-name") ); + + const kindEl = /** @type {HTMLSelectElement} */ ( + dialog?.querySelector("#add-uri-kind") + ); + const uriEl = /** @type {HTMLInputElement} */ ( dialog?.querySelector("#add-uri-uri") ); + const name = nameEl?.value.trim() ?? ""; + const kind = kindEl?.value ?? "interactive"; const uri = uriEl?.value.trim() ?? ""; if (!name || !uri) return; - const facet = await facetFromURI({ name, uri }, { fetchHTML: false }); + + const facet = await facetFromURI({ kind, name, uri }, { fetchHTML: false }); await saveFacet(facet); + /** @type {HTMLDialogElement} */ (dialog).close(); }, ); @@ -137,10 +154,14 @@ function openAddFromURIModal() { const nameEl = /** @type {HTMLInputElement} */ ( dialog.querySelector("#add-uri-name") ); + const kindEl = /** @type {HTMLSelectElement} */ ( + dialog.querySelector("#add-uri-kind") + ); const uriEl = /** @type {HTMLInputElement} */ ( dialog.querySelector("#add-uri-uri") ); if (nameEl) nameEl.value = ""; + if (kindEl) kindEl.value = "interactive"; if (uriEl) uriEl.value = ""; dialog.showModal(); diff --git a/src/facets/scrobble/index.html b/src/facets/scrobble/index.html new file mode 100644 index 00000000..7d77886c --- /dev/null +++ b/src/facets/scrobble/index.html @@ -0,0 +1 @@ + diff --git a/src/facets/scrobble/index.inline.js b/src/facets/scrobble/index.inline.js new file mode 100644 index 00000000..f2b33d8b --- /dev/null +++ b/src/facets/scrobble/index.inline.js @@ -0,0 +1,2 @@ +import foundation from "~/common/facets/foundation.js"; +await foundation.orchestrator.scrobbleAudio(); diff --git a/src/styles/diffuse/page.css b/src/styles/diffuse/page.css index c75ca4de..1c4ce119 100644 --- a/src/styles/diffuse/page.css +++ b/src/styles/diffuse/page.css @@ -225,8 +225,8 @@ textarea { select { appearance: none; background: transparent; - border: 2px solid var(--form-color); - border-radius: var(--radius-md); + border: 3px solid var(--form-color); + border-radius: var(--radius-sm); color: inherit; font-family: inherit; font-size: var(--fs-sm); @@ -304,8 +304,9 @@ textarea { border-radius: 9999px; display: inline-block; font-size: var(--fs-2xs); - font-weight: 500; - padding: 1px var(--space-3xs); + font-weight: 600; + padding: var(--space-3xs); + text-box: trim-both cap alphabetic; vertical-align: middle; }