Implement fit-mode rendering contract with container sizing and pane re-fit

This commit is contained in:
2026-06-05 10:45:41 +03:00
parent f4253f50ca
commit 411bfbc6c2
13 changed files with 552 additions and 73 deletions
+103 -5
View File
@@ -1,16 +1,114 @@
.preview {
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
overflow: auto;
background: var(--bg);
}
.chart {
.header {
flex: 0 0 auto;
display: flex;
align-items: flex-start;
justify-content: center;
min-height: 100%;
align-items: center;
justify-content: flex-end;
gap: var(--space-3);
height: 40px;
padding: 0 var(--space-4);
border-bottom: var(--border-width) solid var(--border);
}
.body {
flex: 1 1 auto;
min-height: 0;
overflow: auto;
padding: var(--space-5);
box-sizing: border-box;
}
/* Segmented control — the four fit modes (spec §04). */
.fit {
display: inline-flex;
border: var(--border-width) solid var(--border-strong);
}
.fitOption {
appearance: none;
border: none;
background: var(--bg);
color: var(--text-secondary);
font: inherit;
font-size: 12px;
line-height: 1;
padding: var(--space-2) var(--space-3);
cursor: pointer;
transition:
background var(--dur-fast) var(--ease),
color var(--dur-fast) var(--ease);
}
.fitOption + .fitOption {
border-left: var(--border-width) solid var(--border-strong);
}
.fitOption:hover {
background: var(--layer-01);
color: var(--text);
}
.fitActive,
.fitActive:hover {
background: var(--accent);
color: var(--accent-contrast);
}
/*
* Chart sizing. The host (passed to vega-embed) is branded `.vega-embed`
* (display:inline-block) at runtime; that shrink-wraps it, which is why
* width:"container" collapsed before. The frame carries the fit class and the
* two-class selectors below out-specify `.vega-embed` to give the host a
* definite box for the responsive modes. `box-sizing:border-box` keeps the
* chart inside the body padding rather than overflowing it.
*/
.frame {
box-sizing: border-box;
}
.host {
box-sizing: border-box;
}
/* Original — natural size; the body scrolls if the chart is larger than the pane. */
.fitOriginal {
display: inline-block;
}
/* Width — host spans the pane width; height stays natural. */
.fitWidth {
display: block;
width: 100%;
}
.fitWidth .host {
width: 100%;
}
/* Height — host spans the pane height; width stays natural. */
.fitHeight {
display: block;
height: 100%;
}
.fitHeight .host {
height: 100%;
}
/* Full — host fills the pane in both dimensions. */
.fitFull {
display: block;
width: 100%;
height: 100%;
}
.fitFull .host {
width: 100%;
height: 100%;
}
.error {