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

Prefix based on hyphen prop(not camel case) #201

Closed
winston0410 opened this issue Jan 17, 2021 · 3 comments
Closed

Prefix based on hyphen prop(not camel case) #201

winston0410 opened this issue Jan 17, 2021 · 3 comments

Comments

@winston0410
Copy link

Is it possible to make inline-style-prefixer prefix based on hyphen prop instead of camelCase? By doing so, I dont have to convert users' input from hyphen to camel-case to hyphen again, thus enhancing the overall performance

@robinweser
Copy link
Owner

Apparently, no. This library aims to prefix inline-style and/or CSS-in-JS style objects which are written in camelCase as that's what the browser APIs default to. In what use-case do you work with kebab-cased properties that need prefixes?

I guess you could check out the prefixer from stylis, which operates on kebab-cased properties instead.

@winston0410
Copy link
Author

Hi @robinweser thank you for your answer. For browser APIs, which one are you referring to? Currently I found camelCase is only used for setting inline styling for component, and I have to use kebab-case set css on a stylesheet with js, through insertRule().
https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule

Ok I think the meaning of the name of this package again after I have written that, I guess I get your point now.

@robinweser
Copy link
Owner

So, this package was originally created for React inline styles which are written in camelCase. Then it got adapted by many CSS-in-JS libraries (especially those operating on objects) and all of those use camelCase properties as well, mainly because it's more readable and easy-to-type in JavaScript.
If you explicitly aim to prefix CSS strings like the ones you pass to insertRule this package might be the wrong solution. In this case the stylis prefixer should be great!

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

No branches or pull requests

2 participants