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

Incorrect CSS emitted for inner media queries #171

Open
vemv opened this issue Feb 4, 2019 · 6 comments
Open

Incorrect CSS emitted for inner media queries #171

vemv opened this issue Feb 4, 2019 · 6 comments

Comments

@vemv
Copy link

vemv commented Feb 4, 2019

The Sass compiler supports "inner media queries" (for lack of a better name, that I know of):

image

I'm failing to replicate that feature with Garden.

This is my attempt:

[:img {:max-width "424px"}
   (at-media {:max-width (u/px 700)}
     {:max-width "100%"})]

But the output is incorrect:

img {
  max-width: 424px;
}

@media (max-width: 700px) {

  max-width: 100%;

}

...In the emitted CSS, the media query lacks the img qualifier.

The following works:

  [[:img {:max-width "424px"}]
   (at-media {:max-width (u/px 700)}
     [:img
      {:max-width "100%"}])]

...but that breaks DRY: the img selector is repeated. In real-world usage the selector may be more complex, with a higher cost for repetition.

Also for bigger stylesheets I find this construction a bit confusing. At least coming from Sass, I see the Sass-style nesting more intuitive.

WDYT?

Thanks - Victor

@noprompt
Copy link
Owner

noprompt commented Feb 4, 2019

I took a quick peek into it and it seems like it should be possible but I'd need to spend a little time investigating it.

@vemv
Copy link
Author

vemv commented Feb 4, 2019

Nice!

@noprompt
Copy link
Owner

@vemv I haven't had a chance to really get into this yet. Apologies.

@vemv
Copy link
Author

vemv commented Feb 16, 2019

No issue 🙌

@green-coder
Copy link

Instead of modifying the CSS generator, I suggest to solve the problem via a function pull-media-query-to-the-root which take a garden data as input and return a garden data as output.

@noprompt
Copy link
Owner

noprompt commented Feb 2, 2021

@green-coder can you submit a patch?

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

3 participants