Skip to content

Let authors frame pictures, and add a minimal variant - #15

Merged
odiwr merged 1 commit into
mainfrom
feat/media-fit-and-minimal
Aug 30, 2026
Merged

odiwr merged 1 commit into
mainfrom
feat/media-fit-and-minimal

Conversation

@odiwr

@odiwr odiwr commented Aug 30, 2026

Copy link
Copy Markdown
Owner

What this changes

Two things a real sheet immediately wanted.

Framing pictures

The media pane is a fixed shape and photographs are not, so an image filled the frame and was cropped from the centre — with no way to say otherwise except a JavaScript property keyed by URL. That is wrong exactly where it matters most: the subject of a portrait sits near the top, and a centre crop takes their head off.

There is now a Media Fit column, next to everything else the author already controls:

You write Result
(empty) cover / 50% 50%
top cover / 50% 0%
contain contain / 50% 50%
80% cover / 50% 80%
30% 70% cover / 30% 70%

Also answers to Crop, Focus, Fit. Trailing punctuation and bare numbers are accepted, because this is a spreadsheet cell and people punctuate.

Security note. This value arrives from a URL the page author does not control and ends up in a style attribute, so the parser is where anything that is not a keyword or a validated percentage has to stop. Output is rebuilt from a whitelist rather than sanitised. There are tests for ten hostile inputs — url(), expression(), calc(), var(), a </style> break-out, out-of-range percentages — asserting that whatever survives is two plain percentages and a known keyword.

A cell it cannot read returns null and the caller uses a centre crop, so a bad value costs nothing. The existing crops property still wins where set.

minimal

<best-time src="…" minimal></best-time>

Strips every border, panel and label chip, leaving the baseline, the dots and the words. Not a theme — a theme changes what colour things are, this changes how much furniture there is. Pure CSS via :host([minimal]), so it stays in step with the standard layout rather than being a second layout to maintain.

Verification

112 tests (20 new). Checked in a browser: all four framing modes produce the correct object-fit and object-position, and minimal renders with no frame and a coloured-text selection instead of a filled chip.


  • npm test passes
  • npm run build passes
  • Behaviour changes in packages/core have a test
  • Comments explain why

Two things a real sheet immediately wanted.

**Framing.** The media pane is a fixed shape and photographs are not, so an
image filled the frame and was cropped from the centre with no way to say
otherwise except a JavaScript property keyed by URL. That is wrong exactly
where it matters most: the subject of a portrait sits near the top, and a
centre crop takes their head off.

There is now a Media Fit column, next to everything else the author already
controls. It reads what a person would plausibly type -- top, bottom, left,
right, top left, 25%, 30% 70%, contain, contain top -- and also answers to
Crop, Focus and Fit.

The value arrives from a URL and ends in a style attribute, so the parser is
where anything that is not a keyword or a validated percentage stops. Output
is rebuilt from a whitelist rather than sanitised, and there are tests for ten
hostile inputs including url(), expression(), calc() and a </style> break-out.
A cell it cannot read falls back to a centre crop rather than failing the row.

The existing `crops` property still wins where it is set, since whoever set it
was looking at that exact picture.

**minimal.** <best-time minimal> strips every border, panel and label chip,
leaving the baseline, the dots and the words. Not a theme -- a theme changes
what colour things are, this changes how much furniture there is -- and it is
pure CSS via :host([minimal]), so it stays in step with the standard layout
rather than being a second layout to maintain.

112 tests. Verified in a browser: all four framing modes produce the right
object-fit and object-position, and the minimal variant renders without a
frame.
@odiwr
odiwr merged commit 45ccc36 into main Aug 30, 2026
3 checks passed
@odiwr
odiwr deleted the feat/media-fit-and-minimal branch August 30, 2026 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant