-
Notifications
You must be signed in to change notification settings - Fork 236
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
Fixed UI Inconsistencies while quoting messages #605
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
1cf7fc2
Fixed the issue of not displaying image, video and audio preview when…
devanshkansagra 43079bc
Formatted using prettier
devanshkansagra 456f7eb
Fixed lint error
devanshkansagra 5884464
Added border in quoted attachments to look proper
devanshkansagra 34bf50f
Fixed Lint error
devanshkansagra c719df9
Fixed no-shadow and no-else-return lint issue
devanshkansagra 613239d
Implemented Recursive quoting
devanshkansagra fe8c398
Implemented recursive quoted message preview and fixed unwanted link …
devanshkansagra 22362ef
CSS fix for recursive quoting in curved variants
devanshkansagra 586850e
Fixed the curved appearence in recursive quoted messages in curved va…
devanshkansagra a2ed7d0
Fixed the rendering of quoted image while quoting
devanshkansagra 9fc4908
Minor Fix
devanshkansagra 9134057
Removed renderMessageContent and used JSX
devanshkansagra 3c7c200
Using one prop author in attachments instead of authorName and author…
devanshkansagra 5b8e7d4
Fixed after conflicts issue
devanshkansagra af4edbe
Merge branch 'develop' into fix#563
Spiral-Memory File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
135 changes: 123 additions & 12 deletions
135
packages/react/src/views/AttachmentHandler/AudioAttachment.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 |
---|---|---|
@@ -1,18 +1,129 @@ | ||
import React from 'react'; | ||
import React, { useContext } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Box } from '@embeddedchat/ui-elements'; | ||
import { css } from '@emotion/react'; | ||
import { Box, Avatar, useTheme } from '@embeddedchat/ui-elements'; | ||
import AttachmentMetadata from './AttachmentMetadata'; | ||
import RCContext from '../../context/RCInstance'; | ||
|
||
const AudioAttachment = ({ attachment, host, variantStyles }) => ( | ||
<Box> | ||
<AttachmentMetadata | ||
attachment={attachment} | ||
url={host + (attachment.title_url || attachment.audio_url)} | ||
variantStyles={variantStyles} | ||
/> | ||
<audio src={host + attachment.audio_url} width="100%" controls /> | ||
</Box> | ||
); | ||
const AudioAttachment = ({ attachment, host, type, author, variantStyles }) => { | ||
const { RCInstance } = useContext(RCContext); | ||
const { colors } = useTheme(); | ||
const getUserAvatarUrl = (icon) => { | ||
const instanceHost = RCInstance.getHost(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prop name such as authorUrl here will be better. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay will change this |
||
const URL = `${instanceHost}${icon}`; | ||
return URL; | ||
}; | ||
const { authorIcon, authorName } = author; | ||
return ( | ||
<Box> | ||
<Box | ||
css={[ | ||
css` | ||
line-height: 0; | ||
border-radius: inherit; | ||
padding: 0.5rem; | ||
`, | ||
(type ? variantStyles.pinnedContainer : '') || | ||
css` | ||
${type === 'file' ? `border: 3px solid ${colors.border};` : ''} | ||
`, | ||
]} | ||
> | ||
{type === 'file' ? ( | ||
<> | ||
<Box | ||
css={[ | ||
css` | ||
display: flex; | ||
gap: 0.3rem; | ||
align-items: center; | ||
`, | ||
variantStyles.textUserInfo, | ||
]} | ||
> | ||
<Avatar | ||
url={getUserAvatarUrl(authorIcon)} | ||
alt="avatar" | ||
size="1.2em" | ||
/> | ||
<Box>@{authorName}</Box> | ||
</Box> | ||
</> | ||
) : ( | ||
'' | ||
)} | ||
<AttachmentMetadata | ||
attachment={attachment} | ||
url={host + (attachment.title_url || attachment.audio_url)} | ||
variantStyles={variantStyles} | ||
/> | ||
<audio src={host + attachment.audio_url} width="100%" controls /> | ||
|
||
{attachment.attachments ? ( | ||
<Box> | ||
<Box | ||
css={[ | ||
css` | ||
line-height: 0; | ||
border-radius: inherit; | ||
padding: 0.5rem; | ||
`, | ||
(attachment.attachments[0].type | ||
? variantStyles.pinnedContainer | ||
: variantStyles.quoteContainer) || | ||
css` | ||
${attachment.attachments[0].type === 'file' | ||
? `border: 3px solid ${colors.border};` | ||
: ''} | ||
`, | ||
]} | ||
> | ||
{attachment.attachments[0].type === 'file' ? ( | ||
<> | ||
<Box | ||
css={[ | ||
css` | ||
display: flex; | ||
gap: 0.3rem; | ||
align-items: center; | ||
`, | ||
variantStyles.textUserInfo, | ||
]} | ||
> | ||
<Avatar | ||
url={getUserAvatarUrl(attachment.author_icon)} | ||
alt="avatar" | ||
size="1.2em" | ||
/> | ||
<Box>@{attachment.author_name}</Box> | ||
</Box> | ||
</> | ||
) : ( | ||
'' | ||
)} | ||
<AttachmentMetadata | ||
attachment={attachment.attachments[0]} | ||
url={ | ||
host + | ||
(attachment.attachments[0].title_url || | ||
attachment.attachments[0].audio_url) | ||
} | ||
variantStyles={variantStyles} | ||
/> | ||
<audio | ||
src={host + attachment.attachments[0].audio_url} | ||
width="100%" | ||
controls | ||
/> | ||
</Box> | ||
</Box> | ||
) : ( | ||
<></> | ||
)} | ||
</Box> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default AudioAttachment; | ||
|
||
|
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why introduce redundant rendering of a component? Instead, you can add the required condition where we are already using
ImageAttachment
,AudioAttachment
, andVideoAttachment
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was easier for me to implement like this and this is also a conditional based rendering