ItsJonQ / g2

✨ An experimental reimagining of WordPress components
http://g2-components.com/
MIT License
105 stars 12 forks source link

Layout: Improve Flex/Grid handling of longer labels #251

Closed ItsJonQ closed 3 years ago

ItsJonQ commented 3 years ago
106353642-4a1ab400-62ec-11eb-8fdf-be147b44a106

Originally reported (https://github.com/WordPress/gutenberg/issues/28612)


The FontSizeControl uses CSS Grid to render it's inner UI. This works to keep the elements tidy. However, it restricts the ability to gracefully handle the rendering of longer translation labels (see screenshot above)

With some experimentation, I was able to adjust it to look like this:

Screen Shot 2021-02-01 at 11 15 51 AM

(Screenshot of Google translated German labels)

Original English labels:

Screen Shot 2021-02-01 at 11 21 47 AM

Flex wrap

This involved swapping Grid -> HStack, and enhancing how Flex/HStack handles wrapping.

Previously, Flex only provided margin gaps on one axis (either x for horizontal, or y for vertical). With the updated <Flex wrap />, the gap value is now applied on both x and y to accommodate wrapped content.

This solution seems to work well. However, it involves quite a bit of manual CSS for the individual children of HStack.