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

renderStatic doesn't render media query from a style object #465

Closed
isymchych opened this issue Nov 8, 2017 · 8 comments
Closed

renderStatic doesn't render media query from a style object #465

isymchych opened this issue Nov 8, 2017 · 8 comments

Comments

@isymchych
Copy link
Contributor

Type: Bug

Packages Version
fela 6.0.x

Description

renderer.renderStatic doesn't render media query from a style object

Steps to reproduce

renderer.renderStatic({
  '@media (max-width: 9999px)': {
    display: 'none',
  },
}, 'html');

Expected Behavior

Page content should be hidden

Actual Behavior

Page content is visible

<style data-fela-type="STATIC" type="text/css">html{}</style>
@robinweser
Copy link
Owner

Hmm, yeah. Actually this is not supported at the moment. But @supports and @media seem like valid rule extensions for static styles as well. I will perhaps write an enhancer for it, because I don't want to bloat the APIs.

Thanks for reporting, never "needed" this functionality by now!

@isymchych
Copy link
Contributor Author

isymchych commented Nov 8, 2017

I assumed it was a bug cause media queries work in renderStatic if style is a string, also they work fine inside rules, so I had a feeling that they should also work in style objects ¯\_(ツ)_/¯

@robinweser
Copy link
Owner

yeah thats true. maybe I can refactor the logic of rule rendering to reuse it for static rendering as well.

@oschade
Copy link

oschade commented Mar 27, 2018

It's the same with pseudo classes like ":selection" or ":before". It's an unexpected behaviour, that they work with "renderRule" bot not with "renderStatic".

@milesj
Copy link
Contributor

milesj commented Jun 27, 2019

Just ran into this. It would be nice if renderStatic supported full nested objects (pseudos, media, etc) like other rules do.

@IgorBabkin
Copy link
Contributor

@robinweser Any news? How to add media queries for html?

@robinweser
Copy link
Owner

robinweser commented Mar 4, 2020

I'm still not sure if I want to add that at all. Fela is not about static styles and thus adding more complexity just for the sake of some DX/readability improvements is not really worth it in my eyes.

If you need some special media query styles you can always just pass a string e.g.

renderer.renderStatic(`
body {
  margin: 10px
}

@media (min-width: 320px) {
  body {
    margin: 20px
  }
}`)

@robinweser
Copy link
Owner

I'm actually going to close this as I want to keep it simple.

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

5 participants