-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Add the core amp-story component #11511
Conversation
html.i-amphtml-story-standalone body, | ||
html[amp-story] body, | ||
html[📖] body { | ||
display: grid !important; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the body need be grid as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is display: grid
for a different reason; this is our current "desktop UI," which is just a centered mobile-phone-sized screen. This will be removed soon, when we have a true desktop UI (that is being developed now).
max-width: 414px; | ||
} | ||
|
||
amp-story[standalone]:-webkit-full-screen, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Combine all fullscreen declarations below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fun fact: you can't :(
Some browsers find other browsers' vendor prefixes to be illegal selectors, and instead of dropping just that part of the compound selector, it drops the whole thing. In other words, because :-moz-full-screen
is present in part of the selector, Chrome would drop amp-story[standalone]:-webkit-fullscreen, amp-story[standalone]:-moz-full-screen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, you should check what our CSS compiler does. I believe it combines all such selectors automatically.
animation-delay: 1.0s; | ||
} | ||
|
||
@keyframes grow { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefix with i-amphtml-
} | ||
|
||
.i-amphtml-story-bookend-article-meta { | ||
font-family: 'Roboto', sans-serif; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this ok for a general support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you mean the high level UX decision of using Roboto: amp-story
has a pretty opinionated default UI as compared to other components.
If you mean whether the font will actually get loaded, we can consider adding an <amp-font>
tag for it, internally to the component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather actually somehow do font-display:optional thing for this. But it's ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But hows does Roboto gets included on pages? Forced by validator? Or we just fallback?
* @param {string} targetPageId | ||
* @return {!Promise} | ||
*/ | ||
// TODO: Update history state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO(ldap)
Added |
Adding @choumx, since he's on all of the other reviews. This seems good to go as long as:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments. Use of offset*
seems ok, though maybe I'm missing something.
|
||
/** | ||
* @param {string} id The ID of the page to be retrieved. | ||
* @return {!AmpStoryPage} Retrieves the page with the specified ID. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
/** | ||
* @param {!Element} el | ||
* @return {boolean} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@private
* @return {!AmpStoryPage} Retrieves the page with the specified ID. | ||
*/ | ||
getPageById_(id) { | ||
return user().assert(this.pages_.find(page => page.element.id === id), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use array.js#findIndex
. Array#find
doesn't have IE support and I don't think we polyfill it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
.expandAsync(user().assertString(rawUrl)) | ||
.then(url => Services.xhrFor(this.win).fetchJson(url)) | ||
.then(response => { | ||
user().assert(response.ok, 'Invalid HTTP response'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Add more error info for user debugging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
/** | ||
* @return {!Promise<?./bookend.BookendConfig>} | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
.then(response => response && { | ||
shareProviders: response['share-providers'], | ||
relatedArticles: response['related-articles'] ? | ||
buildFromJson(response['related-articles']) : [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: Can we change buildFromJson
to just return []
on undefined input?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed #11549
* @param {string} pageId The page to be added to the map. | ||
* @return {!Object<string, number>} A mapping from page ID to the priority of | ||
* that page. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
*/ | ||
getPagesByDistance_() { | ||
const distanceMap = this.getPageDistanceMapHelper_( | ||
/* distance */ 0, /* map */ {}, this.activePage_.element.id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First argument is priority not distance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name was the one that was wrong
const nextScreenAreaMin = this.element./*OK*/offsetLeft + | ||
((1 - NEXT_SCREEN_AREA_RATIO) * this.element./*OK*/offsetWidth); | ||
const nextScreenAreaMax = this.element./*OK*/offsetLeft + | ||
this.element./*OK*/offsetWidth; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Hoist these into local vars for readability.
const offsetWidth = this.element./*OK*/offsetWidth;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
return; | ||
} | ||
|
||
map = this.getPageDistanceMapHelper_(priority + 1, map, adjacentPageId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assignment to map
(and I suppose the return value) doesn't seem necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marked with a TODO
amp-story { | ||
height: 100% !important; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's force box-sizing: border-box;
to ensure height and width 100% are still effective if authors decide to add padding/border
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
html.i-amphtml-story-standalone body, | ||
html[amp-story] body, | ||
html[📖] body { | ||
height: 100% !important; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto box-sizing
text-transform: uppercase; | ||
font-size: 10px; | ||
padding: 0 0 8px; | ||
margin: 48px 0 8px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this probably needs a RTL version to reverse the left/right numbers
} | ||
|
||
.i-amphtml-story-share-list > li:first-child { | ||
padding-left: 32px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto, this and below need rtl rules to reset left to 0 and apply 32px to right
🎉 |
Depends on a number of other PRs: #11502 #11484 #11485 #11506 #11487 #11509 #11510