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

Commit

Permalink
feat(ChatMessage): add hasMention and isImportant variables in Teams …
Browse files Browse the repository at this point in the history
…theme (#841)

* -added hasMention and isImportant variables in teams theme

* -update changelog

* -updated example

* -moved colors to variables

* -added prototype
-renamed mentionColor and importantColor to hasMentionColor and isImportantColor

* -updated changelog
  • Loading branch information
mnajdova authored Feb 5, 2019
1 parent c086719 commit f854f12
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Add static outline and filled class names to icons in Teams theme @miroslavstastny ([#834](https://github.com/stardust-ui/react/pull/834))
- Added slot class names in `ChatMessage`, `ChatItem`, `Dropdown`, `ItemLayout`, `Layout`, `MenuItem` @mnajdova ([#827](https://github.com/stardust-ui/react/pull/827))
- Add `badge` and `badgePosition` properties on the `ChatMessage` @mnajdova ([#823](https://github.com/stardust-ui/react/pull/823))
- Add `hasMention`, `isImportant`, `hasMentionColor` and `isImportantColor` in ChatMessage variables in Teams theme @mnajdova ([#841](https://github.com/stardust-ui/react/pull/841))

### Fixes
- Fix `Dropdown` component styles regression @Bugaa92 ([#824](https://github.com/stardust-ui/react/pull/824))
Expand Down
8 changes: 8 additions & 0 deletions docs/src/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,14 @@ class Sidebar extends React.Component<any, any> {
<Menu.Item as={NavLink} exact to="/icon-viewer" activeClassName="active">
Processed Icons
</Menu.Item>
<Menu.Item
as={NavLink}
exact
to="/important-and-mention-messages"
activeClassName="active"
>
Important and mention messages
</Menu.Item>
</Menu.Menu>
</Menu.Item>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const items = [
mine
badge={{
icon: 'exclamation',
color: 'red',
}}
badgePosition="start"
/>
Expand All @@ -36,13 +35,12 @@ const items = [
timestamp="Yesterday, 10:15 PM"
badge={{
icon: 'at',
color: 'red',
}}
/>
),
},
attached: 'top',
key: 'message-id-4',
key: 'message-id-2',
},
]

Expand Down
95 changes: 95 additions & 0 deletions docs/src/prototypes/ImportantAndMentionMessages/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import * as React from 'react'
import { Avatar, Chat } from '@stardust-ui/react'

const janeAvatar = {
image: 'public/images/avatar/small/ade.jpg',
status: { color: 'green', icon: 'check' },
}

const items = [
{
message: {
content: (
<Chat.Message
content="This is important message"
author="John Doe"
timestamp="Yesterday, 10:15 PM"
mine
badge={{ icon: 'redbang' }}
variables={{ isImportant: true }}
/>
),
},
contentPosition: 'end',
attached: 'top',
key: 'message-id-1',
},
{
gutter: { content: <Avatar {...janeAvatar} /> },
message: {
content: (
<Chat.Message
content="This is another important message (see how the borders radius respect the grouped ones)"
author="Jane Doe"
timestamp="Yesterday, 10:15 PM"
badge={{ icon: 'redbang' }}
variables={{ isImportant: true }}
/>
),
},
attached: 'top',
key: 'message-id-2',
},
{
gutter: { content: <Avatar {...janeAvatar} /> },
message: {
content: (
<Chat.Message
content="This is mention message @John"
author="Jane Doe"
timestamp="Yesterday, 10:15 PM"
badge={{ icon: 'mention' }}
variables={{ hasMention: true }}
/>
),
},
attached: true,
key: 'message-id-3',
},
{
gutter: { content: <Avatar {...janeAvatar} /> },
message: {
content: (
<Chat.Message
content="This is another mention message @John with custom color"
author="Jane Doe"
timestamp="Yesterday, 10:15 PM"
badge={{ icon: 'mention' }}
variables={siteVars => ({ hasMention: true, hasMentionColor: siteVars.brand })}
/>
),
},
attached: 'bottom',
key: 'message-id-4',
},
{
message: {
content: (
<Chat.Message
content="The color for the important messages can also be changed!"
author="John Doe"
timestamp="Yesterday, 10:16 PM"
mine
badge={{ icon: 'redbang' }}
variables={siteVars => ({ isImportant: true, isImportantColor: siteVars.yellow })}
/>
),
},
contentPosition: 'end',
key: 'message-id-5',
},
]

const ChatExample = () => <Chat items={items} />

export default ChatExample
6 changes: 6 additions & 0 deletions docs/src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ const Router = () => (
path="/icon-viewer"
component={require('./prototypes/IconViewer/index').default}
/>,
<DocsLayout
exact
key="/important-and-mention-messages"
path="/important-and-mention-messages"
component={require('./prototypes/ImportantAndMentionMessages/index').default}
/>,
]}
<DocsLayout exact path="/accessibility" component={Accessibility} />
<DocsLayout exact path="/theming" component={Theming} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ const chatMessageStyles: ComponentSlotStylesInput<ChatMessageProps, ChatMessageV
outline: `.2rem solid ${v.contentFocusOutlineColor}`,
},
}),
...((v.hasMention || v.isImportant) && {
'::before': {
content: '""',
backgroundColor: v.hasMention ? v.hasMentionColor : v.isImportantColor,
height: '100%',
left: '0',
position: 'absolute',
top: '0',
width: pxToRem(3),
borderBottomLeftRadius: 'inherit',
borderTopLeftRadius: 'inherit',
},
}),
}),

author: ({ props: p, variables: v }): ICSSInJSStyle => ({
Expand All @@ -45,9 +58,17 @@ const chatMessageStyles: ComponentSlotStylesInput<ChatMessageProps, ChatMessageV
textDecoration: 'underline',
},
}),
badge: ({ props: p, variables: v }) => {
badge: ({
props: p,
variables: v,
theme: {
siteVariables: { white },
},
}) => {
const sidePosition = p.badgePosition === 'start' ? 'left' : 'right'
return {
backgroundColor: v.hasMention ? v.hasMentionColor : v.isImportantColor,
color: white,
boxShadow: v.badgeShadow,
position: 'absolute',
padding: pxToRem(4),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export interface ChatMessageVariables {
contentFocusOutlineColor: string
border: string
badgeShadow: string
isImportant: boolean
hasMention: boolean
hasMentionColor: string
isImportantColor: string
}

export default (siteVars): ChatMessageVariables => ({
Expand All @@ -26,4 +30,8 @@ export default (siteVars): ChatMessageVariables => ({
contentFocusOutlineColor: siteVars.brand,
border: 'none',
badgeShadow: siteVars.shadowLevel1Darker,
isImportant: false,
hasMention: false,
hasMentionColor: siteVars.orange04,
isImportantColor: siteVars.red,
})

0 comments on commit f854f12

Please sign in to comment.