Skip to content

Commit

Permalink
fix: button->div로 변경 및 위시 버튼 컴포넌트 내부에서 관리하도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
maylh committed Jan 14, 2025
1 parent 149304f commit adce9b0
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/components/card/popularCard/PopularCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Icon from '@assets/svgs';
import { useState } from 'react';

import * as styles from './popularCard.css';

interface PopularCardProps {
ranking: number;
templeName: string;
Expand All @@ -18,10 +20,26 @@ const PopularCard = ({
templeImg,
tag,
onClick,
isLiked,
isLiked = false,
}: PopularCardProps) => {
const [liked, setLiked] = useState(isLiked);

const handleLikeClick = (e: React.MouseEvent) => {
e.stopPropagation();
setLiked((prev) => !prev);
};

return (
<button className={styles.cardWrapper} onClick={onClick}>
<div
className={styles.cardWrapper}
onClick={onClick}
role="button"
tabIndex={0}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
onClick();
}
}}>
<div>
<div className={styles.imgBox} style={{ backgroundImage: `url(${templeImg})` }}>
<span className={styles.rankBox}>{ranking}</span>
Expand All @@ -35,12 +53,12 @@ const PopularCard = ({
<span>{tag}</span>
</div>
</div>
<button className={styles.likeBtn}>
{isLiked ? <Icon.IcnFlowerPink /> : <Icon.IncFlowerGray />}
<button className={styles.likeBtn} onClick={handleLikeClick}>
{liked ? <Icon.IcnFlowerPink /> : <Icon.IncFlowerGray />}
</button>
</div>
</div>
</button>
</div>
);
};

Expand Down

0 comments on commit adce9b0

Please sign in to comment.