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

Media queries don't work with @lost variables #407

Open
elliottmangham opened this issue Mar 19, 2018 · 7 comments
Open

Media queries don't work with @lost variables #407

elliottmangham opened this issue Mar 19, 2018 · 7 comments

Comments

@elliottmangham
Copy link

Hello,

Is it possible - and if so how - to change @lost variables using media queries?

For example I have my gutter set to 30px:
@lost gutter 30px;

This works. However, I want to have my gutter set to 6vw on mobile and the follow does not work:

@lost gutter 30px;

@media screen and (max-width: 480px) {
	@lost gutter 7vw;
}

Please can you advise how to get this working?

Thank you.

@elliottmangham elliottmangham changed the title Ensure media queries work with @lost variables i.e. gutter Media queries don't work with @lost variables Mar 19, 2018
@peterramsing
Copy link
Owner

peterramsing commented Mar 20, 2018

@elliottmangham Simply put: this isn't something that LostGrid supports. LostGrid transpiles before it ever sees the browser so it doesn't adapt to media queries.

Action Steps:

  1. You can support this on an individual basis with the following:
.foo {
  lost-column: 1/3 3 30px;
}
@media () {
  .foo {
    lost-column: 1/3 3 7vw;
  }
}

I suspect that isn't ideal for what you're intending here as that can get pretty tedious to write.

  1. Build out support for if a global setting is set within a media query that LostGrid then duplicates each declaration with those different globals set. That has some possible downsides with CSS bloat. It could be pondered, though.

@elliottmangham
Copy link
Author

Thanks @peterramsing for your informative answer, really helpful!

Your action step 1 is a good workaround, although I find that would generate a lot of unnecessary code as it would output the floats, margins, etc. for every media query.

Is it possible to modify only the gutter, for example:

.foo {
  lost-column: 1/3 3 30px;
}
@media () {
  .foo {
    lost-gutter: 7vw;
  }
}

Thanks again

@peterramsing
Copy link
Owner

@elliottmangham I did some work on this over the last week and it'd be quite complex to do. The nature of how LostGrid presently works this would be quite difficult. I'm not afraid of the difficulty that I'd be afraid of the fragility. There would be a lot of complexity to ensure that the gutters maintained the correct columns.

I could be convinced to do it, though, and it would be a really good excuse to refactor much some of the code to make it less fragile.

🤔

@elliottmangham
Copy link
Author

elliottmangham commented Apr 16, 2018

Hey @peterramsing,

Thanks for looking into it!

It might be tedious to implement like you say, though I must argue that it would be a huge step towards writing DRY code. The benefit of modifying only one value (like gutter, for example) would mean that other values like floats, widths etc. are not output again and again for every media query.

A highly-responsive site might have several queries for every individual component, so I can see this being very useful.

I'd certainly love to hear your thoughts.

👍

@peterramsing
Copy link
Owner

peterramsing commented Jun 12, 2018

@elliottmangham, this really is an interesting conversation. DRY has several meanings here. While the source code might be a little drier I can imagine having a solution for this work without configuration could bloat the exported CSS.

That said, I'm all for developer ergonomics. Let me see if a few months have given me some new ideas.

@peterramsing
Copy link
Owner

@elliottmangham, due to technical debt that I need to pay down, this isn't something that I can move forward on right now. I'll move it to the backlog, though, and maybe can come back to in after I work through some refactors.

@elliottmangham
Copy link
Author

Hi @peterramsing, no worries! Thanks a bunch for looking into it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants