0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-09 07:12:40 +00:00

Added conditional partial page rendering

This commit is contained in:
Scott Tolksdorf
2016-12-03 14:49:00 -05:00
parent bec417a325
commit 9285e53e55
6 changed files with 103 additions and 25 deletions

View File

@@ -51,6 +51,16 @@ const MetadataEditor = React.createClass({
});
},
getRedditLink : function(){
const meta = this.props.metadata;
const title = `${meta.title} [${meta.systems.join(' ')}]`;
const text = `Hey guys! I've been working on this homebrew. I'd love your feedback. Check it out.
**[Homebrewery Link](http://homebrewery.naturalcrit.com/share/${meta.shareId})**`;
return `https://www.reddit.com/r/UnearthedArcana/submit?title=${encodeURIComponent(title)}&text=${encodeURIComponent(text)}`;
},
renderSystems : function(){
return _.map(SYSTEMS, (val)=>{
return <label key={val}>
@@ -101,8 +111,22 @@ const MetadataEditor = React.createClass({
</div>
},
renderShareToReddit : function(){
if(!this.props.metadata.shareId) return;
return <div className='field reddit'>
<label>reddit</label>
<div className='value'>
<a href={this.getRedditLink()} target='_blank'>
<button className='publish'>
<i className='fa fa-reddit-alien' /> share to reddit
</button>
</a>
</div>
</div>
},
render : function(){
console.log(this.props.metadata);
return <div className='metadataEditor'>
<div className='field title'>
<label>title</label>
@@ -140,6 +164,8 @@ const MetadataEditor = React.createClass({
</div>
</div>
{this.renderShareToReddit()}
{this.renderDelete()}
</div>

View File

@@ -67,6 +67,11 @@
.button(@red);
}
}
.reddit.field .value{
button{
.button(@purple);
}
}
.authors.field .value{
font-size: 0.8em;
line-height : 1.5em;