🚀 [Story performance] Move aspect-ratio logic to CSS for styling#36061
🚀 [Story performance] Move aspect-ratio logic to CSS for styling#36061mszylkowski merged 6 commits intoampproject:mainfrom
Conversation
gmajoulet
left a comment
There was a problem hiding this comment.
Is this ready for review?
|
@gmajoulet Tests don't fully pass, but implementation is ready. I'll mark this PR as ready when tests are good. |
|
Hey @gmajoulet, @newmuis! These files were changed: |
|
|
||
| --i-amphtml-aspect-ratio-calculated: calc(var(--aspect-ratio)) !important; /* Avoid fractions, which don't work with compilers that remove parenthesis */ | ||
| --i-amphtml-story-page-width: calc(100 * var(--story-page-vw, 1vw)) !important; | ||
| --i-amphtml-story-page-height: calc(100 * var(--story-page-vh, 1vh)) !important; |
There was a problem hiding this comment.
Plz update these variable names, it's too easy to get into collisions at some point with the one-panel-page-height etc
There was a problem hiding this comment.
There are no spared variables now, but if they collide, they would have exactly the same value (as it's literally getting the width and height of the page regardless of UI type), and I could just remove the usage from here. I'm open to moving them up to an ancestor of the grid-layers also, but they aren't currently needed anywhere else afaik. Still think it's worth it to rename it to sth like --i-amphtml-story-ancestor-page-height or similar?
Closes #36048
Moves the logic to calculate the size of the
[aspect-ratio]layer (or[preset]) to the CSS.The calculations are:
The CSS properties needed for this to work (which are created by the runtime or in the CSS styles, but should be added with transformers to benefit from early rendering) are:
--aspect-ratio: w/h(which is different from the attributeaspect-ratio="w:h")Eg: