diff --git a/apps/graphs/src/pages/look.ts b/apps/graphs/src/pages/look.ts index 98507ee..d9b70f6 100644 --- a/apps/graphs/src/pages/look.ts +++ b/apps/graphs/src/pages/look.ts @@ -417,7 +417,8 @@ figure.plate { /* The document plate viewport: full width and 60svh below the datasheet * breakpoint, stretched beside the datasheet above it (see the 1024 px * block). Without scripting it scrolls at scale 1; the plate client - * adds is-live and pans/zooms the drawing itself instead. */ + * adds is-live and pans/zooms the drawing itself instead, and the + * one-column viewport then follows the drawing's proportions (below). */ .doc-cols figure.plate { margin: 0; width: 100%; @@ -430,6 +431,16 @@ figure.plate.is-live { position: relative; touch-action: none; } +/* Live in one column, the viewport takes the drawing's own proportions + * (--plate-ratio, set by the client) between 200 px and 60svh: a wide + * plate fits the full width without the letterbox bands a fixed 60svh + * left above and below it on a phone; a tall one still stops at 60svh. */ +.doc-cols figure.plate.is-live { + height: auto; + aspect-ratio: var(--plate-ratio, auto); + min-height: 200px; + max-height: 60svh; +} .plate svg { display: block; height: auto; margin: 0 auto; } .plate.is-live svg { margin: 0; transform-origin: 0 0; } /* The overlaid zoom controls, rendered by the client: three 44 px targets @@ -676,6 +687,7 @@ pre.prompt, pre.hash { @media (min-width: 1024px) { .doc-cols { flex-direction: row; align-items: stretch; } .doc-cols figure.plate { flex: 1; min-width: 0; width: auto; height: auto; min-height: 420px; } + .doc-cols figure.plate.is-live { aspect-ratio: auto; min-height: 420px; max-height: none; } dl.sheet { flex: 0 0 320px; } } @media (prefers-reduced-motion: reduce) { diff --git a/apps/graphs/src/plate/client.ts b/apps/graphs/src/plate/client.ts index 50666e4..b356485 100644 --- a/apps/graphs/src/plate/client.ts +++ b/apps/graphs/src/plate/client.ts @@ -130,6 +130,9 @@ function mountFigure(figure: HTMLElement): void { figure.classList.add("is-live"); svg.style.width = `${content.w}px`; svg.style.height = `${content.h}px`; + // The drawing's proportions, for the one-column layout's viewport height + // (look.ts): full width, as tall as the fitted drawing within its bounds. + figure.style.setProperty("--plate-ratio", `${content.w} / ${content.h}`); const viewer: Viewer = { figure, svg, diff --git a/apps/graphs/test/__snapshots__/pages.test.ts.snap b/apps/graphs/test/__snapshots__/pages.test.ts.snap index 326d4a9..00dda70 100644 --- a/apps/graphs/test/__snapshots__/pages.test.ts.snap +++ b/apps/graphs/test/__snapshots__/pages.test.ts.snap @@ -377,7 +377,8 @@ figure.plate { /* The document plate viewport: full width and 60svh below the datasheet * breakpoint, stretched beside the datasheet above it (see the 1024 px * block). Without scripting it scrolls at scale 1; the plate client - * adds is-live and pans/zooms the drawing itself instead. */ + * adds is-live and pans/zooms the drawing itself instead, and the + * one-column viewport then follows the drawing's proportions (below). */ .doc-cols figure.plate { margin: 0; width: 100%; @@ -390,6 +391,16 @@ figure.plate.is-live { position: relative; touch-action: none; } +/* Live in one column, the viewport takes the drawing's own proportions + * (--plate-ratio, set by the client) between 200 px and 60svh: a wide + * plate fits the full width without the letterbox bands a fixed 60svh + * left above and below it on a phone; a tall one still stops at 60svh. */ +.doc-cols figure.plate.is-live { + height: auto; + aspect-ratio: var(--plate-ratio, auto); + min-height: 200px; + max-height: 60svh; +} .plate svg { display: block; height: auto; margin: 0 auto; } .plate.is-live svg { margin: 0; transform-origin: 0 0; } /* The overlaid zoom controls, rendered by the client: three 44 px targets @@ -636,6 +647,7 @@ pre.prompt, pre.hash { @media (min-width: 1024px) { .doc-cols { flex-direction: row; align-items: stretch; } .doc-cols figure.plate { flex: 1; min-width: 0; width: auto; height: auto; min-height: 420px; } + .doc-cols figure.plate.is-live { aspect-ratio: auto; min-height: 420px; max-height: none; } dl.sheet { flex: 0 0 320px; } } @media (prefers-reduced-motion: reduce) { @@ -649,7 +661,7 @@ pre.prompt, pre.hash {
- +