Git Product home page Git Product logo

react-native-css's Introduction

We are looking for additional contributors

Raise and issue and I will add you. After a PR.

react-native-css (and SCSS) Circle CI NPM

React-native-css turns valid CSS/SASS into the Facebook subset of CSS.

Install

Global

npm install react-native-css -g

Command Line Interface

React-native-css comes with a cli and you can watch a file and compile it.

# example 1
react-native-css -i INPUT_CSS_FILE -o OUTPUT_JS_FILE --watch
# example 2
react-native-css -i INPUT_CSS_FILE -o OUTPUT_JS_FILE --watch --pretty
# example 3
react-native-css INPUT_CSS_FILE OUTPUT_JS_FILE -w
react-native-css -i style.css -o style.js -w

Flags

  • "-w" or "--watch" - watch for changes and recompile.
  • "-i" takes a input (optional)
  • "-o" takes an output path (optional)
  • "-p" or "--pretty" - pretty print the resulting compiled output
  • "-l" or "--literal" - generates a javascript literal object without StyleSheet.create wrapper

Screenshot

the workflow

Example

Given the following CSS:

description {
  margin-bottom: 20px;
  font-size: 18px;
  text-align: center;
  color: #656656;
}

container {
  padding: 30px;
  margin-top: 65px;
  align-items: center;
  display: block;
}

React-native-css will generate to the following:

// style.js
module.exports = require('react-native').StyleSheet.create(
  {"description":{"marginBottom":20,"fontSize":18,"textAlign":"center","color":"#656656"},"container":{"padding":30,"marginTop":65,"alignItems":"center"}}
  );

You can make use of --literal argument and instead it will generate:

// style.js
module.exports = {
  "description":{"marginBottom":20,"fontSize":18,"textAlign":"center","color":"#656656"},"container":{"padding":30,"marginTop":65,"alignItems":"center"}
  }

Usage

// require the generated style file
var styles = require('./style.js')
 //{"description":{"marginBottom":20,"fontSize":18,"textAlign":"center","color":"#656656"},"container":{"padding":30,"marginTop":65,"alignItems":"center"}}


class SearchPage extends Component {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.description}>
        Buy
        </Text>

      </View>
    );
  }
}

react-native-css's People

Contributors

alexmick avatar alfonsodev avatar caiosba avatar davidgruebl avatar drmabuse23 avatar explodingcabbage avatar irfaan avatar jxpearce-godaddy avatar martnu avatar originalgremlin avatar paulomenezes avatar thabti avatar tylermcginnis avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.