2014-11-16 16:20:04 +01:00
|
|
|
var React = require('react');
|
|
|
|
var _ = require('lodash');
|
2014-11-25 16:24:54 +01:00
|
|
|
var CodeEditor = require('./aceEditor');
|
2014-11-16 16:20:04 +01:00
|
|
|
'use strict';
|
2014-11-17 12:27:57 +01:00
|
|
|
function onChange1(evt) {
|
|
|
|
this.setState({ 'templateHTML': evt.target.value });
|
|
|
|
}
|
|
|
|
function onChange2(evt) {
|
|
|
|
this.setState({ 'templateProps': evt.target.value });
|
|
|
|
}
|
2014-11-27 17:53:37 +01:00
|
|
|
function onSubmit3(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
2014-11-16 16:20:04 +01:00
|
|
|
module.exports = function () {
|
2014-11-27 17:53:37 +01:00
|
|
|
return React.DOM.div({}, React.DOM.div({
|
|
|
|
'id': 'myTab',
|
|
|
|
'role': 'tabpanel',
|
|
|
|
'className': 'code-area'
|
|
|
|
} /* Nav tabs */, React.DOM.ul({
|
|
|
|
'className': 'nav nav-pills',
|
|
|
|
'role': 'tablist'
|
|
|
|
}, React.DOM.li({
|
|
|
|
'role': 'presentation',
|
|
|
|
'className': 'active'
|
|
|
|
}, React.DOM.a({
|
|
|
|
'href': '#template',
|
|
|
|
'aria-controls': 'template',
|
|
|
|
'role': 'tab',
|
|
|
|
'data-toggle': 'tab'
|
|
|
|
}, 'Template')), React.DOM.li({ 'role': 'presentation' }, React.DOM.a({
|
|
|
|
'href': '#classCode',
|
|
|
|
'aria-controls': 'classCode',
|
|
|
|
'role': 'tab',
|
|
|
|
'data-toggle': 'tab'
|
|
|
|
}, 'Class')), React.DOM.li({ 'role': 'presentation' }, React.DOM.a({
|
|
|
|
'href': '#generatedCode',
|
|
|
|
'aria-controls': 'generatedCode',
|
|
|
|
'role': 'tab',
|
|
|
|
'data-toggle': 'tab'
|
|
|
|
}, 'Generated code'))) /* Tab panes */, React.DOM.div({ 'className': 'tab-content' }, React.DOM.div({
|
|
|
|
'role': 'tabpanel',
|
|
|
|
'className': 'tab-pane active',
|
|
|
|
'id': 'template'
|
|
|
|
}, CodeEditor({
|
2014-11-17 12:27:57 +01:00
|
|
|
'className': 'large-text-area',
|
|
|
|
'style': { border: this.validHTML ? '1px solid black' : '2px solid red' },
|
|
|
|
'value': this.state.templateHTML,
|
2014-11-25 16:24:54 +01:00
|
|
|
'mode': 'html',
|
2014-11-17 12:27:57 +01:00
|
|
|
'onChange': onChange1.bind(this)
|
2014-11-27 17:53:37 +01:00
|
|
|
})), React.DOM.div({
|
|
|
|
'role': 'tabpanel',
|
|
|
|
'className': 'tab-pane',
|
|
|
|
'id': 'classCode'
|
|
|
|
}, CodeEditor({
|
2014-11-17 12:27:57 +01:00
|
|
|
'className': 'large-text-area',
|
|
|
|
'style': { border: this.validProps ? '1px solid black' : '2px solid red' },
|
|
|
|
'value': this.state.templateProps,
|
|
|
|
'mode': 'javascript',
|
|
|
|
'onChange': onChange2.bind(this)
|
2014-11-18 14:00:28 +01:00
|
|
|
})), React.DOM.div({
|
2014-11-27 17:53:37 +01:00
|
|
|
'role': 'tabpanel',
|
|
|
|
'className': 'tab-pane',
|
|
|
|
'id': 'generatedCode'
|
|
|
|
}, CodeEditor({
|
2014-11-18 14:00:28 +01:00
|
|
|
'className': 'large-text-area',
|
|
|
|
'style': { border: '1px solid black' },
|
|
|
|
'value': this.templateSource,
|
|
|
|
'mode': 'javascript',
|
|
|
|
'readOnly': true
|
2014-11-27 17:53:37 +01:00
|
|
|
})))), React.DOM.div({
|
|
|
|
'key': 'result-area',
|
|
|
|
'className': 'result-area well'
|
|
|
|
}, React.DOM.br({}), React.DOM.h2({}, 'Preview:'), React.DOM.form({
|
|
|
|
'className': 'sample-view',
|
|
|
|
'onSubmit': onSubmit3.bind(this)
|
|
|
|
}, this.sample({ 'key': 'sample' }))));
|
2014-11-16 16:20:04 +01:00
|
|
|
};
|