-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(member): blog section UI 개선 (#93)
- Loading branch information
Showing
5 changed files
with
79 additions
and
89 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { useCallback } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { createImageUrl } from '@utils/api'; | ||
import { cn } from '@utils/string'; | ||
import Image from '../Image/Image'; | ||
|
||
interface PostCardProps { | ||
to: string; | ||
title: string; | ||
subTitle?: string; | ||
imageUrl?: string; | ||
} | ||
|
||
const PostCard = ({ to, title, subTitle, imageUrl }: PostCardProps) => { | ||
const navigate = useNavigate(); | ||
|
||
const handleClick = useCallback(() => navigate(to), [navigate, to]); | ||
|
||
return ( | ||
<div | ||
role="button" | ||
onClick={handleClick} | ||
className="flex flex-col items-center p-2 space-y-2 transition rounded-lg cursor-pointer hover:bg-gray-100" | ||
> | ||
<Image | ||
src={createImageUrl(imageUrl)} | ||
alt={title} | ||
width="w-48" | ||
height="h-48" | ||
className="object-cover border rounded-lg" | ||
/> | ||
<div className="w-48"> | ||
<p | ||
className={cn('break-keep', { | ||
'text-center': !subTitle, | ||
})} | ||
> | ||
{title} | ||
</p> | ||
{subTitle && ( | ||
<p className="text-sm truncate text-clab-main-light">{subTitle}</p> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PostCard; |
27 changes: 27 additions & 0 deletions
27
apps/member/src/components/main/BlogSection/BlogSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useBlog } from '@hooks/queries'; | ||
import Section from '@components/common/Section/Section'; | ||
import { COMMUNITY_MESSAGE } from '@constants/message'; | ||
import PostCard from '@components/common/PostCard/PostCard'; | ||
import { PATH } from '@constants/path'; | ||
import EmptyBox from '@components/common/EmptyBox/EmptyBox'; | ||
|
||
const BlogSection = () => { | ||
const { data } = useBlog(); | ||
|
||
return ( | ||
<Section> | ||
<Section.Header title="기술 블로그" /> | ||
<Section.Body className="flex gap-2 overflow-scroll scrollbar-hide"> | ||
{data.items.length === 0 ? ( | ||
<EmptyBox>{COMMUNITY_MESSAGE.NO_ARTICLE}</EmptyBox> | ||
) : ( | ||
data.items.map((news) => ( | ||
<PostCard key={news.id} to={PATH.BLOG} {...news} /> | ||
)) | ||
)} | ||
</Section.Body> | ||
</Section> | ||
); | ||
}; | ||
|
||
export default BlogSection; |
35 changes: 0 additions & 35 deletions
35
apps/member/src/components/main/NewsCardSection/NewsCardSection.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters