use jsx transformer

This commit is contained in:
Riku Rouvila
2015-01-22 00:25:52 +02:00
parent 92d7790b4a
commit 61668679a9
3 changed files with 44 additions and 28 deletions

14
jsx-transform.js Normal file
View File

@@ -0,0 +1,14 @@
'use strict';
var through = require('through2');
var jsx = require('jsx-transform');
module.exports = function(file) {
return through(function (buf, enc, next) {
this.push(jsx.transform(buf.toString('utf8'), {
ignoreDocblock: true,
jsx: 'h'
}));
next();
});
};

View File

@@ -38,17 +38,20 @@
"gulp-stylus": "1.3.3",
"gulp-uglify": "~1.0.1",
"gulp-util": "~3.0.1",
"jsx-transform": "^0.10.1",
"karma": "~0.12.21",
"karma-chrome-launcher": "~0.1.4",
"karma-cli": "0.0.4",
"karma-coffee-preprocessor": "~0.2.1",
"karma-jasmine": "~0.2.2",
"pretty-hrtime": "~0.2.2",
"through2": "^0.6.3",
"vinyl-source-stream": "~1.0.0",
"watchify": "~2.0.0"
},
"browserify": {
"transform": [
"./jsx-transform",
"6to5ify",
"debowerify",
"deamdify"

View File

@@ -4,37 +4,36 @@ var {h} = require('virtual-dom');
var classList = require('../util/classList');
function render(props, state) {
var emailInput = h('input', {
className: classList({
'input': true,
'has-success': state.submitted,
'has-error': state.error
}),
type: 'text',
name: 'email',
placeholder: 'Email',
value: state.email,
onkeydown: props.onChange
var formClasses = classList({
'invite-form': true,
'has-success': state.submitted,
'has-error': state.error
});
var submitButton = h('button', {
className: 'btn btn__submit',
type: 'submit',
title: 'Lähetä',
disabled: state.error || state.submitted
}, '⏎');
var inputClasses = classList({
'input': true,
'has-success': state.submitted,
'has-error': state.error
});
return h('form', {
className: classList({
'invite-form': true,
'has-success': state.submitted,
'has-error': state.error
}),
onsubmit: props.onSubmit
}, [
emailInput,
submitButton
]);
return (
<form className={formClasses} onsubmit={props.onSubmit}>
<input
className={inputClasses}
type='text'
name='email'
placeholder='email'
value={state.email}
onkeydown={props.onChange} />
<button
className='btn btn__submit'
type='submit'
title='Lähetä'
disabled={state.error || state.submitted}>
</button>
</form>
)
}
module.exports = render;