Skip to content

✨[Amp story captions] Use amp-story-captions for captions from cache#38108

Merged
processprocess merged 19 commits intoampproject:mainfrom
processprocess:install-captions
Apr 25, 2022
Merged

✨[Amp story captions] Use amp-story-captions for captions from cache#38108
processprocess merged 19 commits intoampproject:mainfrom
processprocess:install-captions

Conversation

@processprocess
Copy link
Copy Markdown
Contributor

@processprocess processprocess commented Apr 18, 2022

demo
** The demo is automatically appending from a track element since cached captions are not launched yet **

Screen Shot 2022-04-19 at 12 49 15 PM

When appending captions from cache this PR

  • lazy loads the amp-story-captions component
  • appends it as a child to the video element with the default captions style
  • Appends a class to position the captions so they do not block cta UI.

Automatically appended captions are positioned so they do not block CTA UI. mockup:
Screen Shot 2022-04-19 at 12 50 43 PM

Closes #37899

@mszylkowski
Copy link
Copy Markdown
Contributor

Can you append a screenshot of how these captions look? My worry is that the captions can be hidden if a video is on a background layer with an overlay (like on our pottery story), so we might want to add the captions onto a new top-level grid-layer so they are always visible on top. I remember this being one of the main complaints of the native captions

@processprocess processprocess marked this pull request as draft April 18, 2022 15:00
@processprocess
Copy link
Copy Markdown
Contributor Author

Converting to draft. Blocked by #37967
We need to see how this looks before merging.

@processprocess
Copy link
Copy Markdown
Contributor Author

Can you append a screenshot of how these captions look? My worry is that the captions can be hidden if a video is on a background layer with an overlay (like on our pottery story), so we might want to add the captions onto a new top-level grid-layer so they are always visible on top. I remember this being one of the main complaints of the native captions

Converting to draft until #37967 is merged.

@processprocess processprocess marked this pull request as ready for review April 19, 2022 18:23
Comment on lines +49 to +50
if (this.element.hasAttribute('auto-append')) {
this.container_.classList.add(`amp-story-captions-auto-append`);
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.

I think you could set a class direclty from the JSX template

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.

That wont work since this element is rendered in shadow dom.

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.

The fact that style-preset=default behaves different depending on if we automatically appended it or not is tripping me a bit.

Can you provide an example of how you position the default preset as a publisher, and what the default position is if a publisher doesn't write any code?

Copy link
Copy Markdown
Contributor Author

@processprocess processprocess Apr 20, 2022

Choose a reason for hiding this comment

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

It trips me a bit too.
The thought process is this:

  • If it's auto-appended we base it on the expected UX of captions and position it relative to the video.
  • It it's publisher specified the assumption is that it's intentionally placed.

The example for publisher writing no code is already in examples/amp-story/amp-story-captions.html as part of #37967

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.

Okay it's a bit tricky, thank you for sharing.
Two things would be awesome if we could make them work together:

  1. Using style-preset=default works awesome out of the box, without requiring a single line of CSS
  2. Publishers can override the default position set by style-preset=default

If both things can't coexist, then let's keep things how you have them.

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.

To follow up from our discussion:

  1. It looks awesome out of the box both inline and auto-attached.
  2. It can be placed anywhere when inline. When auto-attached it is locked in a position.

Comment on lines +49 to +50
if (this.element.hasAttribute('auto-append')) {
this.container_.classList.add(`amp-story-captions-auto-append`);
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.

The fact that style-preset=default behaves different depending on if we automatically appended it or not is tripping me a bit.

Can you provide an example of how you position the default preset as a publisher, and what the default position is if a publisher doesn't write any code?

@processprocess processprocess marked this pull request as draft April 21, 2022 15:31
@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Apr 21, 2022

This pull request introduces 1 alert when merging d11bf73 into 31c8027 - view on LGTM.com

new alerts:

  • 1 for Superfluous trailing arguments

@processprocess processprocess marked this pull request as ready for review April 21, 2022 18:59
@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Apr 21, 2022

This pull request introduces 1 alert when merging 0f15cbb into 01dad70 - view on LGTM.com

new alerts:

  • 1 for Superfluous trailing arguments

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Apr 21, 2022

This pull request introduces 1 alert when merging 1eecd64 into 01dad70 - view on LGTM.com

new alerts:

  • 1 for Superfluous trailing arguments

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Apr 22, 2022

This pull request introduces 1 alert when merging d2e8e12 into 01dad70 - view on LGTM.com

new alerts:

  • 1 for Superfluous trailing arguments

@processprocess processprocess merged commit 4db72a2 into ampproject:main Apr 25, 2022
@processprocess processprocess deleted the install-captions branch April 25, 2022 14:05
@ampprojectbot
Copy link
Copy Markdown
Member

Warning: disparity between this PR Percy build and its main build

The Percy build for this PR was approved (either manually by a member of the AMP team, or automatically if there were no visual diffs). However, during a continuous integration step we generated another Percy build using the commit on the main branch that this PR was merged into, and there appears to be a mismatch between the two.

This is possibly an indication of an issue with this pull request, but could also be the result of flakiness. Please inspect the two builds < This PR's Percy build / main commit's Percy build > and determine further action:

  • If the disparity appears to be caused by this PR, please create an bug report or send out a new PR to fix
  • If the disparity appears to be a flake, please @-mention ampproject/wg-approvers in a comment
  • If there is no disparity and this comment was created by mistake, please @-mention ampproject/wg-infra
  • If unsure, @-mention ampproject/wg-approvers

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 story captions] Render video captions with amp-story-captions when in an amp-story doc and served from cache

4 participants