Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Krot Max committed Feb 5, 2025
1 parent 9de0191 commit d6a8d49
Show file tree
Hide file tree
Showing 10 changed files with 4,141 additions and 2,515 deletions.
6,421 changes: 4,015 additions & 2,406 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"devDependencies": {
"@cypress/react18": "^2.0.1",
"@mate-academy/scripts": "^1.8.5",
"@mate-academy/scripts": "^1.9.12",
"@mate-academy/stylelint-config": "*",
"@vitejs/plugin-react": "^4.3.1",
"cypress": "^13.13.0",
Expand Down
114 changes: 19 additions & 95 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,104 +1,28 @@
import './App.scss';
import postsFromServer from './api/posts.json';
import usersFromServer from './api/users.json';
import { PostList } from './components/PostList/PostList';
import commentsFromServer from './api/comments.json';

// import postsFromServer from './api/posts.json';
// import commentsFromServer from './api/comments.json';
// import usersFromServer from './api/users.json';

export const App = () => (
<section className="App">
<h1 className="App__title">Static list of posts</h1>

<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>

<div className="PostInfo">
<div className="PostInfo__header">
<h3 className="PostInfo__title">doloremque illum aliquid sunt</h3>
function getUserById(userId) {
return usersFromServer.find(user => user.id === userId) || null;
}

<p>
{' Posted by '}
function getCommentsById(commentId) {
return commentsFromServer.find(comment => comment.id === commentId) || null;
}

<a className="UserInfo" href="mailto:[email protected]">
Patricia Lebsack
</a>
</p>
</div>
const posts = postsFromServer.map(post => ({
...post,
user: getUserById(post.userId),
comments: getCommentsById(post.id),
}));

<p className="PostInfo__body">
deserunt eos nobis asperiores et hic est debitis repellat molestiae
optio nihil ratione ut eos beatae quibusdam distinctio maiores earum
voluptates et aut adipisci ea maiores voluptas maxime
</p>

<div className="CommentList">
<div className="CommentInfo">
<div className="CommentInfo__title">
<strong className="CommentInfo__name">pariatur omnis in</strong>

{' by '}

<a
className="CommentInfo__email"
href="mailto:[email protected]"
>
[email protected]
</a>
</div>

<div className="CommentInfo__body">
dolorum voluptas laboriosam quisquam ab totam beatae et aut
aliquid optio assumenda voluptas velit itaque quidem voluptatem
tempore cupiditate in itaque sit molestiae minus dolores magni
</div>
</div>

<div className="CommentInfo">
<div className="CommentInfo__title">
<strong className="CommentInfo__name">
odio adipisci rerum aut animi
</strong>

{' by '}

<a
className="CommentInfo__email"
href="mailto:[email protected]"
>
[email protected]
</a>
</div>

<div className="CommentInfo__body">
quia molestiae reprehenderit quasi aspernatur aut expedita
occaecati aliquam eveniet laudantium omnis quibusdam delectus
saepe quia accusamus maiores nam est cum et ducimus et vero
voluptates excepturi deleniti ratione
</div>
</div>
</div>
</div>
</div>
export const App = () => (
<section className="App">
<h1 className="App__title">Static list of posts</h1>
<PostList posts={ posts} />
</section>
);
8 changes: 1 addition & 7 deletions src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,4 @@ iframe {
font-weight: bold;
}

.CommentList {
display: flex;
flex-direction: column;
gap: 0.7em;
background-color: #eee;
padding: 1em;
}

49 changes: 48 additions & 1 deletion src/components/CommentInfo/CommentInfo.jsx
Original file line number Diff line number Diff line change
@@ -1 +1,48 @@
export const CommentInfo = () => <>Put the comment here</>;
export const CommentInfo = ({comment}) =>
<>
<div className="CommentInfo">
<div className="CommentInfo__title">
<strong className="CommentInfo__name">{comment.name}</strong>

{' by '}

<a
className="CommentInfo__email"
href="mailto:[email protected]"
>
[email protected]
</a>
</div>

<div className="CommentInfo__body">
dolorum voluptas laboriosam quisquam ab totam beatae et aut
aliquid optio assumenda voluptas velit itaque quidem voluptatem
tempore cupiditate in itaque sit molestiae minus dolores magni
</div>
</div>

<div className="CommentInfo">
<div className="CommentInfo__title">
<strong className="CommentInfo__name">
odio adipisci rerum aut animi
</strong>

{' by '}

<a
className="CommentInfo__email"
href="mailto:[email protected]"
>
[email protected]
</a>
</div>

<div className="CommentInfo__body">
quia molestiae reprehenderit quasi aspernatur aut expedita
occaecati aliquam eveniet laudantium omnis quibusdam delectus
saepe quia accusamus maiores nam est cum et ducimus et vero
voluptates excepturi deleniti ratione
</div>
</div>

</>;
9 changes: 8 additions & 1 deletion src/components/CommentList/CommentList.jsx
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
export const CommentList = () => <>Put the list here</>;
import { CommentInfo } from "../CommentInfo/CommentInfo";

export const CommentList = ({ comments }) =>
<div className="CommentList">
{comments.map(comment => (
<CommentInfo comment={comment} />
))}
</div>
8 changes: 7 additions & 1 deletion src/components/CommentList/CommentList.scss
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
// add styles here
.CommentList {
display: flex;
flex-direction: column;
gap: 0.7em;
background-color: #eee;
padding: 1em;
}
27 changes: 26 additions & 1 deletion src/components/PostInfo/PostInfo.jsx
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
export const PostInfo = () => <>Put the post here</>;
import { CommentList } from "../CommentList/CommentList";
import { UserInfo } from "../UserInfo/UserInfo";


export const PostInfo = ({post }) =>
<div className="PostInfo">
<div className="PostInfo__header">
<h3 className="PostInfo__title">{ post.title}</h3>

<p>
{' Posted by '}

Check failure on line 12 in src/components/PostInfo/PostInfo.jsx

View workflow job for this annotation

GitHub Actions / run_linter (20.x)

'user' is not defined
<UserInfo user={user} />
</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 <CommentList comments={commentsFromServer} /></b>

Check failure on line 25 in src/components/PostInfo/PostInfo.jsx

View workflow job for this annotation

GitHub Actions / run_linter (20.x)

'commentsFromServer' is not defined
</div>
12 changes: 11 additions & 1 deletion src/components/PostList/PostList.jsx
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
export const PostList = () => <>Put the list here</>;
import { PostInfo } from "../PostInfo/PostInfo";


export const PostList = ({ posts }) =>
<>
<div className="PostList">
{posts.map(post => (
<PostInfo post={post} />
))}
</div>
</>;
6 changes: 5 additions & 1 deletion src/components/UserInfo/UserInfo.jsx
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export const UserInfo = () => <>Put the user here</>;
export const UserInfo = () =>
<a className="UserInfo" href={`mailto:${user.email}`}>

Check failure on line 2 in src/components/UserInfo/UserInfo.jsx

View workflow job for this annotation

GitHub Actions / run_linter (20.x)

'user' is not defined
{user.name}

Check failure on line 3 in src/components/UserInfo/UserInfo.jsx

View workflow job for this annotation

GitHub Actions / run_linter (20.x)

'user' is not defined
</a>
;

0 comments on commit d6a8d49

Please sign in to comment.