mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-10 17:52:47 +00:00
Added the new pages and router
This commit is contained in:
25
client/homebrew/editPage/editPage.jsx
Normal file
25
client/homebrew/editPage/editPage.jsx
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
var React = require('react');
|
||||||
|
var _ = require('lodash');
|
||||||
|
var cx = require('classnames');
|
||||||
|
|
||||||
|
var EditPage = React.createClass({
|
||||||
|
getDefaultProps: function() {
|
||||||
|
return {
|
||||||
|
text : "",
|
||||||
|
id : null
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
render : function(){
|
||||||
|
var self = this;
|
||||||
|
return(
|
||||||
|
<div className='editPage'>
|
||||||
|
{this.props.id}
|
||||||
|
EditPage Ready!
|
||||||
|
{this.props.text}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = EditPage;
|
||||||
3
client/homebrew/editPage/editPage.less
Normal file
3
client/homebrew/editPage/editPage.less
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
.editPage{
|
||||||
|
|
||||||
|
}
|
||||||
46
client/homebrew/homePage/homePage.jsx
Normal file
46
client/homebrew/homePage/homePage.jsx
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
var React = require('react');
|
||||||
|
var _ = require('lodash');
|
||||||
|
var cx = require('classnames');
|
||||||
|
|
||||||
|
var PHB = require('../phb/phb.jsx');
|
||||||
|
var Editor = require('../editor/editor.jsx');
|
||||||
|
|
||||||
|
var KEY = 'naturalCrit-homebrew';
|
||||||
|
|
||||||
|
var HomePage = React.createClass({
|
||||||
|
|
||||||
|
getInitialState: function() {
|
||||||
|
return {
|
||||||
|
text: "# Welcome"
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
componentDidMount: function() {
|
||||||
|
var storage = localStorage.getItem(KEY);
|
||||||
|
if(storage){
|
||||||
|
this.setState({
|
||||||
|
text : storage
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
handleTextChange : function(text){
|
||||||
|
this.setState({
|
||||||
|
text : text
|
||||||
|
});
|
||||||
|
|
||||||
|
localStorage.setItem(KEY, text);
|
||||||
|
},
|
||||||
|
|
||||||
|
render : function(){
|
||||||
|
var self = this;
|
||||||
|
return(
|
||||||
|
<div className='homePage'>
|
||||||
|
<Editor text={this.state.text} onChange={this.handleTextChange} />
|
||||||
|
<PHB text={this.state.text} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = HomePage;
|
||||||
3
client/homebrew/homePage/homePage.less
Normal file
3
client/homebrew/homePage/homePage.less
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
.homePage{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,63 +4,33 @@ var cx = require('classnames');
|
|||||||
|
|
||||||
var CreateRouter = require('pico-router').createRouter;
|
var CreateRouter = require('pico-router').createRouter;
|
||||||
|
|
||||||
var PHB = require('./phb/phb.jsx');
|
var HomePage = require('./homePage/homePage.jsx');
|
||||||
var Editor = require('./editor/editor.jsx');
|
var EditPage = require('./editPage/editPage.jsx');
|
||||||
|
var SharePage = require('./sharePage/sharePage.jsx');
|
||||||
|
|
||||||
//var Snippets = require('./editor/snippets');
|
|
||||||
|
|
||||||
var KEY = 'naturalCrit-homebrew';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var Router = CreateRouter({
|
|
||||||
'/homebrew' : 'home',
|
|
||||||
'/homebrew/edit/:id' : function(args){
|
|
||||||
|
|
||||||
},
|
|
||||||
'/homebrew/share/:id' : function(args){
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
var Router;
|
||||||
var Homebrew = React.createClass({
|
var Homebrew = React.createClass({
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
return {
|
return {
|
||||||
|
url : "",
|
||||||
text : ""
|
text : ""
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
componentWillMount: function() {
|
||||||
getInitialState: function() {
|
Router = CreateRouter({
|
||||||
return {
|
'/homebrew/edit/:id' : (args) => {
|
||||||
text : "# Holla"
|
return <EditPage id={args.id} text={this.props.text} />
|
||||||
};
|
},
|
||||||
},
|
'/homebrew/share/:id' : (args) => {
|
||||||
|
return <SharePage id={args.id} text={this.props.text} />
|
||||||
componentDidMount: function() {
|
},
|
||||||
var storage = localStorage.getItem(KEY);
|
'/homebrew*' : <HomePage />,
|
||||||
if(storage){
|
|
||||||
this.setState({
|
|
||||||
text : storage
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
handleTextChange : function(text){
|
|
||||||
this.setState({
|
|
||||||
text : text
|
|
||||||
});
|
});
|
||||||
|
|
||||||
localStorage.setItem(KEY, text);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render : function(){
|
render : function(){
|
||||||
var self = this;
|
|
||||||
return(
|
return(
|
||||||
<div className='homebrew'>
|
<div className='homebrew'>
|
||||||
<Editor text={this.state.text} onChange={this.handleTextChange} />
|
<Router initialUrl={this.props.url}/>
|
||||||
<PHB text={this.state.text} />
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
17
client/homebrew/navbar/navbar.jsx
Normal file
17
client/homebrew/navbar/navbar.jsx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
var React = require('react');
|
||||||
|
var _ = require('lodash');
|
||||||
|
var cx = require('classnames');
|
||||||
|
|
||||||
|
var Navbar = React.createClass({
|
||||||
|
|
||||||
|
render : function(){
|
||||||
|
var self = this;
|
||||||
|
return(
|
||||||
|
<div className='navbar'>
|
||||||
|
Navbar Ready!
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = Navbar;
|
||||||
3
client/homebrew/navbar/navbar.less
Normal file
3
client/homebrew/navbar/navbar.less
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
.navbar{
|
||||||
|
|
||||||
|
}
|
||||||
17
client/homebrew/sharePage/sharePage.jsx
Normal file
17
client/homebrew/sharePage/sharePage.jsx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
var React = require('react');
|
||||||
|
var _ = require('lodash');
|
||||||
|
var cx = require('classnames');
|
||||||
|
|
||||||
|
var SharePage = React.createClass({
|
||||||
|
|
||||||
|
render : function(){
|
||||||
|
var self = this;
|
||||||
|
return(
|
||||||
|
<div className='sharePage'>
|
||||||
|
SharePage Ready!
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = SharePage;
|
||||||
3
client/homebrew/sharePage/sharePage.less
Normal file
3
client/homebrew/sharePage/sharePage.less
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
.sharePage{
|
||||||
|
|
||||||
|
}
|
||||||
17
client/homebrew/statusbar/statusbar.jsx
Normal file
17
client/homebrew/statusbar/statusbar.jsx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
var React = require('react');
|
||||||
|
var _ = require('lodash');
|
||||||
|
var cx = require('classnames');
|
||||||
|
|
||||||
|
var Statusbar = React.createClass({
|
||||||
|
|
||||||
|
render : function(){
|
||||||
|
var self = this;
|
||||||
|
return(
|
||||||
|
<div className='statusbar'>
|
||||||
|
Statusbar Ready!
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = Statusbar;
|
||||||
3
client/homebrew/statusbar/statusbar.less
Normal file
3
client/homebrew/statusbar/statusbar.less
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
.statusbar{
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user