Repository navigation
Add avatars for reactions participants - #145
paulmolluzzo wants to merge 11 commits into
Conversation
|
Wow, nice work! |
| const $reactionButtons = $reactionsContainer.find('.comment-reactions-options .reaction-summary-item[aria-label]'); | ||
|
|
||
| $reactionButtons.each((index, element) => { | ||
| const participants = []; |
There was a problem hiding this comment.
Instead of the empty array here and the map below, how about just setting const participants to the return val from .split?
There was a problem hiding this comment.
Yup, good idea. Will do.
|
Nice work! There is one small issue I spotted (that I don't think should preclude the PR, but we should address later). When you "react" to an issue, the user icon doesn't show until a page refresh. At that point, you obviously know which face should be there (your own!), but fixing it would make the UI feel a small bit more consistent. |
|
This closes #95, BTW. |
Can fix. Thanks @DrewML |
453e8ee to
1df71de
Compare
|
OK, this is updated as follows:
About the suggestion in #145 (comment): I tried to do this, but the only "working" solution I have is to set an event listener with a |
|
Loved it! How about adding |
|
I agree you should remove the original number same way facebook does... |
| } | ||
| }); | ||
|
|
||
| function addReactionParticipants() { |
There was a problem hiding this comment.
Maybe move this to a separate file?
👍 |
|
I don't think it should show your own avatar. That's pretty moot and you can already see you've voted. |
👍 |
|
Seems to break the UI when there are a lot of different reactions: react/react#6322 |
What if you're the only vote? It's going to look like this, which is weird:
I can't see what's broken, can you screenshot? |
|
I'd recommend to exclude your own avatar from the list. You already have a different background colour if you have reacted with a certain emoji. No need to listen when you click and update it. Just never include your own avatar in the list. |
|
I pushed changes and didn't squash (we can do that later). I did everything suggested, but can't replicate that but you guys are seeing with the white space. I might have inadvertently fixed it when I removed the original count? Or maybe it was that unclosed CSS bracket? |
@sindresorhus I can't replicate. Can you try to figure what's happening? Please make sure you're up to date with what I pushed. It might be that the two reaction counts were doing it. |
|
@paulmolluzzo Yes, I was using an older version of your PR. But even with latest, if you have enough reactions it will break. Might be an edge-case though. I tried adding two more reactions to react/react#6322 and this is what I got (using the latest version of this PR): Can you fix the merge conflict and add this feature to the readme? |
|
@sindresorhus I replicated it. I tightened up the padding on those buttons to compensate, but this will probably break if the post is super popular. An edge case for sure. |
|
@sindresorhus BTW, moving this to a separate file broke the click event listening. I can't use the LMK if you have an idea for a solution or just want to take out the event binding or thing shoving this back into the main content.js is cool. |
|
@paulmolluzzo I've suggested not listening to click and not showing your own reactions ever. |
@hkdobrev if everyone else agrees taking it out is super easy. I'm already not showing your own avatar, but your reaction is part of the total count. e: "everyone else" meaning "anyone really". I kind of like it, but it's hacky right now. |
a14b40c to
a0f5ca6
Compare
|
OK, I am pretty confident in the current version, and this time I did rebase everything to get it ready to merge. I'm still open to feedback on everything, so please let me know if anyone finds more bugs. @hkdobrev, when you don't have the event listener for @sindresorhus This is still in a separate file, and I should have fixed the UI issue correctly. The caveat to that is with enough reactions on enough different reactions it'll eventually break I think but that's probably a super edge case. // @DrewML |
|
This is awesome! Great work @paulmolluzzo! One issue I'm seeing locally: When "unreacting" to a reaction that has >= 1 other users that chose the same reaction, clicking on the reaction icon itself (rather than the outer blue area) throwns an exceptions, and doesn't unreact. I'm getting a similar exception (using the [https://github.com/react/react/issues/6322](facebook issue thread) as a test-case) when I try to react using a reaction others have used, but it appears to be a bit sporadic right now. |
| height: 200px !important; | ||
| } | ||
|
|
||
| /* styles for reaction avatars */ |
There was a problem hiding this comment.
Specify that it's for our implementation:
styles for our reactions avatar feature
…lying reactions easier; rename files; fix README bug; fix CSS comment
|
@sindresorhus fixed all the issues you pointed out and got this up to date with |
| document.addEventListener('click', event => { | ||
| addReactionParticipants.reapply(event, username); | ||
| }); | ||
| } |
There was a problem hiding this comment.
You could rename username to currentUser for consistency and even put the reapply function body in addListener itself as reapplying only makes sense at the moment in the context of an event listener.
There was a problem hiding this comment.
Changed the username param.
I'm not going to move the reapply function because leaving it here allows us to use it separately in another event listener or whatever.
|
I've been using the updated version and I really love it! ❤️ |
| addPatchDiffLinks(); | ||
| addReactionParticipants.add(username); | ||
| addReactionParticipants.addListener(username); | ||
| } |
There was a problem hiding this comment.
You could combine these in a single if (pageDetect.isPR() || pageDetect.isIssue() || pageDetect.isCommit()). I think it's more consistent, but it would also help with the fact isCommit() would return true for PR commits which match isPR() as well. So in some cases you would match both ifs and execute this twice. With a single if with 3 or expressions, you would execute it only once.
|
LGTM 💫 🎉 🎊 |
| - [Adds links to patch and diff for each commit](https://cloud.githubusercontent.com/assets/737065/13605562/22faa79e-e516-11e5-80db-2da6aa7965ac.png) | ||
| - [Differentiates merge commits from regular commits](https://cloud.githubusercontent.com/assets/170270/14101222/2fe2c24a-f5bd-11e5-8b1f-4e589917d4c4.png) | ||
| - [Hides :+1: :-1: comments and shows their count in the sidebar](https://cloud.githubusercontent.com/assets/170270/13241396/0b708ae8-da1d-11e5-8c01-94eae501034c.png) | ||
| - [Adds user avatars to Reactions](https://cloud.githubusercontent.com/assets/737065/14269443/c80ae418-fab2-11e5-93f7-d776f40a5b25.png) |
There was a problem hiding this comment.
Could you update the screenshot contents?
|
Updated the README @hkdobrev |
|
Yay! 🎉✨ This is super good @paulmolluzzo. Thanks for working so hard on it :) |
|
@paulmolluzzo Awesome work (and of course thanks @hkdobrev for getting this one started)! |
|
@paulmolluzzo Thanks for your very hard work on this! I know a code review so big and all of the amends are hard, but you've plowed through it flawlessly! The feature is working really great! |
|
@sindresorhus |
|
@sindresorhus Do you think you could tag and land this in the web store? |
|
@hkdobrev Done |



Hat tip to @hkdobrev for getting this started and finding the way to get GH user avatars.
This extends the work @hkdobrev did on a new branch that is also up to date with
master. Basically, it takes the avatars of people who add a reaction to a comment and appends their avatar. I am only appending the first 3 (or less) avatars because it quickly gets crazy, and then just add+${remainder}at the end.Suggestions on the design are welcome. I'm thinking we can even get rid of the original number, but not sure.
Example:
