Skip to content

Commit 36b676e

Browse files
committed
[FE-246]feat: CommentSection 컴포넌트 생성
-추상화를 위해 컴포넌트 분리
1 parent 62ee2da commit 36b676e

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import React from 'react'
2+
import { useNavigate } from 'react-router-dom'
3+
import { parentCategoryID } from 'types/category'
4+
import { IRankingRecordData } from 'types/recordData'
5+
import recordIcons from '@assets/record_icons'
6+
7+
interface RankingItemType extends IRankingRecordData {
8+
index?: number
9+
parentCategoryId: parentCategoryID
10+
}
11+
12+
export default function CommentSection({
13+
recordId,
14+
colorName,
15+
title,
16+
writer,
17+
numOfComment,
18+
iconName,
19+
}: RankingItemType) {
20+
const navigate = useNavigate()
21+
const RecordIcon = recordIcons[`${iconName}`]
22+
23+
const screenAvailWidth = window.screen.availWidth
24+
25+
const titleRelativeWidth =
26+
screenAvailWidth > 370
27+
? 'max-w-[45%]'
28+
: screenAvailWidth > 350
29+
? 'max-w-[40%]'
30+
: 'max-w-[35%]'
31+
32+
return (
33+
<div
34+
className="relative mb-5 flex h-12 w-full cursor-pointer items-center justify-between"
35+
onClick={() => navigate(`/record/${recordId}`)}
36+
>
37+
<div className="flex w-full items-center">
38+
<div
39+
className={`${colorName} flex aspect-square w-12 items-center justify-center rounded-full`}
40+
>
41+
<RecordIcon width={36} height={36} />
42+
</div>
43+
<div className={`ml-2 ${titleRelativeWidth} shrink`}>
44+
<p className="truncate text-base font-semibold">{title}</p>
45+
<div className="flex w-full text-xs">
46+
<p className="max-w-[85%] truncate text-grey-9">{writer}</p>
47+
<p className="ml-1.5 text-primary-2">+{numOfComment}</p>
48+
</div>
49+
</div>
50+
</div>
51+
</div>
52+
)
53+
}

0 commit comments

Comments
 (0)