Skip to content
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

Font-family difference between platforms #2648

Merged
merged 3 commits into from
May 7, 2021

Conversation

0xthierry
Copy link
Contributor

@0xthierry 0xthierry commented Apr 30, 2021

Details

This PR fixes the font-family difference between platform

Fixed Issues

#2491

Tests

  1. Send the following message on mobile
  *`test`*
  _`test`_
  1. Italics and bold must be applied.
  2. View the message on desktop / web / ios / android

QA Steps

  1. Click on the text input
  2. Send a message the following messages
1. *`bold`*
2. _`italic`_
3. `normal`
4. *_`italic and bold`_*
  1. The fonts should be applied like in web / desktop

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

Screen Shot 2021-04-30 at 00 24 25

Mobile Web

Screen Shot 2021-04-30 at 00 58 23

Desktop

Screen Shot 2021-04-30 at 00 26 52

iOS

Simulator Screen Shot - iPhone 11 - 2021-04-30 at 00 17 39

Android

WhatsApp Image 2021-04-30 at 00 37 04

@0xthierry 0xthierry marked this pull request as ready for review April 30, 2021 11:49
@0xthierry 0xthierry requested a review from a team as a code owner April 30, 2021 11:49
@MelvinBot MelvinBot requested review from TomatoToaster and removed request for a team April 30, 2021 11:49
@shawnborton
Copy link
Contributor

I think we'll also need these fonts defined in CSS for web/desktop/mobileWeb too right? https://github.com/Expensify/Expensify.cash/blob/main/assets/css/fonts.css

Which means that we (on the Expensify side) need to get these fonts uploaded so we can serve them up.

@0xthierry
Copy link
Contributor Author

Which means that we (on the Expensify side) need to get these fonts uploaded so we can serve them up.

I'm adding this in this css file, but yeah, we need to upload this font files to be accessible via https://www.expensify.com/font/ @shawnborton

@shawnborton
Copy link
Contributor

Sounds good, I just sent a pull request on our side for these fonts, they should be available early next week.

@0xthierry
Copy link
Contributor Author

nice, thanks @shawnborton 🎉

@0xthierry
Copy link
Contributor Author

Do you could send the name of the fonts? @shawnborton

I saw that the names is different from the file name, like this one:

https://www.expensify.com/font/GT-America-Standard-Bold-Italic.woff") format("woff"), url("https://www.expensify.com/font/GT-America-Standard-Bold-Italic.woff2

@shawnborton
Copy link
Contributor

Yeah, the file names are confusing but if we ignore the file names for a moment, the font family's name is GT America Exp, and within this family we have many sub-weights and styles. So for that matter, given that we only have one font family for our brand, I wonder if we don't really need to refer to the formal family name but rather we can just refer to the style? For example, we'd have:

  • Regular (this is the default)
  • Regular Italic
  • Bold
  • Bold Italic
  • Monospaced Regular
  • Monospaced Regular Italic
  • Monospaced Bold
  • Monospaced Bold Italic

There should be a corresponding font file for each one of those styles above. Let me know if that makes sense!

@0xthierry
Copy link
Contributor Author

There should be a corresponding font file for each one of those styles above. Let me know if that makes sense!

More or less @shawnborton, because it could be a little confused, in the web we use just refer to the style and in the other platforms (android and ios) we use GTAmericaExpMono-Bd.

In my opinion a good approach is to use the same name in all platforms (web, android and ios)

@shawnborton
Copy link
Contributor

If you need to standardize on a font fame name, I think GTAmericaExp works well. Then from here, you would have my list above as the sub-styles of the family.

@0xthierry 0xthierry requested a review from Luke9389 May 4, 2021 20:17
@Luke9389
Copy link
Contributor

Luke9389 commented May 5, 2021

@Thierrysantos To verify, have you tested this on all 5 platforms with the most recent fonts that @shawnborton provided?

Luke9389
Luke9389 previously approved these changes May 5, 2021
@0xthierry
Copy link
Contributor Author

