oficina / estilo Public

chrome: the 704px band's scope adds no specificity

Fable's delta review of 4757ccc, LOW: the band's copy was scoped with
:is(...), which added (0,1,0) to every rule, so in the band the controls'
border: 0 outweighed the forced-colors rule after it, and Share and
Format lost their edge there. The scope is :where(...) now, and the copy
keeps each rule's own specificity and the original cascade. At its own
weight the copy no longer outweighs the narrow two-row rules below 800px,
so two hand rules in the band restore the stack and the menu row's
margins.

The browser check (added with the previous commit) renders the compact
bar in forced colours at 768 and 1280px and expects the primary control
to keep a border: 0px at 768 before this, 1px now. It also asserts the
band's title sits over the menu row. The compact bar at 768 and 844x390
and the folded phone bar are pixel-identical to 4757ccc.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev fdcf06fdb33b78e0829c33f336cb9682afb3c36e parent 21f9bc1
3 files changed, +20 −9
  • chrome/chrome.css +6 −3
  • chrome/chrome.go +7 −3
  • chrome/compact_test.go +7 −3
diff --git a/chrome/chrome.css b/chrome/chrome.css
index 506774e..886b320 100644
--- a/chrome/chrome.css
+++ b/chrome/chrome.css
@@ -785,12 +785,15 @@
}
/* Between 704px and 800px a compact bar is the 56px header, as every
stacked bar is from 800px: the copy of the block above that CSS() puts
- here, and these, which undo the narrow two-row layout below 800px and
- put its actions back in the bar. A compact bar with nav keeps its Menu
+ here, and these, which undo the narrow two-row layout below 800px
+ (its stack dissolved, its menu row's margins: the copy keeps the
+ original rules' specificity, so the narrow ones would win) and put its
+ actions back in the bar. A compact bar with nav keeps its Menu
sheet there, as below 800px every bar does. */
@media (min-width: 704px) and (max-width: 799.98px) and (not ((max-height: 480px) and (pointer: coarse))) {
[estilo-bar~="stacked"][estilo-bar~="compact"] { display: flex; block-size: var(--estilo-bar-block-size); }
- [estilo-bar~="stacked"][estilo-bar~="compact"] [estilo-bar-menubar] { align-self: auto; margin-inline-end: 0; }
+ [estilo-bar~="stacked"][estilo-bar~="compact"] [estilo-bar-stack] { display: flex; }
+ [estilo-bar~="stacked"][estilo-bar~="compact"] [estilo-bar-menubar] { align-self: auto; margin-inline: calc(-1 * var(--rst-sp-2)) 0; } /* the 56px header's, which the copy, at its own weight, no longer outweighs here */
[estilo-bar~="compact"] [estilo-bar-actions] { display: flex; }
}
@media (min-width: 64rem) {
diff --git a/chrome/chrome.go b/chrome/chrome.go
index d4ef5ef..414edaf 100644
--- a/chrome/chrome.go
+++ b/chrome/chrome.go
@@ -153,8 +153,12 @@ func scopeRules(body string) string {
}
// scopeSelector limits sel to a compact bar: the bar itself or anything
-// inside one. A pseudo-element stays outside :is(), where it is valid;
-// the root's rule asks for a stacked bar that is also compact.
+// inside one. The scope is :where(), so the copy keeps each rule's own
+// specificity and the cascade around it is the original's: the
+// forced-colors border after the block still outweighs the controls'
+// border: 0 (Fable, on 4757ccc). A pseudo-element stays outside :is(),
+// where it is valid; the root's rule asks for a stacked bar that is also
+// compact.
func scopeSelector(sel string) string {
sel = strings.Join(strings.Fields(sel), " ")
if strings.HasPrefix(sel, ":root") {
@@ -164,7 +168,7 @@ func scopeSelector(sel string) string {
if i := strings.LastIndex(sel, "::"); i >= 0 && !strings.ContainsAny(sel[i:], "()[] ") {
sel, pseudo = sel[:i], sel[i:]
}
- return ":is(" + sel + `):is([estilo-bar~="compact"], [estilo-bar~="compact"] *)` + pseudo
+ return ":is(" + sel + `):where([estilo-bar~="compact"], [estilo-bar~="compact"] *)` + pseudo
}
// splitSelectors splits a selector list at its top-level commas, leaving
diff --git a/chrome/compact_test.go b/chrome/compact_test.go
index 9d24b6f..75755a5 100644
--- a/chrome/compact_test.go
+++ b/chrome/compact_test.go
@@ -257,8 +257,12 @@ func TestOnlyACompactBarMovesTo704px(t *testing.T) {
if strings.Join(strings.Fields(decls(wide)), " ") != strings.Join(strings.Fields(decls(band)), " ") {
t.Error("the band's declarations are not the wide block's")
}
- // A pseudo-element stays outside :is(), where it is valid.
- if !strings.Contains(band, `:is([estilo-bar~="stacked"] [estilo-menubar-title]):is([estilo-bar~="compact"], [estilo-bar~="compact"] *)::before`) {
+ // The scope adds no specificity (:where), so the cascade around the
+ // copy is the original's; a pseudo-element stays outside :is().
+ if strings.Contains(band, `):is([estilo-bar~="compact"]`) {
+ t.Error("the band's scope adds specificity; the forced-colors border would lose to the controls' border: 0")
+ }
+ if !strings.Contains(band, `:is([estilo-bar~="stacked"] [estilo-menubar-title]):where([estilo-bar~="compact"], [estilo-bar~="compact"] *)::before`) {
t.Error("the band does not keep ::before outside :is()")
}
if !strings.Contains(band, `:root:has([estilo-bar~="stacked"][estilo-bar~="compact"]) { --estilo-bar-block-size: 56px; }`) {
@@ -266,7 +270,7 @@ func TestOnlyACompactBarMovesTo704px(t *testing.T) {
}
// Nothing written by hand for the band reaches a bar without Compact.
hand := src[strings.Index(src, "/* Between 704px and 800px"):]
- hand = block(hand, strings.Index(hand, "{")+1)
+ hand = regexp.MustCompile(`(?s)/\*.*?\*/`).ReplaceAllString(block(hand, strings.Index(hand, "{")+1), "")
for _, list := range rules(hand) {
for _, sel := range splitSelectors(list) {
if !strings.Contains(sel, `[estilo-bar~="compact"]`) {