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
✨ New amp-story-bookend components: portrait #15142
Conversation
c8c053e
to
d80f618
Compare
From your screenshot, we can see a few issues:
I tried to break the layout in all possible ways, and I think they're all issues we might want to fix:
I think building a prototype on codepen or any other environment could help figuring out how you can better structure the CSS to handle the crazy cases publishers could come up with. Tweaking CSS rules to fix these bugs one by one without thinking about it as a whole could introduce even more issues, and will drive you crazy. If you need any help with this we can book some time this week! |
Thanks for the feedback @gmajoulet !
Are referring to the small thumbnail image? If so, should we fix this in a separate PR since it's another issue different from the new component?
Thats true, but taking into account support for larger screen sizes and responsive layout, I think we should define a
Ok, should we increase the font size? Meanwhile I will work on the fix for the long titles / domain names and looking into building a prototype to better accommodate the css! |
I don't think this is the "title" but rather the "eyebrow" as it was called in the mocks. The other components (with titles) have this too. I don't believe this component has a title. |
That's correct @newmuis |
Very sorry to be picky, but I believe these will only take a few minutes and will greatly impact our product/design :))
Oh you're right, it's actually currently broken. The fix is as simple as adding
Yes to the columns :) I believe that's the right approach. You can think of the portrait component as an element that has no idea where it's being displayed, and that's going to fill the width of its container. Then, all you have to do is define the container (columns), and append your components in it :)
The serif on the typeface (screenshot) makes me think this is not Roboto. I think the font family declared doesn't exist ( |
examples/amp-story/bookendv1.json
Outdated
}, | ||
{ | ||
"type": "portrait", | ||
"title": "This is an example portrait", |
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.
Per the other comment, this is not actually a title, it's the eyebrow. We should think about what we want to name that, and use that instead (then we can later apply it to the other components 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.
d80f618
to
2c95cbf
Compare
@gmajoulet made the fixes you recommended. let me know what you think! here is a preview: |
2c95cbf
to
1209eb2
Compare
|
||
/** @override */ | ||
assertValidity(headingJson) { | ||
if (!headingJson['text']) { |
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.
- fold in assert:
- rename
isValid() {
return user().assert('text' in headingJson,
'Heading component must...');
}
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.
Per @newmuis comment here I will remove the return and assert directly as you suggested.
|
||
/** @override */ | ||
build(headingJson) { | ||
const heading = { |
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.
Fold in return.
* @return {!PortraitComponentDef} | ||
* */ | ||
build(portraitJson) { | ||
const portrait = { |
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.
Fold-in return.
addAttributesToElement(template, dict({'href': portraitData.url})); | ||
|
||
const heading = | ||
html`<h2 class="i-amphtml-story-bookend-portrait-heading"></h2>`; |
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.
Indent.
const heading = | ||
html`<h2 class="i-amphtml-story-bookend-portrait-heading"></h2>`; | ||
heading.textContent = portraitData.title; | ||
template.appendChild(heading); |
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.
It's faster to use htmlRefs
with one single template instead of building a set of smaller templates and appending to each other.
@alanorozco @gmajoulet PTAL |
@@ -79,27 +72,26 @@ export class PortraitComponent { | |||
const template = | |||
html` | |||
<a class="i-amphtml-story-bookend-portrait" | |||
target="_top"> | |||
target="_top" ref="portraitComponent"> | |||
<h2 class="i-amphtml-story-bookend-portrait-category" |
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.
No need to prefix ref names with "portrait", it's already clear from context. You also don't need a ref (and it won't work, regardless) for the root-level element.
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.
Just a few nits.
This layout is such a big improvement on what we had before! Thanks!
@@ -104,14 +115,29 @@ | |||
padding: 0 32px !important; | |||
} | |||
|
|||
.i-amphtml-story-bookend-portrait { | |||
box-sizing: border-box !important; | |||
display: flex; |
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: !important
color: inherit !important; | ||
overflow: hidden !important; | ||
flex: 1 0 320px !important; | ||
min-width: calc(33%) !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.
You should not need the calc here
@media (min-width: 640px) { | ||
.i-amphtml-story-bookend-article { | ||
.i-amphtml-story-bookend-article, | ||
.i-amphtml-story-bookend-portrait { | ||
max-width: calc(50%) !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.
I know it's not your code, but could you please remove the calc here and below too?
margin: 0 0 8px !important; | ||
} | ||
|
||
.i-amphtml-story-bookend-portrait-category { | ||
margin-top: 0px !important; | ||
font-family: 'Roboto' !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.
If there's no other font in this file, I think it'd be easier to set the typo on a parent div, so all the other elements will inherit from it.
|
||
.i-amphtml-story-bookend-portrait-image > img { | ||
object-fit: cover !important; | ||
position: absolute !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.
Do you still need this?
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.
Yes, since we have to initially set the img width
and height
to 0px
to comply with amp-img
constraints and then we resize based on the available space. The position attribute makes it possible to display the image.
@@ -441,11 +441,14 @@ export class AmpStoryBookend extends AMP.BaseElement { | |||
*/ | |||
renderComponents_(components) { | |||
dev().assertElement(this.bookendEl_, 'Error rendering amp-story-bookend.'); | |||
const container = BookendComponent |
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 it make the linter happy if you do
dev().assertElement(
BookendComponent.buildContainer(this.getInnerContainer_(), this.win.document));
Instead of the if (container)
below?
…pdoc for getAmpdoc.
… text, mantain aspect ratio for portrait.
…ory, removes unecessary fragment.
8eb300f
to
75143d4
Compare
thanks @alanorozco @gmajoulet! finished the changes you asked for, PTAL. |
margin: 24px 0 !important; | ||
padding: 0 32px !important; | ||
} | ||
|
||
.i-amphtml-story-bookend-portrait { | ||
box-sizing: border-box !important; | ||
display: flex; | ||
display: flex !important; | ||
flex-direction: column; |
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.
!important here too : )
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.
woops
d29b538
to
d7bced6
Compare
Part of #12167
portrait
card for the bookend components.i-amphtml-story-bookend-component-set
.article-set-title
toheading
per Rename "article-set-title" bookend component to "heading" #15088 and moves it to its own file.