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

In some cases, the value should be number, not text #1

Open
tvkhoa opened this issue Nov 20, 2016 · 1 comment
Open

In some cases, the value should be number, not text #1

tvkhoa opened this issue Nov 20, 2016 · 1 comment

Comments

@tvkhoa
Copy link

tvkhoa commented Nov 20, 2016

Example: When you parse { padding-top: 10 }.

The resut should be { paddingTop: 10 } instead of { paddingTop: '10' }

It's better if we can config it to ignore px value.
{ padding-top: 10px } -> { paddingTop: 10 }

@tungv
Copy link
Owner

tungv commented Nov 20, 2016

Thanks for your report.
I think it seems trivial at first, however, the root problem is more hideous.
there are a lot of differences between styling react-dom and react-native.

By just looking at the code, I can spot one of the differences: unlike react-dom, react-native has a strict prop type on every css prop. The provided css prop must be included in a predefined list, and its value must satisfy the predefined React.PropTypes function. (Note that all of these constraints are checked only on development env).

After researching, I found that by default, react-native doesn't support other units (other than px) like percent, rem, pt, inches, etc. Some external efforts like react-natvie-extended-stylesheet are made to address those sets of problems.

Based on those differences, I don't recommend you to use css-template on react-native, because it's not css by any definition. If you like the idea behind css-template, I think you can create css-template-native and solve those native-specific problems in there.

However, if you understand the differences and still want to use this lib. I'd like to collect ideas how to force css-template to use numbers? for example: { padding-top: ${10} }

@tungv tungv closed this as completed Nov 20, 2016
@tungv tungv reopened this Nov 20, 2016
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