started creating spreadsheet component
This commit is contained in:
24
app/components/Application.react.js
Normal file
24
app/components/Application.react.js
Normal file
@@ -0,0 +1,24 @@
|
||||
/** @jsx React.DOM */
|
||||
|
||||
var React = require('react');
|
||||
var ChooseFile = require('./ChooseFile.react');
|
||||
var SpreadSheet = require('./SpreadSheet.react');
|
||||
|
||||
var Application = React.createClass({
|
||||
|
||||
render: function () {
|
||||
return (
|
||||
<div>
|
||||
<div className="menu">
|
||||
<ChooseFile />
|
||||
</div>
|
||||
<div className="spreadsheet">
|
||||
<SpreadSheet />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = Application;
|
||||
@@ -1,12 +1,23 @@
|
||||
/** @jsx React.DOM */
|
||||
|
||||
var React = require('react');
|
||||
|
||||
var ChooseFile = React.createClass({
|
||||
|
||||
render: function() {
|
||||
return (
|
||||
<button className="red-button">ChooseFile</button>
|
||||
);
|
||||
}
|
||||
getInitialState: function () {
|
||||
return {fileName: ""};
|
||||
},
|
||||
|
||||
render: function () {
|
||||
if (this.state.fileName === "") {
|
||||
return (<input type="file" accept=".csv" onChange={this._onChange}/>);
|
||||
} else
|
||||
return (<div>Editing file.</div>);
|
||||
},
|
||||
|
||||
_onChange: function(e) {
|
||||
this.setState({fileName: e.target.value})
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = ChooseFile;
|
||||
@@ -1,16 +1,38 @@
|
||||
/** @jsx React.DOM */
|
||||
|
||||
var React = require('react');
|
||||
var ChooseFile = require('./ChooseFile.react');
|
||||
var LocalStore = require('../stores/LocalStore');
|
||||
|
||||
|
||||
var getStateFromStore = function () {
|
||||
return {
|
||||
columns: LocalStore.getColumns(),
|
||||
data: LocalStore.getDataForColumns()
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var SpreadSheet = React.createClass({
|
||||
|
||||
render: function() {
|
||||
return (
|
||||
<div className="spreadsheet">
|
||||
<ChooseFile />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
getInitialState: function() {
|
||||
return getStateFromStore();
|
||||
},
|
||||
|
||||
render: function () {
|
||||
|
||||
var columns = this.state.columns.map(function (column) {
|
||||
return(<th>{column}</th>);
|
||||
});
|
||||
|
||||
|
||||
return (
|
||||
<table className="spreadsheet">
|
||||
<tr>
|
||||
{columns}
|
||||
</tr>
|
||||
</table>
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user