Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🖍 Cleanup several unresolved amp-layout CSS states #28115

Merged
merged 3 commits into from
May 5, 2020

Conversation

jridgewell
Copy link
Contributor

  • Adds unresolved layout for intrinsic styles
  • Fixes specificity for unresolved fixed-height styles
  • Adds unresolved implicit layout responsive styles

css/ampshared.css Outdated Show resolved Hide resolved
css/ampshared.css Show resolved Hide resolved
@@ -237,7 +239,8 @@ i-amphtml-sizer {

/* Hide all children of non-container elements. */
.i-amphtml-notbuilt:not(.i-amphtml-layout-container) > * ,
[layout]:not([layout=container]):not(.i-amphtml-element) > *
[layout]:not([layout=container]):not(.i-amphtml-element) > *,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized this also doesn't account for implicit container layout. Is there even a CSS selector that would match?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What defines implicit container? Is it just a lack of width and height and layout?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amphtml/src/layout.js

Lines 429 to 442 in 67815dc

// Calculate effective layout.
if (inputLayout) {
layout = inputLayout;
} else if (!width && !height) {
layout = Layout.CONTAINER;
} else if (height == 'fluid') {
layout = Layout.FLUID;
} else if (height && (!width || width == 'auto')) {
layout = Layout.FIXED_HEIGHT;
} else if (height && width && (sizesAttr || heightsAttr)) {
layout = Layout.RESPONSIVE;
} else {
layout = Layout.FIXED;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe we can do this without :not(:resolved)

css/ampshared.css Outdated Show resolved Hide resolved
jridgewell added 3 commits May 4, 2020 18:19
- Adds unresolved layout for `intrinsic` styles
- Fixes specificity for unresolved `fixed-height` styles
- Adds unresolved implicit layout `responsive` styles
@jridgewell
Copy link
Contributor Author

Need a bundle size approval.

[layout]:not(.i-amphtml-element)
[layout]:not(.i-amphtml-element),
[width][height][sizes]:not([layout]):not(.i-amphtml-element),
[width][height][heights]:not([layout]):not(.i-amphtml-element)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment that this [width][height][sizes] and [width][height][heights] are "implicit responsive" here and below. Follow-up PR is cool too to avoid the bundle size reapproval.

[layout]:not(.i-amphtml-element)
[layout]:not(.i-amphtml-element),
[width][height][sizes]:not([layout]):not(.i-amphtml-element),
[width][height][heights]:not([layout]):not(.i-amphtml-element)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not handling any of the other implicit layouts either. Not sure if it's better to only fix this for implicit responsive or leave them all unfixed.

Consider leaving a note/TODO about this at least.

Copy link
Contributor Author

@jridgewell jridgewell May 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, fixed-height, fluid and container are the missing ones. fluid isn't documented on https://amp.dev/documentation/guides-and-tutorials/learn/amp-html-layout/#layout, so lets ignore it.

fixed and fixed-height are implicit based on height and width only. Unfortunately, that's very generic, and there are non-amp elmeents that fit that:

  • width + height
    • amp-script > canvas
    • SVG > *
    • td
    • th
    • input
  • width
    • table

And container conflicts with basically everything.

I'm not sure we want to apply these styles to those elements.

I'll add a comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for looking into it.

@jridgewell jridgewell merged commit 5d859d4 into ampproject:master May 5, 2020
@jridgewell jridgewell deleted the intrinsic-css branch May 5, 2020 03:24
jridgewell added a commit to jridgewell/amphtml that referenced this pull request May 5, 2020
jridgewell added a commit that referenced this pull request May 6, 2020
ldoroshe pushed a commit to ldoroshe/amphtml that referenced this pull request May 8, 2020
* Cleanup several unresolved amp-layout CSS states

- Adds unresolved layout for `intrinsic` styles
- Fixes specificity for unresolved `fixed-height` styles
- Adds unresolved implicit layout `responsive` styles

* Fix fixed-height selector

* Add in implicit responsive with heights
ldoroshe pushed a commit to ldoroshe/amphtml that referenced this pull request May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants