Skip to content

✨Bento amp-soundcloud#34828

Merged
caroqliu merged 43 commits intoampproject:mainfrom
rtCamp:bento/amp-soundcloud
Jun 24, 2021
Merged

✨Bento amp-soundcloud#34828
caroqliu merged 43 commits intoampproject:mainfrom
rtCamp:bento/amp-soundcloud

Conversation

@AnuragVasanwala
Copy link
Copy Markdown
Contributor

This PR adds a bento component for amp-soundcloud.

  • Add amp-soundcloud
  • Add types
  • Add type annotations
  • Add test case
  • Update Storybook
  • latestVersion precedes options
  • prettify new amp-soundcloud

Fixes #34734

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jun 11, 2021

CLA assistant check
All committers have signed the CLA.

@amp-owners-bot amp-owners-bot bot requested a review from alanorozco June 11, 2021 10:35
@amp-owners-bot
Copy link
Copy Markdown

amp-owners-bot bot commented Jun 11, 2021

Hey @ampproject/wg-caching! These files were changed:

extensions/amp-soundcloud/1.0/test/validator-amp-soundcloud.html
extensions/amp-soundcloud/1.0/test/validator-amp-soundcloud.out
extensions/amp-soundcloud/validator-amp-soundcloud.protoascii

@kristoferbaxter kristoferbaxter requested a review from caroqliu June 11, 2021 18:31
Copy link
Copy Markdown
Contributor

@caroqliu caroqliu left a comment

Choose a reason for hiding this comment

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

This is a great start and almost there. I had a few comments and suggestions, but otherwise ready to go. 👍 👍 👍

