-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,9 @@ const EXTRA_FONTS = [ | |
fontFamily.GTA_BOLD, | ||
fontFamily.GTA_ITALIC, | ||
fontFamily.MONOSPACE, | ||
fontFamily.MONOSPACE_ITALIC, | ||
fontFamily.MONOSPACE_BOLD, | ||
fontFamily.MONOSPACE_BOLD_ITALIC, | ||
fontFamily.SYSTEM, | ||
]; | ||
|
||
|
@@ -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; | ||
const bold = textStyle.fontWeight === 'bold' && fontFamily.MONOSPACE_BOLD; | ||
const italicBold = italic && bold && fontFamily.MONOSPACE_BOLD_ITALIC; | ||
|
||
const font = italicBold || bold || italic || fontFamily.MONOSPACE; | ||
|
||
const textStyleOverride = { | ||
fontFamily: font, | ||
fontWeight: undefined, | ||
fontStyle: undefined, | ||
Comment on lines
+84
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, when the tags (strong, i, b ...) is within a code block, the style from this tags will be merged and passed as If we add
I will do this change ❤️ |
||
}; | ||
|
||
Luke9389 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return ( | ||
<InlineCodeBlock | ||
TDefaultRenderer={TDefaultRenderer} | ||
boxModelStyle={boxModelStyle} | ||
textStyle={textStyle} | ||
textStyle={{...textStyle, ...textStyleOverride}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I take a look and what this component expect is an object 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
defaultRendererProps={defaultRendererProps} | ||
key={key} | ||
/> | ||
|
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.
I think this logic should be moved to style.js. for Eg
https://github.com/Expensify/Expensify.cash/blob/53acb9ce968a9ea3007302e3debb8b2d9a345ebb/src/styles/styles.js#L1545-L1550
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.
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.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.
We like to keep all the style logic out of JSX.
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.
@parasharrajat nice, so I will move to
styles.js
, thank you 🤘🏽