A lightweight wrapper on top of
css-to-react-native
to allow valid CSS to be turned into React Native Stylesheet objects.
To keep things simple it only transforms class selectors (e.g. .myClass {}) and grouped class selectors (e.g. .myClass, .myOtherClass {}). Parsing of more complex selectors can be added as a new feature behind a feature flag (e.g. transform(css, { parseAllSelectors: true })) in the future if needed.
Parsing the CSS Modules (ICSS) :export is supported. The :export is often used to share variables from CSS or from a preprocessor like Sass/Less/Stylus to Javascript:
When CSS Viewport Units are used, a special __viewportUnits feature flag is added to the result. This is done so that the implementation that transforms viewport units to pixels knows that the style object has viewport units inside it, and can avoid doing extra work if the style object does not contain any viewport units.
For rem unit the root element font-size is currently set to 16 pixels. A
setting needs to be implemented to allow the user to define the root element
font-size.
There is also support for the box-shadow shorthand, and this converts into
shadow- properties. Note that these only work on iOS.
Dependencies
This library has the following packages as dependencies: