DEV Community

Discussion on: Neatly shorten text that is too long to display.

Collapse
 
lankinen profile image
Lankinen

I had this same problem with Trimmed News. I needed to show summary of news for the users. Sometimes summary was pretty short and sometimes it was quite long.

First I tried to change the font size in a way that the font would always fit into the box. This didn’t worked because number of characters isn’t correlation directly with the length. This causes sometimes way too small text.

Then I got advice to design it again. And so I did. Because I didn’t want to just add basic scroll in the final version the text was divided into cards the same way Instagram post can contain multiple images. It worked because one sentence fit into the card easily.

I think in title or some other similar places it might be better to do what you did but often the problem is in designing instead of execution.

Collapse
 
javaofdoom profile image
Joe Tiersma

You bring up an interesting point. Design vs execution. It reminds me of all my psych major classes where we discussed nature vs nuture.

There are definitely those times when coding I see a problem and the solution is obviously a quick design change. Other times I know the solution is in the functionality. Often enough I believe it falls into a blend of the two.

So the philosophical question of being a developer is "How do I find the balance of function and design in my code?" I don't have an answer, but I believe it is the question we will all be continually pondering along our coding journey.

Thanks so much for your story and feedback!!!