-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add stretchy type block #5
Conversation
} | ||
|
||
document.addEventListener( 'DOMContentLoaded', handleFontSize ); | ||
window.addEventListener('resize', handleFontSize ); |
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 tried this with the interactivity API, but it performed noticeably (visually) worse — the text would show up at the default size, and a split second later would resize — and it took a lot more code to do the same thing.
Maybe it could be optimized somehow.
@jffng Take a look at https://cool-tools.mystagingwebsite.com/2024/06/25/stretchy-type/ I played around a bit, noticed the text is by default set to align-wide, unless nested in a full width group block. When nested in a block with horiztontal padding, the text width does not respect the padding, so we probably want to account for that. |
When loading the block, the font resize doesn’t fire as expected, leading to the type sitting off center or breaking out beyond its container. However, when you manually resize the browser window, it fires correctly and resizes the type as expected: Look at the letter “K” and notice how it initially the K is truncated but after resizing it fits properly. |
I was taking a look at this to understand the use case better and see if it could land. I have a couple of questions so far:
|
Almost. The idea is that the font-size for text inside a Stretchy Type block adapts to fit the size of its immediate parent container. Example: https://codepen.io/chriscoyier/pen/gKoVBg
I’m personally okay with this effect extending the paragraph block as long as it can achieve the same thing. But typically, this effect is used on single lines of text. There may be cases where we would want the effect on a text thats more than one line, but we could save that for a second iteration. I also don’t know if there were other reasons for keeping it in a separate block. @Nyiriland may know the reasoning there 🤔 The most important requirements are:
|
I'm guessing it's like what @allancole said: the function is that it's a single line of text (and usually only a word or two), so many of the paragraph options or functions might be unnecessary. |
c12a92f
to
4f9b8cd
Compare
Closing this in favour of #32 where work is continuing. |
Description
This PR implements a stretchy type block, as a part of the Cool Tools project.
The remaining to-dos I think can be follow ups.
To-Do