forked from RocketChat/EmbeddedChat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feat/RocketChat#414-message-notification
- Loading branch information
Showing
26 changed files
with
371 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
import React, { useState, useMemo } from 'react'; | ||
import { css } from '@emotion/react'; | ||
import classes from './AllThreads.module.css'; | ||
import { Icon } from '../Icon'; | ||
import { Box } from '../Box'; | ||
import { ActionButton } from '../ActionButton'; | ||
import { useMessageStore, useUserStore, useThreadsMessageStore } from '../../store'; | ||
import { MessageBody } from '../Message/MessageBody'; | ||
import { MessageMetrics } from '../Message/MessageMetrics'; | ||
import MessageAvatarContainer from '../Message/MessageAvatarContainer'; | ||
import MessageBodyContainer from '../Message/MessageBodyContainer'; | ||
import MessageHeader from '../Message/MessageHeader'; | ||
|
||
|
||
const MessageCss = css` | ||
display: flex; | ||
flex-direction: row; | ||
align-items: flex-start; | ||
padding-top: 0.5rem; | ||
-webkit-padding-before: 0.5rem; | ||
padding-block-start: 0.5rem; | ||
padding-bottom: 0.25rem; | ||
-webkit-padding-after: 0.25rem; | ||
padding-block-end: 0.25rem; | ||
padding-left: 1.25rem; | ||
padding-right: 1.25rem; | ||
padding-inline: 1.25rem; | ||
cursor: pointer; | ||
&:hover { | ||
background: #f2f3f5; | ||
} | ||
`; | ||
|
||
const AllThreads = () => { | ||
const showAvatar = useUserStore((state) => state.showAvatar); | ||
const messages = useMessageStore((state) => state.messages); | ||
const setShowAllThreads = useThreadsMessageStore((state) => state.setShowAllThreads); | ||
const openThread = useMessageStore((state) => state.openThread); | ||
const [text, setText] = useState(''); | ||
|
||
const toggleShowAllThreads = () => { | ||
setShowAllThreads(false); | ||
}; | ||
|
||
const handleOpenThread = (msg) => () => { | ||
openThread(msg); | ||
toggleShowAllThreads(false); | ||
}; | ||
|
||
const handleInputChange = (e) => { | ||
setText(e.target.value); | ||
}; | ||
|
||
const filteredThreads = useMemo(() => { | ||
return messages.filter((message) => | ||
message.msg.toLowerCase().includes(text.toLowerCase()) | ||
); | ||
}, [messages, text]); | ||
|
||
return ( | ||
<Box className={classes.component}> | ||
<Box className={classes.wrapContainer}> | ||
|
||
<Box style={{ padding: '16px' }}> | ||
<Box css={css`display: flex;`}> | ||
<h3 style={{ display: 'contents' }}> | ||
<Icon | ||
name="thread" | ||
size="1.25rem" | ||
style={{ padding: '0px 20px 20px 0px' }} | ||
/> | ||
<Box css={css` | ||
width: 100%; | ||
color: #4a4a4a; | ||
`} | ||
> | ||
Threads | ||
</Box> | ||
<ActionButton onClick={toggleShowAllThreads} ghost size="small"> | ||
<Icon name="cross" size="1.25rem" /> | ||
</ActionButton> | ||
</h3> | ||
</Box> | ||
|
||
<Box | ||
className={classes.searchContainer} | ||
style={{ border: '2px solid #ddd', position: 'relative' }} | ||
> | ||
<input | ||
placeholder="Search Messages" | ||
onChange={handleInputChange} | ||
className={classes.textInput} | ||
/> | ||
|
||
<Icon name="magnifier" size="1.25rem" style={{ padding: '0.125em', cursor: 'pointer' }} /> | ||
</Box> | ||
</Box> | ||
|
||
<Box | ||
style={{ | ||
flex: '1', | ||
overflow: 'auto', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
justifyContent: filteredThreads.length === 0 ? 'center' : 'initial', | ||
alignItems: filteredThreads.length === 0 ? 'center' : 'initial' | ||
}} | ||
> | ||
{filteredThreads.length === 0 ? ( | ||
<Box style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', color: '#4a4a4a' }}> | ||
<Icon name="magnifier" size="3rem" style={{ padding: '0.5rem' }} /> | ||
<span style={{ fontSize: '1.2rem', fontWeight: 'bold' }}>No threads found</span> | ||
</Box> | ||
) : (filteredThreads | ||
.map((message) => ( | ||
!message.t && message.tcount && ( | ||
<Box key={message._id} css={MessageCss} onClick={handleOpenThread(message)}> | ||
{showAvatar && ( | ||
<MessageAvatarContainer | ||
message={message} | ||
sequential={false} | ||
isStarred={false} | ||
/> | ||
)} | ||
<MessageBodyContainer> | ||
{<MessageHeader message={message} isTimeStamped={false} />} | ||
<MessageBody> | ||
{message.attachments && message.attachments.length > 0 ? ( | ||
message.file.name | ||
) : ( | ||
message.msg | ||
)} | ||
</MessageBody> | ||
|
||
<MessageMetrics | ||
message={message} | ||
isReplyButton={false} | ||
/> | ||
</MessageBodyContainer> | ||
</Box> | ||
) | ||
)))} | ||
</Box> | ||
</Box> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default AllThreads; |
41 changes: 41 additions & 0 deletions
41
packages/react/src/components/AllThreads/AllThreads.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.component { | ||
position: fixed; | ||
right: 0; | ||
top: 0; | ||
width: 350px; | ||
height: 100%; | ||
overflow: hidden; | ||
background-color: white; | ||
box-shadow: -1px 0px 5px rgb(0 0 0 / 25%); | ||
z-index: 100; | ||
} | ||
|
||
.wrapContainer { | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.searchContainer { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
background-color: #fff; | ||
} | ||
|
||
.textInput { | ||
width: 75%; | ||
height: 2.5rem; | ||
border: none; | ||
outline: none; | ||
} | ||
|
||
.textInput::placeholder { | ||
padding-left: 5px; | ||
} | ||
|
||
@media (max-width: 550px) { | ||
.component { | ||
width: 100vw; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
packages/react/src/components/DynamicHeader/DynamicHeader.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import styles from './DynamicHeader.module.css'; | ||
import { Icon } from '../Icon'; | ||
import { Box } from '../Box'; | ||
import { ActionButton } from '../ActionButton'; | ||
|
||
const DynamicHeader = ({ title, isClosable = false, handleClose = () => { }, iconName }) => { | ||
return ( | ||
<Box | ||
className={styles.container} | ||
style={{ | ||
paddingBlockStart: '10px', | ||
}} | ||
> | ||
<Box | ||
style={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
flexDirection: 'row', | ||
gap: '0.5rem', | ||
}} | ||
> | ||
{isClosable && ( | ||
<ActionButton onClick={handleClose} ghost display="inline" square small> | ||
<Icon name={iconName} size="1.25rem" /> | ||
</ActionButton> | ||
)} | ||
{!isClosable && ( | ||
<div> | ||
<Icon name={iconName} size="1.25rem" /> | ||
</div> | ||
)} | ||
<h4 className={styles.nospace}>{title}</h4> | ||
</Box> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default DynamicHeader; | ||
|
||
DynamicHeader.propTypes = { | ||
handleClose: PropTypes.func, | ||
title: PropTypes.string, | ||
isClosable: PropTypes.bool, | ||
iconName: PropTypes.string, | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as DynamicHeader } from './DynamicHeader'; |
Oops, something went wrong.