diff options
Diffstat (limited to 'static')
| -rw-r--r-- | static/deck.css | 6 | ||||
| -rw-r--r-- | static/modules/assistant.js | 42 |
2 files changed, 33 insertions, 15 deletions
diff --git a/static/deck.css b/static/deck.css index 48ec626..b322a11 100644 --- a/static/deck.css +++ b/static/deck.css @@ -658,7 +658,9 @@ select { background: var(--udt-mantle); border: 1px solid var(--udt-surface1); border-radius: 12px; padding: 10px; } .assistant .as-strip[hidden], .assistant .as-picking[hidden] { display: none; } -.assistant .as-row { display: flex; flex-wrap: wrap; gap: 8px; } +.assistant .as-group { display: flex; align-items: center; gap: 12px; } +.assistant .as-group small { flex: none; width: 96px; text-align: right; font-size: 0.786rem; color: var(--udt-overlay1); } +.assistant .as-tiles { display: flex; flex-wrap: wrap; gap: 8px; } .assistant .as-sec h3 { margin: 4px 0 0; font-size: 0.857rem; text-transform: uppercase; letter-spacing: .08em; color: var(--udt-subtext0); } .assistant .as-sec p { margin: 2px 0 0; font-size: 0.786rem; color: var(--udt-overlay0); } .assistant .as-tile { @@ -666,7 +668,7 @@ select { justify-content: center; gap: 4px; border-radius: 12px; font: inherit; cursor: pointer; background: var(--udt-surface0); border: 1px solid var(--udt-surface1); color: var(--udt-text); } -.assistant .as-row.op .as-tile { background: var(--udt-surface1); } +.assistant .as-group.op .as-tile { background: var(--udt-surface1); } .assistant .as-tile i { font-size: 1.6rem; } .assistant .as-tile span { font-size: 0.714rem; color: var(--udt-subtext0); max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .assistant .as-picking { display: flex; align-items: center; gap: 12px; min-height: 72px; color: var(--udt-yellow); } diff --git a/static/modules/assistant.js b/static/modules/assistant.js index 3213aa6..e47fe4b 100644 --- a/static/modules/assistant.js +++ b/static/modules/assistant.js @@ -150,6 +150,11 @@ function renderPicking(box, st, el) { box.append(cancel); } +const KIND_LABELS = { + pdf: "PDF", text: "Text", code: "Code", image: "Images", video: "Video", + archive: "Archives", many: "Several files", any: "Any file", +}; + // The presets and ops, in an overlay opened from the header, so the // transcript keeps the screen. function renderStrip(strip, st, el) { @@ -174,20 +179,31 @@ function renderStrip(strip, st, el) { head.firstElementChild.textContent = title; head.lastElementChild.textContent = hint; strip.append(head); - const row = document.createElement("div"); - row.className = `as-row ${kind}`; - for (const item of items) { - const b = document.createElement("button"); - b.className = "as-tile"; - b.title = item.prompt ?? item.label; - b.setAttribute("aria-label", item.label); - b.innerHTML = `<i class="nf"></i><span></span>`; - b.querySelector("i").textContent = item.icon || G.fallback; - b.querySelector("span").textContent = item.label; - b.onclick = () => { strip.hidden = true; act(el, "pick", { [kind]: item.label }); }; - row.append(b); + // One group per kind of file; an item taking several kinds is in each. + const groups = new Map(Object.keys(KIND_LABELS).map((k) => [k, []])); + for (const item of items) for (const k of item.kinds ?? ["any"]) { + if (!groups.has(k)) groups.set(k, []); + groups.get(k).push(item); + } + for (const [k, list] of groups) { + if (!list.length) continue; + const group = document.createElement("div"); + group.className = `as-group ${kind}`; + group.innerHTML = `<small></small><div class="as-tiles"></div>`; + group.firstElementChild.textContent = KIND_LABELS[k] ?? k; + for (const item of list) { + const b = document.createElement("button"); + b.className = "as-tile"; + b.title = item.prompt ?? item.label; + b.setAttribute("aria-label", item.label); + b.innerHTML = `<i class="nf"></i><span></span>`; + b.querySelector("i").textContent = item.icon || G.fallback; + b.querySelector("span").textContent = item.label; + b.onclick = () => { strip.hidden = true; act(el, "pick", { [kind]: item.label }); }; + group.lastElementChild.append(b); + } + strip.append(group); } - strip.append(row); } } |
