Skip to content

Commit

Permalink
Rewrite example in ES6
Browse files Browse the repository at this point in the history
  • Loading branch information
javivelasco committed Sep 21, 2015
1 parent 4b834a0 commit 66fcb6d
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 70 deletions.
3 changes: 3 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"react": ">=0.13"
},
"devDependencies": {
"babel-core": "^5.8.23",
"babel-loader": "^5.3.2",
"babel-runtime": "^5.8.20",
"coffee-jsx-loader": "^0.1.2",
"css-loader": "^0.15.1",
"extract-text-webpack-plugin": "^0.8.2",
Expand Down
32 changes: 0 additions & 32 deletions example/src/app.cjsx

This file was deleted.

33 changes: 33 additions & 0 deletions example/src/app.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* global React */

// React-Toolbox full dependency way:
// import {Button, Form} from 'react-toolbox'

// Standalone dependencies way:
import Button from 'react-toolbox/components/button';
import Form from 'react-toolbox/components/form';

const App = React.createClass({
getInitialState () {
return {
fields: [
{ ref: 'username', label: 'Your username', required: true},
{ ref: 'password', type: 'password', label: 'Your password', required: true},
{ type: 'submit', label: 'Login', disabled: true}
]
};
},

render () {
return (
<app data-toolbox={true}>
<h1>Hello React-Toolbox</h1>
<Form attributes={this.state.fields} />
<Button label='Hello world!' type='square' style='primary'/>
<Button icon='adb' type='circle' style='accent' />
</app>
);
}
});

React.render(<App />, document.body);
38 changes: 0 additions & 38 deletions example/webpack.config.coffee

This file was deleted.

36 changes: 36 additions & 0 deletions example/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
var pkg = require('./package.json');
var node_modules = __dirname + '/node_modules';
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var environment = process.env.NODE_ENV;

module.exports = {
cache: true,
resolve: {
extensions: ['', '.jsx', '.cjsx', '.coffee', '.js', '.json', '.styl']
},
context: __dirname,
entry: {
commons: ['./node_modules/react-toolbox/components/commons.styl'],
test: ['webpack/hot/dev-server', './src/app.jsx']
},
output: {
path: environment === 'production' ? './dist' : './build',
filename: pkg.name + '.[name].js',
publicPath: '/build/'
},
devServer: {
host: '0.0.0.0',
port: 8080,
inline: true
},
module: {
noParse: [node_modules + '/react/dist/*.js'],
loaders: [
{ test: /(\.js|\.jsx)$/, exclude: /(node_modules)/, loader: 'babel?optional=runtime'},
{ test: /\.cjsx$/, loader: 'coffee-jsx-loader'},
{ test: /\.coffee$/, loader: 'coffee-jsx-loader'},
{ test: /\.styl$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss-loader!stylus-loader!')}
]
},
plugins: [new ExtractTextPlugin(pkg.name + '.[name].css', {allChunks: false})]
};

0 comments on commit 66fcb6d

Please sign in to comment.