Skip to content

Commit 1ec7c06

Browse files
committed
refact/ 삭제, UI
1 parent f1e2739 commit 1ec7c06

File tree

2 files changed

+63
-24
lines changed

2 files changed

+63
-24
lines changed

.github/copilot-instructions.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ This is a React 19 TypeScript application built with Vite, featuring a community
2727

2828
### Styling & UI
2929
- **Tailwind CSS**: Utility-first styling with custom config
30-
- **Icons**: Lucide React icons
30+
- **Icons**: Lucide React icons served from `/icons/` directory
3131
- **Fonts**: Pretendard font family
32-
- **Responsive**: Max-width containers (`max-w-[1200px]`)
32+
- **Responsive**: Max-width containers (`max-w-[1200px]` for header, `max-w-[820px]` for post content, `max-w-[944px]` for comments)
33+
- **Korean UI**: All user-facing text in Korean
3334

3435
## Development Workflow
3536

@@ -72,6 +73,7 @@ npm run preview # Preview production build
7273
- **State management**: Multiple `useState` hooks for form inputs, loading, error states
7374
- **Navigation**: `useNavigate` from React Router for programmatic routing
7475
- **URL params**: `useParams` for route parameters like `postId`
76+
- **Modal patterns**: Fixed positioning with `z-50`, centered with flexbox
7577

7678
## Key Files to Reference
7779

@@ -114,5 +116,11 @@ npm run preview # Preview production build
114116
### Styling
115117
- Use Tailwind utility classes primarily
116118
- Follow existing responsive patterns with `max-w-[1200px]` containers
117-
- Maintain header/footer spacing in layout components</content>
119+
- Maintain header/footer spacing in layout components
120+
- Use Korean text for all user-facing content
121+
122+
### MSW Development
123+
- Add mock handlers in `src/mocks/handlers.ts` for new API endpoints
124+
- Follow existing type definitions for mock data structure
125+
- Test API integrations in development before backend implementation</content>
118126
<parameter name="filePath">/Users/admin/Documents/main project/oz_externship_fe_06_team4/.github/copilot-instructions.md

src/pages/community/CommunityDetailPage.tsx

