Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(play-economy): keep the economy panels inside a 320px viewport and move split-bar labels into a legend
nirholas733a5ebcc21a
diff --git a/src/play-economy.css b/src/play-economy.cssindex ed96f7fca..a94c40b3f 100644--- a/src/play-economy.css+++ b/src/play-economy.css@@ -192,7 +192,11 @@.pe-split {display: grid;- grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));+ /* min() on the track floor so the single column of a narrow viewport can+ shrink below its preferred width instead of overflowing. html and body+ carry overflow-x: clip, so an overflowing track is not scrollable: it is+ silently cut off, which lost the right edge of this panel at 320px. */+ grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));gap: 16px;align-items: start;}@@ -201,7 +205,7 @@.pe-cur-grid {display: grid;- grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));+ grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));gap: 16px;}.pe-cur {@@ -380,7 +384,7 @@.pe-fit-grid {display: grid;- grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));+ grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));gap: 14px;margin-bottom: 18px;}@@ -425,6 +429,11 @@background: var(--sw, var(--surface-3, rgba(255, 255, 255, 0.08)));border: 1px solid var(--stroke, rgba(255, 255, 255, 0.14));}+.pe-fit-thumb {+ object-fit: contain;+ padding: 2px;+ background: var(--surface-3, rgba(255, 255, 255, 0.08));+}.pe-fit-body {flex: 1 1 auto;min-width: 0;@@ -499,36 +508,63 @@font-weight: var(--weight-semibold, 600);}+.pe-splitfig {+ margin: 0;+}.pe-splitbar {display: flex;overflow: hidden;+ height: 14px;border-radius: var(--radius-pill, 999px);border: 1px solid var(--stroke, rgba(255, 255, 255, 0.1));}.pe-splitbar-seg {width: var(--w, 50%);- padding: 8px 12px;- font-size: var(--text-2xs, 0.6875rem);- font-weight: var(--weight-semibold, 600);- white-space: nowrap;- overflow: hidden;- text-overflow: ellipsis;- text-align: center;}.pe-splitbar-rewards {- background: color-mix(in srgb, var(--pe-chain) 24%, transparent);- color: var(--pe-chain);+ background: color-mix(in srgb, var(--pe-chain) 62%, transparent);}.pe-splitbar-treasury {- background: color-mix(in srgb, var(--pe-cash) 24%, transparent);- color: var(--pe-cash);+ background: color-mix(in srgb, var(--pe-cash) 62%, transparent);+}+.pe-splitlegend {+ display: flex;+ flex-wrap: wrap;+ gap: 6px 20px;+ margin-top: 10px;+ font-size: var(--text-xs, 0.75rem);+}+.pe-splitkey {+ display: inline-flex;+ align-items: center;+ gap: 7px;+}+.pe-splitdot {+ flex: none;+ width: 10px;+ height: 10px;+ border-radius: var(--radius-pill, 999px);+}+.pe-splitkey-rewards .pe-splitdot {+ background: var(--pe-chain);+}+.pe-splitkey-treasury .pe-splitdot {+ background: var(--pe-cash);+}+.pe-splitpct {+ font-weight: var(--weight-semibold, 600);+ font-variant-numeric: tabular-nums;+ color: var(--ink-bright, #fff);+}+.pe-splitname {+ color: var(--ink-dim, #9aa1ad);}/* --- stats + odds -------------------------------------------------------- */.pe-stats {display: grid;- grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));+ grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));gap: 12px;margin-bottom: 18px;}diff --git a/src/play-economy.js b/src/play-economy.jsindex 0de1261bc..eb460f8e8 100644--- a/src/play-economy.js+++ b/src/play-economy.js@@ -26,6 +26,13 @@ const fmtPct = (n) =>const RARITY_ORDER = ['common', 'uncommon', 'rare', 'epic', 'legendary'];+/**+ * A failed fetch surfaces as a bare browser string ("Failed to fetch") with no+ * terminating period, so appending the retry hint to it produced one run-on+ * sentence. Terminate anything that does not already end one.+ */+const sentence = (s) => (/[.!?]$/.test(s.trim()) ? s.trim() : `${s.trim()}.`);+function el(tag, props = {}, kids = []) {const n = document.createElement(tag);for (const [k, v] of Object.entries(props)) {@@ -188,6 +195,69 @@ function renderBank(data) {]);}+/**+ * A proportional split bar whose labels live in a legend underneath rather than+ * inside the segments. Text inside a segment has to fit that segment, which it+ * cannot at 320px, and clipping "50% holder rewards" down to "50% holder re..."+ * loses the one thing the bar exists to say. A legend also stays readable if the+ * split is ever re-weighted to something lopsided, where the smaller segment+ * would be far too narrow to hold any text at all.+ */+function splitBar(parts, label) {+ return el('figure', { class: 'pe-splitfig' }, [+ el(+ 'div',+ { class: 'pe-splitbar', role: 'img', 'aria-label': label },+ parts.map((p) =>+ el('div', {+ class: `pe-splitbar-seg pe-splitbar-${p.tone}`,+ style: `--w:${p.pct}%`,+ }),+ ),+ ),+ el(+ 'figcaption',+ { class: 'pe-splitlegend' },+ parts.map((p) =>+ el('span', { class: `pe-splitkey pe-splitkey-${p.tone}` }, [+ el('span', { class: 'pe-splitdot', 'aria-hidden': 'true' }),+ el('strong', { class: 'pe-splitpct', text: `${fmtPct(p.pct)}%` }),+ el('span', { class: 'pe-splitname', text: p.label }),+ ]),+ ),+ ),+ ]);+}++/**+ * The visual for one boutique listing. Dyes and auras are a flat colour and get+ * the swatch circle; hats and eyewear are modelled items and ship a rendered+ * thumbnail, which the API already serves. Without this the two thumbnail+ * listings rendered as blank grey circles next to five coloured ones. The alt+ * is empty on purpose: the item name sits beside it, so the image is decorative+ * and announcing it twice only adds noise for a screen reader.+ */+function fitSwatch(c) {+ const plain = () =>+ el('div', {+ class: 'pe-fit-swatch',+ style: c.swatch ? `--sw:${c.swatch}` : null,+ 'aria-hidden': 'true',+ });+ if (!c.thumb) return plain();+ const img = el('img', {+ class: 'pe-fit-swatch pe-fit-thumb',+ src: c.thumb,+ alt: '',+ width: '34',+ height: '34',+ loading: 'lazy',+ decoding: 'async',+ onerror: () => img.replaceWith(plain()),+ });+ return img;+}+function renderBoutique(data) {const { listings, currency, rewardsBps, treasuryBps } = data.boutique;const sorted = [...listings].sort((a, b) => {@@ -202,11 +272,7 @@ function renderBoutique(data) {{ class: 'pe-fit-grid' },sorted.map((c) =>el('article', { class: `pe-fit pe-rar-${c.rarity || 'common'}` }, [- el('div', {- class: 'pe-fit-swatch',- style: c.swatch ? `--sw:${c.swatch}` : null,- 'aria-hidden': 'true',- }),+ fitSwatch(c),el('div', { class: 'pe-fit-body' }, [el('h4', { class: 'pe-fit-name', text: c.name }),el('p', { class: 'pe-fit-meta' }, [@@ -222,18 +288,15 @@ function renderBoutique(data) {),);- const split = el('div', { class: 'pe-splitbar' }, [- el('div', {- class: 'pe-splitbar-seg pe-splitbar-rewards',- style: `--w:${rewardsBps / 100}%`,- text: `${rewardsBps / 100}% holder rewards`,- }),- el('div', {- class: 'pe-splitbar-seg pe-splitbar-treasury',- style: `--w:${treasuryBps / 100}%`,- text: `${treasuryBps / 100}% treasury`,- }),- ]);+ const rewardsPct = rewardsBps / 100;+ const treasuryPct = treasuryBps / 100;+ const split = splitBar(+ [+ { tone: 'rewards', pct: rewardsPct, label: 'holder rewards' },+ { tone: 'treasury', pct: treasuryPct, label: 'treasury' },+ ],+ `Every paid ${currency} sale splits ${fmtPct(rewardsPct)} percent to holder rewards and ${fmtPct(treasuryPct)} percent to the treasury`,+ );return el('div', {}, [cards,@@ -391,7 +454,7 @@ async function load() {root,offline? 'You appear to be offline. Reconnect and try again.'- : `${err.message || 'The request failed.'} These numbers are static config, so a retry usually works.`,+ : `${sentence(err.message || 'The request failed')} These numbers are static config, so a retry usually works.`,load,);if (status) status.textContent = 'Economy reference failed to load';