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

Reader: Update RP on DevDocs #9157

Merged
merged 4 commits into from
Nov 15, 2016
Merged

Conversation

jancavan
Copy link
Contributor

@jancavan jancavan commented Nov 4, 2016

This updates the new Related Posts cards on Devdocs.

Before:
screenshot 2016-11-04 10 21 06

After:
screenshot 2016-11-04 10 27 19

@jancavan jancavan added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Feature] Reader The reader site on Calypso. [Type] Janitorial labels Nov 4, 2016
@jancavan jancavan self-assigned this Nov 4, 2016
@matticbot
Copy link
Contributor

@jancavan
Copy link
Contributor Author

jancavan commented Nov 4, 2016

Although this is using the same exact data for each RP example. If it's a quick fix and anyone can help me with that, it'd be much appreciated.

@samouri
Copy link
Contributor

samouri commented Nov 4, 2016

@jancavan I changed it to use a unique source for each post

@samouri samouri force-pushed the fix/reader/related-posts-v2-devdocs branch from 3dc0ab3 to a17ed6d Compare November 4, 2016 21:23
@jancavan
Copy link
Contributor Author

jancavan commented Nov 4, 2016

Thanks @samouri! It was throwing some errors for me which I fixed in: f461c8a, however, the data you added works perfectly 🎉

@jancavan
Copy link
Contributor Author

jancavan commented Nov 4, 2016

screenshot 2016-11-04 15 17 37

@jancavan jancavan added [Status] In Progress and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Nov 4, 2016
<div className="reader-related-card-v2__blocks is-same-site">
<h1 className="reader-related-card-v2__heading">More in <a className="reader-related-card-v2__link">Cats and Furballs</a></h1>
<ul className="reader-related-card-v2__list">
{ moreOnSameSite.map( item =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the arrow function body be wrapped with parens since it's multi-line? Like so:

moreOnSameSite.map( item => (
    <Component />
)

There's a PR open to change up some of the JS guidelines so I'm not so sure how strict it'll be on wrapping blocks and return values so this is just a suggestion :)

Copy link
Contributor

@samouri samouri Nov 7, 2016

Choose a reason for hiding this comment

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

@spentay, thanks for calling this out!
I wasn't sure what our javascript guidelines said on the topic, so I took a peek.

Turns out that for multi-line arrow function we should use braces like so:

moreOnSameSite.map( item => {
    return <Component />
} )

Copy link
Contributor

Choose a reason for hiding this comment

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

Either parens or braces work, just with their own caveats!
Using curlies would require you to explicitly return the component.
However when using parens you don't since the code within them will just be evaluated and returned implicitly to the arrow function.

So these will both essentially do the same thing:

moreOnSameSite.map( item => {
    return <Component /> // explict return
} )
moreOnSameSite.map( item => (
    <Component /> // implicit return 
) )

As a rule of thumb I typically use braces when some sort of extra logic or or variable declarations need to happen within the block before returning the component/value and use parens when the value can just be returned implicitly

Here's a good recent example of the paren usage

This has got me thinking though... the first example labelled as 'bad' uses parens for execution but claims that doing so is 'too magic'... Since it seems to be a fairly common pattern for returning components it might be worth revising or adding another example to the guidelines! I'll get on that and link the PR here :D

<div className="reader-related-card-v2__blocks is-other-site">
<h1 className="reader-related-card-v2__heading">More in <a className="reader-related-card-v2__link">WordPress.com</a></h1>
<ul className="reader-related-card-v2__list">
{ moreOnWordPress.map( item =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Same goes here :)

@jancavan jancavan added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Feature] Reader The reader site on Calypso. and removed [Feature] Reader The reader site on Calypso. [Status] In Progress labels Nov 4, 2016
Copy link
Contributor

@bluefuton bluefuton left a comment

Choose a reason for hiding this comment

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

I approve this message.

@bluefuton bluefuton added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Nov 15, 2016
@samouri samouri merged commit d46474a into master Nov 15, 2016
@samouri samouri deleted the fix/reader/related-posts-v2-devdocs branch November 15, 2016 19:49
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] Janitorial
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants