-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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: Dynamic emoji size #3561
feat: Dynamic emoji size #3561
Conversation
@chiragsalian I am able to get this to work. But the flatlist is not re-rendering and getting this weird effect on hover as the size changes are not being reflected. Peek.2021-06-12.01-22.mp4 |
return styleVariables.fontSizeSmall; | ||
} | ||
if ( | ||
windowWidth <= 480 |
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.
Let's convert this to a single line if condition for consistency. Its weird seeing a mix of single and double line if statements when they have just 1 condition in them.
|
||
componentDidUpdate(prevProps) { | ||
if ( | ||
this.props.windowWidth !== prevProps.windowWidth |
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.
Same as before, let's make this a single line if statement.
if ( | ||
this.props.windowWidth !== prevProps.windowWidth | ||
) { | ||
// eslint-disable-next-line react/no-did-update-set-state |
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.
Is there a reason you would prefer to disable this rule. IMO it feels just as easy to create a method like setDynamicEmojiSize
and call that method here that would do,
this.setState({emojiSize: dynamicEmojiSize(this.props.windowWidth)});
Then you wouldn't need to disable the eslint rule.
@@ -17,6 +17,8 @@ const propTypes = { | |||
|
|||
/** Whether this menu item is currently highlighted or not */ | |||
isHighlighted: PropTypes.bool.isRequired, | |||
|
|||
size: PropTypes.number.isRequired, |
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.
missing JS doc.
} | ||
|
||
|
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.
remove unnecessary line break
if ( | ||
this.props.windowWidth !== prevProps.windowWidth | ||
) { | ||
// eslint-disable-next-line react/no-did-update-set-state |
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.
Similar comment as here
|
||
const propTypes = { | ||
/** Function to add the selected emoji to the main compose text input */ | ||
onEmojiSelected: PropTypes.func.isRequired, | ||
|
||
...windowDimensionsPropTypes, |
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.
NAB: I see there are many places in our code where this is prop is not documented but as per our style guide it would be nice if you include a JS comment doc for this for consistency.
@chiragsalian I have updated the PR |
Just saw this. I was OOO on Friday so just getting to this today. I'll first ask @stitesExpensify opinion if he knows how to tackle this since he worked on this. Stites could you let us know if you know a fix for the problem he mentioned. He shared a video of the problem too which helps. If you have no idea then I'll pull the code and start debugging. (I'm a little swamped today hence was asking you first) |
Also i think you should be giving emoji size as a prop to |
} | ||
|
||
if (windowWidth <= 320) { return styleVariables.fontSizeSmall; } | ||
if (windowWidth <= 480) { return styleVariables.fontSizeNormal; } |
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.
oh sorry for the confusion, i didn't mean the whole line, just the if condition, i.e.,
if (windowWidth <= 480) {
return styleVariables.fontSizeNormal;
}
That would match our examples in the style guide. Could you make the same changes to the if conditions in your file.
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.
Done
Is this for me @chiragsalian |
So just this part is for stites and the rest was for you. Also it looks like stites is OOO today so I guess now all of it is for you 🙂 |
Also i don't think there is any reason to make your changes to index.js. We don't have any issue with the way the emojis work on web so I think we should just focus on fixing it for mobile. So just having your code for index.native.js and testing it on android and ios for different mobile widths would suffice. |
@pranshuchittora hey! I'm interested in pushing this along and wondering if there were any updates on your end. It looks like the issue is that we expect the |
@nickmurray47 |
@pranshuchittora, so you mention re-rendering. But i don't see how the dimension would change on the mobile device such that we'd have to worry about re-renders (well landscape and portrait could exist but I think that's an improvement for a later date). Then test if its works for |
emojiSize: { | ||
fontSize: dynamicEmojiSize(this.props.windowWidth), | ||
}, |
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 this?
To reduce the memory overhead of creating objects for each emoji.
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.
Nice
@chiragsalian I have updated the PR |
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.
Left a minor comment. The rest looks much better to me. I tested and it works well too.
|
||
this.state = { | ||
emojiSize: {fontSize: dynamicEmojiSize(this.props.windowWidth)}, | ||
}; |
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.
Do you need this state variable? Its not really changing anywhere in the component so I don't quite see the benefit.
How about if you just did,
emojiSize={fontSize: dynamicEmojiSize(this.props.windowWidth)}
over here.
If you think that's not too readable then we should just do this.emojiSize than save it in a state variable. Thoughts?
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.
The idea of keeping it in a state opens the door for any future development for reactivity for emoji sizes.
And adding it to the state doesn't create any overhead.
We can remove it from the state and make it a normal class property.
- this.state.emojiSize
+ this.emojiSize
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.
The idea of keeping it in a state opens the door for any future development for reactivity for emoji sizes.
Making code more complex than it needs to be with the assumption that it will be modified in the future is unnecessary preoptimization. When its needed to be a state variable for any reason then its easy enough to convert so let's not have it be a state variable right now.
Sure I'm fine with class property 👍
Could you update?
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.
Done I have updated the PR
I have updated the PR. Updating the screenshots and QA steps asynchronously. |
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.
Nice, ty. Code LGTM 👍
@nickmurray47 bump to review. |
I have updated all the screenshots and QA steps |
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.
Tests well and code LGTM
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Unfortunately the deploy comments are not working right now. This was deployed to staging yesterday. |
Commented in #4030 (comment) about a regression from this PR |
Details
Fixed Issues
Fixes #2662
Tests
QA Steps
Tested On
Screenshots
Web
Mobile Web
Desktop
iOS
Android
Smallest device possible (approx 320)
Medium Size WVGA
High DPI