forked from bigbluebutton/bigbluebutton
-
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.
fix(chat): Add emoji shortcodes to message reaction labels (bigbluebu…
- Loading branch information
1 parent
12a2261
commit 7270094
Showing
5 changed files
with
152 additions
and
99 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
96 changes: 96 additions & 0 deletions
96
...graphql/chat-message-list/page/chat-message/message-reactions/reaction-item/component.tsx
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,96 @@ | ||
import React, { useId } from 'react'; | ||
import { capitalize } from 'radash'; | ||
import TooltipContainer from '/imports/ui/components/common/tooltip/container'; | ||
import { defineMessages, useIntl } from 'react-intl'; | ||
import Styled from './styles'; | ||
|
||
const intlMessages = defineMessages({ | ||
reactionLabel: { | ||
id: 'app.chat.toolbar.reactions.reactionLabel', | ||
}, | ||
you: { | ||
id: 'app.chat.toolbar.reactions.youLabel', | ||
}, | ||
and: { | ||
id: 'app.chat.toolbar.reactions.andLabel', | ||
}, | ||
}); | ||
|
||
interface ReactionItemProps { | ||
count: number; | ||
userNames: string[]; | ||
reactedByMe: boolean; | ||
reactionEmoji: string; | ||
reactionEmojiId: string; | ||
shortcodes: string; | ||
sendReaction(reactionEmoji: string, reactionEmojiId: string, chatId: string, messageId: string): void; | ||
deleteReaction(reactionEmoji: string, reactionEmojiId: string, chatId: string, messageId: string): void; | ||
chatId: string; | ||
messageId: string; | ||
} | ||
|
||
const ReactionItem: React.FC<ReactionItemProps> = (props) => { | ||
const { | ||
count, | ||
reactedByMe, | ||
reactionEmoji, | ||
reactionEmojiId, | ||
userNames, | ||
shortcodes, | ||
chatId, | ||
messageId, | ||
deleteReaction, | ||
sendReaction, | ||
} = props; | ||
|
||
const intl = useIntl(); | ||
const id = useId(); | ||
|
||
let usersLabel = ''; | ||
if (userNames.length) { | ||
const users = userNames.join(', '); | ||
usersLabel += users; | ||
|
||
if (reactedByMe) { | ||
usersLabel += ` ${intl.formatMessage(intlMessages.and)} ${intl.formatMessage(intlMessages.you)}`; | ||
} | ||
} else if (reactedByMe) { | ||
usersLabel += capitalize(intl.formatMessage(intlMessages.you)); | ||
} | ||
|
||
const label = intl.formatMessage(intlMessages.reactionLabel, { | ||
0: usersLabel, | ||
1: shortcodes, | ||
}); | ||
|
||
return ( | ||
<TooltipContainer title={label} key={reactionEmojiId}> | ||
<Styled.EmojiWrapper | ||
aria-describedby={id} | ||
highlighted={reactedByMe} | ||
onClick={() => { | ||
if (reactedByMe) { | ||
deleteReaction(reactionEmoji, reactionEmojiId, chatId, messageId); | ||
} else { | ||
sendReaction(reactionEmoji, reactionEmojiId, chatId, messageId); | ||
} | ||
}} | ||
> | ||
<em-emoji | ||
size={parseFloat( | ||
window.getComputedStyle(document.documentElement).fontSize, | ||
)} | ||
emoji={{ | ||
id: reactionEmojiId, | ||
native: reactionEmoji, | ||
}} | ||
native={reactionEmoji} | ||
/> | ||
<span>{count}</span> | ||
<span className="sr-only" id={id}>{label}</span> | ||
</Styled.EmojiWrapper> | ||
</TooltipContainer> | ||
); | ||
}; | ||
|
||
export default ReactionItem; |
35 changes: 35 additions & 0 deletions
35
...at-graphql/chat-message-list/page/chat-message/message-reactions/reaction-item/styles.tsx
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,35 @@ | ||
import styled from 'styled-components'; | ||
import { colorGrayLightest, colorOffWhite, colorGrayLighter } from '/imports/ui/stylesheets/styled-components/palette'; | ||
|
||
const EmojiWrapper = styled.button<{ highlighted: boolean }>` | ||
background: none; | ||
border-radius: 1rem; | ||
padding: 0.375rem 1rem; | ||
line-height: 1; | ||
display: flex; | ||
flex-wrap: nowrap; | ||
border: 1px solid ${colorGrayLightest}; | ||
cursor: pointer; | ||
${({ highlighted }) => highlighted && ` | ||
background-color: ${colorOffWhite}; | ||
`} | ||
em-emoji { | ||
[dir='ltr'] & { | ||
margin-right: 0.25rem; | ||
} | ||
[dir='rtl'] & { | ||
margin-left: 0.25rem; | ||
} | ||
} | ||
&:hover { | ||
border: 1px solid ${colorGrayLighter}; | ||
} | ||
`; | ||
|
||
export default { | ||
EmojiWrapper, | ||
}; |
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