Skip to content

Commit

Permalink
add post details styles
Browse files Browse the repository at this point in the history
  • Loading branch information
KRRISH96 committed Feb 25, 2021
1 parent fa7de58 commit e36e0d1
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 28 deletions.
47 changes: 25 additions & 22 deletions src/components/PostDetails/PostDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import BackButton from '../BackButton';
import { PostData } from '../Posts/Posts';
import TextHighlighter from '../TextHighlighter';
import Comments from './Comments';
import './postDetailsStyles.scss';

interface ParamsData {
id: string;
Expand Down Expand Up @@ -42,7 +43,7 @@ function PostDetails() {
};

return (
<div>
<div className="post-details-page">
<h2>
<Link to="/">Users</Link>
<span>{' > '}</span>
Expand Down Expand Up @@ -70,27 +71,29 @@ function PostDetails() {
)}
</div>
{loading && <h2>Fetching Post Details... Hang Tight!</h2>}
<p>
<TextHighlighter
text={postDetails?.title ?? ''}
highlight={searchText}
/>
</p>
<p>
<TextHighlighter
text={postDetails?.body ?? ''}
highlight={searchText}
/>
</p>
{postDetails?.id && (
<button
className="danger"
onClick={() => deletePost(postDetails.id)}
disabled={loading}
>
{deleteLoading ? 'Deleting...' : 'Delete Post'}
</button>
)}
<article className="post-content card">
<h2 className="post-content__title">
<TextHighlighter
text={postDetails?.title ?? ''}
highlight={searchText}
/>
</h2>
<p className="post-content__body">
<TextHighlighter
text={postDetails?.body ?? ''}
highlight={searchText}
/>
</p>
{postDetails?.id && (
<button
className="danger"
onClick={() => deletePost(postDetails.id)}
disabled={loading}
>
{deleteLoading ? 'Deleting...' : 'Delete Post'}
</button>
)}
</article>
{showComments ? (
<Comments postId={Number(id)} />
) : (
Expand Down
12 changes: 12 additions & 0 deletions src/components/PostDetails/postDetailsStyles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.post-details-page {
.post-content {
padding: var(--s-1);
&__title {
text-transform: capitalize;
}
&__body {
line-height: 1.5rem;
letter-spacing: 0.05rem;
}
}
}
2 changes: 1 addition & 1 deletion src/components/Posts/PostsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface PostsListProps {
}
function PostsList({ posts, titleFilter }: PostsListProps) {
return (
<ul className="posts-list">
<ul className="posts-list card">
{posts.map(({ userId, id, title }) => (
<li key={`${userId}-${id}`} className="posts-list__item">
<a href={`/posts/${id}`} className="posts-list__item-link">
Expand Down
5 changes: 0 additions & 5 deletions src/components/Posts/postsStyles.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
.posts-page {
.posts-list {
margin-bottom: var(--s-1);
background-color: var(--bg-secondary);
box-shadow: var(--shadow-secondary);
padding: var(--s-1) var(--s-0_75);
border-radius: 0.4rem;
font-size: var(--font-20);
text-transform: capitalize;
&__item {
Expand Down
8 changes: 8 additions & 0 deletions src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,11 @@ button {
flex-direction: column;
}
}

.card {
margin-bottom: var(--s-1);
background-color: var(--bg-secondary);
box-shadow: var(--shadow-secondary);
padding: var(--s-1) var(--s-0_75);
border-radius: 0.4rem;
}

0 comments on commit e36e0d1

Please sign in to comment.