oficina / base Public

Cut a job pill's title to its least before its status

Ruling R26, round 2: the 50% cap let a long status be cut short while
the title still had room. The status now never shrinks as a flex item;
its cap is the room left beside the mark, the gaps and the title at its
least (--title-least), so the title gives way first, then the status.
The test measures the status's whole width on an uncapped, unshrunk
copy, and adds long statuses at 1280px and 390px.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 4257bb511a8473a99d84df72aa724e295fe7b643 parent 2deed9b
2 files changed, +25 −14
  • internal/browsertest/cards_test.go +17 −9
  • internal/look/static/app.css +8 −5
diff --git a/internal/browsertest/cards_test.go b/internal/browsertest/cards_test.go
index 008d596..c102dd4 100644
--- a/internal/browsertest/cards_test.go
+++ b/internal/browsertest/cards_test.go
@@ -228,12 +228,15 @@ func statusShownJS(id string) string {
if (t.scrollWidth <= t.clientWidth) p.push("the title is not cut short");
// The status is cut short only once the title is down to its least
// (measured to the fraction of a pixel: a sliver less already draws
- // an ellipsis).
- const drawn = s.getBoundingClientRect().width;
- s.style.flex = "none";
- const whole = s.getBoundingClientRect().width;
- s.style.flex = "";
- if (whole - drawn > 0.01 && t.getBoundingClientRect().width > parseFloat(getComputedStyle(t).minWidth) + 1) p.push("the status is cut short before the title: " + drawn + "px of " + whole);
+ // an ellipsis). Its whole width is a copy's, set beside it with no
+ // cap and no shrinking.
+ const drawn = s.getBoundingClientRect().width, copy = s.cloneNode(true);
+ copy.style.cssText = "position: absolute; visibility: hidden; flex: none; max-width: none; min-width: 0; width: max-content";
+ s.parentElement.append(copy);
+ const whole = copy.getBoundingClientRect().width;
+ copy.remove();
+ const title = t.getBoundingClientRect().width, least = parseFloat(getComputedStyle(t).minWidth);
+ if (whole - drawn > 0.01 && title > least + 0.5) p.push("the status is cut short (" + drawn + "px of " + whole + ") while the title is " + title + "px, more than its least " + least);
if (!j.querySelector(".pill-link")) p.push("no link");
const pill = j.querySelector(".pill").getBoundingClientRect(), log = document.querySelector("#ask-panel .thread").getBoundingClientRect();
if (pill.right > log.right + 0.5) p.push("the pill overflows the chat");
@@ -263,9 +266,14 @@ func TestAskJobStatusStaysVisible(t *testing.T) {
chromedp.Poll[chromedp.Void](readJS, chromedp.WithPollingTimeout(5*time.Second)))
}
id := f.AskJob(title)
- for _, st := range []struct{ state, result, label string }{{"ready", "Ready to try", "Try it"}, {"done", "Done", "Open your site"}} {
+ for _, st := range []struct{ state, result, label string }{
+ {"ready", "Ready to try", "Try it"},
+ {"done", "Done", "Open your site"},
+ {"ready", "Ready to try on a phone, a tablet and a computer", "Try it"},
+ {"done", "Done, and live for everyone who visits", "Open your site"},
+ } {
f.SetJob(id, st.state, st.result, "One sentence more.", equipo.Link{Label: st.label, URL: "https://site.example.test/"})
- drive(t, rig, chromedp.Poll[chromedp.Void](`document.querySelector('#ask-panel li.job')?.dataset.state === "`+st.state+`"`,
+ drive(t, rig, chromedp.Poll[chromedp.Void](`document.querySelector('#ask-panel li.job .pill-stage')?.textContent === `+strconv.Quote(st.result),
chromedp.WithPollingTimeout(10*time.Second)))
// Measured in the page's own font, once it has loaded.
drive(t, rig, chromedp.Poll[chromedp.Void](`document.fonts.status === "loaded"`, chromedp.WithPollingTimeout(10*time.Second)),
@@ -273,7 +281,7 @@ func TestAskJobStatusStaysVisible(t *testing.T) {
if got := harness.Evaluate[string](rig, statusShownJS(id)); got != "" {
t.Errorf("%s, %s: %s", view.name, st.state, got)
}
- mobileShot(t, rig, "job-"+st.state+"-"+view.name)
+ mobileShot(t, rig, "job-"+st.state+"-"+strconv.Itoa(len(st.result))+"-"+view.name)
}
})
}
diff --git a/internal/look/static/app.css b/internal/look/static/app.css
index 724a61d..0bf7762 100644
--- a/internal/look/static/app.css
+++ b/internal/look/static/app.css
@@ -535,11 +535,14 @@ aside.ask-panel { position: absolute; top: 16px; right: 16px; bottom: 16px; widt
list-style: none; cursor: pointer; font-size: 13.5px; line-height: 20px; white-space: nowrap; }
.pill-main::-webkit-details-marker { display: none; }
.pill-main:focus-visible { outline-offset: 2px; }
-.pill-title { flex: 0 1 auto; min-width: 3em; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
-/* The status keeps its whole width (a share that shrinks by a sliver
- already draws an ellipsis) up to half the pill; only a longer one is
- cut short. */
-.pill-stage { flex: none; min-width: 3em; max-width: 50%; overflow: hidden; text-overflow: ellipsis; color: var(--haze); font-size: 13px; }
+/* Space runs short: the title gives way first, down to --title-least;
+ only then the status (ruling R26). The status never shrinks as a flex
+ item (a share of even a sliver draws an ellipsis); its cap is the room
+ left beside the mark, the two gaps and the title at its least. */
+.pill-main { --title-least: 40px; }
+.pill-title { flex: 0 1 auto; min-width: var(--title-least); overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
+.pill-stage { flex: none; min-width: 0; max-width: calc(100% - 28px - 2 * 8px - var(--title-least)); overflow: hidden; text-overflow: ellipsis;
+ color: var(--haze); font-size: 13px; }
.pill-stage::before { content: "·"; margin: 0 6px 0 0; }
.pill-link { flex: none; align-self: stretch; display: flex; align-items: center; margin-left: -5px; padding: 0 14px 0 10px; border-radius: 0 999px 999px 0;
font-size: 13.5px; font-weight: 600; color: var(--focus); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap;