Skip to content

Commit d633c4d

Browse files
committed
solutiom
1 parent 61f14ea commit d633c4d

File tree

10 files changed

+50
-68
lines changed

10 files changed

+50
-68
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ This task is similar to [Static List of TODOs](https://github.com/mate-academy/r
1313
- Install Prettier Extention and use this [VSCode settings](https://mate-academy.github.io/fe-program/tools/vscode/settings.json) to enable format on save.
1414
- Implement a solution following the [React task guideline](https://github.com/mate-academy/react_task-guideline#react-tasks-guideline).
1515
- Open one more terminal and run tests with `npm test` to ensure your solution is correct.
16-
- Replace `<your_account>` with your Github username in the [DEMO LINK](https://<your_account>.github.io/react_static-list-of-posts-js/) and add it to the PR description.
16+
- Replace `<your_account>` with your Github username in the [DEMO LINK](https://MarushchacM.github.io/react_static-list-of-posts-js/) and add it to the PR description.

src/App.scss

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,3 @@ iframe {
55
.App__title {
66
text-align: center;
77
}
8-
9-
.PostInfo {
10-
margin: 10px auto;
11-
width: 90%;
12-
border: 1px solid #000;
13-
border-radius: 8px;
14-
background-color: lightgray;
15-
padding: 1em;
16-
17-
&__title {
18-
margin: 0;
19-
}
20-
21-
&__header {
22-
margin-bottom: 1em;
23-
}
24-
}
25-
26-
.UserInfo {
27-
font-weight: bold;
28-
}
29-
30-
.CommentList {
31-
display: flex;
32-
flex-direction: column;
33-
gap: 0.7em;
34-
background-color: #eee;
35-
padding: 1em;
36-
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export const CommentInfo = ({ comment }) => {
2-
<>
1+
export const CommentInfo = ({ comment }) => (
2+
<div className="CommentInfo">
33
<div className="CommentInfo__title">
44
<strong className="CommentInfo__name">{comment.name}</strong>
55
by
@@ -8,5 +8,5 @@ export const CommentInfo = ({ comment }) => {
88
</a>
99
</div>
1010
<div className="CommentInfo__body">{comment.body}</div>
11-
</>;
12-
};
11+
</div>
12+
);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import './CommentList.scss';
2+
13
import { CommentInfo } from '../CommentInfo';
24

35
export const CommentList = ({ comments }) => (
46
<div className="CommentList">
57
{comments.map(comment => (
6-
<div className="CommentInfo">
7-
<CommentInfo comment={comment} />
8-
</div>
8+
<CommentInfo key={comment.id} comment={comment} />
99
))}
1010
</div>
1111
);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
11
// add styles here
2+
3+
.CommentList {
4+
display: flex;
5+
flex-direction: column;
6+
gap: 0.7em;
7+
background-color: #eee;
8+
padding: 1em;
9+
}

src/components/PostInfo/PostInfo.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
import './PostInfo.scss';
2+
13
import { UserInfo } from '../UserInfo';
4+
import { CommentList } from '../CommentList';
25

36
export const PostInfo = ({ post }) => (
4-
<>
7+
<div className="PostInfo">
58
<div className="PostInfo__header">
69
<h3 className="PostInfo__title">{post.title}</h3>
710
<UserInfo user={post.user} />
811
</div>
912
<p className="PostInfo__body">{post.body}</p>
10-
</>
13+
{post.comments.length > 0 ? (
14+
<CommentList comments={post.comments} />
15+
) : (
16+
<b data-cy="NoCommentsMessage">No comments yet</b>
17+
)}
18+
</div>
1119
);

src/components/PostInfo/PostInfo.scss

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
11
// add styles here
2+
3+
.PostInfo {
4+
margin: 10px auto;
5+
width: 90%;
6+
border: 1px solid #000;
7+
border-radius: 8px;
8+
background-color: lightgray;
9+
padding: 1em;
10+
11+
&__title {
12+
margin: 0;
13+
}
14+
15+
&__header {
16+
margin-bottom: 1em;
17+
}
18+
}

src/components/PostList/PostList.jsx

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,9 @@
1-
import { CommentList } from '../CommentList';
21
import { PostInfo } from '../PostInfo';
32

43
export const PostList = ({ posts }) => (
54
<div className="PostList">
6-
{/* <div className="PostInfo">
7-
<div className="PostInfo__header">
8-
<h3 className="PostInfo__title">qui est esse</h3>
9-
10-
<p>
11-
{' Posted by '}
12-
13-
<a className="UserInfo" href="mailto:[email protected]">
14-
Leanne Graham
15-
</a>
16-
</p>
17-
</div>
18-
19-
<p className="PostInfo__body">
20-
est rerum tempore vitae sequi sint nihil reprehenderit dolor beatae ea
21-
dolores neque fugiat blanditiis voluptate porro vel nihil molestiae ut
22-
reiciendis qui aperiam non debitis possimus qui neque nisi nulla
23-
</p>
24-
25-
<hr />
26-
27-
<b data-cy="NoCommentsMessage">No comments yet</b>
28-
</div> */}
29-
305
{posts.map(post => (
31-
<div className="PostInfo">
32-
<PostInfo key={post.id} post={post} />
33-
<CommentList comments={post.comments} />
34-
</div>
6+
<PostInfo key={post.id} post={post} />
357
))}
368
</div>
379
);

src/components/UserInfo/UserInfo.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import './UserInfo.scss';
2+
13
export const UserInfo = ({ user }) => (
24
<p>
35
Posted by

src/components/UserInfo/UserInfo.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
// add styles here
2+
3+
.UserInfo {
4+
font-weight: bold;
5+
}

0 commit comments

Comments
 (0)