mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-06 01:22:44 +00:00
Added in an editable title navitem
This commit is contained in:
33
client/homebrew/navbar/editTitle.navitem.jsx
Normal file
33
client/homebrew/navbar/editTitle.navitem.jsx
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
var React = require('react');
|
||||||
|
var _ = require('lodash');
|
||||||
|
var cx = require('classnames');
|
||||||
|
var Nav = require('naturalcrit/nav/nav.jsx');
|
||||||
|
|
||||||
|
const MAX_TITLE_LENGTH = 50;
|
||||||
|
|
||||||
|
|
||||||
|
var RedditShare = React.createClass({
|
||||||
|
getDefaultProps: function() {
|
||||||
|
return {
|
||||||
|
title : '',
|
||||||
|
onChange : function(){}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
handleChange : function(e){
|
||||||
|
if(e.target.value.length > MAX_TITLE_LENGTH) return;
|
||||||
|
this.props.onChange(e.target.value);
|
||||||
|
},
|
||||||
|
render : function(){
|
||||||
|
return <Nav.item className='editTitle'>
|
||||||
|
<input type='text' value={this.props.title} onChange={this.handleChange} />
|
||||||
|
|
||||||
|
<div className={cx('charCount', {'max' : this.props.title.length >= MAX_TITLE_LENGTH})}>
|
||||||
|
{this.props.title.length}/{MAX_TITLE_LENGTH}
|
||||||
|
</div>
|
||||||
|
</Nav.item>
|
||||||
|
},
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = RedditShare;
|
||||||
@@ -1,19 +1,42 @@
|
|||||||
.homebrew nav{
|
|
||||||
|
|
||||||
|
.homebrew nav{
|
||||||
.homebrewLogo{
|
.homebrewLogo{
|
||||||
.animate(color);
|
.animate(color);
|
||||||
font-family : CodeBold;
|
font-family : CodeBold;
|
||||||
font-size: 12px;
|
font-size : 12px;
|
||||||
|
color : white;
|
||||||
div{
|
div{
|
||||||
margin-top: 2px;
|
margin-top : 2px;
|
||||||
margin-bottom: -2px;
|
margin-bottom : -2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
color : white;
|
|
||||||
&:hover{
|
&:hover{
|
||||||
color : @blue;
|
color : @blue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.editTitle.navItem{
|
||||||
|
padding : 2px 12px;
|
||||||
|
input{
|
||||||
|
margin : 0;
|
||||||
|
padding : 2px;
|
||||||
|
width : 250px;
|
||||||
|
background-color : #333;
|
||||||
|
font-family : 'Open Sans', sans-serif;
|
||||||
|
font-size : 12px;
|
||||||
|
font-weight : 800;
|
||||||
|
color : white;
|
||||||
|
text-align : center;
|
||||||
|
border : 1px solid @blue;
|
||||||
|
outline : none;
|
||||||
|
}
|
||||||
|
.charCount{
|
||||||
|
display : inline-block;
|
||||||
|
vertical-align : bottom;
|
||||||
|
margin-left : 8px;
|
||||||
|
text-align : right;
|
||||||
|
color : #666;
|
||||||
|
&.max{
|
||||||
|
color : @red;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ var request = require("superagent");
|
|||||||
|
|
||||||
var Nav = require('naturalcrit/nav/nav.jsx');
|
var Nav = require('naturalcrit/nav/nav.jsx');
|
||||||
var Navbar = require('../../navbar/navbar.jsx');
|
var Navbar = require('../../navbar/navbar.jsx');
|
||||||
|
var EditTitle = require('../../navbar/editTitle.navitem.jsx');
|
||||||
|
|
||||||
|
|
||||||
var SplitPane = require('naturalcrit/splitPane/splitPane.jsx');
|
var SplitPane = require('naturalcrit/splitPane/splitPane.jsx');
|
||||||
@@ -31,9 +32,8 @@ var NewPage = React.createClass({
|
|||||||
text : storage
|
text : storage
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onbeforeunload = function(e){
|
window.onbeforeunload = function(e){
|
||||||
return "Your homebrew isn't saved. Are you sure you want to leave?";
|
//return "Your homebrew isn't saved. Are you sure you want to leave?";
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -46,6 +46,12 @@ var NewPage = React.createClass({
|
|||||||
this.refs.editor.update();
|
this.refs.editor.update();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handleTitleChange : function(title){
|
||||||
|
this.setState({
|
||||||
|
title : title
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
handleTextChange : function(text){
|
handleTextChange : function(text){
|
||||||
this.setState({
|
this.setState({
|
||||||
text : text
|
text : text
|
||||||
@@ -93,7 +99,7 @@ var NewPage = React.createClass({
|
|||||||
renderNavbar : function(){
|
renderNavbar : function(){
|
||||||
return <Navbar>
|
return <Navbar>
|
||||||
<Nav.section>
|
<Nav.section>
|
||||||
<Nav.item>{this.state.title}</Nav.item>
|
<EditTitle title={this.state.title} onChange={this.handleTitleChange} />
|
||||||
</Nav.section>
|
</Nav.section>
|
||||||
|
|
||||||
<Nav.section>
|
<Nav.section>
|
||||||
|
|||||||
Reference in New Issue
Block a user