Skip to content

Commit

Permalink
solutiom
Browse files Browse the repository at this point in the history
  • Loading branch information
MarushchakM committed Feb 12, 2025
1 parent 61f14ea commit d633c4d
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 68 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ This task is similar to [Static List of TODOs](https://github.com/mate-academy/r
- Install Prettier Extention and use this [VSCode settings](https://mate-academy.github.io/fe-program/tools/vscode/settings.json) to enable format on save.
- Implement a solution following the [React task guideline](https://github.com/mate-academy/react_task-guideline#react-tasks-guideline).
- Open one more terminal and run tests with `npm test` to ensure your solution is correct.
- 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.
- 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.
29 changes: 0 additions & 29 deletions src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,3 @@ iframe {
.App__title {
text-align: center;
}

.PostInfo {
margin: 10px auto;
width: 90%;
border: 1px solid #000;
border-radius: 8px;
background-color: lightgray;
padding: 1em;

&__title {
margin: 0;
}

&__header {
margin-bottom: 1em;
}
}

.UserInfo {
font-weight: bold;
}

.CommentList {
display: flex;
flex-direction: column;
gap: 0.7em;
background-color: #eee;
padding: 1em;
}
8 changes: 4 additions & 4 deletions src/components/CommentInfo/CommentInfo.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const CommentInfo = ({ comment }) => {
<>
export const CommentInfo = ({ comment }) => (
<div className="CommentInfo">
<div className="CommentInfo__title">
<strong className="CommentInfo__name">{comment.name}</strong>
by
Expand All @@ -8,5 +8,5 @@ export const CommentInfo = ({ comment }) => {
</a>
</div>
<div className="CommentInfo__body">{comment.body}</div>
</>;
};
</div>
);
6 changes: 3 additions & 3 deletions src/components/CommentList/CommentList.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import './CommentList.scss';

import { CommentInfo } from '../CommentInfo';

export const CommentList = ({ comments }) => (
<div className="CommentList">
{comments.map(comment => (
<div className="CommentInfo">
<CommentInfo comment={comment} />
</div>
<CommentInfo key={comment.id} comment={comment} />
))}
</div>
);
8 changes: 8 additions & 0 deletions src/components/CommentList/CommentList.scss
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
// add styles here

.CommentList {
display: flex;
flex-direction: column;
gap: 0.7em;
background-color: #eee;
padding: 1em;
}
12 changes: 10 additions & 2 deletions src/components/PostInfo/PostInfo.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import './PostInfo.scss';

import { UserInfo } from '../UserInfo';
import { CommentList } from '../CommentList';

export const PostInfo = ({ post }) => (
<>
<div className="PostInfo">
<div className="PostInfo__header">
<h3 className="PostInfo__title">{post.title}</h3>
<UserInfo user={post.user} />
</div>
<p className="PostInfo__body">{post.body}</p>
</>
{post.comments.length > 0 ? (
<CommentList comments={post.comments} />
) : (
<b data-cy="NoCommentsMessage">No comments yet</b>
)}
</div>
);
17 changes: 17 additions & 0 deletions src/components/PostInfo/PostInfo.scss
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
// add styles here

.PostInfo {
margin: 10px auto;
width: 90%;
border: 1px solid #000;
border-radius: 8px;
background-color: lightgray;
padding: 1em;

&__title {
margin: 0;
}

&__header {
margin-bottom: 1em;
}
}
30 changes: 1 addition & 29 deletions src/components/PostList/PostList.jsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,9 @@
import { CommentList } from '../CommentList';
import { PostInfo } from '../PostInfo';

export const PostList = ({ posts }) => (
<div className="PostList">
{/* <div className="PostInfo">
<div className="PostInfo__header">
<h3 className="PostInfo__title">qui est esse</h3>
<p>
{' Posted by '}
<a className="UserInfo" href="mailto:[email protected]">
Leanne Graham
</a>
</p>
</div>
<p className="PostInfo__body">
est rerum tempore vitae sequi sint nihil reprehenderit dolor beatae ea
dolores neque fugiat blanditiis voluptate porro vel nihil molestiae ut
reiciendis qui aperiam non debitis possimus qui neque nisi nulla
</p>
<hr />
<b data-cy="NoCommentsMessage">No comments yet</b>
</div> */}

{posts.map(post => (
<div className="PostInfo">
<PostInfo key={post.id} post={post} />
<CommentList comments={post.comments} />
</div>
<PostInfo key={post.id} post={post} />
))}
</div>
);
2 changes: 2 additions & 0 deletions src/components/UserInfo/UserInfo.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import './UserInfo.scss';

export const UserInfo = ({ user }) => (
<p>
Posted by
Expand Down
4 changes: 4 additions & 0 deletions src/components/UserInfo/UserInfo.scss
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
// add styles here

.UserInfo {
font-weight: bold;
}

0 comments on commit d633c4d

Please sign in to comment.