day8 / re-com

A ClojureScript library of reusable components for Reagent
https://re-com.day8.com.au
MIT License
799 stars 145 forks source link

Responsive layout container #68

Open skrat opened 9 years ago

skrat commented 9 years ago

I'm trying to figure out how to make a list item, that displays it's children horizontally when there's enough space (desktop), but wraps them into multiple "lines" when there isn't (mobile). Am I missing something or is this simply not possible with the built-in h-box / v-box? Is re-com missing some layout component that would do this for me? I'm new to bootstrap but I tried to use row and col-md-4 classes to no avail. Apparently they don't work when I use input-text components.

mike-thompson-day8 commented 9 years ago

@skrat h-box and v-box are a layer over flexbox but they don't have direct support for wrapping. It hasn't ever been on our radar.

Untested: you might be able to add a flexbox :style to an h-box like {:flex-wrap: "wrap"}.

metasoarous commented 8 years ago

I just came up against this as well. It seems that adding :style {:flex-wrap "wrap"} doesn't work, because h-box and v-box use :flex-flow "row|column no-wrap", and :flex-flow takes precedence over a separate :flex-wrap declaration.

Of course, it's possible to pass :style {:flex-flow "row|column wrap"} as appropriate, but this feels a little silly; h-box and v-box already have row|column specified, so we're duplicating work there. Admittedly, it's not a lot of work, but it makes it more cumbersome to pass around style maps that you might want to share between h-box and v-box components.

I see two options here (aside from not doing anything and letting us hack around it):

While the former might look nice, the latter might lead to better composability using style maps.

jeaye commented 6 years ago

This is still an issue and I vote for having :wrap as a keyword argument for these layout components.

MawiraIke commented 2 years ago

I have created a PR #312 which should fix this issue. The PR allows users to use :wrap keyword in h-box and v-box. In the case that :wrap keyword is not passed to re-com, the default of nowrap remains to avoid breaking changes for current use cases.