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

Commit fc92d68

Browse files
authored
docs(ChatPane): Add attachments and link to chat pane messages in prototype (#514)
* Add attachments and link to chat pane messages in prototype * Small improvement * Small improvement * Improvements after CR
1 parent d33711e commit fc92d68

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

docs/src/prototypes/chatPane/services/dataMock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class ChatMock {
6666
timestamp: timestamp.short,
6767
timestampLong: timestamp.long,
6868
isImportant: random.boolean(),
69+
withAttachment: random.boolean(),
6970
}
7071

7172
return message

docs/src/prototypes/chatPane/services/messageFactoryMock.ts renamed to docs/src/prototypes/chatPane/services/messageFactoryMock.tsx

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Attachment, Popup, Button, Menu, popupFocusTrapBehavior } from '@stardust-ui/react'
2+
import * as React from 'react'
13
import * as _ from 'lodash'
24
import { ChatMessageProps } from 'src/components/Chat/ChatMessage'
35
import { DividerProps } from 'src/components/Divider/Divider'
@@ -32,7 +34,9 @@ const statusMap: Map<UserStatus, StatusPropsExtendable> = new Map([
3234
function generateChatMsgProps(msg: MessageData, fromUser: UserData): ChatMessage {
3335
const { content, mine } = msg
3436
const msgProps: ChatMessage = {
35-
content,
37+
content: msg.withAttachment
38+
? { content: createMessageContentWithAttachments(content) }
39+
: content,
3640
mine,
3741
tabIndex: 0,
3842
timestamp: { content: msg.timestamp, title: msg.timestampLong },
@@ -44,6 +48,56 @@ function generateChatMsgProps(msg: MessageData, fromUser: UserData): ChatMessage
4448
return msgProps
4549
}
4650

51+
function createMessageContentWithAttachments(content: string) {
52+
const contextMenu = (
53+
<Menu
54+
items={[
55+
{ key: 'download', content: 'Download', icon: 'download' },
56+
{ key: 'linkify', content: 'Get link', icon: 'linkify' },
57+
{ key: 'tab', content: 'Make this a tab', icon: 'folder open' },
58+
]}
59+
vertical
60+
pills
61+
/>
62+
)
63+
64+
const actionPopup = (
65+
<Popup
66+
accessibility={popupFocusTrapBehavior}
67+
trigger={
68+
<Button aria-label="More attachment options" iconOnly circular icon="ellipsis horizontal" />
69+
}
70+
content={{ content: contextMenu }}
71+
/>
72+
)
73+
74+
return (
75+
<>
76+
<span>
77+
{content} <a href="/"> Some link </a>
78+
</span>
79+
<div style={{ marginTop: '20px', display: 'flex' }}>
80+
{_.map(['MeetingNotes.pptx', 'Document.docx'], (fileName, index) => (
81+
<Attachment
82+
icon="file word outline"
83+
aria-label={`File attachment ${fileName}. Press tab for more options Press Enter to open the file`}
84+
header={fileName}
85+
action={{ icon: 'ellipsis horizontal' }}
86+
renderAction={() => actionPopup}
87+
data-is-focusable={true}
88+
styles={{
89+
'&:focus': {
90+
outline: '.2rem solid #6264A7',
91+
},
92+
...(index === 1 ? { marginLeft: '15px' } : {}),
93+
}}
94+
/>
95+
))}
96+
</div>
97+
</>
98+
)
99+
}
100+
47101
function generateDividerProps(props: DividerProps): Divider {
48102
const { content, important, type = 'secondary' } = props
49103
const dividerProps: Divider = { itemType: ChatItemTypes.divider, content, important, type }

docs/src/prototypes/chatPane/services/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface MessageData {
1919
from: string
2020
isImportant: boolean
2121
mine: boolean
22+
withAttachment?: boolean
2223
}
2324

2425
export interface ChatData {

0 commit comments

Comments
 (0)