@Luke9389 this changes that @shawnborton made just impact in the web.

Fetching the new fonts from expensify:
Screen Shot 2021-05-05 at 21 08 30

Web
Screen Shot 2021-05-05 at 21 10 51

@Luke9389
Copy link
Contributor

Luke9389 commented May 6, 2021

Awesome. Thanks!

Luke9389
Luke9389 previously approved these changes May 6, 2021
@Luke9389
Copy link
Contributor

Luke9389 commented May 6, 2021

All you @TomatoToaster!

return (
<InlineCodeBlock
TDefaultRenderer={TDefaultRenderer}
boxModelStyle={boxModelStyle}
textStyle={textStyle}
textStyle={{...textStyle, ...textStyleOverride}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should pass the new styles as Array as per the new StyleGuide. Change the prop type if necessary. Thanks.

Copy link
Contributor Author

@0xthierry 0xthierry May 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take a look and what this component expect is an object 🤔

Copy link
Member

@parasharrajat parasharrajat May 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I am not sure about the style prop that Internal TDefaultRenderer expect so its fine here. Otherwise you can just change that to array type and see how it works.

@@ -65,11 +68,24 @@ function CodeRenderer({
// We split wrapper and inner styles
// "boxModelStyle" corresponds to border, margin, padding and backgroundColor
const {boxModelStyle, otherStyle: textStyle} = splitBoxModelStyle(style);

const italic = textStyle.fontStyle === 'italic' && fontFamily.MONOSPACE_ITALIC;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can move to styles.js, but I think that is not necessary, because this logic is specific for <CodeRenderer />, so in my option is better keep this logic here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We like to keep all the style logic out of JSX.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parasharrajat nice, so I will move to styles.js, thank you 🤘🏽

Comment on lines +80 to +81
fontWeight: undefined,
fontStyle: undefined,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just set it on the default styles for Code blocks as we are just resetting them unconditionally? Also, a comment saying why undefined is used would be helpful as I worked over this a little back and these type of changes does not really make sense until specified.
https://github.com/Expensify/Expensify.cash/blob/53acb9ce968a9ea3007302e3debb8b2d9a345ebb/src/styles/styles.js#L1409

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just set it on the default styles for Code blocks as we are just resetting them unconditionally?

No, when the tags (strong, i, b ...) is within a code block, the style from this tags will be merged and passed as text Style, and with that we can know which font must be used.

If we add undefined in these properties(font Weight and font Family) in this tags(strong, i, b...), when these tags is inside a code block, we can't know which font must be used.
https://github.com/Expensify/Expensify.cash/blob/7a7fd7d8fc2836c9c2f2a4457776c6ec06407fdc/src/components/RenderHTML.js#L67

Also, a comment saying why undefined is used would be helpful as I worked over this a little back and these type of changes does not really make sense until specified.

I will do this change ❤️

@parasharrajat
Copy link
Member

parasharrajat commented May 6, 2021

@Thierrysantos Just posted a few friendly concerns. Thanks.
@Luke9389 Kindly let me know if I am allowed to add review comments. I worked over it earlier so reviewed it to make sure there are no regressions.

@0xthierry
Copy link
Contributor Author

@parasharrajat Thank you for your review 🤘🏽

@Luke9389
Copy link
Contributor

Luke9389 commented May 6, 2021

Yea @parasharrajat, feel free to leave review comments!

@0xthierry
Copy link
Contributor Author

@Luke9389 @parasharrajat I update the PR with your suggestions 🤘🏽

@0xthierry 0xthierry requested a review from Luke9389 May 7, 2021 14:37
Copy link
Contributor

@Luke9389 Luke9389 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making these changes!

Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Luke9389 Luke9389 merged commit a5c6352 into Expensify:main May 7, 2021
@OSBotify
Copy link
Contributor

OSBotify commented May 7, 2021

🚀 Deployed to staging in version: 1.0.39-5🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented May 8, 2021

🚀 Deployed to production in version: 1.0.39-5🚀

platform result
🤖 android 🤖 failure ❌
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants