mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-08 07:32:40 +00:00
User page now running properly
This commit is contained in:
@@ -56,7 +56,7 @@
|
|||||||
background-color : #ddd;
|
background-color : #ddd;
|
||||||
.snippet{
|
.snippet{
|
||||||
.animate(background-color);
|
.animate(background-color);
|
||||||
padding : 10px;
|
padding : 5px;
|
||||||
cursor : pointer;
|
cursor : pointer;
|
||||||
font-size : 10px;
|
font-size : 10px;
|
||||||
i{
|
i{
|
||||||
|
|||||||
@@ -1,19 +1,37 @@
|
|||||||
const React = require('react');
|
const React = require('react');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const cx = require('classnames');
|
const cx = require('classnames');
|
||||||
|
const moment = require('moment');
|
||||||
|
|
||||||
const BrewItem = React.createClass({
|
const BrewItem = React.createClass({
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
return {
|
return {
|
||||||
brew : {
|
brew : {
|
||||||
|
title : '',
|
||||||
|
description : '',
|
||||||
|
|
||||||
|
authors : []
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
render : function(){
|
render : function(){
|
||||||
|
const brew = this.props.brew;
|
||||||
return <div className='brewItem'>
|
return <div className='brewItem'>
|
||||||
BrewItem Component Ready.
|
<h4>{brew.title}</h4>
|
||||||
|
<p className='description'><em>{brew.description}</em></p>
|
||||||
|
<hr />
|
||||||
|
<ul>
|
||||||
|
<li><strong>Authors: </strong> {brew.authors.join(', ')}</li>
|
||||||
|
<li>
|
||||||
|
<strong>Last updated: </strong>
|
||||||
|
{moment(brew.updatedAt).fromNow()}
|
||||||
|
</li>
|
||||||
|
<li><strong>Views: </strong> {brew.views} </li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<a href={`/share/${brew.shareId}`} target='_blank'>Share link</a>
|
||||||
|
{(!!brew.editId ? <a href={`/edit/${brew.editId}`} target='_blank'>Edit link</a> : null)}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
.brewItem{
|
|
||||||
|
|
||||||
|
.brewItem{
|
||||||
|
display : inline-block;
|
||||||
|
vertical-align : top;
|
||||||
|
width : 33%;
|
||||||
|
margin-bottom : 15px;
|
||||||
|
-webkit-column-break-inside : avoid;
|
||||||
|
page-break-inside : avoid;
|
||||||
|
break-inside : avoid;
|
||||||
|
p.description{
|
||||||
|
overflow : hidden;
|
||||||
|
width : 90%;
|
||||||
|
text-overflow : ellipsis;
|
||||||
|
white-space : nowrap;
|
||||||
|
}
|
||||||
|
a{
|
||||||
|
margin-right : 10px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -15,15 +15,20 @@ const UserPage = React.createClass({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
renderBrews : function(){
|
renderBrews : function(brews){
|
||||||
return _.map(this.props.brews, (brew) => {
|
return _.map(brews, (brew, idx) => {
|
||||||
return <BrewItem brew={brew} />
|
return <BrewItem brew={brew} key={idx}/>
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
getSortedBrews : function(){
|
||||||
|
return _.groupBy(this.props.brews, (brew)=>{
|
||||||
|
return (brew.published ? 'published' : 'private')
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
render : function(){
|
render : function(){
|
||||||
console.log(this.props.brews);
|
const brews = this.getSortedBrews();
|
||||||
|
|
||||||
return <div className='userPage page'>
|
return <div className='userPage page'>
|
||||||
<Navbar>
|
<Navbar>
|
||||||
<Nav.section>
|
<Nav.section>
|
||||||
@@ -33,8 +38,10 @@ const UserPage = React.createClass({
|
|||||||
|
|
||||||
<div className='content'>
|
<div className='content'>
|
||||||
<div className='phb'>
|
<div className='phb'>
|
||||||
<h1>{this.props.username}</h1>
|
<h1>{this.props.username}'s brews</h1>
|
||||||
{this.renderBrews()}
|
{this.renderBrews(brews.published)}
|
||||||
|
{brews.private ? <h1>{this.props.username}'s unpublished brews</h1> : null}
|
||||||
|
{this.renderBrews(brews.private)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
.userPage{
|
.userPage{
|
||||||
.content .phb{
|
.content .phb{
|
||||||
margin: 20px auto;
|
margin: 20px auto;
|
||||||
|
min-height : 350px;
|
||||||
|
height : 80%;
|
||||||
|
column-count : 1;
|
||||||
|
&::after{
|
||||||
|
display : none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user