Git Product home page Git Product logo

rax's Introduction

Rax

A hyperscript render engine.


Community


Fast: blazing fast virtual DOM.

🎯 Tiny: 12.6 KB minified + gzipped.

🎨 Universal: works in browsers, Weex, Node.js, Mini-program, WebGL and could works more container that implement driver specification.

Quick Start

Install the Rax CLI tools to init project:

$ npm install rax-cli -g
$ rax init <YourProjectName>

Start local server to launch project:

$ cd YourProjectName
$ npm run start

Example

JSX DSL

// Hello.jsx
import {createElement, Component} from 'rax';

export default class extends Component {
  state = {
    name: 'world'
  };
  onChange = ()=>{
    this.setState({
      name: 'rax'
    });
  };
  render() {
    return (
      <view style={styles.hello}>
        <text style={styles.title} onClick={this.onChange}>
        Hello {this.state.name}
        </text>
      </view>
    );
  }
}

const styles = {
  hello: {
    flexDirection: 'column',
    justifyContent: 'center',
    alignItems: 'center'
  },
  title: {
    fontSize: '40px',
    textAlign: 'center'
  }
};

SFC(Single File Component) DSL

SFC is a Vue-like DSL that will compile to JSX DSL.

<!-- hello.html -->
<template>
  <view class="hello">
    <text class="title" @click="change">Hello {{name}}</text>
  </view>
</template>

<script>
  export default {
    data: function () {
      return {
        name: 'world'
      }
    },
    methods: {
      change () {
        this.name = 'rax';
      }
    }
  }
</script>

<style>
  .hello {
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  .title {
    font-size: 40px;
    text-align: center;
  }
</style>
// app.js
import {render} from 'rax';
import Hello from './hello';

render(<Hello name="world" />);

Rax Renderers

Compatible with React Components

Usage with Webpack or Babel makes React-based components work with Rax, without any code changes.

Usage with Webpack

Add an alias for react and react-dom:

{
  // ...
  resolve: {
    alias: {
      'react': 'rax',
      'react-dom': 'rax-dom',
      // Not necessary unless you consume a module using `createClass`
      'create-react-class': "rax/lib/createClass"
    }
  }
  // ...
}

Usage with Babel

Install the babel plugin for aliasing: npm install --save-dev babel-plugin-module-resolver

Add an alias for react and react-dom in your .babelrc:

{
  // ...
  "plugins": [
    ["module-resolver", {
      "root": ["."],
      "alias": {
        "react": "rax",
        "react-dom": "rax-dom",
        // Not necessary unless you consume a module using `createClass`
        "create-react-class": "rax/lib/createClass"
      }
    }]
  ]
  // ...
}

Developer Tools

  • React Developer Tools: Allow you inspect and modify the state of your Rax components at runtime in Chrome Developer Tools.

React Developer Tools

Redux DevTools extension

Contributing

Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing.

Development Workflow

After cloning rax, run npm install to fetch its dependencies.
Run npm run setup link and bootstrap project before development. Then, you can run several commands:

  • npm run lint checks the code style.
  • npm test runs the complete test suite.
  • npm test -- --watch runs an interactive test watcher.
  • npm test <pattern> runs tests with matching filenames.
  • npm run build creates lib and dist folder with all the packages.
  • npm start start local server with examples folder.

Core Team


@yuanyan

Core


@imsobear

Development


@yacheng

Components


@boiawang

Babel Loaders & Plugins


@noyobo

Webpack Plugins


⬆ back to top

rax's People

Contributors

yuanyan avatar wssgcg1213 avatar yacheng avatar noyobo avatar boiawang avatar solojiang avatar imsobear avatar playing avatar huxiaoqi567 avatar chenjun1011 avatar franklife avatar zhangmengxue avatar alvinhui avatar tinple avatar yongningfu avatar fengwuxp avatar yujiangshui avatar hijiangtao avatar xcodebuild avatar gengjiawen avatar jasminecjc avatar ahkari avatar azu avatar weekeight avatar buaaljy avatar crazybear avatar leanhunter avatar rccoder avatar leedut avatar zunyan avatar

Watchers

 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.