oficina / estilo Public

chrome: keep the controls' borders in forced colours

Fable's P2.2 on estilo #34. In forced-colors mode the controls set's
border: 0 outweighed rastrillo's forced-colors ButtonBorder on [rst-btn],
so Share and Format lost every edge and Format's aria-expanded="true"
tint vanished with nothing in its place. A forced-colors block after the
set gives the controls a 1px ButtonBorder and draws an expanded toggle in
Highlight (border, plus a 1px outline unless the focus ring is showing).

TestTheControlsKeepTheirBoundaryInForcedColours holds the rules (the repo
checks CSS by its text). Checked in Chromium and WebKit with
forcedColors: 'active' at 1280px: Share 1px solid, Format 1px Highlight
border and outline; with forced colours off nothing changes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 9d7a881302cb082072578bb177fd019a49aa40f5 parent befbc29
2 files changed, +39 −0
  • chrome/chrome.css +12 −0
  • chrome/stack_test.go +27 −0
diff --git a/chrome/chrome.css b/chrome/chrome.css
index 2278520..cc44d6e 100644
--- a/chrome/chrome.css
+++ b/chrome/chrome.css
@@ -607,6 +607,18 @@
background-position: right center;
}
}
+/* Forced colours drop the controls' fills and shadows, leaving their
+ border to draw them, and the set's border: 0 above outweighs
+ rastrillo's forced-colors border on [rst-btn]: Share and Format would
+ lose every edge. So the set gives it back, at its own weight and after
+ it. An expanded toggle's tint is gone too, so it is drawn in Highlight,
+ two pixels deep with the outline (left to the focus ring while that
+ shows). At every width: below 800px the same border is rastrillo's. */
+@media (forced-colors: active) {
+ :is([estilo-bar-control] > a, [estilo-bar-control] > button, [estilo-bar-control] > form > button) { border: 1px solid ButtonBorder; }
+ :is([estilo-bar-control] > a, [estilo-bar-control] > button, [estilo-bar-control] > form > button)[aria-expanded="true"] { border-color: Highlight; }
+ :is([estilo-bar-control] > a, [estilo-bar-control] > button, [estilo-bar-control] > form > button)[aria-expanded="true"]:not(:focus-visible) { outline: 1px solid Highlight; }
+}
@media (prefers-reduced-motion: reduce) {
:is([estilo-bar~="stacked"], [estilo-bar]:has([estilo-bar-lead])) [estilo-account] [estilo-avatar] { transition: none; }
}
diff --git a/chrome/stack_test.go b/chrome/stack_test.go
index 136b678..6730ef8 100644
--- a/chrome/stack_test.go
+++ b/chrome/stack_test.go
@@ -316,3 +316,30 @@ func TestAStackedTitleNeverShowsAnEllipsis(t *testing.T) {
t.Error("the stacked title field still ends a short guess with an ellipsis")
}
}
+
+// Forced colours drop the controls' fills and shadows, so their border is
+// all that is left to draw them, and rastrillo's forced-colors border on
+// [rst-btn] loses to the controls set's border: 0. The set restores it
+// itself, after that rule and at its weight, and marks an expanded toggle
+// (Format with the inspector open) in Highlight, since its tint is gone.
+func TestTheControlsKeepTheirBoundaryInForcedColours(t *testing.T) {
+ src := string(CSS())
+ src = src[strings.Index(src, barStackMarker):]
+ controls := `:is([estilo-bar-control] > a, [estilo-bar-control] > button, [estilo-bar-control] > form > button)`
+ set := strings.Index(src, controls+" {\n display: inline-flex;")
+ at := strings.Index(src, "@media (forced-colors: active) {")
+ if set < 0 || at < 0 || at < set {
+ t.Fatal("no forced-colors block after the controls set's rules")
+ }
+ block := src[at:]
+ block = block[:strings.Index(block, "\n}\n")]
+ for _, want := range []string{
+ controls + " { border: 1px solid ButtonBorder; }",
+ controls + `[aria-expanded="true"] { border-color: Highlight; }`,
+ controls + `[aria-expanded="true"]:not(:focus-visible) { outline: 1px solid Highlight; }`,
+ } {
+ if !strings.Contains(block, want) {
+ t.Errorf("the forced-colors block lacks %s in\n%s", want, block)
+ }
+ }
+}