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

✨ New amp-story-bookend components: portrait #15142

Merged
merged 11 commits into from May 16, 2018

Conversation

Enriqe
Copy link
Contributor

@Enriqe Enriqe commented May 7, 2018

Part of #12167

@Enriqe Enriqe force-pushed the new-bookend-components branch 4 times, most recently from c8c053e to d80f618 Compare May 9, 2018 16:25
@gmajoulet
Copy link
Contributor

From your screenshot, we can see a few issues:

  • we could better position the image inside the its container, to crop as little as possible. Right now we only see the top left corner of the image
  • The portrait image is not full width

I tried to break the layout in all possible ways, and I think they're all issues we might want to fix:

  • Titles line height
  • Handling long domain names
  • Making sure the images fill their containers, and cropping as little as possible
  • I'm not sure about the portrait's title font, it is very hard to read :(

image

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!

@Enriqe
Copy link
Contributor Author

Enriqe commented May 10, 2018

Thanks for the feedback @gmajoulet !

we could better position the image inside the its container, to crop as little as possible. Right now we only see the top left corner of the image.

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?

The portrait image is not full width

Thats true, but taking into account support for larger screen sizes and responsive layout, I think we should define a max-width so that no matter how large the screen is, at one point it should not grow in width. But I guess we could use columns for this and make it always take 100% width in its own column:
image

I'm not sure about the portrait's title font, it is very hard to read :(

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!

@newmuis
Copy link
Contributor

newmuis commented May 10, 2018

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.

@Enriqe
Copy link
Contributor Author

Enriqe commented May 10, 2018

That's correct @newmuis

@gmajoulet
Copy link
Contributor

Very sorry to be picky, but I believe these will only take a few minutes and will greatly impact our product/design :))
I'm available to help you offline if you have to submit this quickly.

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?

Oh you're right, it's actually currently broken. The fix is as simple as adding height: 100%; width: 100%; on the <img> that has the object-fit: cover;, it might be worth adding it : )
Same image before and after

The portrait image is not full width

Thats true, but taking into account support for larger screen sizes and responsive layout, I think we should define a max-width so that no matter how large the screen is, at one point it should not grow in width. But I guess we could use columns for this and make it always take 100% width in its own column

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 :)

Ok, should we increase the font size?

The serif on the typeface (screenshot) makes me think this is not Roboto. I think the font family declared doesn't exist (Roboto-Bold) and it fallbacks to something else depending on your system.
I'm sending you a link to the material guidelines for typography, that's usually helpful when you're not sure about which size/weight to use :)

},
{
"type": "portrait",
"title": "This is an example portrait",
Copy link
Contributor

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)

Copy link
Contributor Author

@Enriqe Enriqe May 10, 2018

Choose a reason for hiding this comment

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

how does category sound? goes with what the mocks depict and sounds more intuitive. Also I was thinking whether we want it to be a required field.

image

image

@Enriqe
Copy link
Contributor Author

Enriqe commented May 10, 2018

@gmajoulet made the fixes you recommended. let me know what you think! here is a preview:

image


/** @override */
assertValidity(headingJson) {
if (!headingJson['text']) {
Copy link
Member

Choose a reason for hiding this comment

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

  1. fold in assert:
  2. rename
isValid() {
  return user().assert('text' in headingJson,
      'Heading component must...');
}

Copy link
Contributor Author

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 = {
Copy link
Member

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 = {
Copy link
Member

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>`;
Copy link
Member

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);
Copy link
Member

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.

@Enriqe
Copy link
Contributor Author

Enriqe commented May 15, 2018

@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"
Copy link
Member

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.

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.

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;
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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?

@Enriqe
Copy link
Contributor Author

Enriqe commented May 15, 2018

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

!important here too : )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

woops

@gmajoulet gmajoulet merged commit 11f3e23 into ampproject:master May 16, 2018
@Enriqe Enriqe deleted the new-bookend-components branch May 16, 2018 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants