mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 08:50:06 +02:00
first react view up
This commit is contained in:
parent
c76963d86e
commit
a7b23e0342
5 changed files with 88 additions and 3 deletions
|
@ -1,10 +1,12 @@
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
var Backbone = require('backbone');
|
var Backbone = require('backbone');
|
||||||
|
var React = require('react');
|
||||||
|
|
||||||
var util = require('../util');
|
var util = require('../util');
|
||||||
var intl = require('../intl');
|
var intl = require('../intl');
|
||||||
var LocaleStore = require('../stores/LocaleStore');
|
var LocaleStore = require('../stores/LocaleStore');
|
||||||
var LocaleActions = require('../actions/LocaleActions');
|
var LocaleActions = require('../actions/LocaleActions');
|
||||||
|
var Dialog = require('../react_views/TestView.jsx').Dialog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Globals
|
* Globals
|
||||||
|
@ -214,6 +216,12 @@ var initDemo = function(sandbox) {
|
||||||
"levels"
|
"levels"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
if (params.hasOwnProperty('STARTREACT')) {
|
||||||
|
React.render(
|
||||||
|
React.createElement(Dialog, {}),
|
||||||
|
document.getElementById(params['STARTREACT'])
|
||||||
|
);
|
||||||
|
}
|
||||||
if (commands) {
|
if (commands) {
|
||||||
sandbox.mainVis.customEvents.on('gitEngineReady', function() {
|
sandbox.mainVis.customEvents.on('gitEngineReady', function() {
|
||||||
eventBaton.trigger('commandSubmitted', commands.join(''));
|
eventBaton.trigger('commandSubmitted', commands.join(''));
|
||||||
|
|
|
@ -1,11 +1,71 @@
|
||||||
var React = require('react');
|
var React = require('react');
|
||||||
|
|
||||||
var MyComponent = React.createClass({
|
var reactUtil = require('../util/reactUtil');
|
||||||
|
var keyMirror = require('react/lib/keyMirror');
|
||||||
|
|
||||||
|
var STATUSES = keyMirror({
|
||||||
|
IN_QUEUE: null,
|
||||||
|
PROCESSING: null,
|
||||||
|
FINISHED: null
|
||||||
|
});
|
||||||
|
|
||||||
|
var STATUS_TO_CLASS = {};
|
||||||
|
STATUS_TO_CLASS[STATUSES.IN_QUEUE] = 'inqueue';
|
||||||
|
STATUS_TO_CLASS[STATUSES.PROCESSING] = 'processing';
|
||||||
|
STATUS_TO_CLASS[STATUSES.FINISHED] = 'finished';
|
||||||
|
|
||||||
|
var CommandView = React.createClass({
|
||||||
|
|
||||||
|
getInitialState: function() {
|
||||||
|
return {
|
||||||
|
status: STATUSES.IN_QUEUE,
|
||||||
|
rawStr: 'git commit',
|
||||||
|
resultType: '',
|
||||||
|
result: '',
|
||||||
|
formattedWarnings: ''
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
var commandClass = reactUtil.joinClasses([
|
||||||
|
STATUS_TO_CLASS[this.state.status],
|
||||||
|
'commandLine',
|
||||||
|
'transitionBackground'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// TODO add 0px 5px margin to icons
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<p>Howdy</p>
|
<div className="reactCommandView">
|
||||||
|
<p className={commandClass}>
|
||||||
|
<span className="prompt">{'$'}</span>
|
||||||
|
{' ' + this.state.rawStr}
|
||||||
|
<span className="icons transitionAllSlow">
|
||||||
|
<i className="icon-exclamation-sign"></i>
|
||||||
|
<i className="icon-check-empty"></i>
|
||||||
|
<i className="icon-retweet"></i>
|
||||||
|
<i className="icon-check"></i>
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div className={'commandLineResult ' + this.state.resultType}>
|
||||||
|
{this.state.result}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="commandLineWarnings">
|
||||||
|
{this.state.formattedWarnings}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = MyComponent;
|
var Dialog = React.createClass({
|
||||||
|
render: function() {
|
||||||
|
return (
|
||||||
|
<CommandView />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
exports.Dialog = Dialog;
|
||||||
|
|
5
src/js/util/reactUtil.js
Normal file
5
src/js/util/reactUtil.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
var joinClasses = function(classes) {
|
||||||
|
return classes.join(' ');
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.joinClasses = joinClasses;
|
|
@ -443,6 +443,10 @@ div.controls div.box.flex1 div.plus {
|
||||||
|
|
||||||
/* Command Line */
|
/* Command Line */
|
||||||
|
|
||||||
|
div.reactCommandView p.commandLine i {
|
||||||
|
margin: 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
p.commandLine,
|
p.commandLine,
|
||||||
div.commandLineResult {
|
div.commandLineResult {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
|
@ -482,6 +486,12 @@ p.commandLine span.icons i:first-child {
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.reactCommandView p.commandLine span.icons i:first-child {
|
||||||
|
margin-left: 4px;
|
||||||
|
position: relative;
|
||||||
|
left: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
p.commandLine span.icons i {
|
p.commandLine span.icons i {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -473,6 +473,8 @@
|
||||||
</li>
|
</li>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<div id="reactMount" />
|
||||||
|
|
||||||
<!-- The compiled and minified build file (that actually does everything) is below.
|
<!-- The compiled and minified build file (that actually does everything) is below.
|
||||||
For a much easier time perusing the source, see the individual files at:
|
For a much easier time perusing the source, see the individual files at:
|
||||||
https://github.com/pcottle/learnGitBranching
|
https://github.com/pcottle/learnGitBranching
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue