Skip to content

Isometric line figures that answer the pointer. For React and for anything with a DOM.

Site: a made tile stays clear until its page shows only the stage, so its controls never flash

Lucas Marques54e1bbf1b0c0
diff --git a/apps/site/app/globals.css b/apps/site/app/globals.css
index d9a6f6c..436db62 100644
--- a/apps/site/app/globals.css
+++ b/apps/site/app/globals.css
@@ -416,7 +416,10 @@ footer a::after { content: ""; position: absolute; inset: -12px -8px; }
.example-frame { display: block; width: 100%; height: calc(min(100cqw - 32px, 640px) * 0.8 + 148px + 48px + max(0px, 392px - 100cqw) * 0.75); border: 0; }
/* a figure the skill made, on its tile: only the page's stage, in the figures' own box, so a page that does not load
leaves the tile its shape */
-.made-frame { display: block; width: 100%; aspect-ratio: 5 / 4; border: 0; background: transparent; }
+.made-frame { display: block; width: 100%; aspect-ratio: 5 / 4; border: 0; background: transparent; transition: opacity 180ms ease-out; }
+/* until the page in it shows only its stage, the frame shows nothing: its controls never flash in the tile */
+.made-frame:not([data-quiet]) { opacity: 0; }
+@media (prefers-reduced-motion: reduce) { .made-frame { transition: none; } }
/* /figures. The shelves are a filter: from 1100px a list by the column's left edge, sticky inside the page's grid so it
stops where the column ends and never runs over the footer; below that the docs' strip under the top bar. The list's
diff --git a/apps/site/components/made-frame.tsx b/apps/site/components/made-frame.tsx
index 777e4e3..4449f39 100644
--- a/apps/site/components/made-frame.tsx
+++ b/apps/site/components/made-frame.tsx
@@ -12,6 +12,10 @@ const ONLY_STAGE = "#name, #read, #rules, #means, .controls { display: none !imp
* nothing else. The frame has the figures' own 5:4 box from CSS, so a page
* that is slow, missing or broken leaves the tile its shape. The page's ground
* goes clear, so the tile's ring, drawn under the frame, still shows.
+ *
+ * The style can only go in once the page has loaded, and the page paints
+ * before that, controls and all: so the frame stays clear until its page has
+ * the style (`data-quiet`), and only the stage is ever seen.
*/
export function MadeFrame({ src, title }: { src: string; title: string }) {
const frame = useRef<HTMLIFrameElement>(null);
@@ -28,6 +32,8 @@ export function MadeFrame({ src, title }: { src: string; title: string }) {
style.id = QUIET;
style.textContent = ONLY_STAGE;
doc.head.append(style);
+ // the blank document a frame starts with is not the page
+ if (doc.URL !== "about:blank") el.dataset.quiet = "";
unkey?.();
unkey = forwardEscape(el, doc);
};
diff --git a/apps/site/test/figures.spec.ts b/apps/site/test/figures.spec.ts
index 944ffa8..cbaa53b 100644
--- a/apps/site/test/figures.spec.ts
+++ b/apps/site/test/figures.spec.ts
@@ -250,3 +250,20 @@ test("a made tile keeps its box when its page is missing", async ({ page }) => {
const box = (await page.locator("#shelf-marks .fig-tile").nth(1).locator("iframe.made-frame").boundingBox())!;
expect(box.width / box.height).toBeCloseTo(5 / 4, 1);
});
+
+// a made page paints its controls before the tile can hide them: the frame shows nothing until it shows only the stage
+test("a made tile never shows its page's controls while the page loads", async ({ page }) => {
+ let release!: () => void;
+ const held = new Promise<void>((done) => (release = done));
+ await page.route("**/skill/hairline-vercel.html*", async (route) => {
+ await held;
+ await route.continue();
+ });
+ await page.goto("/figures#marks");
+ const frame = page.locator("#shelf-marks .fig-tile").first().locator("iframe.made-frame");
+ await expect(frame).toHaveCSS("opacity", "0");
+ release();
+ await expect(frame).toHaveAttribute("data-quiet", "");
+ await expect(frame).toHaveCSS("opacity", "1");
+ await expect(frame.contentFrame().locator(".controls")).toBeHidden();
+});