Use clamp to interpolate between font-sizes that ensure that things remain on two lines
now depends on D3430
Differential D3392
[landing] Keep hero `TextLoop` to two lines atul on Mar 9 2022, 3:38 PM. Authored by Tags None Referenced Files
Details Use clamp to interpolate between font-sizes that ensure that things remain on two lines now depends on D3430 Set the text to "gaming guilds" (the longest one) and made sure the text never broke to three lines. Also checked iPhone 13 mini to make sure that it looks okay at a very low breakpoint
Diff Detail
Event Timeline
Comment Actions There's a lot going on in this diff and in such a case we should explain it to the reviewers. In this case, there's a relationship between these two formulas and font-size for different widths. Also, the formulas look quite arbitrary - it should either be stated, or it should be explained that there's a deeper reason behind choosing these exact values.
Comment Actions Sorry yeah, for @media (max-width: 1099px) I interpolated over values that I found kept things to two lines. I used https://css-tricks.com/linearly-scale-font-size-with-css-clamp-based-on-the-viewport/ to figure out what values to use. 24px font-size at <=399px width Then converted those units to rem assuming 1rem = 16px 1.5rem font-size at <=25rem width and then plugged it into the math they provided: and it worked as expected.. As for the font-size outside of the media-query, I couldn't get things to work for the life of me... so I just experimented with values until I got the desired result. I think I misunderstood rem and relative units generally, I'll take another look today... the tool @benschac linked looks promising
We actually don't have to worry about this because the layout reflows when we make the "transition" between those breakpoints Comment Actions The issue here is with the following in global.css:html: /* Fallback styling if clamp isn't supported */ font-size: 1rem; /* https://css-tricks.com/simplified-fluid-typography/ */ font-size: clamp( var(--min-font-size), calc(0.75rem + 1vw), var(--max-font-size) ); which changes the definition of 1rem = 16px to something that varies with the width. We shouldn't be doing this, as it messes up the math downstream. I've created an issue to address this: https://linear.app/comm/issue/ENG-867/remove-font-size-clamp-from-globalcss We can either let this diff through with values that we've found work experimentally, or we can make that change and do it "correctly." The issue is that after removing that global clamp, we'll need to change the other 4-5 occurrences of font-size: clamp and make sure they continue to look as expected. Comment Actions I'm okay with the experimental fix for the moment. I'd rather go back and really fix the typography in the near future. Sorry for introducing this concept the wrong way! Comment Actions Discussed this with @atul today, I agree that making 1rem dynamic makes it harder to denominate things in terms of rems, especially when those second-order things need to be dynamically sized |