Skip to content

Usage? #80

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

Closed
corysimmons opened this issue Feb 19, 2018 · 7 comments
Closed

Usage? #80

corysimmons opened this issue Feb 19, 2018 · 7 comments

Comments

@corysimmons
Copy link

Like, is there a way to write something like:

/* Buttons.css.js */
export const primary `
  background-color: green;
  padding: 15px 30px;
`

export const danger `
  background-color: red;
  padding: 15px 30px;
`
/* Form.js */
import * as Buttons from './css/Buttons.css'

<Text style={Buttons.primary}>Submit</Text>
<Text style={Buttons.danger}>Delete</Text>

And have css-to-react-native transform it somehow?

Sorry, I see how it works for people who might want to write a plugin for it, but not for casual users just trying to avoid writing standard RN style objects.

@jacobp100
Copy link
Contributor

We are more aimed at plugins. Generally you'd use this with postcss or another CSS parser. Have a look what they do in styled-components.

@corysimmons
Copy link
Author

If it's somewhat trivial to expose to something similar to my use case can this issue be converted to a feature request? If not, go ahead and close.

@jacobp100
Copy link
Contributor

CSS parsers are usually pretty hefty, so adding one would have a huge impact on this library's size. Besides that, all the projects using this do different things with CSS anyway, so there's not really a universal solution to this.

Hope this helps!

@mxstbr
Copy link
Member

mxstbr commented Feb 19, 2018

If you want to avoid writing standard RN style objects then please use styled-components, which lets you write CSS as you're used to on the web.

If you're not happy with the API that s-c exposes then feel free to write your own wrapper around css-to-react-native, but offering more APIs is definitely out of scope of this package 😊

@corysimmons
Copy link
Author

corysimmons commented Feb 19, 2018

styled-components doesn't support media queries in RN.

SC has a really nice approach, but the 2 things I want from it: media queries in RN (required) and PostCSS (a nicety), are shot down as "doesn't interest us [closed/locked]".

So... yeah, if I get time I'll take a shot at implementing my own. Until then I'm stuck with react-native-extended-stylesheet and ugly POJO css.

I was hoping with this lib I could at least sidestep the POJO stuff.

Not upset. Just poking to see what needs built.


Just to be clear, I really appreciate your work and understand my needs not matching your priorities.

@jacobp100
Copy link
Contributor

If you want to live on the edge, check out cssta. We have media queries in the master branch (so add the git repo over the npm package as your dependency)

@corysimmons
Copy link
Author

@jacobp100 Looks awesome! I'm behind deadline on this project but should have it done in a week or two, then I should have a bit of time to contrib. :D

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

3 participants