Skip to content

Thought this was CSS to react native StyleSheet object? #50

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
NordlingDev opened this issue Oct 25, 2017 · 3 comments
Closed

Thought this was CSS to react native StyleSheet object? #50

NordlingDev opened this issue Oct 25, 2017 · 3 comments

Comments

@NordlingDev
Copy link

NordlingDev commented Oct 25, 2017

The module does the exact opposite. You take StyleSheet object and turn it into a CSS string with the transform function:

import CSS from "css-to-react-native";

CSS({
    test: {
        color: "#ff0000"
    }
}); // Returns CSS string: ".test { color: #ff0000; }"

But I thought this is what it was supposed to do:

import CSS from "css-to-react-native";

CSS(`
    .test {
        color: #ff0000
    }
`); // Should return: { test: { color: "#ff0000" } }

What am I missing? There is nothing documented on how to actually convert CSS to a React Native StyleSheet object.

Thanks in advance!

@jacobp100
Copy link
Contributor

Look at the readme for the docs! It does convert css to react native objects.

Note that it only converts css declarations, not rules. You’ll want to look into styled-components for how that’s done.

@mxstbr mxstbr closed this as completed Oct 25, 2017
@brunolemos
Copy link
Member

brunolemos commented Nov 12, 2017

@jacobp100 @NordlingArt any hidden way to do the opposite? rn obj to css string?
Tried the code above but didn't work. Also didn't find this on the source code

e.g.

input: { backgroundColor: 'red' }
output: background-color: red

input: { opacity: 1, fontSize: 10 } (need to check manually where to add px?)
output: opacity:1;fontSize:10px

input: { borderColor: 'red', borderWidth: 1, borderStyle: 'solid' }
output: border: 1px solid red

@jacobp100
Copy link
Contributor

This package won’t do that.

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

4 participants