fix: lay out every file card

With content-visibility: auto an off-screen card took a 320px
placeholder, so the links of the card above were drawn over its own and
Lighthouse failed target-size on the PS2 page (31 links on desktop, 7
on mobile). Laying out every card moved no Lighthouse metric: TBT stays
at 0 ms on the PS2 and Project64 pages, mobile.
This commit is contained in:
Abdessamad Derraz committed 2026-11-19 18:42:55 +01:00
1 parent 7e4192870f
commit 3eb5d1fce1
2 files changed
+11 -7

No files matched your search

+5 -2
View File
@@ -183,8 +183,11 @@ class ThemeStylesheet(unittest.TestCase):
def test_card_pages(self):
cards = next(b for s, b in _blocks(self.css) if s == ".sl-markdown-content :is(.rb-sys-file, .rb-file-entry)")
self.assertIn("content-visibility: auto", cards)
self.assertIn("contain-intrinsic-size: auto 320px", cards)
# A card off screen with content-visibility kept a placeholder
# height, and the links of the card above were drawn over its own
# (Lighthouse target-size, 31 links on the PS2 page, desktop).
self.assertNotIn("content-visibility", cards)
self.assertNotRegex(self.css, r"content-visibility\s*:")
self.assertIn("--sl-content-width: var(--rb-grid-width)", _rules(self.css, "body:has(.rb-sys-file, .rb-file-entry)")[0])
self.assertEqual(_theme_tokens(self.css, ":root")["--rb-grid-width"], "54rem")
facts = _rules(self.css, "dl.rb-facts")[0]
+6 -5
View File
@@ -451,15 +451,16 @@
border-top: 1px solid var(--rb-border);
}
/* File cards on system and emulator pages. A page holds hundreds: those
off screen are laid out when they come near, and the column is wide
enough for a sha256 on one line. */
/* File cards on system and emulator pages. The column is wide enough for a
sha256 on one line. Every card is laid out: with content-visibility an
off-screen card took a 320px placeholder, the links of the card above it
were drawn over its own, and Lighthouse failed target-size on the PS2
page (31 links on desktop, 7 on mobile). A page is split at about 280 cards, and laying them all out
moved no Lighthouse metric (PS2 page, mobile: TBT 0 ms both ways). */
body:has(.rb-sys-file, .rb-file-entry) { --sl-content-width: var(--rb-grid-width); }
.sl-markdown-content :is(.rb-sys-file, .rb-file-entry) {
border-top: 1px solid var(--rb-border);
padding: 0.75rem 0 0.25rem;
content-visibility: auto;
contain-intrinsic-size: auto 320px;
}
.sl-markdown-content :is(.rb-sys-file, .rb-file-entry) > :first-child { margin-top: 0; }
.sl-markdown-content .rb-file-title {