Skip to content

Commit 8f04541

Browse files
Merge pull request #81 from sparcs-kaist/feat/MainPage
modify Article List Component and make document page like StoryBoard
2 parents b150340 + 52d5431 commit 8f04541

File tree

5 files changed

+325
-418
lines changed

5 files changed

+325
-418
lines changed

src/app/document/ArticleList/page.tsx

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
"use client";
2+
3+
import ArticleList from "@/components/ArticleList/ArticleList";
4+
import { useState } from "react";
5+
import Link from "next/link";
6+
import Image from "next/image";
7+
8+
// 옵션 타입 정의
9+
interface UIOptions {
10+
showWriter: boolean;
11+
showBoard: boolean;
12+
showProfile: boolean;
13+
showHit: boolean;
14+
showStatus: boolean;
15+
showAttachment: boolean;
16+
showRank: boolean;
17+
showAnswerStatus: boolean;
18+
showTimeAgo: boolean;
19+
}
20+
21+
// 옵션 컨트롤 컴포넌트 타입 정의
22+
interface OptionControlProps {
23+
options: UIOptions;
24+
onChange: (option: string, value: boolean) => void;
25+
containerWidth: number;
26+
onWidthChange: (width: number) => void;
27+
titleFontSize: string;
28+
onFontSizeChange: (size: string) => void;
29+
titleFontWeight: string;
30+
onFontWeightChange: (weight: string) => void;
31+
}
32+
33+
// 옵션 컨트롤 컴포넌트
34+
const OptionControl = ({
35+
options,
36+
onChange,
37+
containerWidth,
38+
onWidthChange,
39+
titleFontSize,
40+
onFontSizeChange,
41+
titleFontWeight,
42+
onFontWeightChange
43+
}: OptionControlProps) => {
44+
return (
45+
<div className="p-4 bg-white rounded-lg shadow-sm mb-4 border border-gray-200">
46+
<h3 className="text-lg font-bold mb-3">UI 옵션 설정</h3>
47+
48+
<div className="mb-4 p-3 bg-gray-50 rounded-lg">
49+
<label className="block text-sm font-medium mb-2">컨테이너 너비: {containerWidth}px</label>
50+
<input type="range" min="300" max="800" value={containerWidth} onChange={(e) => onWidthChange(parseInt(e.target.value))} className="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer" />
51+
<div className="flex justify-between text-xs text-gray-500 mt-1"><span>300px</span><span>550px (기본)</span><span>800px</span></div>
52+
</div>
53+
54+
<div className="mb-4 p-3 bg-gray-50 rounded-lg">
55+
<label className="block text-sm font-medium mb-2">제목 폰트 크기 (Tailwind): {titleFontSize}</label>
56+
<select value={titleFontSize} onChange={(e) => onFontSizeChange(e.target.value)} className="w-full p-2 border border-gray-300 rounded-lg">
57+
<option value="text-xs">text-xs</option><option value="text-sm">text-sm</option><option value="text-base">text-base (기본)</option><option value="text-lg">text-lg</option><option value="text-xl">text-xl</option><option value="text-2xl">text-2xl</option>
58+
</select>
59+
</div>
60+
61+
<div className="mb-4 p-3 bg-gray-50 rounded-lg">
62+
<label className="block text-sm font-medium mb-2">제목 폰트 굵기 (Tailwind): {titleFontWeight}</label>
63+
<select value={titleFontWeight} onChange={(e) => onFontWeightChange(e.target.value)} className="w-full p-2 border border-gray-300 rounded-lg">
64+
<option value="font-light">font-light</option><option value="font-normal">font-normal (기본)</option><option value="font-medium">font-medium</option><option value="font-semibold">font-semibold</option><option value="font-bold">font-bold</option>
65+
</select>
66+
</div>
67+
68+
<div className="grid grid-cols-3 gap-2">
69+
{Object.entries(options).map(([key, value]) => (
70+
<div key={key} className="flex items-center">
71+
<input type="checkbox" id={key} checked={value} onChange={() => onChange(key, !value)} className="mr-2" />
72+
<label htmlFor={key} className="text-sm">{key.replace('show', '')}</label>
73+
</div>
74+
))}
75+
</div>
76+
</div>
77+
);
78+
};
79+
80+
export default function ArticleListDocumentPage() {
81+
const [containerWidth, setContainerWidth] = useState(550);
82+
const [titleFontSize, setTitleFontSize] = useState("text-base");
83+
const [titleFontWeight, setTitleFontWeight] = useState("font-normal");
84+
const [uiOptions, setUiOptions] = useState<UIOptions>({
85+
showWriter: true, showBoard: true, showProfile: false, showHit: true, showStatus: true,
86+
showAttachment: true, showRank: false, showAnswerStatus: false, showTimeAgo: true
87+
});
88+
const handleOptionChange = (option: string, value: boolean) => {
89+
setUiOptions(prev => ({ ...prev, [option]: value }));
90+
};
91+
92+
const testArticles = [
93+
{ id: 1, title: "이것은 매우 긴 게시글 제목입니다. 실제로는 이보다 더 길 수도 있고 말줄임표(...) 처리가 잘 되는지 확인해보겠습니다", author: "개발자", timeAgo: "9분 전", likes: 50, dislikes: 2, comments: 15, boardName: "개발 게시판", hasAttachment: true, attachmentType: 'image' as const, hit: 230, answered: true, profileImage: "/assets/ServiceAra.svg" },
94+
{ id: 2, title: "UI 옵션을 변경해보세요!", author: "디자이너", timeAgo: "20분 전", likes: 40, dislikes: 3, comments: 10, boardName: "디자인 게시판", hasAttachment: false, hit: 185, answered: false },
95+
{ id: 3, title: "프로필 이미지와 순위 표시 테스트 - 이 제목도 상당히 길게 만들어서 말줄임 처리를 확인해보겠습니다", author: "테스터", timeAgo: "1시간 전", likes: 35, dislikes: 1, comments: 8, boardName: "테스트 게시판", hasAttachment: true, attachmentType: 'both' as const, hit: 142, answered: true, profileImage: "/assets/ServiceAra.svg" },
96+
{ id: 4, title: "첨부파일 표시 기능 확인", author: "사용자", timeAgo: "2시간 전", likes: 25, dislikes: 0, comments: 5, boardName: "일반 게시판", hasAttachment: true, attachmentType: 'file' as const, hit: 98, answered: false }
97+
];
98+
99+
return (
100+
<div className="max-w-[1200px] mx-auto p-4">
101+
<h1 className="text-3xl font-bold mb-4">ArticleList Component Document</h1>
102+
103+
<div className="mb-6">
104+
<OptionControl
105+
options={uiOptions} onChange={handleOptionChange} containerWidth={containerWidth} onWidthChange={setContainerWidth}
106+
titleFontSize={titleFontSize} onFontSizeChange={setTitleFontSize} titleFontWeight={titleFontWeight} onFontWeightChange={setTitleFontWeight}
107+
/>
108+
</div>
109+
110+
<div className="flex justify-center">
111+
<div className="w-full p-4 rounded-lg shadow-sm transition-all duration-300 bg-white border" style={{ maxWidth: `${containerWidth}px` }}>
112+
<ArticleList posts={testArticles} titleFontSize={titleFontSize} titleFontWeight={titleFontWeight} {...uiOptions} />
113+
</div>
114+
</div>
115+
</div>
116+
);
117+
}

0 commit comments

Comments
 (0)