Skip to content

Commit 2f34aaa

Browse files
feat : IT News 리스트 페이지 UI (#53)
Co-authored-by: 정석호 <[email protected]>
1 parent 5253993 commit 2f34aaa

File tree

7 files changed

+317
-81
lines changed

7 files changed

+317
-81
lines changed

frontend/zicdding-class.com/app/(test)/test/ITNews/page.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
'use client';
2-
import ITNews from '@/app/_components/ITNews';
2+
import ITNews from '@/app/_components/ITNewsCard';
33

44
export default function TestPage() {
55
return (
66
<ITNews
7-
id={1}
7+
id="7b205a4d-f17f-4b65-a463-38a270d1ab39"
88
title="샘플 IT 뉴스 제목"
99
thumbnailSrc="https://via.placeholder.com/300x200"
1010
type="공모전"
11-
date={{
12-
start: '2024-01-01',
13-
end: '2024-12-31',
14-
}}
15-
likeCount={15}
16-
viewCount={99}
17-
commentCount={13}
11+
startedDate="2023-04-01"
12+
endDate="2023-04-30"
13+
likeCnt={15}
14+
viewCnt={99}
15+
commentCnt={13}
1816
myLike={false}
1917
/>
2018
);

frontend/zicdding-class.com/app/_components/ITNews.tsx

Lines changed: 0 additions & 72 deletions
This file was deleted.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import { Icon } from '@ui/components/Icon';
2+
import { Card, CardHeader, CardFooter, CardTitle, CardContent, CardDescription } from '@zicdding-web/ui';
3+
import { cn } from '@ui/lib/utils';
4+
import Image from 'next/image';
5+
import type { MouseEvent } from 'react';
6+
7+
interface Props extends React.ComponentPropsWithRef<typeof Card> {
8+
id: string;
9+
title: string;
10+
thumbnailSrc: string;
11+
type: string;
12+
startedDate: string;
13+
endDate: string;
14+
likeCnt: number;
15+
viewCnt: number;
16+
commentCnt: number;
17+
myLike: boolean;
18+
19+
onClick?: (e: MouseEvent<HTMLDivElement>) => void;
20+
onClickLike?: (e: MouseEvent<SVGAElement>) => void;
21+
}
22+
23+
export default function ITNews({
24+
id,
25+
title,
26+
thumbnailSrc,
27+
type,
28+
startedDate,
29+
endDate,
30+
likeCnt,
31+
viewCnt,
32+
commentCnt,
33+
myLike,
34+
className,
35+
onClick,
36+
onClickLike,
37+
...rest
38+
}: Props) {
39+
return (
40+
<Card className={cn('relative rounded-[20px] border border-black', className)} onClick={onClick} {...rest}>
41+
<CardHeader className="relative w-full pb-56 pt-0 rounded-tl-[20px] rounded-tr-[20px] overflow-hidden">
42+
<Image src={thumbnailSrc} alt={title} layout="fill" />
43+
</CardHeader>
44+
<CardContent className="px-[15px]">
45+
<CardDescription className="mt-[10px] px-5 py-1 inline-block text-[14px] text-muted-foreground border bg-gray-300 rounded">
46+
{type}
47+
</CardDescription>
48+
<CardTitle className="mt-[15px] font-semibold text-xl leading-none tracking-tight">{title}</CardTitle>
49+
<div className="flex gap-1 mt-[10px] text-sm">
50+
<span>기간 :</span>
51+
<span className="font-semibold">
52+
{startedDate} ~ {endDate}
53+
</span>
54+
</div>
55+
</CardContent>
56+
<CardFooter className="mt-[20px] justify-end px-[15px] pb-[15px] pt-0">
57+
<ul className="flex items-center justify-end gap-4 text-sm">
58+
<li className="flex gap-1">
59+
<span>⭐️</span>
60+
<span>{likeCnt}</span>
61+
</li>
62+
<li className="flex gap-1">
63+
<span>👁️</span>
64+
<span>{viewCnt}</span>
65+
</li>
66+
<li className="flex gap-1">
67+
<span>💬</span>
68+
<span>{commentCnt}</span>
69+
</li>
70+
</ul>
71+
</CardFooter>
72+
<div className="absolute cursor-pointer top-2 right-2">
73+
<Icon
74+
name="star"
75+
className={myLike ? 'text-yellow-400' : 'text-gray-400'}
76+
onClick={(e) => {
77+
e.stopPropagation();
78+
onClickLike?.(e);
79+
}}
80+
/>
81+
</div>
82+
</Card>
83+
);
84+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default function ItNewsDetailPage() {
2+
return (
3+
<div>
4+
<h1>아이티 뉴스 상세 페이지</h1>
5+
</div>
6+
);
7+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use client';
2+
3+
import { Tabs } from '@zicdding-web/ui/Tabs';
4+
5+
type TabItem = {
6+
title: string;
7+
value: string;
8+
};
9+
10+
interface ItTabsProps {
11+
item: TabItem[];
12+
}
13+
14+
export function ItTabs({ item }: ItTabsProps) {
15+
return <Tabs items={item} defaultValue="recent" onChange={(e) => console.log(e)} />;
16+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { Button } from '@zicdding-web/ui';
2+
import { useState } from 'react';
3+
4+
const TypeOptions = [
5+
{ label: '전체', value: 'all' },
6+
{ label: '해커톤', value: 'hackathon' },
7+
{ label: '이벤트', value: 'event' },
8+
{ label: '공모전', value: 'competition' },
9+
];
10+
11+
export function TypeButton() {
12+
const [selectedType, setSelectedType] = useState<string>('all');
13+
14+
const handleTypeClick = (type: string) => {
15+
setSelectedType(type);
16+
console.log(`선택된 타입: ${type}`);
17+
};
18+
19+
return (
20+
<div className="flex gap-[30px]">
21+
{TypeOptions.map(({ label, value }) => (
22+
<Button
23+
className={`px-0 text-2xl ${value === selectedType ? 'text-black' : 'text-gray-400'} hover:text-black`}
24+
key={value}
25+
variant="link"
26+
size="lg"
27+
onClick={() => handleTypeClick(value)}
28+
>
29+
{label}
30+
</Button>
31+
))}
32+
</div>
33+
);
34+
}

0 commit comments

Comments
 (0)