-
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.
피드 아이템 컴포넌트 확장(좋아요 버튼 합성, onClick props 추가) (#616)
also add LikeButton component and compose on FeedPanel
- Loading branch information
1 parent
0df28e7
commit 7787b9f
Showing
4 changed files
with
99 additions
and
80 deletions.
There are no files selected for viewing
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
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,42 @@ | ||
import LikeActiveIcon from '@assets/svg/like_active.svg'; | ||
import LikeDefaultIcon from '@assets/svg/like_default.svg'; | ||
import { LIKE_MAX_COUNT } from '@constants/feed'; | ||
import { styled } from 'stitches.config'; | ||
|
||
interface LikeButtonProps { | ||
isLiked: boolean; | ||
likeCount: number; | ||
onClickLike: (e: React.MouseEvent<HTMLButtonElement>) => void; | ||
} | ||
|
||
export default function LikeButton({ isLiked, likeCount, onClickLike }: LikeButtonProps) { | ||
const formattedLikeCount = likeCount > LIKE_MAX_COUNT ? `${LIKE_MAX_COUNT}+` : likeCount; | ||
|
||
return ( | ||
<SLikeButton like={isLiked} onClick={onClickLike}> | ||
{isLiked ? <LikeActiveIcon /> : <LikeDefaultIcon />} | ||
{formattedLikeCount} | ||
</SLikeButton> | ||
); | ||
} | ||
|
||
const SLikeButton = styled('button', { | ||
display: 'flex', | ||
alignItems: 'center', | ||
fontStyle: 'H5', | ||
|
||
variants: { | ||
like: { | ||
true: { | ||
color: '$red', | ||
}, | ||
false: { | ||
color: '$gray10', | ||
}, | ||
}, | ||
}, | ||
|
||
'& > svg': { | ||
mr: '$6', | ||
}, | ||
}); |
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
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