diff --git a/components/Heart/Heart.tsx b/components/Heart/Heart.tsx index 14cd890..b9c3e11 100644 --- a/components/Heart/Heart.tsx +++ b/components/Heart/Heart.tsx @@ -5,15 +5,27 @@ import HeartIcon from './HeartIcon'; interface HeartProps { initialCount: number; onClick?: () => void; + textSize?: string; + iconSize?: string; + className?: string; } /** * Heart count component * @param {number} initialCount - 초기 카운트 수 * @param {function} onClick - 클릭 시 동작 할 이벤트(옵션) + * @param {string} textSize - 텍스트 사이즈(옵션) + * @param {string} iconSize - 아이콘 사이즈(옵션) + * @param {string} className - 커스텀 클래스(옵션) * @example console.log('클릭')} /> */ -export default function Heart({ initialCount, onClick }: HeartProps) { +export default function Heart({ + initialCount, + onClick, + textSize, + iconSize, + className, +}: HeartProps) { const [isClicked, setIsClicked] = useState(false); const [count, setCount] = useState(initialCount); @@ -34,11 +46,13 @@ export default function Heart({ initialCount, onClick }: HeartProps) { return ( - - + + {count} diff --git a/components/Heart/HeartIcon.tsx b/components/Heart/HeartIcon.tsx index a1d461f..010a7ba 100644 --- a/components/Heart/HeartIcon.tsx +++ b/components/Heart/HeartIcon.tsx @@ -2,11 +2,17 @@ * Heart icon * @param {string} fill - 색상 */ -export default function HeartIcon({ fill = '#8F95B2' }: { fill?: string }) { +export default function HeartIcon({ + fill = '#8F95B2', + iconSize, +}: { + fill?: string; + iconSize?: string; +}) { return ( diff --git a/pages/boards/components/BoardItem.tsx b/pages/boards/components/BoardItem.tsx new file mode 100644 index 0000000..8a66388 --- /dev/null +++ b/pages/boards/components/BoardItem.tsx @@ -0,0 +1,61 @@ +import Link from 'next/link'; + +import Heart from '@/components/Heart/Heart'; +import useCheckMobile from '@/hooks/useCheckMobile'; +import dateConversion from '@/utils/dateConversion'; + +interface BoardItemProps { + id: number; + title: string; + name: string; + likeCount: number; + updatedAt: string; + className?: string; +} + +/** + * 게시글 리스트 아이템 + * @param {number} id - 게시글 아이디 + * @param {string} title - 게시글 제목 + * @param {string} name - 작성자 이름 + * @param {number} likeCount - 좋아요 수 + * @param {string} updatedAt - 업데이트 날짜 + * @param {string} className - 커스텀 클래스 + * @example + */ +export default function BoardItem({ + id, + title, + name, + likeCount, + updatedAt, + className, +}: BoardItemProps) { + const isMobile = useCheckMobile(); + + const textColors = 'mo:text-gray-400'; + + return ( + +

{id}

+

{title}

+

{name}

+ {isMobile ? ( + + ) : ( +

{likeCount}

+ )} +

+ {dateConversion(updatedAt)} +

+ + ); +} diff --git a/pages/boards/components/BoardList.tsx b/pages/boards/components/BoardList.tsx new file mode 100644 index 0000000..5ae6361 --- /dev/null +++ b/pages/boards/components/BoardList.tsx @@ -0,0 +1,34 @@ +import BoardItem from './BoardItem'; + +/** + * 게시글 리스트 + * @param {any[]} data - 게시글 데이터 + * @example + */ +export default function BoardList({ data }: { data: any[] }) { + const tableStyles = + 'grid grid-cols-[50px_2fr_100px_100px_150px] py-[11px] mo:py-[14px] border-b items-center text-16 pc:px-[50px] ta:px-[20px]'; + + return ( +
+
+ 번호 + 제목 + 작성자 + 좋아요 + 날짜 +
+ {data.map((item) => ( + + ))} +
+ ); +} diff --git a/pages/test/boardTable.tsx b/pages/test/boardTable.tsx new file mode 100644 index 0000000..e410ccd --- /dev/null +++ b/pages/test/boardTable.tsx @@ -0,0 +1,28 @@ +import BoardList from '../boards/components/BoardList'; + +const data = [ + { + updatedAt: '2024-12-17T08:25:07.098Z', + likeCount: 123, + writer: { + name: '이름', + id: 1, + }, + title: '게시글 제목입니다.', + id: 1, + }, + { + updatedAt: '2024-12-17T08:25:07.098Z', + likeCount: 10, + writer: { + name: '이름', + id: 2, + }, + title: '게시글 제목입니다.', + id: 2, + }, +]; + +export default function BoardTableTest() { + return ; +}