oficina / base Public

Keep the Ask panel clear of the Oficina rail at every width

Wider than a phone, with the rail on Home, the panel is capped at the
viewport less the rail, a 16px gap and its own 12px inset (460px at
most, as before). A browser test opens the panel at 601 to 1280 wide
and checks the gap and that nothing overflows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 293623b1e26c95e3fd4673859bbc6c600a4ec2b8 parent 5841583
2 files changed, +49 −0
  • internal/browsertest/oficina_test.go +43 −0
  • internal/look/static/app.css +6 −0
diff --git a/internal/browsertest/oficina_test.go b/internal/browsertest/oficina_test.go
index 2492c89..e2ab388 100644
--- a/internal/browsertest/oficina_test.go
+++ b/internal/browsertest/oficina_test.go
@@ -5,10 +5,12 @@ package browsertest
import (
"context"
"encoding/json"
+ "fmt"
"net/http"
"os"
"path/filepath"
"testing"
+ "time"
"github.com/chromedp/chromedp"
@@ -177,3 +179,44 @@ func TestOficinaRail(t *testing.T) {
drive(t, rig, chromedp.Navigate(rig.Origin+"/"), chromedp.WaitVisible(chromedp.CSS(".hello")))
viewportShot(t, rig, "home-desktop")
}
+
+// The open Ask panel keeps a gap to the Oficina rail at every width the
+// rail shows at, and nothing runs off the screen.
+func TestAskPanelBesideRail(t *testing.T) {
+ f := equipotest.New(t)
+ apps := teamApps(t)
+ var b *baseApp
+ rig := newRig(t, func(origin string) http.Handler {
+ cfg := baseConfig(origin)
+ cfg.EquipoOrigin = f.URL
+ cfg.OficinaApps = apps
+ b = newBase(t, cfg)
+ return b.handler
+ })
+ drive(t, rig, chromedp.EmulateViewport(1280, 800))
+ signInByEmail(t, rig, rig.Origin, b.mail)
+ for _, width := range []int64{601, 640, 700, 800, 900, 1024, 1280} {
+ drive(t, rig, chromedp.EmulateViewport(width, 800), chromedp.Navigate(rig.Origin+"/"), chromedp.WaitVisible(chromedp.CSS(`a.ask`)),
+ chromedp.Click(chromedp.CSS(`a.ask`)),
+ chromedp.Poll[chromedp.Void](`(() => { const p = document.querySelector("#ask-panel"); return p.open && getComputedStyle(p).transform === "none" && getComputedStyle(p).opacity === "1"; })()`,
+ chromedp.WithPollingTimeout(5*time.Second)))
+ if got := harness.Evaluate[string](rig, `(() => {
+ const problems = [], vw = document.documentElement.clientWidth;
+ const rail = document.querySelector("nav.rail").getBoundingClientRect();
+ const p = document.querySelector("#ask-panel").getBoundingClientRect();
+ if (rail.width === 0) problems.push("no rail");
+ if (p.left < rail.right + 12 || p.width < 200) problems.push("panel starts at " + p.left + ", rail ends at " + rail.right);
+ if (p.right > vw) problems.push("panel ends at " + p.right + " of " + vw);
+ if (p.width > 460.5) problems.push("panel is " + p.width + " wide");
+ if (document.documentElement.scrollWidth > vw) problems.push("page is " + document.documentElement.scrollWidth + " wide");
+ return problems.join("; ");
+ })()`); got != "" {
+ t.Errorf("at %dx800: %s", width, got)
+ }
+ if width == 800 || width == 1280 {
+ viewportShot(t, rig, fmt.Sprintf("panel-%d", width))
+ }
+ drive(t, rig, chromedp.KeyEvent("\u001b"),
+ chromedp.Poll[chromedp.Void](`!document.querySelector("#ask-panel").open`, chromedp.WithPollingTimeout(5*time.Second)))
+ }
+}
diff --git a/internal/look/static/app.css b/internal/look/static/app.css
index d99faac..9dae1d5 100644
--- a/internal/look/static/app.css
+++ b/internal/look/static/app.css
@@ -219,6 +219,12 @@ dialog.ask-panel { position: fixed; inset: 12px 12px 12px auto; width: min(460px
flex-direction: column; overflow: hidden;
transition: transform .35s cubic-bezier(.2,.7,0,1), opacity .35s, overlay .35s allow-discrete, display .35s allow-discrete;
transform: translateX(32px); opacity: 0; }
+/* Beside the Oficina rail (wider than a phone) the panel keeps a 16px gap to
+ it: the rail ends 106px in (Home's 26px padding and its 80px), plus the
+ gap and the panel's own 12px inset on the right. */
+@media (min-width: 601px) {
+ body:has(nav.rail) dialog.ask-panel { width: min(460px, calc(100% - 134px)); }
+}
dialog.ask-panel[open] { display: flex; transform: none; opacity: 1; }
@starting-style { dialog.ask-panel[open] { transform: translateX(32px); opacity: 0; } }
dialog.ask-panel::backdrop { background: rgba(10,12,30,.38); }