8000 Reader: Add new thumbnail and excerpt component for Refresh by jancavan · Pull Request #8463 · Automattic/wp-calypso · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Reader: Add new thumbnail and excerpt component for Refresh #8463

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

Merged
merged 8 commits into from
Oct 11, 2016

Conversation

jancavan
Copy link
Contributor
@jancavan jancavan commented Oct 4, 2016
  • Card with thumbnail and excerpt:
    screenshot 2016-10-06 09 34 34
  • Mobile:
    screenshot 2016-10-06 09 34 46

@jancavan jancavan added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] In Progress [Feature] Reader The reader site on Calypso. labels Oct 4, 2016
@jancavan jancavan self-assigned this Oct 4, 2016
@matticbot
Copy link
Contributor

@jancavan jancavan added this to the Reader: Stream Refresh milestone Oct 4, 2016
@jancavan
Copy link
Contributor Author
jancavan commented Oct 4, 2016

To dos:

  • Fix styles, breakpoint issues
  • Photo-only cards
  • Gallery card (maybe just a sample)

@blowery
Copy link
Contributor
blowery commented Oct 4, 2016

Just a sample for the gallery card would be enough I think. Or we can leave it for another PR.

@bluefuton bluefuton changed the title Reader: Add new card component for Refresh Reader: Add new thumbnail and excerpt component for Refresh Oct 5, 2016
@jancavan
Copy link
Contributor Author
jancavan commented Oct 6, 2016

We're going to just create separate PRs for each card type instead of adding them all in this PR:

<li className="reader-post-card__visit">
<ExternalLink icon={ true }>Visit</ExternalLink>
</li>
<li className="reader-post-card__share">
Copy link
Contributor

Choose a reason for hiding this comment

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

When #8568 lands, we can replace the buttons here with ReaderPostActions.

.reader-share__button-label,
.comment-button__label-status,
.like-button__label-status {
.is-group-reader .reader-share__button-label,
Copy link
Contributor Author
@jancavan jancavan Oct 7, 2016

Choose a reason for hiding this comment

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

@bluefuton I had to scope this to .is-group-reader because it trumps the styles that I'm assigning to the action labels.

@jancavan jancavan added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Oct 8, 2016
@jancavan
Copy link
Contributor Author
jancavan commented Oct 8, 2016

This addresses (HTML/CSS): #8515

@bluefuton bluefuton added the [Status] Needs Design Review Add this when you'd like to get a review / feedback from the Design team on your PR label Oct 9, 2016
@bluefuton bluefuton force-pushed the add/reader/refresh-new-card-component-take-2 branch from 53423ce to a063c6b Compare October 9, 2016 21:39
@bluefuton
Copy link
Contributor

@jancavan @blowery is http://calypso.localhost:3000/devdocs/blocks/refresh-card the right place to be reviewing this?

The new card style isn't appearing in my Following stream, although I see some card factory logic that suggests that's the plan?

@jancavan
Copy link
Contributor Author
jancavan commented Oct 10, 2016

@bluefuton Yes, it's on http://calypso.dev:3000/devdocs/blocks/refresh-card. Not sure why you're not seeing it?

screenshot 2016-10-09 20 23 16

@bluefuton
Copy link
Contributor

Thanks @jancavan - yep, I'm seeing it there, but as per your screenshot I saw the action buttons overlapping the bottom of the card. I assume that's alright because the new stream is on a white background? If so, should we add some more padding to the container card in devdocs perhaps?

@blowery
Copy link
Contributor
blowery commented Oct 10, 2016

Working on getting it into the streams. Turns out we're not actually using reader/following/main for the main following stream. :/

@jancavan
Copy link
Contributor Author

I assume that's alright because the new stream is on a white background?

This is exactly why. But looking at the mockups, they do appear narrower so I'm going to try adding a padding. Good call.

@jancavan jancavan added [Status] In Progress and removed [Status] Needs Design Review Add this when you'd like to get a review / feedback from the Design team on your PR [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Oct 10, 2016
@jancavan
Copy link
Contributor Author

In 607bd8d, made sure content width is 688px to match the mockups (if main is set to 720px without padding). Still looks bad on Devdocs (also need to fix RP on this page btw):

screenshot 2016-10-10 12 06 22

So added a bit more padding just so these cards look more presentable on Devdocs:
screenshot 2016-10-10 12 06 34

@jancavan jancavan added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Status] Needs Design Review Add this when you'd like to get a review / feedback from the Design team on your PR and removed [Status] In Progress labels Oct 10, 2016
@bluefuton
Copy link
Contributor

Thanks for the feedback @fraying! I suggest we address all of that in a followup PR and get this one 🚢 - then we can drop in the new action links component too.

