robinweser / fela

State-Driven Styling in JavaScript
http://fela.js.org
MIT License
2.27k stars 182 forks source link

[fela-plugin-prefixer] use UserAgent to avoid unnecessary style props #157

Closed menelike closed 7 years ago

menelike commented 7 years ago

It would be great if fela-plugin-prefixer would use the UserAgent if available. This should be conflict free with https://github.com/rofrischmann/inline-style-prefixer as without a proper UserAgent it would switch to static behaviour (fallback).

If using an unsupported browser or even run without any userAgent, it will use inline-style-prefixer/static as a fallback.

Because of this we had to remove fela-preset-web and create the plugin list manually.

const prefixer = new Prefixer({ userAgent: navigator.userAgent });
const renderer = createRenderer({
  plugins: [
    (style = {}) => prefixer.prefix(style),
    fallbackValue(),
    lvha(),
    unit(),
  ],
});

This is just an enhancement for better convenience

robinweser commented 7 years ago

How about using the fela-plugin-dynamic-prefixer instead ;)? I use the static version as it saves a lot of bytes. Anyways prefixing will be improved soon. While the static prefixer already adds prefixes to the atomic declarations itself, the dynamic version creates new classes for every prefixed property, due to behaviour.

menelike commented 7 years ago

I missed that, sorry for that. Make absolute sense why there are two prefixer available. Still it might make sense to merge both prefixer into a single one at some point.

On a sidenote:

It's a tough challenge these days to pick the right react/css solution. After several attempts at different implementations (jss, styletron, styled-components etc.) we're quiet happy about fela, great concept, great API. Thanks a lot!

robinweser commented 7 years ago

Np :P Great to hear that! Feel free to join us on Gitter with any question :)