Skip to content

Commit

Permalink
fix: remove disable emoji props and add custom style
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipe Marins committed Apr 28, 2022
1 parent 680641c commit 62e329e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 26 deletions.
12 changes: 11 additions & 1 deletion apps/meteor/app/theme/client/imports/components/emojiPicker.css
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,17 @@
image-rendering: auto;
}

.emoji.big {
/* Move this style to fuselage */
.emoji.big,
.emojione.big {
width: 44px;
height: 44px;
}

.rcx-message-thread__message {
& .emoji,
& .emojione {
width: 1em;
height: 1em;
}
}
10 changes: 5 additions & 5 deletions apps/meteor/client/components/Emoji.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React, { ReactElement, CSSProperties } from 'react';
import React, { ReactElement } from 'react';

import { getEmojiClassNameAndDataTitle } from '../lib/utils/renderEmoji';

type EmojiProps = {
emojiHandle: string; // :emoji:
style?: CSSProperties;
className?: string;
};

function Emoji({ emojiHandle, style }: EmojiProps): ReactElement {
const { image: backgroundImage, ...emojiProps } = getEmojiClassNameAndDataTitle(emojiHandle);
function Emoji({ emojiHandle, className }: EmojiProps): ReactElement {
const { image: backgroundImage, className: emojiClassName, ...emojiProps } = getEmojiClassNameAndDataTitle(emojiHandle);

return <span style={{ backgroundImage, ...style }} {...emojiProps} />;
return <span style={{ backgroundImage }} className={`${emojiClassName} ${className || ''}`} {...emojiProps} />;
}

export default Emoji;
Original file line number Diff line number Diff line change
@@ -1,28 +1,17 @@
import { Box } from '@rocket.chat/fuselage';
import { BigEmoji as ASTBigEmoji } from '@rocket.chat/message-parser';
import React, { FC } from 'react';

import Emoji from '../../Emoji';

type BigEmojiProps = {
value: ASTBigEmoji['value'];
disableBigEmoji: boolean;
};

const emojiStyle = { width: '100%', height: '100%' };

// TODO ENGINEERING DAY:
// Create new parser renderer for threadPreview instead of
// disabling big emoji via disableBigEmoji prop
const BigEmoji: FC<BigEmojiProps> = ({ value, disableBigEmoji }) => (
const BigEmoji: FC<BigEmojiProps> = ({ value }) => (
<>
{disableBigEmoji
? value.map((block, index) => <Emoji key={index} emojiHandle={`:${block.value.value}:`} />)
: value.map((block, index) => (
<Box size='x44' key={index}>
<Emoji emojiHandle={`:${block.value.value}:`} style={emojiStyle} />
</Box>
))}
{value.map((block, index) => (
<Emoji emojiHandle={`:${block.value.value}:`} className='big' key={index} />
))}
</>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import MessageBodyRender from '../../../../components/Message/MessageBodyRender'
import { useMessageActions } from '../../contexts/MessageContext';
import EncryptedMessageRender from './EncryptedMessageRender';

const MessageRender: FC<{ message: IMessage; disableBigEmoji?: boolean }> = ({ message, disableBigEmoji = false }) => {
const MessageRender: FC<{ message: IMessage }> = ({ message }) => {
const {
actions: { openRoom, openUserCard },
} = useMessageActions();
Expand All @@ -23,7 +23,6 @@ const MessageRender: FC<{ message: IMessage; disableBigEmoji?: boolean }> = ({ m
mentions={message?.mentions || []}
channels={message?.channels || []}
tokens={message.md}
disableBigEmoji={disableBigEmoji}
/>
)}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ export const ThreadMessagePreview: FC<{ message: IThreadMessage; sequential: boo
{isSelecting && <CheckBox checked={isSelected} onChange={toggleSelected} />}
</ThreadMessageLeftContainer>
<ThreadMessageContainer>
<ThreadMessageBody>
{message.ignored ? t('Message_Ignored') : <MessageRender message={message} disableBigEmoji />}
</ThreadMessageBody>
<ThreadMessageBody>{message.ignored ? t('Message_Ignored') : <MessageRender message={message} />}</ThreadMessageBody>
</ThreadMessageContainer>
</ThreadMessageRow>
</ThreadMessageTemplate>
Expand Down

0 comments on commit 62e329e

Please sign in to comment.