AnuragVasanwala and others added 8 commits June 14, 2021 07:19
Bento components are required to be R1. We have an equivalent static getPreconnects(element) in R1 designed to take care of this.

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
ampproject#34838

Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>
No need to override `init` if no changes were made to it except calling parent class's `init`.

Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>
…children`


Since `passthrough` gives a `<slot>` reference to the children prop in all cases, let's make this passthroughNonEmpty -- which will only give a `<slot>` if there are children in the given markup.

Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>
AnuragVasanwala and others added 12 commits June 14, 2021 12:15
No need to explicitly specify boolean `true` for conditional block.

Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>
Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>
`height`, `heights`, `media`, `sizes`, and `width` are not needed to pass through as these attributes are specific to AMP's layout system and handled by the runtime.

Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>
`height`, `heights`, `media`, `sizes`, and `width` are not needed to pass through as these attributes are specific to AMP's layout system and handled by the runtime. Thus they do not need to be specify in typedef.

Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@caroqliu caroqliu left a comment

Choose a reason for hiding this comment

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

For some reason I'm not able to comment on the comment thread on IframeEmbed -- there's not currently a way to execute the unmount logic in the IframeEmbed. We can add onMount/onUnmount props to that component so that the Soundcloud component can pass these in, though the current approach is fine as-is as well.

One last recommendation - I noticed that there are unit tests for the Preact layer but not the AMP layer. Please also add extensions/amp-soundcloud/1.0/test/test-amp-soundcloud.js. It can have similar test cases to the one in 0.1, though the iframe reference will come from shadow instead (see amp-instagram unit tests for an example of waiting for render and retrieving the iframe)

AnuragVasanwala and others added 2 commits June 15, 2021 21:47
Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>
Comment on lines +69 to +81
useEffect(() => {
/** Unmount Procedure */
return () => {
// Pause widget
iframeRef.current?.contentWindow?./*OK*/ postMessage(
JSON.stringify(dict({'method': 'pause'})),
'https://w.soundcloud.com'
);

// Release iframe resources
iframeRef.current = null;
};
}, []);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@jridgewell Should this section be implemented via BaseElement['unloadOnPause'] or by providing a pause API? Asking based on this logic here, not seeing good examples of how/when to use:

/** @override */
pauseCallback() {
const Ctor = this.constructor;
if (Ctor['unloadOnPause']) {
this.mutateProps(dict({'loading': Loading.UNLOAD}));
this.resetLoading_ = true;
} else {
const {currentRef_: api} = this;
api?.['pause']?.();
}
}

Copy link
Copy Markdown
Member

@antiphoton antiphoton left a comment

Choose a reason for hiding this comment

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

LGTM validator files

@caroqliu
Copy link
Copy Markdown
Contributor

Looks like CI is stuck on the lint phase -- please run amp lint --local_changes --fix to resolve.

@caroqliu
Copy link
Copy Markdown
Contributor

It looks like it is still having trouble on the lint step: https://app.circleci.com/pipelines/github/ampproject/amphtml/11890/workflows/5e9b2c18-36fd-4d4e-aa63-677a7efe6bc1/jobs/188651 Have you tried merging with main -- we recently introduced aliased imports (i.e. ../../../src/preact -> #preact) and that is likely what it is wanting to see.

@AnuragVasanwala
Copy link
Copy Markdown
Contributor Author

Thank you so much to draw attention 👍🏻
I pulled recent updates and fixed aliased imports.
I have also logged in to CircleCI dashboard for the insights to check and solve bug, if any.

@AnuragVasanwala
Copy link
Copy Markdown
Contributor Author

I am not sure why GitHub Actions / build (windows-latest) (pull_request) is failing. I am looking into the Guthub Actions. Please let me know if any necessary steps are needed from my side.

@caroqliu
Copy link
Copy Markdown
Contributor

I am not sure why GitHub Actions / build (windows-latest) (pull_request) is failing. I am looking into the Guthub Actions. Please let me know if any necessary steps are needed from my side.

It looks like an issue unrelated to your PR. I triggered a rerun and will keep an eye on it today so we can get this merged. :)

@caroqliu caroqliu merged commit 7d996a4 into ampproject:main Jun 24, 2021
antiphoton pushed a commit to antiphoton/amphtml that referenced this pull request Jun 25, 2021
* Initial Commit

* Property mappings and Cleanup

* Minor fixes, Formatting and Comments

* More readable variable name

* Test Cases for Bento

* Updated test-cases and Storybook

* Added base CSS File

* Bug Fix: Layout System and Unit

* Parent element changed from <div> to <>

* Type correction for 'visual' parameter

* Bug fix for color parameter in storybook

* Update extensions/amp-soundcloud/1.0/base-element.js

Bento components are required to be R1. We have an equivalent static getPreconnects(element) in R1 designed to take care of this.

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>

* ♻️ Add 'wrapper' designation to bento

ampproject#34838

Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>

* 🚮 Delete init/constructor of `amp-soundcloud`

No need to override `init` if no changes were made to it except calling parent class's `init`.

Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>

* ♻️ Use `passthroughNonEmpty` which only give `<slot>` for non empty `children`

Since `passthrough` gives a `<slot>` reference to the children prop in all cases, let's make this passthroughNonEmpty -- which will only give a `<slot>` if there are children in the given markup.

Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>

* ♻️ Warning for required props when not present

* ♻️ Warning for required pros when not present

* ♻️ Warning for required props when not present

* ♻️ `trackId` and `playlistId` order chek

Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>

* ♻️ `trackId` and `playlistId` order check

Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>

* ♻️ Removed explicitly specify boolean `true` for conditional block

No need to explicitly specify boolean `true` for conditional block.

Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>

* ♻️ Added default value for `visual` prop in Preact component

Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>

* 🚮 Removed props handled by AMP's layout system

`height`, `heights`, `media`, `sizes`, and `width` are not needed to pass through as these attributes are specific to AMP's layout system and handled by the runtime.

Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>

* 🚮 Removed unnecessary typedef

`height`, `heights`, `media`, `sizes`, and `width` are not needed to pass through as these attributes are specific to AMP's layout system and handled by the runtime. Thus they do not need to be specify in typedef.

Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>

* 🚮 Removed interface as no API exposed

* ♻️ Moved `converter.js` into storybook

* 🚮 Removed `layout` from Preact example, ♻️ Added `height` into style

* 🚮 Removed empty CSS and `hasCss` from `bundles.config.extensions.json`

* 🐛 `htmlFor` import fix for test case, ♻️ added `data-trackid` attribute

* ♻️ Replaced `<iframe>` with `<IframeEmbed>`

* ♻️ Updated specification for validation

* 🏗 Added `npm` to `bundles.config.extensions.json`

Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>

* ♻️ New line at EOF in `validator-amp-soundcloud.out`

* Added 'loadable' to indicate a resource intensive component

* 🏗 Fixes reported by 'amp lint' for CI

* 🏗 Fixes for aliased imports for CI

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
Co-authored-by: Caroline Liu <10456171+caroqliu@users.noreply.github.com>
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.

I2I: Create a bento component for soundcloud [amp-soundcloud:1.0]

6 participants