Skip to content

Commit

Permalink
feat: BestContents 컴포넌트 수정 (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssuminii committed Nov 11, 2024
1 parent 5397e35 commit dbd016a
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions src/components/BestContents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import styled from '@emotion/styled'
import colors from '@/constants/color'
import { fontSize, fontWeight } from '@/constants/font'
import { Heart } from 'lucide-react'
import { Link } from 'react-router-dom'

interface ContentItem {
id: number
title: string
userName: string
username: string
likes: number
}

Expand All @@ -21,17 +22,19 @@ const BestContents = ({ title, content }: BestContentsProps) => {
<div className="title">{title}</div>
<Ranking>
<ol>
{content.map(({ id, title, userName, likes }) => (
<li key={id} className="list-container">
<div>
{id}. <span>{title}</span>
</div>
<div className="list-info">
<div className="user-name">{userName}</div>
<Heart color={colors.primaryBlue} fill={colors.primaryBlue} size={16} />
<span>{likes}</span>
</div>
</li>
{content.map(({ id, title, username, likes }, i) => (
<Link to={`/postDetail/스터디/@${username}/${encodeURIComponent(title)}/${id}`}>
<li key={id} className="list-container">
<div className="title-text">
{i + 1}. <span>{title}</span>
</div>
<div className="list-info">
<div className="user-name">{username}</div>
<Heart color={colors.primaryBlue} fill={colors.primaryBlue} size={16} />
<span>{likes}</span>
</div>
</li>
</Link>
))}
</ol>
</Ranking>
Expand Down Expand Up @@ -69,6 +72,13 @@ const Ranking = styled.div`
}
}
.title-text {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 120px; /* 원하는 너비에 맞게 설정 */
}
.list-info {
display: flex;
span {
Expand Down

0 comments on commit dbd016a

Please sign in to comment.