Skip to content

Commit

Permalink
fix: lesson card title 긴 글자 수 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
seoyeon08 committed Jul 8, 2024
1 parent 4e09eb4 commit a166dab
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/molecules/LessonCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export const LessonCard = ({
show,
handleClick,
}: IProps) => {
const truncateTitle = (title: string, maxLength: number) => {
return title.length > maxLength ? `${title.slice(0, maxLength)}...` : title;
};

return (
<div className='relative w-[108px] h-[156px] px-4 pt-5 mr-[15px] bg-white font-hanaRegular rounded-2xl shadow-md lesson-card'>
{show && (
Expand All @@ -26,7 +30,7 @@ export const LessonCard = ({
/>
)}
<img src={image} alt='cardImg' className='w-20 h-20 relative' />
<p className='text-xs mt-1'>{title}</p>
<p className='text-xs mt-1'>{truncateTitle(title, 7)}</p>
<div className='flex justify-between mt-4 text-[6px]'>
<p># {category}</p>
<p>{date}</p>
Expand Down

0 comments on commit a166dab

Please sign in to comment.