Skip to content

Commit

Permalink
Updated babel
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielbull committed Feb 23, 2016
1 parent fa9a985 commit a8d4b17
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 35 deletions.
9 changes: 8 additions & 1 deletion .babelrc
@@ -1,3 +1,10 @@
{
"stage": 0
"presets": [
"es2015",
"stage-0",
"react"
],
"plugins": [
"transform-decorators-legacy"
]
}
2 changes: 1 addition & 1 deletion docs/windows/progress-circle.md
Expand Up @@ -23,7 +23,7 @@ export default class extends Component {
return (
<ProgressCircle
color={this.props.color}
size="100"
size={100}
/>
);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/windows/progress-circle.js
Expand Up @@ -10,7 +10,7 @@ export default class extends Component {
return (
<ProgressCircle
color={this.props.color}
size="100"
size={100}
/>
);
}
Expand Down
18 changes: 11 additions & 7 deletions package.json
Expand Up @@ -31,14 +31,18 @@
"react-dom": "~0.14"
},
"devDependencies": {
"babel": "^5.8.35",
"babel-core": "^5.8.35",
"babel-eslint": "^4.1.6",
"babel-loader": "^5.4.0",
"babel": "^6.5.2",
"babel-core": "^6.5.2",
"babel-eslint": "^5.0.0",
"babel-loader": "^6.2.3",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-es2015": "^6.5.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"chai": "^3.5.0",
"eslint": "^1.10.3",
"eslint-plugin-react": "^3.16.1",
"html-webpack-plugin": "^1.7.0",
"eslint": "^2.2.0",
"eslint-plugin-react": "^4.0.0",
"html-webpack-plugin": "^2.9.0",
"jsdom": "^8.0.1",
"mocha": "^2.4.5",
"react": "^0.14.7",
Expand Down
11 changes: 6 additions & 5 deletions playground/examples-loader.js
Expand Up @@ -27,16 +27,17 @@ module.exports = function(source) {
var dirname = path.join(__dirname, '..');
var files = scanDir(path.join(dirname, 'examples'));
var file;
var data;

source = 'var data = {};\n';
source = 'let data = {};\n';
for (var i = 0, len = files.length; i < len; ++i) {
file = files[i];
var filename = file.file.replace(dirname, '').replace(/\.js$/, '');
data = 'data[\'' + filename + '\'] = require(\'..' + filename + '\');\n';
source = source + data;
var key = filename.replace(/[\/\-]/g, '_');
source += 'import ' + key + ' from \'..' + filename + '\';\n';
source += 'data[\'' + filename + '\'] = ' + key + ';\n';
}
source = source + '\nmodule.exports = data;\n';

source += 'export default data;';

return source;
};
33 changes: 16 additions & 17 deletions playground/ui/examples/examples.js
Expand Up @@ -32,39 +32,38 @@ class Examples extends Component {
list: PropTypes.object
};

click = (key) => {
key = (this.props.path + '/' + key).replace(/^\//, '');
click = (category, key) => {
key = (category + '/' + key).replace(/^\//, '');
this.context.playground.showExample(key);
};

render() {
let name = this.props.name ? <h1 style={styles.title}>{this.props.name}</h1> : null;

return (
<div>
{name}
{this.renderItems()}
{this.renderCategories(this.props.list)}
</div>
);
}

renderItems() {
renderCategories(categories) {
let children = [];
for (let prop in this.props.list) {
if (this.props.list.hasOwnProperty(prop)) {
let item = this.props.list[prop];
if (typeof item === 'function') {
children.push(this.renderItem(item, prop));
} else {
children.push(<Examples key={prop} name={prop} list={item} path={(this.props.path || '') + '/' + prop}/>);
}
for (let prop in categories) {
if (categories.hasOwnProperty(prop)) {
children.push(<h1 key={prop} style={styles.title}>{prop}</h1>);
children.push(...this.renderItems(prop, categories[prop]));
}
}
return children;
}

renderItem(item, key) {
return <a key={key} style={styles.item} onClick={() => this.click(key)}>{key}</a>
renderItems(category, items) {
let children = [];
for (let prop in items) {
if (items.hasOwnProperty(prop)) {
children.push(<a key={category + '/' + prop} style={styles.item} onClick={() => this.click(category, prop)}>{prop}</a>);
}
}
return children;
}
}

Expand Down
4 changes: 2 additions & 2 deletions playground/webpack.config.js
Expand Up @@ -51,12 +51,12 @@ module.exports = {
loaders: [
{
test: /\?examples/,
loaders: ['babel-loader?stage=0', 'examples-loader']
loaders: ['babel', 'examples-loader']
},
{
test: /\.(js)$/,
exclude: /node_modules/,
loader: 'babel-loader?stage=0'
loader: 'babel'
}
]
},
Expand Down
Expand Up @@ -9,7 +9,7 @@ class ProgressRingWindows extends Component {
static propTypes = {
absolute: PropTypes.bool,
color: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
size: PropTypes.number
size: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
};

componentDidMount() {
Expand Down

0 comments on commit a8d4b17

Please sign in to comment.