Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

feat(Reaction): add Reaction component and use it in the ChatMessage #959

Merged
merged 32 commits into from
Feb 27, 2019

Conversation

mnajdova
Copy link
Contributor

@mnajdova mnajdova commented Feb 25, 2019

The aim of this PR is to implement the RFC proposed here: #942
The PR adds the following things:

  • Reaction component, which contains icon and count (maybe this should be shorthand of the Button component?)
  • reactions collection shorthand in the ChatMessage.
  • reactionsPosition prop in the ChatMessage with the values 'start' and 'end', to indicate whether they should appear before or after the content in the generated HTML structure.

Chat message with reactions:
image

@codecov
Copy link

codecov bot commented Feb 25, 2019

Codecov Report

Merging #959 into master will increase coverage by 0.1%.
The diff coverage is 90.69%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master    #959     +/-   ##
========================================
+ Coverage      81%   81.1%   +0.1%     
========================================
  Files         665     671      +6     
  Lines        8528    8612     +84     
  Branches     1443    1514     +71     
========================================
+ Hits         6908    6985     +77     
- Misses       1606    1612      +6     
- Partials       14      15      +1
Impacted Files Coverage Δ
...emes/teams/components/Chat/chatMessageVariables.ts 100% <ø> (ø) ⬆️
.../themes/teams/components/Chat/chatMessageStyles.ts 19.23% <0%> (-0.77%) ⬇️
...es/react/src/components/Reaction/ReactionGroup.tsx 100% <100%> (ø)
packages/react/src/index.ts 100% <100%> (ø) ⬆️
...kages/react/src/themes/teams/componentVariables.ts 100% <100%> (ø) ⬆️
...eams/components/Reaction/reactionGroupVariables.ts 100% <100%> (ø)
...src/themes/teams/components/Chat/chatItemStyles.ts 40.74% <100%> (+2.27%) ⬆️
...mes/teams/components/Reaction/reactionVariables.ts 100% <100%> (ø)
packages/react/src/components/Chat/ChatMessage.tsx 95% <100%> (+1.38%) ⬆️
packages/react/src/themes/teams/componentStyles.ts 100% <100%> (ø) ⬆️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6036da4...a97ba92. Read the comment docs.

@@ -22,6 +23,9 @@ const getChatMessageEvaluatedStyles = (p: ChatItemProps) => ({
paddingTop: pxToRem(5),
paddingBottom: pxToRem(7),
...getPositionStyles(p),
[chatMessageContentClassNameSelector]: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to conditionally change the display prop on the content, because if the author and timestamp are not visible in Teams theme, the reactions should appear after the content. No better idea in the moment (tried added float elements, but then the paddings are broken...) I didn't want to create additional element for wrapping this, so this seemed like the only option.

@mnajdova mnajdova changed the title [WIP] feat(Reaction): add Reaction component and use it in the ChatMessage feat(Reaction): add Reaction component and use it in the ChatMessage Feb 25, 2019
-fixing imports
Copy link
Collaborator

@bmdalex bmdalex left a comment

Choose a reason for hiding this comment

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

minor comments, everything else looks like @layershifter covered it, nice job 👍

manajdov added 2 commits February 26, 2019 14:24
@@ -104,12 +112,15 @@ class ChatMessage extends UIComponent<ReactProps<ChatMessageProps>, ChatMessageS
timestamp: customPropTypes.itemShorthand,
onBlur: PropTypes.func,
onFocus: PropTypes.func,
reactionGroup: customPropTypes.itemShorthand,
Copy link
Contributor

Choose a reason for hiding this comment

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

client's voice in me would say that originally taken reactions name would work better - although we might want to be absolutely pedantic in terms of matching prop names with component types used as a default value, I would rather expect that these two concepts will be decoupled from each other, in general. These are the main reasons for that:

  • reactions prop name looks nicer to the client
  • in general we might foresee that, for some reason, ReactionsGroup name that was originally taken for this component will change. Then, if we would still strive for strict correspondence between these two, we would need to change the name of the prop in the API as well - and, actually, it might be not the only place where this change would be necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, the reason I renamed it is correlated with the next comment you've added...

  • I would have reactions={{items: [....]}} which looks even more awkward.. With preserving the name reactionGroup, I would feel less bad for having items there...
  • At this moment, it seems more consistent with the other shorthands.

These are the only reasions why I have chosen this name. I may change it, but then we will have on the same component the props: actionMenu and reactions (inconsistency even in the same component's API). Let me know what do you think...

Additional thought, maybe for some of the components that represent group of other components, like the Menu, ButtonGroup, ReactionGroup etc, we may create special shorthand that will be list and will be applied on the collection shorthand that they represent. This would solve lots of these inconsistency and awkward api...

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, absolutely agree - lets just keep this in mind and defer to follow-up PR the necessary changes for shorthand to be able to process array values. This would solve this problem, as well as the problems that @layershifter has reminded us about here: https://github.com/stardust-ui/react/pull/959/files#r260743449

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is the created issue for reference: #984

@mnajdova mnajdova merged commit 310f4fd into master Feb 27, 2019
@delete-merged-branch delete-merged-branch bot deleted the feat/chat-message-reactions branch February 27, 2019 17:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants