diff --git a/_config.ts b/_config.ts index 2a471714..8593a24e 100644 --- a/_config.ts +++ b/_config.ts @@ -123,7 +123,8 @@ phosphor("bold/Phosphor-Bold.woff2"); // MISC -site.add("/themes/loader/constituent/examples/"); +site.add([".htm"]); +site.add([".txt"]); site.use(sourceMaps()); site.script("copy-type-defs", () => { diff --git a/src/_components/constituents.vto b/src/_components/constituents.vto new file mode 100644 index 00000000..341a2714 --- /dev/null +++ b/src/_components/constituents.vto @@ -0,0 +1,17 @@ + diff --git a/src/themes/loader/constituent/examples/generate-playlist.txt b/src/constituents/examples/generate-playlist.html.txt similarity index 100% rename from src/themes/loader/constituent/examples/generate-playlist.txt rename to src/constituents/examples/generate-playlist.html.txt diff --git a/src/themes/loader/constituent/examples/now-playing.txt b/src/constituents/examples/now-playing.html.txt similarity index 100% rename from src/themes/loader/constituent/examples/now-playing.txt rename to src/constituents/examples/now-playing.html.txt diff --git a/src/themes/loader/constituent/index.js b/src/constituents/index.js similarity index 79% rename from src/themes/loader/constituent/index.js rename to src/constituents/index.js index 3ab006cf..a72b793b 100644 --- a/src/themes/loader/constituent/index.js +++ b/src/constituents/index.js @@ -35,18 +35,23 @@ effect(() => { ${col.map((c) => html`
  • - - ${c.name} - -
    - - - Delete - - + ${c.name} +
    +
    + Open + + + +
    +
  • ` )} @@ -63,8 +68,7 @@ effect(() => { const emptyConstituentsList = html`

    - You have not added any constituents yet. Add - or create some using the tools below. + You have not saved any constituents yet.

    `; @@ -73,6 +77,9 @@ const emptyConstituentsList = html` */ function deleteConstituent({ cid, name }) { return () => { + const c = confirm("Are you sure you want to delete this constituent?"); + if (!c) return; + output.constituents.save( output.constituents.collection().filter((c) => !(c.name === name && c.cid === cid) @@ -161,9 +168,7 @@ async function onBuildSubmit(event) { const selected = document.body.querySelector("#example-select"); if (selected?.value) { - const text = await fetch( - `themes/loader/constituent/examples/${selected.value}`, - ).then((r) => r.text()); + const text = await fetch(selected.value).then((r) => r.text()); editor.dispatch({ changes: { from: 0, to: editor.state.doc.length, insert: text }, @@ -176,7 +181,7 @@ async function onBuildSubmit(event) { break; case "save+open": await saveConstituent(constituent); - window.open(`${location.href}s/?cid=${constituent.cid}`, "blank"); + window.open(`./constituents/l/?cid=${constituent.cid}`, "blank"); break; } } diff --git a/src/themes/loader/constituent/index.vto b/src/constituents/index.vto similarity index 71% rename from src/themes/loader/constituent/index.vto rename to src/constituents/index.vto index 5e6730f5..4bd14998 100644 --- a/src/themes/loader/constituent/index.vto +++ b/src/constituents/index.vto @@ -1,6 +1,6 @@ --- layout: layouts/constituent.vto -base: ../../../ +base: ../ styles: - styles/base.css @@ -9,7 +9,23 @@ styles: - styles/vendor/phosphor/fill/style.css scripts: - - themes/loader/constituent/index.js + - constituents/index.js + +# CONSTITUENTS + +constituents: + - url: "themes/blur/artwork-controller/constituent.html.txt" + title: "Blur / Artwork controller" + desc: > + Audio playback controller with an artwork display. + - url: "themes/webamp/browser/constituent.html.txt" + title: "Webamp / Browser" + desc: > + Collection browser + search in a retro, win98, look. + - url: "themes/webamp/configurators/input/constituent.html.txt" + title: "Webamp / Input Configurator" + desc: > + Windows 98 styled input configurator where you can add music sources. ---
    @@ -19,46 +35,61 @@ scripts: {{ await comp.diffuse.logo() }} -

    - Constituent loader ❈ +

    + Constituents

    - Missing a feature, or prefer a different user interface that is not part of Diffuse? Add it here. This tool allows you to load a custom constituent besides the existing ones. + Constituents are various interface components each loaded in their own web page. Every used component is configured so that it operates in broadcast mode, making all the pages communicate with each other.

    + +
    - -
    -
    - -
    -

    Yours

    -
    -
    -
    - - +
    -

    Generate

    -

    - On the todo list, the idea is to have AI generate a piece of UI for you; building on the logical blocks provided by Diffuse. -

    +

    Built-in

    + +
    + {{ await comp.constituents({ items: constituents }) }} +

    Community

    - +

    Nothing here yet, too early.

    + +
    +
    +

    Your collection

    +
    +
    + +
    +

    Examples

    +
    +
    + + +
    +

    Build

    @@ -75,7 +106,7 @@ scripts:

    - Your code here builds on the foundation listed below, it'll be injected into a <div id="container"> element in the body. + Your code here builds on the foundation listed below, it'll be injected into a <div id="container"> element in the body.

    @@ -93,8 +124,8 @@ scripts: - - + +

    diff --git a/src/themes/loader/constituent/s/index.js b/src/constituents/l/index.js similarity index 71% rename from src/themes/loader/constituent/s/index.js rename to src/constituents/l/index.js index 7f2b2a25..8f3efc18 100644 --- a/src/themes/loader/constituent/s/index.js +++ b/src/constituents/l/index.js @@ -1,3 +1,5 @@ +import * as CID from "@atcute/cid"; + import foundation from "@common/constituents/foundation.js"; import { effect } from "@common/signal.js"; @@ -15,10 +17,11 @@ const output = foundation.orchestrator.output(); // URL PARAMS //////////////////////////////////////////// -const url = new URL(document.location.href); +const docUrl = new URL(document.location.href); -const cid = url.searchParams.get("cid"); -const name = url.searchParams.get("name"); +const cid = docUrl.searchParams.get("cid"); +const name = docUrl.searchParams.get("name"); +const url = docUrl.searchParams.get("url"); //////////////////////////////////////////// // LOAD @@ -29,7 +32,7 @@ if (!containerNull) throw new Error("Container not found"); const container = /** @type {HTMLDivElement} */ (containerNull); -effect(() => { +effect(async () => { const collection = output.constituents.collection(); if (output.constituents.state() !== "loaded") return; @@ -39,6 +42,20 @@ effect(() => { constituent = collection.find((c) => c.cid === cid); } else if (name) { constituent = collection.find((c) => c.name === name); + } else if (url) { + const html = await fetch(url).then((res) => res.text()); + const cid = await CID.create(0x55, new TextEncoder().encode(html)); + const name = "tryout"; + + /** @type {Constituent} */ + const c = { + $type: "sh.diffuse.output.constituent", + cid: CID.toString(cid), + html, + name, + }; + + constituent = c; } // TODO: Message that constituent was not found diff --git a/src/themes/loader/constituent/s/index.vto b/src/constituents/l/index.vto similarity index 56% rename from src/themes/loader/constituent/s/index.vto rename to src/constituents/l/index.vto index ed2de573..c8f9cf46 100644 --- a/src/themes/loader/constituent/s/index.vto +++ b/src/constituents/l/index.vto @@ -1,9 +1,9 @@ --- layout: layouts/constituent.vto -base: ../../../../ +base: ../../ scripts: - - themes/loader/constituent/s/index.js + - constituents/l/index.js ---

    diff --git a/src/index.vto b/src/index.vto index fadf7079..b1c32a98 100644 --- a/src/index.vto +++ b/src/index.vto @@ -27,26 +27,6 @@ themes: desc: > **Winamp 2 + Windows 98**. Uses Webamp as the audio player connected to various Diffuse elements. Also features a desktop-like Windows 98 environment in which you can open "programs" that control the used Diffuse elements. -# CONSTITUENTS - -constituents: - - url: "themes/blur/artwork-controller/" - title: "Blur / Artwork controller" - desc: > - Audio playback controller with artwork display. - - url: "themes/loader/constituent/" - title: "Loader" - desc: > - **Bring in other constituents!** Load a constituent from a code snippet, store it in your user data output, explore community creations, or generate one. - - url: "themes/webamp/browser/" - title: "Webamp / Browser" - desc: > - Collection browser + search in a retro, win98, look. - - url: "themes/webamp/configurators/input/" - title: "Webamp / Input Configurator" - desc: > - Windows 98 styled input configurator where you can add music sources. - # ELEMENTS configurators: diff --git a/src/styles/diffuse/page.css b/src/styles/diffuse/page.css index 7569c85a..e7ad9830 100644 --- a/src/styles/diffuse/page.css +++ b/src/styles/diffuse/page.css @@ -344,18 +344,30 @@ ul li::marker { } .list-description { + color: oklch(from currentColor l c h / 0.6); font-size: var(--fs-xs); margin-bottom: var(--space-xs); margin-top: var(--space-2xs); - opacity: 0.6; a { text-underline-offset: 3px; } + button, + .button { + line-height: 1; + padding: var(--space-3xs); + border-radius: var(--radius-xs); + } + code { font-size: var(--fs-xs); } + + .button-row { + gap: var(--space-3xs); + margin: 0 0 var(--space-2xs); + } } .table-of-contents { diff --git a/src/themes/blur/artwork-controller/constituent.html.txt b/src/themes/blur/artwork-controller/constituent.html.txt new file mode 100644 index 00000000..dcb417d5 --- /dev/null +++ b/src/themes/blur/artwork-controller/constituent.html.txt @@ -0,0 +1,7 @@ + + + diff --git a/src/themes/blur/artwork-controller/constituent.js b/src/themes/blur/artwork-controller/constituent.js new file mode 100644 index 00000000..30bd84d6 --- /dev/null +++ b/src/themes/blur/artwork-controller/constituent.js @@ -0,0 +1,24 @@ +import foundation from "@common/constituents/foundation.js"; +import ArtworkController from "@themes/blur/artwork-controller/element.js"; + +// Setup the prerequisite elements +foundation.features.fillQueueAutomatically(); +foundation.features.playAudioFromQueue(); +foundation.features.processInputs(); + +const aud = foundation.engine.audio(); +const art = foundation.processor.artwork(); +const inp = foundation.orchestrator.input(); +const que = foundation.engine.queue(); +const rse = foundation.engine.repeatShuffle(); + +// Controller +const dac = new ArtworkController(); +dac.setAttribute("artwork-processor-selector", art.selector); +dac.setAttribute("audio-engine-selector", aud.selector); +dac.setAttribute("input-selector", inp.selector); +dac.setAttribute("queue-engine-selector", que.selector); +dac.setAttribute("repeat-shuffle-engine-selector", rse.selector); + +// Add to DOM +document.body.append(dac); diff --git a/src/themes/index.js b/src/themes/index.js new file mode 100644 index 00000000..e69de29b diff --git a/src/themes/index.vto b/src/themes/index.vto new file mode 100644 index 00000000..25132695 --- /dev/null +++ b/src/themes/index.vto @@ -0,0 +1,43 @@ +--- +layout: layouts/constituent.vto +base: ../ + +styles: + - styles/base.css + - styles/diffuse/page.css + - styles/vendor/phosphor/bold/style.css + - styles/vendor/phosphor/fill/style.css + +scripts: + - themes/index.js +--- + +
    +
    +
    + +
    +

    + Themes +

    +

    + Themes are element compositions and provide a traditional browser web application way of + using them. In other words, pretty much the whole thing, besides your data, lives inside a single browser tab. +

    + +

    + + + Each theme is unique, not just a skin; each one might have a totally different feature set. + +

    +
    +
    +
    +
    +

    + TODO +

    +
    diff --git a/src/themes/webamp/browser/index.vto b/src/themes/webamp/browser/constituent.html.txt similarity index 68% rename from src/themes/webamp/browser/index.vto rename to src/themes/webamp/browser/constituent.html.txt index dbf0ea4e..0d5fcc7a 100644 --- a/src/themes/webamp/browser/index.vto +++ b/src/themes/webamp/browser/constituent.html.txt @@ -1,18 +1,3 @@ ---- -layout: layouts/constituent.vto -base: ../../../ - -styles: - - styles/vendor/98.css - - themes/webamp/fonts.css - - themes/webamp/constituent.css - -scripts: - - themes/webamp/browser/index.js ---- - - -
    + + + + diff --git a/src/themes/webamp/browser/index.js b/src/themes/webamp/browser/constituent.js similarity index 100% rename from src/themes/webamp/browser/index.js rename to src/themes/webamp/browser/constituent.js diff --git a/src/themes/webamp/configurators/input/index.vto b/src/themes/webamp/configurators/input/constituent.html.txt similarity index 67% rename from src/themes/webamp/configurators/input/index.vto rename to src/themes/webamp/configurators/input/constituent.html.txt index 5cd474fd..0629f310 100644 --- a/src/themes/webamp/configurators/input/index.vto +++ b/src/themes/webamp/configurators/input/constituent.html.txt @@ -1,18 +1,3 @@ ---- -layout: layouts/constituent.vto -base: ../../../../ - -styles: - - styles/vendor/98.css - - themes/webamp/fonts.css - - themes/webamp/constituent.css - -scripts: - - themes/webamp/configurators/input/index.js ---- - - -
    + + + + diff --git a/src/themes/webamp/configurators/input/index.js b/src/themes/webamp/configurators/input/constituent.js similarity index 100% rename from src/themes/webamp/configurators/input/index.js rename to src/themes/webamp/configurators/input/constituent.js