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

🖍 [amp-story-player] Adds css for pre-fetch experience #26557

Merged
merged 4 commits into from
Feb 3, 2020

Conversation

Enriqe
Copy link
Contributor

@Enriqe Enriqe commented Jan 29, 2020

  • Sets up basic css for the amp-story-player which will set a placeholder specified by the publisher (--story-player-poster).
  • In the case no poster is specified, falls back to a spinner.
  • Finally hides the above styles when the story is loaded.

Partial for #24539 #26308

css/amp-story-player.css Outdated Show resolved Hide resolved
build-system/tasks/css.js Outdated Show resolved Hide resolved
css/amp-story-player.css Outdated Show resolved Hide resolved
@@ -2,6 +2,7 @@
<head>
<title>Story Player (Non-AMP)</title>
<script async src="../../dist/amp-story-player.js"></script>
<link href="../../build/css/amp-story-player-out.css" rel='stylesheet' type='text/css'>
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to get a URL that works on our machines during development, and that we can host on firebase using the existing scripts?
What's going to be the final production URL to load this stylesheet?

Copy link
Contributor

Choose a reason for hiding this comment

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

Final production URL with this configuration would be https://cdn.ampproject.org/amp-story-player-out.css.

I agree with your comment above; let's rename this to something more user-friendly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The url in this example works on our machines during development, I am not sure about hosting on firebase.

For context, this is currently the only way we can export a css file without it being a part of an AMP extension (otherwise we could do it through bundles.config.js, but since this is under src/ and not under extensions/it won't be picked up by the build system), video-autoplay is another example that does this.

If we want it to be hosted on firebase I see 3 options:

  1. Copy + paste the file manually from the local amphtml/**/build/* to a firebase/build/ dir.
  2. Modify the firebase script to also include files in the build/* directory.
  3. Create an AMP extension (which we will eventually) and use its css file instead of this one.

Copy link
Contributor

@newmuis newmuis Jan 30, 2020

Choose a reason for hiding this comment

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

I think we just need to use the output from dist for this to work. For example, right now, I can hit http://stamp-gmajoulet.firebaseapp.com/dist/video-autoplay-out.css. I would still expect the relative URLs to work just fine, even on Firebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh nice! I should've checked this before 😅

@@ -2,6 +2,7 @@
<head>
<title>Story Player (Non-AMP)</title>
<script async src="../../dist/amp-story-player.js"></script>
<link href="../../build/css/amp-story-player-out.css" rel='stylesheet' type='text/css'>
Copy link
Contributor

Choose a reason for hiding this comment

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

Final production URL with this configuration would be https://cdn.ampproject.org/amp-story-player-out.css.

I agree with your comment above; let's rename this to something more user-friendly.

examples/amp-story/player.html Outdated Show resolved Hide resolved
css/amp-story-player.css Outdated Show resolved Hide resolved
build-system/tasks/css.js Outdated Show resolved Hide resolved
Copy link
Contributor

@gmajoulet gmajoulet left a comment

Choose a reason for hiding this comment

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

LGTM pending the discussion with Hong about the default size

@@ -36,7 +36,7 @@ const LoadStateClass = {

/** @const {string} */
const CSS = `
:host { all: initial; display: block; border-radius: 0 !important; width: 405px; height: 720px; overflow: auto; }
:host { all: initial; display: block; border-radius: 0 !important; width: 320px; height: 480px; overflow: auto; }
Copy link
Member

@alanorozco alanorozco Jan 30, 2020

Choose a reason for hiding this comment

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

Unrelated suggestion: You can use a separate CSS file that's compiled inline into here as well. See src/service/video/install-autoplay-styles.js for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, correct me if I'm wrong but it looks like this would only work for AMP docs? Since this is a JS library (non-AMP) I don't think we can use this.

Copy link
Member

Choose a reason for hiding this comment

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

This part still works:

import {cssText} from '../../../build/video-autoplay.css';

Regardless of delivery mechanism you can build the cssText string that way to get all other CSS tooling.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, will address in a follow-up. Thanks for the pointer!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Following up in #26604

Copy link
Collaborator

@estherkim estherkim left a comment

Choose a reason for hiding this comment

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

css gulp task LGTM

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.

7 participants