Code Monkey home page Code Monkey logo

Comments (5)

thabti avatar thabti commented on July 21, 2024

Not sure if React-native css supports media queries. I might make this to be compatible with React. Please note, this module isn't fully complete. @pukhalski

from react-native-css.

punkwang avatar punkwang commented on July 21, 2024

snip20150422_3
snip20150422_4

from react-native-css.

thabti avatar thabti commented on July 21, 2024

@pukhalski yep I noticed that error.

facebook/react-native#971, checking if react-native has support for FS. I will work on it tonight.

from react-native-css.

thabti avatar thabti commented on July 21, 2024

@pukhalski
I will update the doc soon.

I think React-native doesn't have support for node modules. So i found this alternative:

  1. please update to version 1.1.1 of this project: npm install [email protected] --save
  2. make a style.css file with some css styles within your project
  3. add the follow to your package.json scripts json path:
  "scripts": {
    "css": "node_modules/.bin/rncss -i style.css -o style.js",
    "start": "npm run css && node_modules/react-native/packager/packager.sh"
  }

notice rncss!

node_modules/.bin/rncss -i SOURCE_CSS_PATH_AND_FILE_NAME.css -o PATH_TO_AND_JS_FILENAME.js

what css script will do is, take an input (-i) css file and out (`-o') javascript file name, it will generate the follow:

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

then within index.ios.js' just require in the generatedstyle.js`:

var styles = require('./style')

full example of the demo app:

'use strict';

var React = require('react-native');
var {
  AppRegistry,
  StyleSheet,
  Text,
  View,
} = React;

var styles = require('./style')

var saybrrlinksapps = React.createClass({
  render: function() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
        <Text style={styles.instructions}>
          To get started, edit index.ios.js
        </Text>
        <Text style={styles.instructions}>
          Press Cmd+R to reload,{'\n'}
          Cmd+Control+Z for dev menu
        </Text>
      </View>
    );
  }
});


AppRegistry.registerComponent('saybrrlinksapps', () => saybrrlinksapps);

We lose the refresh command, I will see if I can hooking the packager and get it to execute this module. For now just open another terminal and run:
node_modules/.bin/rncss -i SOURCE_CSS_PATH_AND_FILE_NAME.css -o PATH_TO_AND_JS_FILENAME.js

from react-native-css.

thabti avatar thabti commented on July 21, 2024

@pukhalski a new version with file watching has been added, ignore the text above.
[email protected] improves the cli

from react-native-css.

Related Issues (20)

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.