mapbox / assembly

Making the hard parts of designing for the web easy.
https://www.mapbox.com/assembly/
134 stars 27 forks source link

Remove `flex-grow` from `.col` #1016

Closed katydecorah closed 3 years ago

katydecorah commented 3 years ago

When using grid to build a col layout, if there are uneven number of items the last item will go full-width:

image Reduce test case

This happens because .col sets flex-grow: 1. Since we have two options to allow items to grow .col--auto and .flex-child-grow, we should remove flex-grow from .col.

With this change, it will change the concept of .col slightly since the class will depend on other to give its shape within the grid.

Which classes benefit from flex-grow?

If we make this change, we lose the concept of the uncontrolled grid with the .col class. This means you will need to use a .w-* or .col--auto class to take advantage of the grid:

.col with flex-grow .col without flex-grow
Screen Shot 2021-05-19 at 1 53 18 PM Screen Shot 2021-05-19 at 1 53 22 PM

If we make this change, the %-based margins may need a .w-* or .col--auto class:

.col with flex-grow .col without flex-grow
Screen Shot 2021-05-19 at 1 44 36 PM Screen Shot 2021-05-19 at 1 44 10 PM

What alternatives have you tried?

samanpwbb commented 3 years ago

If we make this change, we lose the concept of the uncontrolled grid with the .col class. This means you will need to use a .w-* or .col--auto class to take advantage of the grid:

I like this! Reducing the scope of individual classes makes Assembly more flexible. We can recommend using col in combination with flex-child-grow to get the old behavior!