@bluefuton bluefuton added [Status] Ready to Merge and removed [Status] Needs Design Review Add this when you'd like to get a review / feedback from the Design team on your PR [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Oct 11, 2016
@jancavan jancavan merged commit 7e17e83 into master Oct 11, 2016
@jancavan jancavan deleted the add/reader/refresh-new-card-component-take-2 branch October 11, 2016 21:31
<a className="reader-post-card__link">catsandfurballs.wordpress.com</a>
<div className="reader-post-card__timestamp-and-tag">
<span className="reader-post-card__timestamp">1 hour ago</span>
<span className="reader-post-card__tag"><Gridicon icon="tag" />Pets</span>
Copy link
Member

Choose a reason for hiding this comment

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

Is there a way we can eliminate this hard-coded data so it doesn't get deployed by accident to production? If it's only here for development purposes, it seems like we could at least make it explicitly test data, passing it in as a prop with the fake data standing out in the file

];

const RefreshCards = React.createClass( {
displayName: 'RefreshCard',
Copy link
Member

Choose a reason for hiding this comment

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

This displayName isn't needed because we are assigning the component to a variable name, in which case it's automatically inferred

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed in #8736 👍

}
];

const RefreshCards = React.createClass( {
Copy link
Member

Choose a reason for hiding this comment

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

since this is new code and Facebook has chosen to move away from createClass(), do you think we could convert this? it looks like it's a good candidate for a functional stateless component.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed in #8736 👍

const isPhotoOnly = post.display_type & DisplayTypes.PHOTO_ONLY;
const title = truncate( post.title, {
length: isPhotoOnly ? 50 : 140,
separator: /,? +/
Copy link
Member

Choose a reason for hiding this comment

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

is the space inside the regex a typo or is it only supposed to split on either a , or more than one ? there is the\s character class to indicate space characters…

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed in #8713 👍

</li>
<li className="reader-post-card__comments">
<CommentButton
commentCount={ post.discussion.comment_count }
Copy link
Member

Choose a reason for hiding this comment

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

Could we get a post without a discussion property? if so, we could fail at runtime. How about either filtering out those invalid post objects before we get here or use a safe-defaulting getter such as this:

import { get } from 'lodash';

commentCount={ get( post, 'discussion.comment_count', 0 ) }

postId={ post.ID }
tagName="span"
showZeroCount={ true }
showLabel={ true } />
Copy link
Member
@dmsnell dmsnell Oct 13, 2016

Choose a reason for hiding this comment

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

Let's check on the indentation here. Typically we start indenting the attributes one more than the component

<LikeButton
    siteId={ post.site_ID }
    
/>

(also applies elsewhere but I only wanted to leave a single comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed in #8712 👍


@include breakpoint( "<480px" ) {
padding-left: 0;
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not su 10000 re how far this applies, but our coding guidelines dictate that we should be mobile-first, in which case padding-left: 0 should be the default and the 265px modifier should be allocated to some > breakpoint


onCommentClick() {
this.props.handleClick && this.props.handleClick( this.props.post, { comments: true } );
}
Copy link
Member

Choose a reason for hiding this comment

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

we've been starting to use class properties in lieu of binding in the constructor. it can be helpful in places like this…

onClick = () => this.props.handleClick( this.props.post );

we get the appropriate this binding without ever declaring the bind()

also note that I skipped checking for the presence of this.props.handleClick. we can do this safely by defining a default prop…

import { noop } from 'lodash';

static defaultProps = {
    handleClick: noop,
};

let cardFactory = null;
if ( config.isEnabled( 'reader/refresh/stream' ) ) {
cardFactory = refreshCardFactory;
}
Copy link
Member

Choose a reason for hiding this comment

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

this could be an immutable assignment

const cardFactory = config.isEnabled( 'reader/refresh/stream' )
    ? refreshCardFactory
    : null;

@@ -459,8 +461,10 @@ module.exports = React.createClass( {
showingStream = true;
}

const StreamMain = config.isEnabled( 'reader/refresh/stream' ) ? ReaderMain : Main;
Copy link
Member

Choose a reason for hiding this comment

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

usually we want to put each item in the ternary on a new line unless it's very small. this case may fit but I think it could be a bit better on three lines…

const StreamMain = config.isEnabled( 'reader/refresh/stream' )
    ? ReaderMain
    : Main;

@dmsnell
Copy link
Member
dmsnell commented Oct 13, 2016

Hi @jancavan - I popped in for a post-facto review because I noticed that the reader is now broken in master - all of the post authors are Sue Smith and the blogs are all catsandfurballs.wordpress.com. It would be great if we could slowly merge some of this stuff in without disrupting everyone else doing development work. The PR was pretty big too for what we like to merge in Calypso. While I was reading over thi CEB7 s code to figure out what was going on, I left a few more comments too. I realize this has been merged, but it would be nice if we could address some of those comments and clean this up a bit.

Immediately we need to fix the reader in master if you ask me though: priority # 1.

Please feel free to reach out to me if you have any questions about this or about my comments. I'd love to be able to be a help.

@nylen
Copy link
Contributor
nylen commented Oct 13, 2016

Here is a quick fix for master that also allows for continued development.

Set "reader/refresh/stream": false in development.json and commit that, then either change it back locally without committing, or run Calypso like this:

ENABLE_FEATURES=reader/refresh/stream make run

@blowery
Copy link
Contributor
blowery commented Oct 13, 2016

What dev is this "blocking"?

@dmsnell
Copy link
Member
dmsnell commented Oct 13, 2016

@blowery to whom and about what are you asking your question? I couldn't find any reference to "blocking" above…

@blowery
Copy link
Contributor
blowery commented Oct 13, 2016

@dmsnell i think i was conflating the "immediately" with "blocking". too early, not enough ☕️ :)

@bluefuton
Copy link
Contributor

@dmsnell I appreciate the review (and there's some useful feedback there, thank you).

I'm curious about the same thing as @blowery I think: in what respect was having this feature flag enabled in development only "disrupting everyone else doing development work"? Was it because you thought the Reader was broken in other environments, so you went to investigate?

@dmsnell
Copy link
Member
dmsnell commented Oct 14, 2016

in what respect was having this feature flag enabled in development only "disrupting everyone else doing development work"? Was it because you thought the Reader was broken in other environments, so you went to investigate?

right @bluefuton - I logged in and noticed that every post in the reader view was showing invalid data. this started a chain reaction of questing if I had broken it, if it was broken in production, if it was broken in master, asking people and getting others involved in the Slack channel, finding that it was intentionally broken, and dealing with it. maybe this sounds dramatic here the way I wrote it, but several of us ended up wasting a bunch of time and adrenaline because we thought we had an emergency.

probably since the reader is at the forefront of everything in Calypso it stunned us more than some small feature on the periphery. we ended up doing almost the same amount of work to discover that this was intentional as we would have done to fix it had it been a bug.

that's why I used the word "disruption"

it ended up not being broken in production, and it ended up being something at least a couple people were aware of, but to the rest of us it was kind of all-hands-on-deck when we saw it.

I think in cases like this where something so visible as the author of posts in the reader view get mangled, some clear communication on the p2 and in Slack would be a minimum requirement, if not making it work before merging.

I'm sure this is a big feature being broken into multiple parts, but my general rule is to try hard and not merge anything that wouldn't be right in production. in this case I'm not sure how much extra effort it would have required to get the author and blog mapping right before merging or how many other things are affected by the new layout, but as big as the PR already was it seems like it could have fit in there (or ideally to have been broken up even further into separate and incremental PRs)

I appreciate all your work and don't want to cast a shadow or any sense of blame or shame here. in the future I think there are probably some better ways to merge in changes without risking these kinds of disruptions.

❤️

@bluefuton
Copy link
Contributor
bluefuton commented Oct 14, 2016

I appreciate the thoughtful response @dmsnell. We're sorry if the changes caused a panic!

Like you I'm a fan of small PRs, and this one is a bit bigger than we'd like, but it lays the foundations for a series of smaller PRs implementing the Reader Stream Refresh (https://github.com/Automattic/wp-calypso/projects/10). To get the cards to the point where they'd be right in production would make this PR pretty enormous. For example, sorting out the author and site name in the header (the issue that originally caused the alarm) is handled in #8701, currently running at 163 lines on its own. The feature flag enables us to break the project in smaller pieces but the tradeoff is we have to accept that, early on, there may be work going into master that isn't ready to be seen in production yet.

In terms of changes for next time, I think we should have kept the feature flag turned off by default until the new stream cards were in reasonable shape. We've now made that change and are using ENABLE_FEATURES=to flip the flag on for testing (as per @nylen's #8463 (comment)).

Thanks again for your feedback :)

@dmsnell
Copy link
Member
dmsnell commented Oct 14, 2016

In terms of changes for next time, I think we should have kept the feature flag turned off by default until the new stream cards were in reasonable shape.

Thanks @bluefuton - I like disabling it until it's ready. Another idea I had is something I've done before; namely to post a big alert box above the UI indicating that this is a work-in-progress. For example, had the reader loaded with a card at the top that indicated it was staging-only and in-progress, that would have also prevented the panic. I like your solution better though 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Reader The reader site on Calypso. [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
0