oficina / base Public

Put Open Equipo behind a ⋯ menu in the Ask header

The panel header (desktop and phone) and /ask's header show the title,
a 44px round glass ⋯ button labelled "More", and (in the panel) close.
⋯ is a <details>, so it opens without scripts; its small glass menu
holds Open Equipo (new tab, rel="noopener"). With scripts on, Escape
closes the menu without closing the panel and a click elsewhere closes
it too, with focus back on ⋯. Close is now the same round button.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev c4b81a4d46af1d186611fa1b30c97a345b5e17a9 parent 0ad7840
7 files changed, +97 −7
  • docs/copy-pending.md +2 −1
  • internal/browsertest/ask_test.go +16 −0
  • internal/browsertest/mobile_test.go +10 −1
  • internal/look/static/app.css +16 −3
  • internal/look/static/ask.js +31 −0
  • internal/web/templates/partials/chat.html +4 −2
  • internal/webtest/ask_test.go +18 −0
diff --git a/docs/copy-pending.md b/docs/copy-pending.md
index 4a5adc1..3c4c598 100644
--- a/docs/copy-pending.md
+++ b/docs/copy-pending.md
@@ -221,7 +221,8 @@ Review 5 (pending): "Ask Base anything", the chat with Equipo's coordinator.
| internal/web/templates/home.html | Home, the Ask field with the chat on (a link that opens the panel; "/" drawn after it) | Ask Base anything |
| internal/web/templates/partials/chat.html | Panel and /ask page, heading | Ask Base |
| internal/web/templates/home.html | Home on a phone: the round Ask icon's accessible name (the icon replaces the field; reuses the heading) | Ask Base |
-| internal/web/templates/partials/chat.html | Panel and /ask page, link to Equipo (new tab) | Open Equipo |
+| internal/web/templates/partials/chat.html | Panel and /ask page header, the round ⋯ button's accessible name (it opens a small menu) | More |
+| internal/web/templates/partials/chat.html | Panel and /ask page, the ⋯ menu's one item (opens Equipo in a new tab) | Open Equipo |
| internal/web/templates/partials/chat.html | Panel, close button's accessible name | Close |
| internal/web/templates/partials/chat.html | Not connected, body | Connect Equipo, and its coordinator answers you here. |
| internal/web/templates/partials/chat.html | Not connected, button (also Settings and the connect page) | Connect Equipo |
diff --git a/internal/browsertest/ask_test.go b/internal/browsertest/ask_test.go
index bee0287..52f7d59 100644
--- a/internal/browsertest/ask_test.go
+++ b/internal/browsertest/ask_test.go
@@ -8,6 +8,7 @@ import (
"os"
"path/filepath"
"regexp"
+ "strconv"
"testing"
"time"
@@ -155,6 +156,21 @@ func TestAskPanel(t *testing.T) {
}
}
+ // The ⋯ menu holds Open Equipo. Escape closes the menu (not the panel)
+ // and gives focus back to ⋯; a click elsewhere closes it too.
+ more, menuLink := `#ask-panel summary[aria-label="More"]`, `#ask-panel .ask-menu a[href^="`+f.URL+`"][target="_blank"][rel="noopener"]`
+ drive(t, rig, chromedp.Click(chromedp.CSS(more)), chromedp.WaitVisible(chromedp.CSS(menuLink)))
+ if got := harness.Evaluate[string](rig, `document.querySelector(`+strconv.Quote(menuLink)+`).textContent`); got != "Open Equipo" {
+ t.Errorf("menu item %q", got)
+ }
+ drive(t, rig, chromedp.KeyEvent("\u001b"), chromedp.Poll[chromedp.Void](`!document.querySelector("#ask-panel details.ask-more").open`, chromedp.WithPollingTimeout(3*time.Second)),
+ chromedp.Poll[chromedp.Void](`document.activeElement.matches("summary")`, chromedp.WithPollingTimeout(3*time.Second)))
+ if !harness.Evaluate[bool](rig, `document.querySelector("#ask-panel").open`) {
+ t.Fatal("Escape in the menu closed the panel")
+ }
+ drive(t, rig, chromedp.Click(chromedp.CSS(more)), chromedp.WaitVisible(chromedp.CSS(menuLink)),
+ chromedp.Click(chromedp.CSS(`#ask-panel .thread`)), chromedp.Poll[chromedp.Void](`!document.querySelector("#ask-panel details.ask-more").open`, chromedp.WithPollingTimeout(3*time.Second)))
+
drive(t, rig, chromedp.KeyEvent("\u001b"),
chromedp.Poll[chromedp.Void](`!document.querySelector("#ask-panel").open`, chromedp.WithPollingTimeout(5*time.Second)))
if got := harness.Evaluate[string](rig, `document.activeElement.className`); got != "ask" {
diff --git a/internal/browsertest/mobile_test.go b/internal/browsertest/mobile_test.go
index b7842b2..e44236e 100644
--- a/internal/browsertest/mobile_test.go
+++ b/internal/browsertest/mobile_test.go
@@ -133,7 +133,12 @@ func TestMobile(t *testing.T) {
if (head.top < 0 || head.top > 1) problems.push("header at " + head.top);
const c = document.querySelector("#ask-panel form.composer").getBoundingClientRect();
if (c.top < 0 || c.bottom > vh + 0.5 || c.height === 0) problems.push("composer at " + c.top + "-" + c.bottom + " of " + vh);
- for (const el of document.querySelectorAll("#ask-panel .ask-head .btn, #ask-panel form.composer .btn, #ask-panel textarea")) {
+ const more = document.querySelector("#ask-panel .ask-head summary");
+ if (!more || more.getAttribute("aria-label") !== "More") problems.push("no ⋯ button");
+ const link = document.querySelector("#ask-panel .ask-head a[target=_blank]");
+ if (link && link.checkVisibility()) problems.push("Open Equipo shows in the header");
+ if (head.height > 64) problems.push("header is " + head.height + "px tall");
+ for (const el of document.querySelectorAll("#ask-panel .ask-head summary, #ask-panel .ask-head .close, #ask-panel form.composer .btn, #ask-panel textarea")) {
const r = el.getBoundingClientRect();
if (r.height < 44 || r.width < 44) problems.push(el.textContent.trim() + " is " + r.width + "x" + r.height);
}
@@ -152,6 +157,10 @@ func TestMobile(t *testing.T) {
}
mobileShot(t, rig, "4-panel-conversation")
mobileShot(t, rig, "4c-panel-tight")
+ mobileShot(t, rig, "4d-panel-menu-closed")
+ drive(t, rig, chromedp.Click(chromedp.CSS(`#ask-panel summary`)), chromedp.WaitVisible(chromedp.CSS(`#ask-panel .ask-menu a`)))
+ mobileShot(t, rig, "4e-panel-menu-open")
+ drive(t, rig, chromedp.Click(chromedp.CSS(`#ask-panel summary`)), chromedp.Poll[chromedp.Void](`!document.querySelector("#ask-panel details.ask-more").open`, chromedp.WithPollingTimeout(3*time.Second)))
drive(t, rig, chromedp.KeyEvent("\u001b"),
chromedp.Poll[chromedp.Void](`!document.querySelector("#ask-panel").open`, chromedp.WithPollingTimeout(3*time.Second)))
// Focus goes back once the close event has run.
diff --git a/internal/look/static/app.css b/internal/look/static/app.css
index af1b05b..f43582f 100644
--- a/internal/look/static/app.css
+++ b/internal/look/static/app.css
@@ -200,8 +200,21 @@ dialog.ask-panel[open] { display: flex; transform: none; opacity: 1; }
dialog.ask-panel::backdrop { background: rgba(10,12,30,.38); }
.ask-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 12px 20px; border-bottom: 1px solid rgba(238,242,248,.12); }
.ask-head h2 { flex: 1; margin: 0; font-size: 20px; font-weight: 500; letter-spacing: -0.02em; font-variation-settings: "STYL" 0; }
-.ask-head .close { width: 44px; padding: 0; display: grid; place-items: center; }
-.ask-head .close svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; fill: none; }
+/* The header's round glass buttons: ⋯ (a menu holding Open Equipo) and close. */
+.ask-head .round { flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
+ color: var(--frost); background: rgba(238,242,248,.08); box-shadow: inset 0 0 0 1px rgba(238,242,248,.2); transition: background .2s, box-shadow .2s; }
+.ask-head .round:hover, .ask-more[open] > summary { background: rgba(238,242,248,.16); box-shadow: inset 0 0 0 1px rgba(110,231,220,.45); }
+.ask-head .round svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; fill: none; }
+.ask-more summary svg { width: 22px; height: 22px; stroke-width: 3.2; }
+.ask-more { position: relative; }
+.ask-more > summary { list-style: none; }
+.ask-more > summary::-webkit-details-marker { display: none; }
+.ask-menu { position: absolute; z-index: 2; right: 0; top: calc(100% + 6px); min-width: 180px; padding: 6px; border-radius: 12px;
+ background: linear-gradient(rgba(238,242,248,.08), rgba(238,242,248,.04)), rgb(24,28,62);
+ box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 18px 40px -12px rgba(8,12,22,.8); }
+.ask-menu a { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 8px; color: var(--frost);
+ text-decoration: none; font-size: 15px; font-weight: 500; white-space: nowrap; }
+.ask-menu a:hover, .ask-menu a:focus-visible { background: rgba(238,242,248,.1); }
.ask-note { padding: 22px 20px; display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.ask-note p { margin: 0; color: var(--haze); }
.ask-chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
@@ -250,7 +263,7 @@ main { min-height: 100dvh; }
.people li { flex-wrap: wrap; }
dialog.ask-panel { inset: auto 0 auto 0; top: var(--vv-top, 0); width: 100%; height: var(--vv-h, 100dvh); max-height: var(--vv-h, 100dvh);
border: 0; border-radius: 0; padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left); }
- dialog.ask-panel .ask-head { position: sticky; top: 0; padding: max(8px, env(safe-area-inset-top)) 12px 8px; }
+ dialog.ask-panel .ask-head { position: sticky; top: 0; z-index: 1; padding: max(8px, env(safe-area-inset-top)) 12px 8px; }
dialog.ask-panel .ask-head h2 { font-size: 18px; }
dialog.ask-panel .composer { padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
dialog.ask-panel .ask-foot { padding: 0 8px; }
diff --git a/internal/look/static/ask.js b/internal/look/static/ask.js
index bbc7de2..4172dd2 100644
--- a/internal/look/static/ask.js
+++ b/internal/look/static/ask.js
@@ -260,10 +260,41 @@ function start(root) {
setTurn(out.turn);
});
+ // The ⋯ menu: Escape (without closing the panel) and a click elsewhere
+ // close it, and focus goes back to ⋯. Without scripts it is a plain
+ // <details>.
+ let menuEscape = false;
+ for (const menu of root.querySelectorAll("details.ask-more")) {
+ const button = menu.querySelector("summary");
+ const shut = () => {
+ if (!menu.open) return;
+ menu.open = false;
+ button.focus();
+ };
+ menu.addEventListener("keydown", (e) => {
+ if (e.key !== "Escape" || !menu.open) return;
+ // In the panel the same key asks the dialog to close; its cancel
+ // handler below sees this flag and keeps it open.
+ menuEscape = !!dialog;
+ setTimeout(() => { menuEscape = false; }, 100);
+ if (!dialog) e.preventDefault();
+ shut();
+ });
+ document.addEventListener("click", (e) => {
+ if (menu.open && !menu.contains(e.target)) shut();
+ });
+ menu.querySelector(".ask-menu a").addEventListener("click", () => { menu.open = false; });
+ }
+
if (!dialog) {
load();
return;
}
+ // Escape that closed the ⋯ menu leaves the panel open.
+ dialog.addEventListener("cancel", (e) => {
+ if (menuEscape) e.preventDefault();
+ menuEscape = false;
+ });
// On a phone the sheet follows the visual viewport, which shrinks when the
// keyboard opens: the composer stays above it.
diff --git a/internal/web/templates/partials/chat.html b/internal/web/templates/partials/chat.html
index e312cc3..d535a15 100644
--- a/internal/web/templates/partials/chat.html
+++ b/internal/web/templates/partials/chat.html
@@ -1,7 +1,9 @@
{{/* The chat behind "Ask Base anything": the panel over Home, and /ask. Every state's block is drawn and the one for .State shows; the panel's script moves between them. */}}
-{{define "ask-head"}}<div class="ask-head"><h2 id="ask-title">Ask Base</h2><a class="btn ghost" href="{{.Equipo}}" target="_blank" rel="noopener">Open Equipo</a></div>{{end}}
+{{define "ask-head"}}<div class="ask-head"><h2 id="ask-title">Ask Base</h2>{{template "ask-more" .}}</div>{{end}}
+{{/* Open Equipo, behind a ⋯ menu: a <details>, so it opens without scripts. */}}
+{{define "ask-more"}}<details class="ask-more"><summary class="round" aria-label="More"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 12h.01M12 12h.01M18 12h.01"/></svg></summary><div class="ask-menu glass"><a href="{{.Equipo}}" target="_blank" rel="noopener">Open Equipo</a></div></details>{{end}}
{{define "ask-panel"}}<dialog id="ask-panel" class="ask-panel glass" aria-labelledby="ask-title" data-ask data-state="{{.State}}">
-<div class="ask-head"><h2 id="ask-title">Ask Base</h2><a class="btn ghost" href="{{.Equipo}}" target="_blank" rel="noopener">Open Equipo</a><button class="btn ghost close" type="button" data-ask-close aria-label="Close"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg></button></div>
+<div class="ask-head"><h2 id="ask-title">Ask Base</h2>{{template "ask-more" .}}<button class="round close" type="button" data-ask-close aria-label="Close"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg></button></div>
{{template "ask-body" .}}</dialog>{{end}}
{{define "ask-body"}}<div class="ask-note" data-when="connect"{{if not (.Shows "connect")}} hidden{{end}}>
<p>Connect Equipo, and its coordinator answers you here.</p>
diff --git a/internal/webtest/ask_test.go b/internal/webtest/ask_test.go
index e59ef53..f7c3679 100644
--- a/internal/webtest/ask_test.go
+++ b/internal/webtest/ask_test.go
@@ -600,3 +600,21 @@ func TestConnectStoreFailureRevokes(t *testing.T) {
t.Fatalf("page:\n%s", page)
}
}
+
+// "Open Equipo" sits behind a ⋯ menu, a <details> so it works without
+// scripts, in the panel and on /ask.
+func TestAskMoreMenu(t *testing.T) {
+ a, f := newAskApp(t)
+ a.connectEquipo(f)
+ menu := regexp.MustCompile(`(?s)<details class="ask-more"><summary class="round" aria-label="More">.*?</summary>.*?<a href="` +
+ regexp.QuoteMeta(f.URL) + `/" target="_blank" rel="noopener">Open Equipo</a>.*?</details>`)
+ for _, page := range []string{"/", "/ask"} {
+ body := a.get(page).Body
+ if !menu.MatchString(body) {
+ t.Errorf("%s has no ⋯ menu holding Open Equipo:\n%s", page, body)
+ }
+ if strings.Count(body, ">Open Equipo</a>") != 1 {
+ t.Errorf("%s shows Open Equipo outside the menu", page)
+ }
+ }
+}