Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Delete modal is now improved and Reaction emoji is added in message toolbar. #914

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 34 additions & 62 deletions packages/react/src/views/Message/MessageToolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
appendClassNames,
useTheme,
} from '@embeddedchat/ui-elements';
import { css } from '@emotion/react';
import RCContext from '../../context/RCInstance';
import { EmojiPicker } from '../EmojiPicker';
import { getMessageToolboxStyles } from './Message.styles';
Expand Down Expand Up @@ -125,7 +126,7 @@ export const MessageToolbox = ({
label: 'Add reaction',
id: 'reaction',
onClick: () => setEmojiOpen(true),
iconName: 'emoji',
iconName: 'reaction',
visible: true,
},
pin: {
Expand Down Expand Up @@ -261,75 +262,46 @@ export const MessageToolbox = ({
{showDeleteModal && (
<Modal onClose={handleOnClose}>
<Modal.Header>
<Modal.Title>
<Icon
name="trash"
size="1.25rem"
style={{ marginRight: '0.5rem' }}
/>{' '}
Delete this message?
</Modal.Title>
<Box
css={css`
margin: 0.6rem 0px 0rem 0.45rem;
`}
>
<Modal.Title>
<Icon
name="trash"
size="1.35rem"
style={{ marginRight: '0.2rem', color: 'red' }}
/>
Are you sure?
</Modal.Title>
</Box>
<Modal.Close onClick={handleOnClose} />
</Modal.Header>
<Modal.Content
style={{
overflow: 'scroll',
whiteSpace: 'wrap',
padding: '1rem',
maxHeight: '50vh',
overflow: 'hidden',
}}
>
{message.file ? (
message.file.type.startsWith('image/') ? (
<div>
<img
src={`${instanceHost}/file-upload/${message.file._id}/${message.file.name}`}
alt={message.file.name}
style={{ maxWidth: '100px', maxHeight: '100px' }}
/>
<div>{`${message.file.name} (${(
message.file.size / 1024
).toFixed(2)} kB)`}</div>
</div>
) : message.file.type.startsWith('video/') ? (
<video
controls
style={{ maxWidth: '100%', maxHeight: '200px' }}
>
<source
src={`${instanceHost}/file-upload/${message.file._id}/${message.file.name}`}
type={message.file.type}
/>
Your browser does not support the video tag.
</video>
) : message.file.type.startsWith('audio/') ? (
<audio controls style={{ maxWidth: '100%' }}>
<source
src={`${instanceHost}/file-upload/${message.file._id}/${message.file.name}`}
type={message.file.type}
/>
Your browser does not support the audio element.
</audio>
) : (
<Markdown body={message} md={message.md} isReaction={false} />
)
) : (
<Markdown body={message} md={message.md} isReaction={false} />
)}
{message.attachments &&
message.attachments.length > 0 &&
message.msg &&
message.msg[0] === '[' &&
message.attachments.map((attachment, index) => (
<Attachment
key={index}
attachment={attachment}
type={attachment.type}
host={instanceHost}
/>
))}
<Box
css={css`
margin-top: 1.5rem;
font-size: 0.9rem;
margin-left: 1rem;
margin-down: 1rem;
`}
>
You will not be able to recover this message!
</Box>
</Modal.Content>
<Modal.Footer>
<Modal.Footer
style={{
marginTop: '1rem',
padding: '0.5rem 1rem',
}}
>
<Button type="secondary" onClick={handleOnClose}>
Cancel
</Button>
Expand All @@ -340,7 +312,7 @@ export const MessageToolbox = ({
handleOnClose();
}}
>
Delete message
Yes, delete
</Button>
</Modal.Footer>
</Modal>
Expand Down
15 changes: 15 additions & 0 deletions packages/ui-elements/src/components/Icon/icons/Reaction.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/ui-elements/src/components/Icon/icons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import File from './File';
import Mobile from './Mobile';
import Star from './Star';
import Pin from './Pin';
import Reaction from './Reaction';
import ReplyDirectly from './ReplyDirectly';
import Hash from './Hash';
import HashLock from './HashLock';
Expand Down Expand Up @@ -69,6 +70,7 @@ const icons = {
mobile: Mobile,
star: Star,
pin: Pin,
reaction: Reaction,
'reply-directly': ReplyDirectly,
hash: Hash,
hash_lock: HashLock,
Expand Down
1 change: 1 addition & 0 deletions packages/ui-elements/tools/icons-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const iconsList = [
'circle-check',
'send',
'emoji',
'reaction',
'plus',
'thread',
'user',
Expand Down
Loading