use-clamp-text
use-clamp-text copied to clipboard
Clamping structured text
Right now, the hook only allows for clamping a pure text node. This means if i want to clamp "structured" text, for example a blogpost or a news article that is split into several paragraphs, i would only be able to apply line clamping to each paragraph.
I also am not able to clamp text that has bold underlined, or otherwise marked parts. Imo, a better solution would be to allow JSX as input into the hook.
You will then also encounter a problem with safari, because while the above suggestion would be fairly straightforward for most chromium based browsers, safari does not like line clamping on parent elements. Check out this sandbox: https://codesandbox.io/s/spring-butterfly-w2i6xj?file=/index.html
Looks fine in chrome, but this is what safari makes out of it:
Thanks for filling this along with the codesandbox. Will try to come up with a solution for it. Will provides updates on this issue as I do.