-
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
fix inline code blocks for native platforms #2307
fix inline code blocks for native platforms #2307
Conversation
@shawnborton I hope this style matches the desired one. |
Hey @parasharrajat, I'm noticing that this gets a bit clunky when there are longer words in the text. Here's what I'm talkin' about: Think there's any way for us to fill in the white space with the code text style? |
@Luke9389. I not sure how to tackle this behavior. In this solution, each word is wrapped into a separate view, and then these views are being flex wrapped in the next line. but if a single word would be very big it will wrap to the next line leaving a gap in the previous line (Same behavior for Web). So far I have no idea of how to intelligently break that word into child views. |
Updated @shawnborton. Let me know if that works. |
…asharrajat/quotedText
@parasharrajat did you update the screenshots as well? |
Oh no. I will update them. But for IOS , could you please test it. I am not a lot sure about that. |
@shawnborton I have updated the screens. Just I don't have IOS so I have put the image from snap. |
@shawnborton I tried a lot of ways for this. On IOS, the gap is equal but on Android, the inline code is vertically top relative to the text so I have to push the inline code towards the bottom to Keep it centered which Increases the gap where inline code comes on the same line with the text. After many trials, I found this solution to add border and border-radius to the inline code which has this drawback on Android. Previously, we(including other proposals) were only able to achieve the background-color for the inline code so far. I am open to suggestions if someone can look at the code and help me improve it. It seems that android does not handle it well natively but IOS can. |
Going to tag my pal @marcaaron for thoughts on this from a technical perspective, as I know we've gone through this one a few times now. It seems like we're getting close to the solution though. Is there any way you can make it so that both the normal text and inline code have a height of 20? If we can get the 20px tall containers to line up correctly, we hopefully can control the styles inside of them. |
I see that we set the line height of the whole text message then we can reach to almost equal gap but that text is not controlled by the inline code block and I don't think we don't want to change the line height for all messages. But let me see what I can do here. |
Hmm I don't think I am quite following your comment. But I am pretty sure the line height for a default message is 20 right? So my thinking is that if a block of text has a height/line height of 20, and then an inline code block is wrapped with a height of 20, those two elements should vertically align. Inside of the inline code block wrapper, we can make the code appear to be 18 tall with a margin top of 1 and a margin bottom of 1. Let me know if that makes sense. |
Coming in a bit late to this PR and the overall direction and I'm curious... did we ever consider applying a solution like this in As for styling advice, let's keep trying to achieve what we want for a bit. I don't have time to look into this today, but if we are still stuck down the line I'll jump in and see what I can do. |
@shawnborton So This is how it is rendered initially Now to make the text inline I have to move the boxes some px downwards which works fine for the box which has normal inline text such as line 2 but when we have a whole line of code block then the negative margin which we gave to pull it down is not necessary and thus as a side effect it unnecessarily pull the whole line downwards and reducing the gap between this and next line. |
Hmm okay. Are all of your changes pushed to your branch? Maybe I can pull it down and test on my end and let you know what I find. |
@shawnborton That would be really great. yeah its pushed. |
Thanks for the detailed breakdown @shawnborton. If we can make the inline code block vertically center without passing the margin (this does not seem to be supported by native platforms), then this mystery could be resolved. |
@shawnborton @Luke9389. Breakthrough here. I have managed the gap. 🥳 🥳 |
Whoa, amazing Rajat!! |
I think this is the behavior we want on all platforms, not just native. Is it possible to implement this everywhere? |
@shawnborton Yup. |
Awesome, design-wise this looks great to me. |
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.
Hey Rajat, this looks awesome, nice job.
I put some knit-picky whitespace reviews in, but otherwise this looks great!
…harrajat/quotedText
@Luke9389 Updated. Thanks |
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.
Nailed it Rajat, way to go!
🚀 Deployed to staging 🚀
|
Chat - Sent code blocks are not properly centeredExpected ResultSent message and code blocks are vertically centered/alligned Actual ResultCode block is not centered vertically Action Performed
PlatformiOS ✔️ Build 1.0.28-0 Notes/Images/Video |
Since this is a deploy blocker, the fix for which is still in review, I'm going to revert this PR. @parasharrajat what this means for you is that you'll need to resubmit a new PR that's a combination of this PR (#2307) and the fix for the deploy blocker (#2527). That way, we can hopefully move forward with a production deploy as soon as possible. Let me know if you have any questions. |
Sure |
🚀 Deployed to production in version: 1.0.39-5🚀
|
fontFamily: fontFamily.MONOSPACE, | ||
lineHeight: 18, | ||
fontSize: 13, |
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 inline code block font size was being inherited. But after explicitly setting it to 13px, it's always rendered at 13px even if the parent is a H1
where the font size is expected to be a little bigger. (Coming from #30203)
Please review @sketchydroide.
Details
Problem
We (Including other contributors) tried using a combination of Text & View tag to achieve the above UI but there are a couple of issues as follows:
How I fixed it?
I had an idea of tokenizing the text. Then apply the style selectively. This is working well. I have made a small snap here.
Fixed Issues
Fixes #986Tests / QA Steps
This is a test to see
how code renders in the middle
of a sentence on mobile.Issue(Not blocker)
Inline Rendered code block is not vertically center with respect to the text.✔️ FixedTested On
Screenshots
Web / Desktop
Android
IOS
I don't have an IOS device thus I mimicked the logic here and which can be seen working well.