oficina / base Public

Tidy Settings, close inner pages to Home, stop double-tap zoom

From Paul's live check:

- Every element is touch-action: manipulation, so a double tap on a
  phone is two taps, never a zoom. Pinch zoom stays: the viewport sets
  no maximum scale.
- Settings, Store, People, Uninstall and /ask get an X at the top
  right (the chat's round close, a plain link Home, named "Close"),
  from one crumb partial.
- Settings is grouped under small headings (You, This Base, Ask Base),
  every row its name and value on the left and its control on the
  right, centred and one height. Appearance's pill is one control
  height. Signing out is the last section, its explanation under it.
  Rows keep their approved words; the headings are pending review.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 70686f35cb01e396dba5a5d29c20c4c9c5fcf136 parent 218c82d
12 files changed, +269 −21
  • docs/copy-pending.md +9 −0
  • internal/browsertest/light_test.go +2 −2
  • internal/browsertest/mobile_test.go +50 −0
  • internal/browsertest/settings_test.go +79 −0
  • internal/look/static/app.css +31 −6
  • internal/web/templates/ask.html +1 −1
  • internal/web/templates/partials/crumb.html +2 −0
  • internal/web/templates/people.html +1 −1
  • internal/web/templates/settings.html +21 −9
  • internal/web/templates/store.html +1 −1
  • internal/web/templates/uninstall.html +1 −1
  • internal/webtest/settings_test.go +71 −0
diff --git a/docs/copy-pending.md b/docs/copy-pending.md
index 915693a..2cdac6e 100644
--- a/docs/copy-pending.md
+++ b/docs/copy-pending.md
@@ -390,3 +390,12 @@ Review 9 (approved) (Task 19, the job view, plan decision D19): when a job start
| ask.go, ask.js | APPROVED: the job view, a job started an hour ago | Started 1 hour ago |
| ask.go, ask.js | APPROVED: the job view, a job started 2 to 23 hours ago | Started {n} hours ago |
| ask.go, ask.js | APPROVED: the job view, a job started a day ago or more (the day and month, such as "2 January") | Started on {2 January} |
+
+Review 10 (pending): Paul's live check of Settings. Settings is grouped into sections under small headings, and every inner page gets a close. Only the headings are new words; every row keeps its approved words.
+
+| File | Context | Text |
+|---|---|---|
+| internal/web/templates/settings.html | PENDING: Settings, the heading over Signed in as, Appearance, Passkeys (and Oficina account) | You |
+| internal/web/templates/settings.html | PENDING: Settings, the heading over Base name | This Base |
+| internal/web/templates/settings.html | PENDING: Settings, the heading over the Ask Base row (shown only with the chat on; the row keeps its approved name, Ask Base) | Ask Base |
+| internal/web/templates/partials/crumb.html | APPROVED: the X at the top right of Settings, Store, People, Uninstall and /ask, a link Home; its accessible name reuses the chat's approved close | Close |
diff --git a/internal/browsertest/light_test.go b/internal/browsertest/light_test.go
index 73aef3b..d851359 100644
--- a/internal/browsertest/light_test.go
+++ b/internal/browsertest/light_test.go
@@ -291,9 +291,9 @@ func TestLightMode(t *testing.T) {
// Settings.
drive(t, rig, chromedp.EmulateViewport(1280, 800), chromedp.Navigate(rig.Origin+"/settings"), chromedp.WaitVisible(chromedp.CSS(`form.segmented`)))
- checkContrast(t, rig, "Settings, light", ".sheet h2", ".people .who", ".people .who small", ".soon", "form.segmented button")
+ checkContrast(t, rig, "Settings, light", ".sheet h2", ".settings .group h3", ".rows .who", ".rows .who small", ".signout .note", "form.segmented button")
lightShot(t, rig, "settings")
- for _, sel := range []string{"a.wordmark", "form.segmented button", ".people .btn.ghost"} {
+ for _, sel := range []string{"a.wordmark", ".crumb a.close", "form.segmented button", ".rows .btn.ghost"} {
focusRing(t, rig, "Settings, light", sel)
}
diff --git a/internal/browsertest/mobile_test.go b/internal/browsertest/mobile_test.go
index 1de7f08..9bf5cbb 100644
--- a/internal/browsertest/mobile_test.go
+++ b/internal/browsertest/mobile_test.go
@@ -216,6 +216,7 @@ func TestMobile(t *testing.T) {
}
drive(t, rig, chromedp.KeyEvent("\u001b"), reducedMotion("dark", false))
+ // Every inner page has an X at its top right, 44px, that goes Home.
for _, p := range []struct{ path, wait, name string }{
{"/store", ".sheet", "5-store"},
{"/people", ".sheet", "6-people"},
@@ -224,7 +225,56 @@ func TestMobile(t *testing.T) {
} {
drive(t, rig, chromedp.Navigate(rig.Origin+p.path), chromedp.WaitVisible(chromedp.CSS(p.wait)))
noOverflow(t, rig, p.path)
+ if got := harness.Evaluate[string](rig, closeJS); got != "" {
+ t.Errorf("%s's close: %s", p.path, got)
+ }
mobileShot(t, rig, p.name)
+ drive(t, rig, chromedp.Click(chromedp.CSS(`.crumb a.close`)), chromedp.WaitVisible(chromedp.CSS(`.hello`)))
+ if here := harness.Read(rig, chromedp.Location()); here != rig.Origin+"/" {
+ t.Errorf("%s's close went to %s, want Home", p.path, here)
+ }
+ }
+}
+
+// closeJS describes what is wrong with an inner page's close, "" if
+// nothing: one X at the top right of the sheet, 44px, named Close, a link
+// to Home.
+const closeJS = `(() => {
+ const all = document.querySelectorAll(".crumb a.close"), problems = [];
+ if (all.length !== 1) return all.length + " close links";
+ const x = all[0], r = x.getBoundingClientRect(), sheet = x.closest(".sheet").getBoundingClientRect();
+ if (x.getAttribute("href") !== "/") problems.push("goes to " + x.getAttribute("href"));
+ if (x.getAttribute("aria-label") !== "Close") problems.push("named " + x.getAttribute("aria-label"));
+ if (!x.checkVisibility({ visibilityProperty: true })) problems.push("not shown");
+ if (Math.round(r.width) !== 44 || Math.round(r.height) !== 44) problems.push("is " + r.width + "x" + r.height);
+ if (sheet.right - r.right > 36 || r.top - sheet.top > 36 || r.top < sheet.top) problems.push("not at the top right: " + Math.round(sheet.right - r.right) + " from the right, " + Math.round(r.top - sheet.top) + " from the top");
+ const w = document.querySelector(".crumb .wordmark").getBoundingClientRect();
+ if (Math.abs((w.top + w.bottom) / 2 - (r.top + r.bottom) / 2) > 1) problems.push("not level with the wordmark");
+ if (getComputedStyle(x).borderRadius !== "50%") problems.push("not round: " + getComputedStyle(x).borderRadius);
+ return problems.join("; ");
+})()`
+
+// On a phone a double tap is two taps, never a zoom: the page and what is
+// tapped on it are touch-action: manipulation. Pinching still zooms: the
+// viewport sets no maximum scale and doesn't stop the person scaling it.
+func TestMobileNoDoubleTapZoom(t *testing.T) {
+ rig, _, b := askBaseOn(t, nil, chromedp.EmulateViewport(390, 844, chromedp.EmulateMobile, chromedp.EmulateScale(3)))
+ installAll(t, b)
+ for _, p := range []struct{ path, wait string }{
+ {"/", ".hello"}, {"/settings", "form.segmented"}, {"/store", ".listing"}, {"/people", ".people"}, {"/ask", ".ask-page .composer"},
+ } {
+ drive(t, rig, chromedp.Navigate(rig.Origin+p.path), chromedp.WaitVisible(chromedp.CSS(p.wait)))
+ if got := harness.Evaluate[string](rig, `(() => {
+ const problems = [], meta = document.querySelector('meta[name="viewport"]').content;
+ if (/maximum-scale|user-scalable/i.test(meta)) problems.push("the viewport stops zooming: " + meta);
+ for (const el of [document.documentElement, document.body, ...document.querySelectorAll("a, button, input, textarea, summary, label, li, p, .sheet, .glass")]) {
+ const ta = getComputedStyle(el).touchAction;
+ if (ta !== "manipulation") problems.push(el.tagName.toLowerCase() + (el.className ? "." + el.className : "") + " is touch-action: " + ta);
+ }
+ return [...new Set(problems)].slice(0, 6).join("; ");
+ })()`); got != "" {
+ t.Errorf("%s: %s", p.path, got)
+ }
}
}
diff --git a/internal/browsertest/settings_test.go b/internal/browsertest/settings_test.go
new file mode 100644
index 0000000..5117822
--- /dev/null
+++ b/internal/browsertest/settings_test.go
@@ -0,0 +1,79 @@
+//go:build browser
+
+package browsertest
+
+import (
+ "testing"
+
+ "github.com/chromedp/chromedp"
+
+ "amadan.net/rastrillo/rastrillo/harness"
+)
+
+// settingsLayoutJS describes what is out of place in Settings, "" if
+// nothing: its sections in order under their headings; every row one
+// height, its name on the left and its control on the right, centred on
+// the row; Appearance's pill as tall as a button; signing out last, its
+// explanation right under it.
+const settingsLayoutJS = `(() => {
+ const problems = [];
+ const heads = [...document.querySelectorAll(".settings .group h3")].map(h => h.textContent).join(", ");
+ if (heads !== "You, This Base, Ask Base") problems.push("headings: " + heads);
+ const rows = [...document.querySelectorAll(".settings .rows li")];
+ const names = rows.map(li => li.querySelector(".who").firstChild.textContent).join(", ");
+ if (names !== "Signed in as, Appearance, Passkeys, Base name, Ask Base") problems.push("rows: " + names);
+ const heights = new Set(rows.map(li => Math.round(li.getBoundingClientRect().height)));
+ if (heights.size !== 1) problems.push("rows of heights " + [...heights].join(", "));
+ const btn = document.querySelector(".settings .rows .btn.ghost:not([hidden])").getBoundingClientRect();
+ const pill = document.querySelector("form.segmented").getBoundingClientRect();
+ if (Math.round(pill.height) !== Math.round(btn.height)) problems.push("Appearance is " + pill.height + "px tall, a button " + btn.height);
+ for (const li of rows) {
+ const r = li.getBoundingClientRect(), who = li.querySelector(".who").getBoundingClientRect();
+ const mid = (r.top + r.bottom) / 2;
+ const control = [...li.children].find(c => c !== li.querySelector(".who") && c.checkVisibility());
+ if (Math.abs((who.top + who.bottom) / 2 - mid) > 1.5) problems.push(li.textContent.slice(0, 20) + ": name not centred");
+ if (!control) continue;
+ const c = control.getBoundingClientRect();
+ if (Math.abs((c.top + c.bottom) / 2 - mid) > 1.5) problems.push(li.textContent.slice(0, 20) + ": control not centred");
+ if (Math.abs(c.right - r.right) > 1) problems.push(li.textContent.slice(0, 20) + ": control " + (r.right - c.right) + "px off the right");
+ if (c.left < who.right) problems.push(li.textContent.slice(0, 20) + ": control overlaps the name");
+ }
+ const last = [...document.querySelector(".settings").children].pop();
+ if (!last.matches(".signout") || !last.querySelector('form[action="/auth/signout"]')) problems.push("signing out is not last");
+ const out = last.querySelector("button").getBoundingClientRect(), note = last.querySelector(".note").getBoundingClientRect();
+ if (note.top < out.bottom || note.top - out.bottom > 16 || Math.abs(note.left - out.left) > 1) problems.push("the explanation is not under Sign out");
+ return problems.join("; ");
+})()`
+
+// Settings is in tidy sections at a phone's width and a laptop's, light
+// and dark. With BASE_BROWSER_ARTIFACTS set it saves each.
+func TestSettingsLayout(t *testing.T) {
+ rig, _, _ := askBaseOn(t, nil, chromedp.EmulateViewport(390, 844, chromedp.EmulateMobile, chromedp.EmulateScale(3)))
+ for _, v := range []struct {
+ name string
+ view chromedp.Action[chromedp.Void]
+ }{
+ {"390", chromedp.EmulateViewport(390, 844, chromedp.EmulateMobile, chromedp.EmulateScale(3))},
+ {"1280", chromedp.EmulateViewport(1280, 800)},
+ } {
+ for _, scheme := range []string{"light", "dark"} {
+ drive(t, rig, v.view, reducedMotion(scheme, true), chromedp.Navigate(rig.Origin+"/settings"), chromedp.WaitVisible(chromedp.CSS(`form.segmented`)))
+ // The add-a-passkey button shows once its script has looked.
+ drive(t, rig, chromedp.Poll[chromedp.Void](`!document.querySelector("[data-passkey-add]").hidden`))
+ noOverflow(t, rig, "Settings at "+v.name)
+ if got := harness.Evaluate[string](rig, settingsLayoutJS); got != "" {
+ t.Errorf("Settings at %s, %s: %s", v.name, scheme, got)
+ }
+ if got := harness.Evaluate[string](rig, closeJS); got != "" {
+ t.Errorf("Settings' close at %s: %s", v.name, got)
+ }
+ mobileShot(t, rig, "settings-"+v.name+"-"+scheme)
+ }
+ }
+ // The Store and People pages' close, on a phone.
+ drive(t, rig, chromedp.EmulateViewport(390, 844, chromedp.EmulateMobile, chromedp.EmulateScale(3)), reducedMotion("dark", true))
+ for _, p := range []string{"store", "people"} {
+ drive(t, rig, chromedp.Navigate(rig.Origin+"/"+p), chromedp.WaitVisible(chromedp.CSS(`.crumb a.close`)))
+ mobileShot(t, rig, p+"-390-dark")
+ }
+}
diff --git a/internal/look/static/app.css b/internal/look/static/app.css
index 30c86f6..ed13bf0 100644
--- a/internal/look/static/app.css
+++ b/internal/look/static/app.css
@@ -263,6 +263,9 @@
}
}
* { box-sizing: border-box; }
+/* A double tap is two taps, never a zoom, so tapping quickly through the
+ page doesn't jump it about. Pinching still zooms: the viewport allows it. */
+* { touch-action: manipulation; }
html { background: var(--sky); }
body { margin: 0; min-height: 100vh; position: relative; isolation: isolate; font: 400 16px/1.5 var(--font); font-variation-settings: "STYL" 100; color: var(--frost);
background: linear-gradient(165deg, var(--sky-1) 0%, var(--sky-2) var(--sky-stop), var(--sky-3) 100%) fixed; }
@@ -408,6 +411,9 @@ a.app:hover { background: var(--hover); }
.sheet { flex: 1; border-radius: 16px; padding: 22px 24px 24px; }
.crumb { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.crumb span { color: var(--haze); font-size: 14px; }
+/* The X at the top right closes the page back to Home: the chat's round
+ close, level with the wordmark and tucked towards the corner. */
+.crumb .close { margin: 0 -8px 0 auto; }
.inner h2 { font-size: 28px; font-weight: 500; letter-spacing: -0.025em; margin: 0 0 8px; }
.inner .lead { margin: 0 0 22px; color: var(--haze); max-width: 50ch; }
.invite { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
@@ -423,11 +429,29 @@ a.app:hover { background: var(--hover); }
/* Settings' Appearance: System, Light and Dark in one pill, the chosen one
filled. Each is a submit button, so it works without scripts. */
.segmented { display: flex; flex: none; gap: 2px; padding: 3px; border-radius: 13px; background: var(--well); box-shadow: inset 0 0 0 1px var(--well-edge); }
-.segmented button { height: 44px; padding: 0 16px; border: 0; border-radius: 10px; background: none; color: var(--frost);
+/* The pill is one control height, as tall as a button beside it. */
+.segmented button { height: 38px; padding: 0 14px; border: 0; border-radius: 10px; background: none; color: var(--frost);
font: inherit; font-size: 15px; font-weight: 500; cursor: pointer; transition: background .2s; }
.segmented button:hover { background: var(--hover); }
.segmented button[aria-pressed="true"] { background: var(--btn); color: var(--btn-ink); font-weight: 600; }
+/* Settings: sections under small headings. Every row is its name (and its
+ value under it) on the left and its control on the right, centred, all
+ one height whether or not there is a control. Signing out comes last,
+ its explanation under it. */
+.settings { max-width: 720px; }
+.settings .group { margin-top: 28px; }
+.settings .group h3 { margin: 0 0 6px; font-size: 14px; font-weight: 600; line-height: 20px; color: var(--haze); }
+.rows { list-style: none; margin: 0; padding: 0; border-bottom: 1px solid var(--rule-strong); }
+.rows li { display: flex; flex-wrap: wrap; align-items: center; column-gap: 16px; row-gap: 10px; min-height: 69px; padding: 12px 0;
+ border-top: 1px solid var(--rule-strong); }
+.rows .who { flex: 1 1 6.5em; min-width: 0; font-weight: 500; line-height: 24px; }
+.rows .who small { display: block; color: var(--haze); font-size: 14px; font-weight: 400; line-height: 20px; overflow-wrap: anywhere; }
+.rows .status { margin: 4px 0 0; min-height: 0; font-weight: 400; line-height: 20px; }
+.rows .status:empty { margin: 0; }
+.settings .signout { margin-top: 32px; }
+.settings .signout .note { margin: 10px 0 0; color: var(--haze); font-size: 14px; max-width: 56ch; }
+
.listing { display: flex; gap: 16px; align-items: center; padding: 16px 0;
border-top: 1px solid var(--rule-strong); border-bottom: 1px solid var(--rule-strong); }
.listing .tile { flex: none; width: 56px; height: 56px; border-radius: 16px; }
@@ -500,11 +524,12 @@ aside.ask-panel { position: absolute; top: 16px; right: 16px; bottom: 16px; widt
transition: transform .45s var(--ease), opacity .3s, visibility 0s; }
.ask-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 12px 20px; border-bottom: 1px solid var(--rule); }
.ask-head h2 { flex: 1; display: flex; align-items: center; gap: 10px; margin: 0; font-size: 20px; font-weight: 500; letter-spacing: -0.02em; font-variation-settings: "STYL" 0; }
-/* The header's round glass button: 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: var(--chip); box-shadow: inset 0 0 0 1px var(--chip-edge); transition: background .2s, box-shadow .2s; }
-.ask-head .round:hover { background: var(--chip-hover); box-shadow: inset 0 0 0 1px var(--accent-edge); }
-.ask-head .round svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; fill: none; }
+/* The header's round glass button: close. Inner pages' close is the same. */
+.ask-head .round, .crumb .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: var(--chip); box-shadow: inset 0 0 0 1px var(--chip-edge); transition: background .2s, box-shadow .2s;
+ text-decoration: none; }
+.ask-head .round:hover, .crumb .round:hover { background: var(--chip-hover); box-shadow: inset 0 0 0 1px var(--accent-edge); }
+.ask-head .round svg, .crumb .round svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; fill: none; }
.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; }
diff --git a/internal/web/templates/ask.html b/internal/web/templates/ask.html
index a2ce106..91a56ce 100644
--- a/internal/web/templates/ask.html
+++ b/internal/web/templates/ask.html
@@ -2,7 +2,7 @@
{{define "head"}}{{if .Ask.Turn}}<noscript><meta http-equiv="refresh" content="5"></noscript>{{end}}{{end}}
{{define "main"}}<main class="inner">
<section class="sheet glass ask-page" data-ask data-state="{{.Ask.State}}">
-<div class="crumb"><a class="wordmark" href="/">base</a><span>Ask Base</span></div>
+{{template "crumb" "Ask Base"}}
{{template "ask-head" .Ask}}
{{template "ask-body" .Ask}}
</section>
diff --git a/internal/web/templates/partials/crumb.html b/internal/web/templates/partials/crumb.html
new file mode 100644
index 0000000..2aa8a24
--- /dev/null
+++ b/internal/web/templates/partials/crumb.html
@@ -0,0 +1,2 @@
+{{/* An inner page's top line: the wordmark (a link Home), where the page is, and at the top right an X that closes the page back to Home. Both are plain links, so they work without scripts; the X is the chat's close, and its name the chat's "Close". */}}
+{{define "crumb"}}<div class="crumb"><a class="wordmark" href="/">base</a><span>{{.}}</span><a class="round close" href="/" aria-label="Close"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg></a></div>{{end}}
diff --git a/internal/web/templates/people.html b/internal/web/templates/people.html
index dda6c52..4691084 100644
--- a/internal/web/templates/people.html
+++ b/internal/web/templates/people.html
@@ -1,7 +1,7 @@
{{define "title"}}People · {{.Name}}{{end}}
{{define "main"}}<main class="inner">
<div class="sheet glass">
-<div class="crumb"><a class="wordmark" href="/">base</a><span>People</span></div>
+{{template "crumb" "People"}}
<h2>People</h2>
<p class="lead">Everyone here can sign in to every app on {{.Name}}'s Base. Each app decides what they can do in it.</p>
{{if .BadEmail}}<p role="status">That doesn't look like an email address.</p>
diff --git a/internal/web/templates/settings.html b/internal/web/templates/settings.html
index ab15db6..c55da47 100644
--- a/internal/web/templates/settings.html
+++ b/internal/web/templates/settings.html
@@ -1,20 +1,32 @@
{{define "title"}}Settings · {{.Name}}{{end}}
{{define "main"}}<main class="inner">
<div class="sheet glass">
-<div class="crumb"><a class="wordmark" href="/">base</a><span>Settings</span></div>
+{{template "crumb" "Settings"}}
+{{/* Settings in sections under small headings, each row its name (and value under it) on the left and its control on the right; signing out comes last. */}}<div class="settings">
<h2>Settings</h2>
-<ul class="people">
-<li><div class="who">Base name<small>{{.Name}}</small></div></li>
+<section class="group" aria-labelledby="set-you"><h3 id="set-you">You</h3>
+<ul class="rows">
<li><div class="who">Signed in as<small>{{.Address}}</small></div></li>
<li><div class="who" id="appearance">Appearance</div><form class="segmented" method="post" action="/settings/appearance" role="group" aria-labelledby="appearance">{{range .Themes}}<button type="submit" name="theme" value="{{.Value}}" aria-pressed="{{.On}}">{{.Label}}</button>{{end}}</form></li>
-<li><div class="who">Passkeys<small id="passkeys">{{if .Passkeys}}{{.Passkeys}} added{{else}}None yet{{end}}</small></div>{{if .CanAddPasskey}}{{/* Hidden until the script finds the browser can make a passkey, so with scripts off there is no dead button. */}}<button class="btn ghost" type="button" hidden data-passkey-add data-module="{{.ModuleURL}}" data-begin="{{.RegisterBegin}}" data-finish="{{.RegisterEnd}}" data-rp-name="{{.Name}}" data-user-id="{{.UserID}}" data-user-name="{{.Address}}" data-done="/settings?passkey=added" data-cancelled="No passkey was added." data-failed="That didn't work. Try again." aria-describedby="passkey-msg">Add a passkey</button>{{end}}</li>
-{{with .Equipo}}<li><div class="who">Ask Base<small>{{if eq . "ready"}}{{with $.EquipoPerson}}Connected as {{.}}{{else}}Connected{{end}}{{else if eq . "pending"}}Waiting for your approval{{else if eq . "reconnect"}}Needs setting up again{{else}}Not set up{{end}}</small></div>{{if eq . "ready"}}<form method="post" action="/ask/disconnect"><button class="btn ghost" type="submit">Disconnect</button></form>{{else if eq . "pending"}}<a class="btn ghost" href="/ask/connect?next=settings">Finish setting up</a>{{else}}<form method="post" action="/ask/connect"><input type="hidden" name="next" value="settings"><button class="btn ghost" type="submit">{{if eq . "reconnect"}}Set it up again{{else}}Set up Ask Base{{end}}</button></form>{{end}}</li>
-{{end}}{{if .Connect}}<li><div class="who">Oficina account<small>Not connected</small></div><a class="btn ghost" href="/account/home">{{.ConnectLabel}}</a></li>
+<li><div class="who">Passkeys<small id="passkeys">{{if .Passkeys}}{{.Passkeys}} added{{else}}None yet{{end}}</small>{{if .PasskeyAdded}}<p class="status" role="status" id="passkey-added">Passkey added. Next time, sign in with it.</p>{{end}}<p class="status" id="passkey-msg" aria-live="polite"></p></div>{{if .CanAddPasskey}}{{/* Hidden until the script finds the browser can make a passkey, so with scripts off there is no dead button. */}}<button class="btn ghost" type="button" hidden data-passkey-add data-module="{{.ModuleURL}}" data-begin="{{.RegisterBegin}}" data-finish="{{.RegisterEnd}}" data-rp-name="{{.Name}}" data-user-id="{{.UserID}}" data-user-name="{{.Address}}" data-done="/settings?passkey=added" data-cancelled="No passkey was added." data-failed="That didn't work. Try again." aria-describedby="passkey-msg">Add a passkey</button>{{end}}</li>
+{{if .Connect}}<li><div class="who">Oficina account<small>Not connected</small></div><a class="btn ghost" href="/account/home">{{.ConnectLabel}}</a></li>
{{end}}</ul>
-{{if .PasskeyAdded}}<p class="status" role="status" id="passkey-added">Passkey added. Next time, sign in with it.</p>
-{{end}}<p class="status" id="passkey-msg" aria-live="polite"></p>
+</section>
+<section class="group" aria-labelledby="set-base"><h3 id="set-base">This Base</h3>
+<ul class="rows">
+<li><div class="who">Base name<small>{{.Name}}</small></div></li>
+</ul>
+</section>
+{{with .Equipo}}<section class="group" aria-labelledby="set-ask"><h3 id="set-ask">Ask Base</h3>
+<ul class="rows">
+<li><div class="who">Ask Base<small>{{if eq . "ready"}}{{with $.EquipoPerson}}Connected as {{.}}{{else}}Connected{{end}}{{else if eq . "pending"}}Waiting for your approval{{else if eq . "reconnect"}}Needs setting up again{{else}}Not set up{{end}}</small></div>{{if eq . "ready"}}<form method="post" action="/ask/disconnect"><button class="btn ghost" type="submit">Disconnect</button></form>{{else if eq . "pending"}}<a class="btn ghost" href="/ask/connect?next=settings">Finish setting up</a>{{else}}<form method="post" action="/ask/connect"><input type="hidden" name="next" value="settings"><button class="btn ghost" type="submit">{{if eq . "reconnect"}}Set it up again{{else}}Set up Ask Base{{end}}</button></form>{{end}}</li>
+</ul>
+</section>
+{{end}}<section class="group signout">
<form method="post" action="/auth/signout"><button class="btn ghost" type="submit">Sign out of Base</button></form>
-<p class="soon">{{if .Oficina}}This signs you out of Base and your Oficina account. Apps you've opened stay signed in until you sign out of each one.{{else}}This signs you out of Base only. Apps you've opened stay signed in until you sign out of each one.{{end}}</p>
+<p class="note">{{if .Oficina}}This signs you out of Base and your Oficina account. Apps you've opened stay signed in until you sign out of each one.{{else}}This signs you out of Base only. Apps you've opened stay signed in until you sign out of each one.{{end}}</p>
+</section>
+</div>
</div>
<script type="module" src="{{asset "static/passkey-add.js"}}"></script>
</main>{{end}}
diff --git a/internal/web/templates/store.html b/internal/web/templates/store.html
index bf6c8e6..a862005 100644
--- a/internal/web/templates/store.html
+++ b/internal/web/templates/store.html
@@ -2,7 +2,7 @@
{{define "head"}}{{if .Installing}}<meta http-equiv="refresh" content="2">{{end}}{{end}}
{{define "main"}}<main class="inner">
<div class="sheet glass">
-<div class="crumb"><a class="wordmark" href="/">base</a><span>Store</span></div>
+{{template "crumb" "Store"}}
<h2>Store</h2>
<p class="lead">Apps that run on {{.Name}}'s Base. Install one and it's on Home for everyone at {{.Name}}.</p>
{{if .Busy}}<p role="status">This app is still installing. Try again in a moment.</p>
diff --git a/internal/web/templates/uninstall.html b/internal/web/templates/uninstall.html
index 0bb5f37..508cad9 100644
--- a/internal/web/templates/uninstall.html
+++ b/internal/web/templates/uninstall.html
@@ -1,7 +1,7 @@
{{define "title"}}Uninstall {{.App.Name}} · {{.Name}}{{end}}
{{define "main"}}<main class="inner">
<div class="sheet glass">
-<div class="crumb"><a class="wordmark" href="/">base</a><span>Store</span></div>
+{{template "crumb" "Store"}}
<h2>Uninstall {{.App.Name}}?</h2>
<div class="confirm">
<p>Uninstall {{.App.Name}}? It's removed from Home for everyone at {{.Name}}. Its data is kept, and comes back if you install it again.</p>
diff --git a/internal/webtest/settings_test.go b/internal/webtest/settings_test.go
index e6bd4cf..ace6c30 100644
--- a/internal/webtest/settings_test.go
+++ b/internal/webtest/settings_test.go
@@ -140,3 +140,74 @@ func TestSettingsShowsEquipoPerson(t *testing.T) {
t.Fatalf("Settings after reconnecting:\n%s", s)
}
}
+
+// Every inner page reached from Home has a close control, an X at the top
+// right: a plain link Home, so it works without scripts, named with the
+// chat's approved "Close".
+func TestInnerPagesCloseToHome(t *testing.T) {
+ const closeLink = `<a class="round close" href="/" aria-label="Close"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg></a></div>`
+ a := newApp(t)
+ a.signedInOwner()
+ a.setInstall("scratchpad", "installed", "")
+ pages := map[string]string{}
+ for _, p := range []string{"/people", "/store", "/settings", "/store/scratchpad/uninstall"} {
+ pages[p] = a.get(p).Body
+ }
+ ask, _ := newAskApp(t)
+ pages["/ask"] = ask.get("/ask").Body
+ for p, body := range pages {
+ crumb := regexp.MustCompile(`(?s)<div class="crumb">.*?</div>`).FindString(body)
+ if !strings.HasSuffix(crumb, closeLink) {
+ t.Errorf("%s: the crumb has no close link Home at its end:\n%s", p, crumb)
+ }
+ if strings.Count(body, `aria-label="Close"`) != 1 && p != "/ask" {
+ t.Errorf("%s: want one Close, got %d", p, strings.Count(body, `aria-label="Close"`))
+ }
+ }
+}
+
+// Settings is in sections, each under a small heading: You, This Base and
+// (with the chat on) Ask Base, each row in its section, and signing out is
+// the last thing on the page, its explanation under it.
+func TestSettingsSections(t *testing.T) {
+ sections := regexp.MustCompile(`(?s)<section class="group[^"]*"[^>]*>(?:<h3 id="[^"]+">(.*?)</h3>)?(.*?)</section>`)
+ labels := regexp.MustCompile(`<div class="who"[^>]*>([^<]*)`)
+ layout := func(body string) []string {
+ var got []string
+ for _, s := range sections.FindAllStringSubmatch(body, -1) {
+ line := s[1] + ":"
+ for _, l := range labels.FindAllStringSubmatch(s[2], -1) {
+ line += " " + l[1] + ","
+ }
+ if strings.Contains(s[2], `action="/auth/signout"`) {
+ line += " sign out"
+ }
+ got = append(got, line)
+ }
+ return got
+ }
+ check := func(name, body string, want []string) {
+ t.Helper()
+ if got := layout(body); strings.Join(got, "\n") != strings.Join(want, "\n") {
+ t.Errorf("%s: Settings is laid out as\n%s\nwant\n%s", name, strings.Join(got, "\n"), strings.Join(want, "\n"))
+ }
+ // Signing out closes the page, the explanation right under its button.
+ if !regexp.MustCompile(`(?s)<button class="btn ghost" type="submit">Sign out of Base</button></form>\s*<p class="note">This signs you out of Base only\. [^<]*</p>\s*</section>\s*</div>\s*</div>\s*<script`).MatchString(body) {
+ t.Errorf("%s: signing out is not the last thing, its explanation under it:\n%s", name, body)
+ }
+ }
+ a := newApp(t)
+ a.signedInOwner()
+ check("chat off", a.get("/settings").Body, []string{
+ "You: Signed in as, Appearance, Passkeys,",
+ "This Base: Base name,",
+ ": sign out",
+ })
+ ask, _ := newAskApp(t)
+ check("chat on", ask.get("/settings").Body, []string{
+ "You: Signed in as, Appearance, Passkeys,",
+ "This Base: Base name,",
+ "Ask Base: Ask Base,",
+ ": sign out",
+ })
+}