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

feat(chat message): add author and timestamp props #242

Merged
merged 9 commits into from
Sep 19, 2018

Conversation

bmdalex
Copy link
Collaborator

@bmdalex bmdalex commented Sep 17, 2018

Chat.Message: author and timestamp

This PR introduces author and timestamp props for Chat.Message subcomponent

TODO

  • Conformance test
  • Minimal doc site example
  • Stardust base theme
  • Teams Light theme
  • Teams Dark theme
  • Teams Contrast theme
  • Confirm RTL usage
  • W3 accessibility check
  • Stardust accessibility check
  • Update glossary props table
  • Update the CHANGELOG.md

author

Rendered only in "their" messages (mine=false).

screen shot 2018-09-17 at 20 23 51

<Chat.Message author="John Doe" content="Hello there"  />

renders

<li class="ui-layout ui-chat__message">
  <div class="ui-layout__main">
    <div class="ui-layout">
      <div class="ui-layout__start">
        <span class="ui-text a">John Doe</span>
      </div>
      <div class="ui-layout__main">Hello there</div>
    </div>
  </div>
</li>

timestamp

screen shot 2018-09-17 at 20 23 42

<Chat.Message timestamp="Yesterday, 10:15 PM" content="Hello there"  />

renders

<li class="ui-layout ui-chat__message">
  <div class="ui-layout__main">
    <div class="ui-layout">
      <div class="ui-layout__start">
        <span class="ui-text a">Yesterday, 10:15 PM</span>
      </div>
      <div class="ui-layout__main">Hello there</div>
    </div>
  </div>
</li>

CHANGELOG.md Outdated
@@ -27,6 +27,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Features
- Add `FocusZone` to `renderComponent`, change `Menu` behavior to support arrow keys @tomasiser ([#116](https://github.com/stardust-ui/react/pull/116))
- Add `value`, `disabled`, `checked`, `defaultChecked` and `onChange` props to `Radio` component @mnajdova ([#206](https://github.com/stardust-ui/react/pull/206))
- Add `author` and `timestamp` props for `Chat.Message` component @Bugaa92 ([#242](https://github.com/stardust-ui/react/pull/242))
Copy link
Contributor

Choose a reason for hiding this comment

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

consider to move this entry to 'Unreleased' section

timestamp={timestamp}
content={content}
size="sm"
styles={{ root: { marginRight: pxToRem(10) } }}
Copy link
Contributor

Choose a reason for hiding this comment

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

we shouldn't hardcode styles in component's implementation code. Lets rather introduce timestamp part in the ChatMessage's styles, and provide this margin there


private renderText = (content: string, timestamp?: boolean) => (
<Text
timestamp={timestamp}
Copy link
Contributor

Choose a reason for hiding this comment

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

lets use two separate components for that - one for displaying timestamp, another one - to display content. This is necessary because Text component is seen to be a basic one, so it would support either timestamp variant, or regular content one. More than that, it is highly likely that timestamp variant won't be introduced as part of core Stardust

@@ -3,6 +3,7 @@ import { IChatMessageProps } from '../../../../components/Chat/ChatMessage'
import { IChatMessageVariables } from './chatMessageVariables'
import { pxToRem } from '../../../../lib'

const rem10 = pxToRem(10)
Copy link
Contributor

Choose a reason for hiding this comment

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

would rather suggest name like px10asRem - otherwise the name is a bit misleading and reads like '10 rem'

@@ -0,0 +1,7 @@
export interface IChatVariables {
backgroundColor: string
Copy link
Contributor

Choose a reason for hiding this comment

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

this is better to be handled by the code of examples for now - more than that, we could adjust padding aspects there as well

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I added the backgroundColor and the padding to the variables with some defaults that would match the Team's theme, as we are developing this theme, so why not have this look by default. Please share your thoughts on this. Also, I added avatar slot in the ChatMessage, for configuring the statusBorderColor to match the background. Actually I have one thing that I am not 100% sure that should be implement this way. The Chat component has it's own backgroundColor and this color should match the Avatar's statusBorderColor. The problem is that, the Avatar is inside the ChatMessage component, and I am not confident that the Chat component should define the avatar's slot in the ChatMessage component. For now, those colors are independent variables in the Chat, and the ChatMessage's avatar slot component. What do you think about this @kuzhelov? This is how the default look of the examples looks now:
image

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds quite reasonable, thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

agreed to not introduce these two as variables for now, just inline them into styles directly

Copy link
Contributor

Choose a reason for hiding this comment

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

We are going to stick with the backgroundColor as variable in order to reuse the siteVariables. Paddings are deleted from variables

@kuzhelov kuzhelov added needs author changes Author needs to implement changes before merge and removed 🚀 ready for review labels Sep 17, 2018
avatar?: ItemShorthand
children?: ReactChildren
className?: string
content?: any
mine?: boolean
styles?: IComponentPartStylesInput
timestamp?: string
variables?: ComponentVariablesInput
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we make the text and the author shorthands for the Text component?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah - have discussed with @mnajdova, here proposal is essentially to introduce author and timestamp shorthands (slots) for the ChatMessage component, and use Text as a default component for these.

Totally support this idea 👍

@mnajdova
Copy link
Contributor

Can we close #41 in favor of this one?

@kuzhelov
Copy link
Contributor

sure, lets do that

@codecov
Copy link

codecov bot commented Sep 19, 2018

Codecov Report

Merging #242 into master will increase coverage by 0.31%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #242      +/-   ##
==========================================
+ Coverage   91.84%   92.15%   +0.31%     
==========================================
  Files          61       61              
  Lines        1042     1058      +16     
  Branches      154      155       +1     
==========================================
+ Hits          957      975      +18     
+ Misses         82       80       -2     
  Partials        3        3
Impacted Files Coverage Δ
src/components/Text/Text.tsx 100% <100%> (ø) ⬆️
src/components/Chat/ChatMessage.tsx 97.5% <100%> (+1.5%) ⬆️
src/components/Layout/Layout.tsx 98% <0%> (+4%) ⬆️

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 5db6547...aa314f3. Read the comment docs.

@mnajdova mnajdova added 🚀 ready for review and removed needs author changes Author needs to implement changes before merge labels Sep 19, 2018
CHANGELOG.md Outdated
@@ -17,6 +17,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

### BREAKING CHANGES
- Fixed `Divider` wrong usage of the `typeSecondary{color, backgroundColor}` and `default{color, backgroundColor}` variables; renamed `default{color, backgroundColor}` variables to `color` and `backgroundColor` @mnajdova ([#234](https://github.com/stardust-ui/react/pull/234))
Copy link
Contributor

Choose a reason for hiding this comment

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

👍


export interface IChatMessageProps {
as?: any
author?: ItemShorthand
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@mnajdova mnajdova merged commit 98e70f2 into master Sep 19, 2018
@bmdalex bmdalex deleted the feat/chat-author-and-timestamp branch October 12, 2018 14:00
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

3 participants