display date of posts and comments
This commit is contained in:
@@ -25,7 +25,6 @@ const App = () => {
|
||||
if(selectedPost) {
|
||||
setSelectedPost(posts.find(post => post.id === selectedPost.id));
|
||||
}
|
||||
console.log(posts);
|
||||
}, [posts]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
54
src/App.scss
54
src/App.scss
@@ -55,7 +55,7 @@ h3 {
|
||||
align-items: flex-start;
|
||||
border: 1px solid #ddd;
|
||||
margin: 10px 0;
|
||||
padding: 15px;
|
||||
padding: 5px 5px 15px 15px;
|
||||
border-radius: 10px;
|
||||
background-color: #fff;
|
||||
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
|
||||
@@ -65,28 +65,46 @@ h3 {
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
.votes {
|
||||
.post-right {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-evenly;
|
||||
|
||||
button {
|
||||
padding: 10px;
|
||||
margin-bottom: 5px;
|
||||
background-color: transparent;
|
||||
color: #ff9908;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: 1.5em;
|
||||
|
||||
&:hover {
|
||||
color: #e68a00;
|
||||
}
|
||||
.post-date {
|
||||
position: relative;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 1.2em;
|
||||
margin-bottom: 5px;
|
||||
.row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-end;
|
||||
|
||||
.votes {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
button {
|
||||
padding: 10px;
|
||||
margin-bottom: 5px;
|
||||
background-color: transparent;
|
||||
color: #ff9908;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: 1.5em;
|
||||
|
||||
&:hover {
|
||||
color: #e68a00;
|
||||
}
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 1.2em;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,20 +13,27 @@ const PostComment = ({ post, vote, type }) => {
|
||||
<p>{post.content}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="votes">
|
||||
<button onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
vote(post.id, post.reaction !== null ? null : true);
|
||||
}}>
|
||||
<FontAwesomeIcon icon={faCaretUp} />
|
||||
</button>
|
||||
<span>{post.reactions.positive - post.reactions.negative}</span>
|
||||
<button onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
vote(post.id, post.reaction !== null ? null : false);
|
||||
}}>
|
||||
<FontAwesomeIcon icon={faCaretDown} />
|
||||
</button>
|
||||
<div className="post-right">
|
||||
<div className="post-date">
|
||||
{post.date.slice(8, 10) + "." + post.date.slice(5, 7) + "." + post.date.slice(0, 4)}
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="votes">
|
||||
<button onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
vote(post.id, post.reaction !== null ? null : true);
|
||||
}}>
|
||||
<FontAwesomeIcon icon={faCaretUp}/>
|
||||
</button>
|
||||
<span>{post.reactions.positive - post.reactions.negative}</span>
|
||||
<button onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
vote(post.id, post.reaction !== null ? null : false);
|
||||
}}>
|
||||
<FontAwesomeIcon icon={faCaretDown}/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user