Let authors frame pictures, and add a minimal variant - #15
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 Fitcolumn, next to everything else the author already controls:cover/50% 50%topcover/50% 0%containcontain/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
nulland the caller uses a centre crop, so a bad value costs nothing. The existingcropsproperty still wins where set.minimalStrips 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-fitandobject-position, andminimalrenders with no frame and a coloured-text selection instead of a filled chip.npm testpassesnpm run buildpassespackages/corehave a test