Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"reverse" not working #5

Open
CharlieIGG opened this issue Jul 18, 2017 · 7 comments
Open

"reverse" not working #5

CharlieIGG opened this issue Jul 18, 2017 · 7 comments
Labels

Comments

@CharlieIGG
Copy link

The reverse prop for is just not working for me, either as a boolean or as an object. Help?

@jameslnewell
Copy link
Owner

👋 Hey. It works for me?

<Grid reverse>
	<Grid.Unit width={0.25}>#1</Grid.Unit>
	<Grid.Unit width={0.25}>#2</Grid.Unit>
	<Grid.Unit width={0.25}>#3</Grid.Unit>
	<Grid.Unit width={0.25}>#4</Grid.Unit>
</Grid>

Can you provide some way to reproduce it not working?

@CharlieIGG
Copy link
Author

CharlieIGG commented Jul 20, 2017

Hi @jameslnewell I just realized this works for me with most use cases with one important exception:

<Grid reverse wrap>
    <Grid.Unit style={{backgroundColor: "blue"}} width={1}>
       <span>Foo</span>
     </Grid.Unit>
     <Grid.Unit style={{backgroundColor: "red"}} width={1}>
       <span>Bar</span>
     </Grid.Unit> 
</Grid>

This is a simplified example, but I have a use case where, if the user is on mobile, I want the Grid.Units that I'm using to take up all of the space each, but I want them to switch places.
Sort of like with Bootstrap's push and pull: https://scotch.io/tutorials/reorder-css-columns-using-bootstrap

@jameslnewell
Copy link
Owner

Thanks for the report! I'll look at it in the next few days.

@jameslnewell
Copy link
Owner

Try 1.0.0-preview.11.
b0165de

@CharlieIGG
Copy link
Author

Im traveling right now, but the adjustment you made seems about right

@grgcnnr
Copy link

grgcnnr commented Jun 4, 2019

I'm going to revive this issue since there is a complex case where wrap and reverse still bump up against each other:
Consider something like this:

<Grid reverse={{xs: false, sm: true, md:false}}>
          <GridUnit size={{xs:1/2, md: 1}}>1</GridUnit>
          <GridUnit size={{xs:1/2, md: 1}}>2</GridUnit>
 </Grid>

What we might expect:

xs [1 , 2]
sm [2, 1]
md [1
    2]

On a medium and above screen we would expect the grid to behave as a columns, however wrap-reverse is never unset so what we actually get is

md [2
    1]

Have included a demo of the bug in the example project grgcnnr@8b27330

@jameslnewell
Copy link
Owner

Hmm great find.

This appears to be due to this line where we're expecting reverse to be false but instead we get the truthy value of {mobile: false, tablet: true, desktop: false} since map only works on a single value.

halign likely suffers from the same problem.

Let me think about the best way of solving it.

@jameslnewell jameslnewell reopened this Jun 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants