-
Notifications
You must be signed in to change notification settings - Fork 2
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
post detail page changes #869
Conversation
Do you have the link to Invision?
|
they're all in the 'detail' section, here: https://invis.io/B2MF7PWGMY7 |
this one in particular shows the final design for the buttons along the bottom: https://projects.invisionapp.com/share/B2MF7PWGMY7#/screens/305904717 |
Codecov Report
@@ Coverage Diff @@
## master #869 +/- ##
==========================================
- Coverage 96.31% 96.31% -0.01%
==========================================
Files 321 323 +2
Lines 11124 11227 +103
Branches 374 374
==========================================
+ Hits 10714 10813 +99
- Misses 351 355 +4
Partials 59 59
Continue to review full report at Codecov.
|
static/js/containers/ProfileImage.js
Outdated
@@ -36,6 +36,7 @@ class ProfileImage extends React.Component<*> { | |||
startPhotoEdit: (p: File) => void, | |||
updatePhotoEdit: (b: Blob) => void, | |||
useSmall?: boolean, | |||
useMicro?: 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.
Rather than having multiple boolean fields for each type (which must/should all agree or we could end up in undefined behavior, e.g. <ProfileImage useMicro useSmall />
is valid with this implementation), I'd suggest passing a single size
prop that is typed as a union and determine whether you're using micro, small, medium off of that.
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.
yeah, that makes sense to me
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.
unfortunately it seems that because of the connect
call the props for the ProfileImage
aren't actually checked anywhere when the component is mounted...seeing if there's an easy way to work around that
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.
Would flow-typed
defs for react-redux
help flow infer that? https://github.com/flow-typed/flow-typed/blob/master/definitions/npm/react-redux_v5.x.x/flow_v0.63.0-/react-redux_v5.x.x.js
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.
yeah I added them, unfortunately that broke flow typings for a bunch of other things so I had to fiddle with it for a while. I just got it all typechecking now (haven't pushed the commits yet though)
<ProfileImage | ||
profile={{ | ||
name: post.author_name, | ||
image_small: post.profile_image |
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.
Here, because useMicro
is specified makeProfileImageUrl
ends up returning the default profile image because the useSmall
value passed to it is undefined
and there is no medium profile image passed here.
image_small: post.profile_image | ||
}} | ||
useSmall={true} | ||
/> | ||
<div className="post-title">{formatPostTitle(post)}</div> |
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 think the font size of this should increase to match the mockup. I'm uncertain as to what exact size it should be.
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.
yeah, it's 28px on the Zeplin thing so I'll change it to that
> | ||
<a href="#">report</a> | ||
<div className="left"> | ||
<PostVotingButtons |
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.
Are you addressing the icon change for the upvote button in a separate PR?
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 last I heard the design wasn't yet finalized, so I have held off on it so far
static/js/components/SharePopup.js
Outdated
<input ref={ref => (this.input = ref)} readOnly value={url} /> | ||
<div className="bottom-row"> | ||
<div className="share-buttons"> | ||
<FacebookShareButton url={url}> |
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: these buttons could probably use a little horizontal padding between each other
static/js/components/SharePopup.js
Outdated
<div className="share-popup"> | ||
<div className="triangle" /> | ||
<div className="share-title">Share a link to this post:</div> | ||
<input ref={ref => (this.input = ref)} readOnly value={url} /> |
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.
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.
Firefox seems to set a different default box-sizing
on <input>
tags than chrome, it should be fixed now
static/js/components/SharePopup.js
Outdated
closePopup() | ||
} | ||
|
||
selectInputText = () => { |
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 needs some preventDefault()
magic so the page doesn't scroll when you click it.
static/js/components/SharePopup.js
Outdated
import { FacebookIcon, TwitterIcon, LinkedinIcon } from "react-share" | ||
|
||
export class SharePopupHelper extends React.Component<*> { | ||
input: ?HTMLInputElement |
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.
Should use React.createRef()
instead: https://reactjs.org/docs/refs-and-the-dom.html#creating-refs
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.
nice, I didn't know about the new API
</div> | ||
{postShareMenuOpen ? ( | ||
<SharePopup | ||
url={window.location.href} |
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 don't think we want to do window.location.href
here because it's not always the canoncial link to the post. A counterexample can be seen if you click on the "permalink" button for a comment and then click the "share" button, you get the url to the comment, not the post, which I don't think is what we want.
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.
makes sense, I'll write a library function for getting a post permalink
eccf2a5
to
5ea94a9
Compare
770dfb1
to
a8c822e
Compare
@rhysyngsun ok I think all your comments should be addressed now |
nvm, I have one more thing to do (we don't want to show the social sharing buttons on private channels) |
4b0f709
to
df229f3
Compare
ok, I think things should be ready for review now |
df229f3
to
952041a
Compare
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.
Looking good, just a few small things
const imageSizeClass = useSmall ? "small" : "medium" | ||
const imageUrl = makeProfileImageUrl( | ||
profile, | ||
imageSize === "micro" || imageSize === "small" |
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.
Would it be a good idea to use constant values for these?
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 was on the fence when I was writing it, on the one hand it would prevent typos, but Flow should do that automatically. One thing that is annoying about these union types is that it doesn't seem to allow you to declare constants (as JS variables) and then declare a type using those variables. I wanted to do something like this:
const PROFILE_IMAGE_MICRO = "micro"
const PROFILE_IMAGE_SMALL = "small"
const PROFILE_IMAGE_MEDIUM = "medium"
type ImageSize =
| PROFILE_IMAGE_MICRO
| PROFILE_IMAGE_SMALL
| PROFILE_IMAGE_MEDIUM
But when I tried it gave me an error about needing to use the typeof
operator - but when I do that the type for ImageSize
ends up being string | string | string
! With the current setup for the ImageSize
type it throws a type error if I pass, for instance, "Micro" as the imageSize
prop, but if the type is string | string | string
it will obviously accept any string.
I'm not sure if this is a limitation for Flow or I just don't know the right syntax. Anyway, so we could declare constants for the three strings, which would make it easier to change them in one place later if we wanted, but it doesn't seem like they can be used in the flow type :/
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 provides a little context for that: facebook/flow#2639
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'll go ahead and declare constants to use when setting the size prop though
|
||
it("should hide buttons, if hideSocialButtons === true", () => { | ||
const wrapper = renderSharePopupHelper({ hideSocialButtons: true }) | ||
;[FacebookShareButton, LinkedinShareButton, TwitterShareButton].forEach( |
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.
Take it or leave it: one thing I've found useful that enzyme
does is allow you to find components by their name (e.g. "FacebookShareButton"
, that has the benefit of not having to couple this test via an import and the test will still fail if the component changes and the test doesn't or vice versa.
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.
sure
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.
so I gave that a try and, just changing all the component names to strings, my tests are failing. I think maybe the names of these components aren't set to the same thing as the same of the export (that can happen with things created with HOCs, and looking at the source the author wrote a system to create all the different icons with a HOC). I'm going to leave it as-is, since it looks like all the icons have the same name (CreatedButton
).
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.
ah ok, that's a bit odd that such a low-level component is an hoc
17c51cf
to
2814eec
Compare
2814eec
to
f048197
Compare
This updates the display of the post to match the most recent designs. This includes a refactor of how we display the little post action buttons, adds a new sharing menu, and a few other things. As part of this PR I also updated the flow-typed typedefs for all our installed dependencies. We were missing, somewhat crucially, the typedefs for react-redux, so none of our connected components were being properly type-checked (because Flow didn't know how the type signature of the `connect` function). So, now that that has been added, we should be in a more-completely-type-checked world. This change also involved a small refactor of the profile image component, to add a "micro" size option. closes #834 pr #869
f048197
to
b84655d
Compare
What are the relevant tickets?
closes #834
What's this PR do?
This updates the detail page display of the post for the most recent designs. The design on the linked issue isn't the most up-to-date, look on invision instead.
Basically, some stuff is moved around, and some of the post actions are now moved into a little dropdown menu (similar to on the post list view). There is also a little 'share' menu, which lets you easily copy a link to the post or share it to your fb or whatever.
How should this be manually tested?
Check that the changes implement the design, and that the new stuff works alright. Nothing should be weird...