display date of posts and comments

This commit is contained in:
Pete Gerlach
2024-06-12 01:38:09 +02:00
parent 8287b72e60
commit be9d309f4d
3 changed files with 57 additions and 33 deletions

View File

@@ -25,7 +25,6 @@ const App = () => {
if(selectedPost) {
setSelectedPost(posts.find(post => post.id === selectedPost.id));
}
console.log(posts);
}, [posts]);
useEffect(() => {

View File

@@ -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,6 +65,22 @@ h3 {
margin-right: 20px;
}
.post-right {
display: flex;
flex-direction: column;
justify-content: space-evenly;
.post-date {
position: relative;
bottom: 0;
right: 0;
}
.row {
display: flex;
flex-direction: row;
justify-content: flex-end;
.votes {
display: flex;
flex-direction: column;
@@ -89,6 +105,8 @@ h3 {
margin-bottom: 5px;
}
}
}
}
.comment-form {
display: flex;

View File

@@ -13,6 +13,11 @@ const PostComment = ({ post, vote, type }) => {
<p>{post.content}</p>
</div>
</div>
<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();
@@ -29,6 +34,8 @@ const PostComment = ({ post, vote, type }) => {
</button>
</div>
</div>
</div>
</div>
);
};