1+ import { Attachment , Popup , Button , Menu , popupFocusTrapBehavior } from '@stardust-ui/react'
2+ import * as React from 'react'
13import * as _ from 'lodash'
24import { ChatMessageProps } from 'src/components/Chat/ChatMessage'
35import { DividerProps } from 'src/components/Divider/Divider'
@@ -32,7 +34,9 @@ const statusMap: Map<UserStatus, StatusPropsExtendable> = new Map([
3234function 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+
47101function generateDividerProps ( props : DividerProps ) : Divider {
48102 const { content, important, type = 'secondary' } = props
49103 const dividerProps : Divider = { itemType : ChatItemTypes . divider , content, important, type }
0 commit comments