Skip to content

🖍 Cleanup several unresolved amp-layout CSS states#28115

Merged
jridgewell merged 3 commits intoampproject:masterfrom
jridgewell:intrinsic-css
May 5, 2020
Merged

🖍 Cleanup several unresolved amp-layout CSS states#28115
jridgewell merged 3 commits intoampproject:masterfrom
jridgewell:intrinsic-css

Conversation

@jridgewell
Copy link
Copy Markdown
Contributor

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

/* 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) > *,
Copy link
Copy Markdown

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
Copy Markdown
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?

Copy link
Copy Markdown

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
Copy Markdown
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)

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
Copy Markdown
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)
Copy link
Copy Markdown

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)
Copy link
Copy Markdown

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
Copy Markdown
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.

Copy link
Copy Markdown

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