Skip to content

Commit

Permalink
Merge pull request #3738 from rdjuric/bigSingleEmoji
Browse files Browse the repository at this point in the history
Feature: Make lonely emojis bigger
  • Loading branch information
robertjchen authored Jun 24, 2021
2 parents 3fdea74 + ff5cb8f commit cef11b7
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 12 deletions.
24 changes: 13 additions & 11 deletions src/CONST.js

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions src/libs/ValidationUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ function isValidAddress(value) {
return !CONST.REGEX.PO_BOX.test(value);
}

/**
* Validates that this string is composed of a single emoji
*
* @param {String} message
* @returns {Boolean}
*/
function isSingleEmoji(message) {
const match = message.match(CONST.REGEX.EMOJIS);

if (!match) {
return false;
}

const matchedEmoji = match[0];
return message.length === matchedEmoji.length;
}

/**
* Validate date fields
*
Expand Down Expand Up @@ -85,4 +102,5 @@ export {
isValidIndustryCode,
isValidIdentity,
isValidZipCode,
isSingleEmoji,
};
6 changes: 5 additions & 1 deletion src/pages/home/report/ReportActionItemFragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import themeColors from '../../../styles/themes/default';
import RenderHTML from '../../../components/RenderHTML';
import Text from '../../../components/Text';
import Tooltip from '../../../components/Tooltip';
import {isSingleEmoji} from '../../../libs/ValidationUtils';

const propTypes = {
/** The message fragment needing to be displayed */
Expand Down Expand Up @@ -56,7 +57,10 @@ class ReportActionItemFragment extends React.PureComponent {
debug={false}
/>
) : (
<Text selectable>
<Text
selectable
style={isSingleEmoji(fragment.text) ? styles.singleEmojiText : undefined}
>
{Str.htmlDecode(fragment.text)}
{fragment.isEdited && (
<Text
Expand Down
5 changes: 5 additions & 0 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,11 @@ const styles = {
textDecorationLine: 'none',
},

singleEmojiText: {
fontSize: variables.fontSizeSingleEmoji,
lineHeight: variables.fontSizeSingleEmojiHeight,
},

createMenuPositionSidebar: {
left: 18,
bottom: 100,
Expand Down
2 changes: 2 additions & 0 deletions src/styles/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export default {
componentBorderRadiusCard: 12,
avatarSizeNormal: 40,
avatarSizeSmall: 28,
fontSizeSingleEmoji: 30,
fontSizeSingleEmojiHeight: 35,
fontSizeSmall: 11,
fontSizeExtraSmall: 9,
fontSizeLabel: 13,
Expand Down

0 comments on commit cef11b7

Please sign in to comment.