JSPM

css-to-react-native-stylesheet

0.0.7
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q33105F
  • License MIT

Transform a css file into a React Native stylesheet.

Package Exports

  • css-to-react-native-stylesheet

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (css-to-react-native-stylesheet) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

css-to-react-native-stylesheet

Transform a css file into a React Native stylesheet. This is a command line tool that uses css-to-react-native-transform to transform a file with valid CSS into a file that contains a React Native stylesheet. The result is not escaped or stringified to json, it is a valid stylesheet.

Installation:

npm i css-to-react-native-stylesheet -g

Usage:

transform [options] <css_file> [file_to]

Options:

-h, --help  output usage information

Example usage:

csstransform transform "D:\Testing\csstest\example.css" kittens.js

Outputs the result in the named file, or to "result.js" if no file_to is specified.

Example:

csstransform transform example.css
.myClass {
  font-size: 18px;
  line-height: 24px;
  color: red;
}

.other {
  padding: 1rem;
}

is transformed into a file that contains:

import { StyleSheet } from 'react-native';

export default StyleSheet.create({ 
    myClass: { 
        fontSize: 18, 
        lineHeight: 24,
        color: 'red' 
        },
    other: { 
        paddingTop: 16, 
        paddingRight: 16, 
        paddingBottom: 16, 
        paddingLeft: 16 
        } 
});