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

feat(ChatMessage): add badge and badgePosition props #823

Merged
merged 12 commits into from
Feb 4, 2019

Conversation

mnajdova
Copy link
Contributor

@mnajdova mnajdova commented Feb 1, 2019

This PR adds the badge and badgePosition ('start' | 'end') props to the ChatMessage.
TODO

  • update changelog
  • provide examples for the badge

Here are examples of this:

  • Mine message with badge at the end:
 <Chat.Message
          content="Hello"
          author="John Doe"
          timestamp="Yesterday, 10:15 PM"
          mine
          badge={{
            icon: 'redbang',
            color: 'red',
          }}
/>

image

  • Mine message with badge at the start
 <Chat.Message
          content="Hello"
          author="John Doe"
          timestamp="Yesterday, 10:15 PM"
          mine
          badge={{
            icon: 'redbang',
            color: 'red',
          }}
         badgePosition="start"
/>

image

  • Other message with badge at the end
       <Chat.Message
          content="Hi"
          author="Jane Doe"
          timestamp="Yesterday, 10:15 PM"
          badge={{
            icon: 'mention',
            color: 'red',
          }}
        />

image

  • Other message with badge at the start
        <Chat.Message
          content="Hi"
          author="Jane Doe"
          timestamp="Yesterday, 10:15 PM"
          badge={{
            icon: 'mention',
            color: 'red',
          }}
          badgePosition="start"
        />

image

Example in chat:
image

manajdov added 2 commits January 31, 2019 21:59
-restricted position to start and end
Copy link
Member

@layershifter layershifter left a comment

Choose a reason for hiding this comment

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

I am not sure about badge, can we go with label for now?
And when we will have decision about naming just rename it everywhere?

@codecov
Copy link

codecov bot commented Feb 4, 2019

Codecov Report

Merging #823 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #823   +/-   ##
=======================================
  Coverage   93.54%   93.54%           
=======================================
  Files          21       21           
  Lines         728      728           
  Branches       69       69           
=======================================
  Hits          681      681           
  Misses         47       47

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 a8f10c8...5cd1c7f. Read the comment docs.

@mnajdova
Copy link
Contributor Author

mnajdova commented Feb 4, 2019

@layershifter in my opinion label as a word has nothing semantically with the ChatMessage, although it is shorthand for label (yep, the name had already produced us enough headache). Even if this was shorthand for the Icon component, I would still go with badge, as it is much more clear what it represents...

Copy link
Member

@miroslavstastny miroslavstastny left a comment

Choose a reason for hiding this comment

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

What about Styled Chat Item example?

return {
boxShadow: v.badgeShadow,
position: 'absolute',
height: pxToRem(24),
Copy link
Member

Choose a reason for hiding this comment

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

This breaks when you change icon size. Any chance this could work without absolute values?

Something like:

      boxShadow: v.badgeShadow,
      position: 'absolute',
      padding: pxToRem(4),
      height: 'auto',
      width: 'auto',
      borderRadius: '50%',
      top: pxToRem(4),
      zIndex: '1',
      [sidePosition]: 0,
      transform: p.badgePosition === 'start' ? 'translateX(-50%)' : 'translateX(50%)',

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 for using transform

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Miro, I've changed the styles, work with every size of icon, and the default is according to the specs. I've added badge in the styles ChatItem example as well. Let me know if there is anything else.

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.

looks good, I vote for having badge for name for now
https://ant.design/components/badge/

-improved styles for the badge
@@ -83,6 +93,7 @@ class ChatMessage extends UIComponent<ReactProps<ChatMessageProps>, ChatMessageS
static defaultProps = {
accessibility: chatMessageBehavior,
as: 'div',
badgePosition: 'end',
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure about this default - lot of examples where badge appears at start

Copy link
Contributor

@kuzhelov kuzhelov left a comment

Choose a reason for hiding this comment

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

not sure about default badge's position - I would rather suggest to make it start one.

@mnajdova mnajdova merged commit 8207b8a into master Feb 4, 2019
@layershifter layershifter deleted the feat/chat-message-badge branch February 4, 2019 17:56
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

5 participants