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

Support layout=container in amp-list #27159

Merged
merged 39 commits into from
Mar 20, 2020

Conversation

caroqliu
Copy link
Contributor

@caroqliu caroqliu commented Mar 9, 2020

Builds off #26888, Closes #26873

PR deploy bot demo

@dreamofabear
Copy link

Is this ready for review?

@caroqliu
Copy link
Contributor Author

@choumx Yes go ahead. :) Thanks!

extensions/amp-list/0.1/amp-list.js Show resolved Hide resolved
extensions/amp-list/0.1/amp-list.js Show resolved Hide resolved
extensions/amp-list/0.1/amp-list.js Outdated Show resolved Hide resolved
extensions/amp-list/0.1/amp-list.js Outdated Show resolved Hide resolved
@amp-owners-bot
Copy link

Hey @ampproject/wg-caching, these files were changed:

extensions/amp-list/0.1/test/validator-amp-list.html
extensions/amp-list/0.1/test/validator-amp-list.out
extensions/amp-list/validator-amp-list.protoascii
validator/testdata/amp4email_feature_tests/amp_list.html
validator/testdata/amp4email_feature_tests/amp_list.out

Copy link

@dreamofabear dreamofabear left a comment

Choose a reason for hiding this comment

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

Just needs documentation next?

[filter formats="websites, stories"]
In several cases, we may need the `<amp-list>` to resize on user interaction. For example, when the `<amp-list>` contains an amp-accordion that a user may tap on, when the contents of the `<amp-list>` change size due to bound CSS classes, or when the number of items inside an `<amp-list>` changes due to a bound `[src]` attribute. The `changeToLayoutContainer` action handles this by changing the amp list to `layout="CONTAINER"` when triggering this action. See the following example:
Before support for `layout="CONTAINER"` was added, in several cases, we needed the `<amp-list>` to resize on user interaction. For example, when the `<amp-list>` contains an amp-accordion that a user may tap on, when the contents of the `<amp-list>` change size due to bound CSS classes, or when the number of items inside an `<amp-list>` changes due to a bound `[src]` attribute. The `changeToLayoutContainer` action handles this by changing the amp list to `layout="CONTAINER"` when triggering this action. See the following example:

Choose a reason for hiding this comment

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

I think API documentation probably always reflect the latest state; describing new features usually is done in a blog or release notes.

It may be more useful to explain when to use layout=container and when to use changeToLayoutContainer action here.

Choose a reason for hiding this comment

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

Heh, this is tricky to explain. Let's get this in and iterate.

We can also revisit in V2. changeToLayoutContainer and [is-layout-container] probably should be changed.

Copy link
Member

@alanorozco alanorozco left a comment

Choose a reason for hiding this comment

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

Nice. Just nits :)

examples/amp-list-container.amp.html Outdated Show resolved Hide resolved
extensions/amp-list/0.1/amp-list.js Outdated Show resolved Hide resolved
* Applicable for layout=container.
* @private
*/
unlockHeight_() {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: somehow communicate that this should be done inside a mutate callback, I usually add a suffix.

Suggested change
unlockHeight_() {
unlockHeightInsideMutate_() {

caroqliu and others added 3 commits March 19, 2020 17:12
Co-Authored-By: Alan Orozco <alanorozco@users.noreply.github.com>
Co-Authored-By: Alan Orozco <alanorozco@users.noreply.github.com>
@caroqliu caroqliu merged commit b0187b7 into ampproject:master Mar 20, 2020
twintwox pushed a commit to twintwox/amphtml that referenced this pull request Mar 24, 2020
* Prototype for container layout in amp-list.

* Remove unused import

* Don't apply fillContent for layout=container

* Restore old example page

* Move layout=container example to new document

* Move isLayoutSizeDefined_ to buildCallback

* Add line

* Set isLayoutSizeDefined when changing to container

* Check layout is defined

* Replace isLayoutSizeDefined with isLayoutContainer

* Fix some tests, comment out 4

* Remove bottom padding for sample

* Move resize logic to attemptToFit

* Set styles on refresh

* Uncomment tests

* Restore line

* Will comments

* Handle changeToLayoutContainer action

* Only set height for layout=container

* Validate layout=container

* Assert placeholder presence for layout=container

* Fix indent

* Move height locking to helper methods

* Unit test for unlock

* Unlock height inside render

* Move measure to `lockHeightAndMutate`

* Catch errors inside attemptToFit

* Remove arrow

* Always measure height

* Will comments

* Add documentation

* Update md language

* Update info link

Co-Authored-By: Alan Orozco <alanorozco@users.noreply.github.com>

* Re-shrink boilerplate code

Co-Authored-By: Alan Orozco <alanorozco@users.noreply.github.com>

* Rename unlockHeight

Co-authored-by: William Chou <willchou@google.com>
Co-authored-by: Alan Orozco <alanorozco@users.noreply.github.com>
honeybadgerdontcare added a commit to honeybadgerdontcare/amphtml that referenced this pull request Mar 25, 2020
honeybadgerdontcare added a commit to honeybadgerdontcare/amphtml that referenced this pull request Mar 25, 2020
honeybadgerdontcare added a commit that referenced this pull request Mar 25, 2020
* cl/302030563 Revision bump for #27280

* cl/302033641 Remove trailing whitespace from protoascii

* cl/302035592 Revision bump for #27159

* cl/302061262 github commit msg missing or malformed

* revert

* revert

* revert

* revert

* revert

* trying to kickstart travis

Co-authored-by: Greg Grothaus <greggrothaus@google.com>
erwinmombay added a commit that referenced this pull request Apr 3, 2020
caroqliu added a commit to caroqliu/amphtml that referenced this pull request Apr 14, 2020
danielrozenberg pushed a commit that referenced this pull request Apr 14, 2020
* Revert "[amp-list]: make layout=container and load-more mutually exclusive (#27521)"

This reverts commit 14329bc.

* Revert "Support layout=container in amp-list (#27159)"

This reverts commit b0187b7.
danielrozenberg pushed a commit that referenced this pull request Apr 14, 2020
* Revert "[amp-list]: make layout=container and load-more mutually exclusive (#27521)"

This reverts commit 14329bc.

* Revert "Support layout=container in amp-list (#27159)"

This reverts commit b0187b7.

(cherry picked from commit dceac64)
danielrozenberg pushed a commit that referenced this pull request Apr 14, 2020
* Revert "[amp-list]: make layout=container and load-more mutually exclusive (#27521)"

This reverts commit 14329bc.

* Revert "Support layout=container in amp-list (#27159)"

This reverts commit b0187b7.

(cherry picked from commit dceac64)
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.

amp-list: Support layout=container?
7 participants