Lines changed: 52 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default function CommunityDetailPage() {
2525
// 댓글 작성
2626
const [newComment, setNewComment] = useState('')
2727
const [isSubmitting, setIsSubmitting] = useState(false)
28+
const [isSubmitClicked, setIsSubmitClicked] = useState(false)
2829

2930
// 좋아요 상태
3031
const [isLiked, setIsLiked] = useState(false)
@@ -131,21 +132,26 @@ export default function CommunityDetailPage() {
131132

132133
try {
133134
setIsSubmitting(true)
135+
setIsSubmitClicked(true)
134136
await createCommunityComment(Number(postId), { content: newComment })
135137

136138
// 댓글 목록 새로고침
137139
const commentData = await getCommunityComments(Number(postId))
138140
setComments(commentData.results || [])
139-
141+
140142
// 게시글 정보도 업데이트 (댓글 개수 반영)
141143
const postData = await getCommunityPostDetail(Number(postId))
142144
setPost(postData)
143-
145+
144146
setNewComment('')
145147
alert('댓글이 등록되었습니다.')
148+
149+
// 약간의 딜레이 후 클릭 상태 초기화
150+
setTimeout(() => setIsSubmitClicked(false), 200)
146151
} catch (err) {
147152
console.error('댓글 작성 실패:', err)
148153
alert('댓글 작성에 실패했습니다.')
154+
setIsSubmitClicked(false)
149155
} finally {
150156
setIsSubmitting(false)
151157
}
@@ -156,15 +162,15 @@ export default function CommunityDetailPage() {
156162
try {
157163
// API 호출 구현 필요
158164
// await deleteCommunityComment(Number(postId), commentId)
159-
165+
160166
// 임시: 로컬에서 삭제
161167
setComments(prev => prev.filter(c => c.id !== commentId))
162-
168+
163169
// 댓글 개수 업데이트
164170
if (post) {
165171
setPost({ ...post, comment_count: post.comment_count - 1 })
166172
}
167-
173+
168174
setDeleteCommentId(null)
169175
alert('댓글이 삭제되었습니다.')
170176
} catch (err) {
@@ -244,18 +250,21 @@ export default function CommunityDetailPage() {
244250
{/* 좋아요 / 공유하기 */}
245251
<div className="mt-10 flex justify-end gap-3">
246252
<button
247-
className={`flex items-center gap-1 rounded-full border px-4 py-2 text-[12px] transition-colors ${
248-
isLiked
249-
? 'border-[#6201E0] bg-[#6201E0] text-white'
250-
: 'border-[#CECECE] text-[#707070] hover:bg-gray-50'
251-
}`}
253+
className={`flex items-center gap-1 rounded-full border-2 px-4 py-2 text-[12px] transition-all ${isLiked
254+
? 'border-[#6201E0] bg-[#F5EFFF] text-[#6201E0]'
255+
: 'border-[#CECECE] bg-white text-[#707070]'
256+
}`}
252257
onClick={handleLikeToggle}
253258
>
254259
<img
255260
src="/icons/thumbs-up.svg"
256261
className="h-4 w-4"
257262
alt="좋아요"
258-
style={{ filter: isLiked ? 'brightness(0) invert(1)' : 'none' }}
263+
style={{
264+
filter: isLiked
265+
? 'invert(21%) sepia(100%) saturate(6534%) hue-rotate(268deg) brightness(91%) contrast(117%)'
266+
: 'none'
267+
}}
259268
/>
260269
{likeCount.toLocaleString()}
261270
</button>
@@ -277,7 +286,7 @@ export default function CommunityDetailPage() {
277286
{/* 댓글 작성 영역 - 로그인한 경우만 표시 */}
278287
{loggedIn && (
279288
<div className="mb-6 flex justify-center">
280-
<div className="relative w-[944px] h-[120px] rounded-[12px] border border-[#CECECE] bg-white p-4">
289+
<div className="relative w-[944px] h-[120px] rounded-[12px] border border-[#CECECE] bg-white p-4 focus-within:border-[#6201E0] transition-colors">
281290
<textarea
282291
className="w-full h-[60px] resize-none bg-transparent text-[16px] text-[#121212] placeholder-[#CECECE] focus:outline-none"
283292
placeholder="개인정보를 공유 및 요청하거나, 명예 회손, 무단 광고, 불법 정보 유포시 모니터링 후 삭제될 수 있습니다."
@@ -290,9 +299,15 @@ export default function CommunityDetailPage() {
290299
{newComment.length}/{MAX_COMMENT_LENGTH}
291300
</span>
292301
<button
293-
className="rounded-full bg-[#E5E5E5] px-5 py-1.5 text-[16px] text-[#9D9D9D] hover:bg-[#6201E0] hover:text-white disabled:bg-[#E5E5E5] disabled:text-[#9D9D9D] disabled:cursor-not-allowed transition-colors"
294302
onClick={handleCommentSubmit}
295-
disabled={isSubmitting || !newComment.trim()}
303+
disabled={!newComment.trim() || isSubmitting}
304+
className={`
305+
rounded-full px-5 py-1.5 text-[16px] font-medium transition-all
306+
${!newComment.trim() || isSubmitting
307+
? 'bg-[#E5E5E5] text-[#9D9D9D] cursor-not-allowed'
308+
: 'bg-[#EFE6FC] text-[#6201E0] border-2 border-[#6201E0] hover:bg-[#DED3F5] active:scale-95'
309+
}
310+
`}
296311
>
297312
{isSubmitting ? '등록 중...' : '등록'}
298313
</button>
@@ -309,7 +324,7 @@ export default function CommunityDetailPage() {
309324
댓글 {post.comment_count}
310325
</div>
311326

312-
<button
327+
<button
313328
className="flex items-center gap-1 text-[16px] text-[#4D4D4D] hover:text-[#6201E0]"
314329
onClick={handleSortToggle}
315330
>
@@ -388,21 +403,37 @@ export default function CommunityDetailPage() {
388403
{/* 댓글 삭제 확인 팝업 */}
389404
{deleteCommentId !== null && (
390405
<div className="fixed inset-0 z-50 flex items-center justify-center">
391-
<div className="w-[428px] h-[165px] rounded-[20px] bg-white p-8 shadow-xl border border-[#E5E5E5]">
392-
<h2 className="mb-6 text-center text-[20px] font-bold text-[#121212]">
406+
<div className="w-[428px] h-[165px] rounded-[40px] bg-white p-10 shadow-xl border border-[#E5E5E5]">
407+
<h2 className="mb-10 text-left text-[16px] font-regular text-[#303030]">
393408
댓글을 삭제하시겠습니까?
394409
</h2>
395-
396-
<div className="flex gap-3">
410+
411+
<div className="flex justify-end gap-4">
397412
<button
398413
onClick={() => setDeleteCommentId(null)}
399-
className="flex-1 rounded-full bg-[#E8E0F5] py-3 text-[16px] font-medium text-[#6201E0] hover:bg-[#D8CEEB] transition-colors"
414+
className="
415+
w-[76px] h-[42px]
416+
rounded-full
417+
bg-[#EFE6FC]
418+
text-[16px] font-medium text-[#4E01B3]
419+
flex items-center justify-center
420+
hover:bg-[#E1D2FA]
421+
transition-colors
422+
"
400423
>
401424
취소
402425
</button>
403426
<button
404427
onClick={() => handleDeleteComment(deleteCommentId)}
405-
className="flex-1 rounded-full bg-[#6201E0] py-3 text-[16px] font-medium text-white hover:bg-[#5001C0] transition-colors"
428+
className="
429+
w-[76px] h-[42px]
430+
rounded-full
431+
bg-[#6201E0]
432+
text-[16px] font-medium text-white
433+
flex items-center justify-center
434+
hover:bg-[#5200BE]
435+
transition-colors
436+
"
406437
>
407438
확인
408439
</button>

0 commit comments

Comments
 (0)