-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat] QFEED-66 Q-Space 상세 페이지 컴포넌트 구현 (#31)
* feat: qfeed-66 토론방 상세 페이지 방장 프로필 컨테이너 추가 * feat: qfeed-66 토론방 상세 멤버 관리 버튼 추가 * feat: qfeed-66 KebabMenu 컴포넌트 추가 * feat: qfeed-66 MembeContainer 추가
- Loading branch information
Showing
11 changed files
with
587 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/pages/QSpaceDetail/components/DetailsHeader/DetailsHeader.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import DetailsHeader from './DetailsHeader'; | ||
|
||
const meta = { | ||
title: 'Components/QSpaceDetail/DetailsHeader', | ||
component: DetailsHeader, | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
tags: ['autodocs'], | ||
argTypes: { | ||
title: { | ||
control: 'text', | ||
description: '토론방의 제목', | ||
}, | ||
creator: { | ||
control: 'text', | ||
description: '방 개설자의 닉네임', | ||
}, | ||
profileImage: { | ||
control: 'text', | ||
description: '방 개설자의 프로필 이미지 URL', | ||
}, | ||
}, | ||
} satisfies Meta<typeof DetailsHeader>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
title: '제주도 맛집 토론방', | ||
creator: '닉네임', | ||
}, | ||
}; | ||
|
||
export const WithProfileImage: Story = { | ||
args: { | ||
title: '제주도 맛집 토론방', | ||
creator: '닉네임', | ||
profileImage: 'https://via.placeholder.com/40', | ||
}, | ||
}; | ||
|
||
export const LongTitle: Story = { | ||
args: { | ||
title: '아주 긴 제목의 토론방입니다. 이렇게 길게 써도 잘 보여야 합니다.', | ||
creator: '닉네임', | ||
}, | ||
}; | ||
|
||
export const LongCreatorName: Story = { | ||
args: { | ||
title: '제주도 맛집 토론방', | ||
creator: '아주긴닉네임입니다만어떠신가요', | ||
}, | ||
}; |
51 changes: 51 additions & 0 deletions
51
src/pages/QSpaceDetail/components/DetailsHeader/DetailsHeader.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import styled from '@emotion/styled'; | ||
import theme from '@/styles/theme'; | ||
import ProfileImage from '@/components/ui/ProfileImageCon/ProfileImageCon'; | ||
|
||
interface DetailsHeaderProps { | ||
title: string; | ||
creator: string; | ||
profileImage?: string; | ||
} | ||
|
||
const DetailsHeader = ({ title, creator, profileImage }: DetailsHeaderProps) => { | ||
return ( | ||
<Container> | ||
<ProfileImage src={profileImage} size={40} bgColor={theme.colors.gray[200]} alt='프로필 이미지' /> | ||
<TextContent> | ||
<Title>{title}</Title> | ||
<CreatorInfo>{creator}</CreatorInfo> | ||
</TextContent> | ||
</Container> | ||
); | ||
}; | ||
|
||
const Container = styled.div` | ||
display: flex; | ||
align-items: center; | ||
gap: 0.75rem; | ||
padding: 1rem; | ||
`; | ||
|
||
const TextContent = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 0.25rem; | ||
`; | ||
|
||
const Title = styled.h2` | ||
font-family: ${theme.typography.fontFamily.korean}; | ||
font-size: ${theme.typography.body1.size}; | ||
font-weight: ${theme.typography.weights.semiBold}; | ||
color: ${theme.colors.black}; | ||
margin: 0; | ||
`; | ||
|
||
const CreatorInfo = styled.p` | ||
font-family: ${theme.typography.fontFamily.korean}; | ||
font-size: ${theme.typography.body3.size}; | ||
color: ${theme.colors.gray[400]}; | ||
margin: 0; | ||
`; | ||
|
||
export default DetailsHeader; |
45 changes: 45 additions & 0 deletions
45
src/pages/QSpaceDetail/components/KebabMenu/KebabMenu.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// KebabMenu.stories.tsx | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import KebabMenu from './KebabMenu'; | ||
|
||
const meta = { | ||
title: 'Components/QSpaceDetail/KebabMenu', | ||
component: KebabMenu, | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
tags: ['autodocs'], | ||
argTypes: { | ||
initialRecruitmentStatus: { | ||
control: 'boolean', | ||
description: '초기 모집 상태 (true: 모집 중, false: 모집 완료)', | ||
}, | ||
onEditClick: { | ||
action: 'edited', | ||
description: '수정 버튼 클릭 핸들러', | ||
}, | ||
onDeleteClick: { | ||
action: 'deleted', | ||
description: '삭제 버튼 클릭 핸들러', | ||
}, | ||
onRecruitmentStatusChange: { | ||
action: 'recruitment status changed', | ||
description: '모집 상태 변경 핸들러', | ||
}, | ||
}, | ||
} satisfies Meta<typeof KebabMenu>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
initialRecruitmentStatus: true, | ||
}, | ||
}; | ||
|
||
export const RecruitingComplete: Story = { | ||
args: { | ||
initialRecruitmentStatus: false, | ||
}, | ||
}; |
120 changes: 120 additions & 0 deletions
120
src/pages/QSpaceDetail/components/KebabMenu/KebabMenu.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import { useState, useRef, useEffect } from 'react'; | ||
import styled from '@emotion/styled'; | ||
import { VscKebabVertical } from 'react-icons/vsc'; | ||
import theme from '@/styles/theme'; | ||
|
||
interface KebabMenuProps { | ||
onEditClick?: () => void; | ||
onDeleteClick?: () => void; | ||
onRecruitmentStatusChange?: (isRecruiting: boolean) => void; | ||
initialRecruitmentStatus?: boolean; | ||
} | ||
|
||
const KebabMenu = ({ | ||
onEditClick, | ||
onDeleteClick, | ||
onRecruitmentStatusChange, | ||
initialRecruitmentStatus = true, // true: 모집 중, false: 모집 완료 | ||
}: KebabMenuProps) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const [isRecruiting, setIsRecruiting] = useState(initialRecruitmentStatus); | ||
const menuRef = useRef<HTMLDivElement>(null); | ||
|
||
useEffect(() => { | ||
const handleClickOutside = (event: MouseEvent) => { | ||
if (menuRef.current && !menuRef.current.contains(event.target as Node)) { | ||
setIsOpen(false); | ||
} | ||
}; | ||
|
||
document.addEventListener('mousedown', handleClickOutside); | ||
return () => { | ||
document.removeEventListener('mousedown', handleClickOutside); | ||
}; | ||
}, []); | ||
|
||
const handleToggle = () => { | ||
setIsOpen(!isOpen); | ||
}; | ||
|
||
const handleRecruitmentStatusClick = () => { | ||
const newStatus = !isRecruiting; | ||
setIsRecruiting(newStatus); | ||
onRecruitmentStatusChange?.(newStatus); | ||
setIsOpen(false); | ||
}; | ||
|
||
return ( | ||
<Container ref={menuRef}> | ||
<IconButton onClick={handleToggle}> | ||
<VscKebabVertical size={24} /> | ||
</IconButton> | ||
|
||
{isOpen && ( | ||
<MenuPopup> | ||
<MenuItem onClick={handleRecruitmentStatusClick}> | ||
{isRecruiting ? '모집 완료로 변경' : '모집 중으로 변경'} | ||
</MenuItem> | ||
<MenuItem onClick={onEditClick}>글 수정하기</MenuItem> | ||
<MenuItem onClick={onDeleteClick}>글 삭제하기</MenuItem> | ||
</MenuPopup> | ||
)} | ||
</Container> | ||
); | ||
}; | ||
|
||
const Container = styled.div` | ||
position: relative; | ||
display: inline-block; | ||
`; | ||
|
||
const IconButton = styled.button` | ||
background: none; | ||
border: none; | ||
padding: 0.5rem; | ||
cursor: pointer; | ||
color: ${theme.colors.gray[400]}; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
transition: color 0.2s ease-in-out; | ||
&:hover { | ||
color: ${theme.colors.gray[600]}; | ||
} | ||
`; | ||
|
||
const MenuPopup = styled.div` | ||
position: absolute; | ||
top: 100%; | ||
right: 0; | ||
min-width: 160px; | ||
background-color: ${theme.colors.white}; | ||
border-radius: 8px; | ||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); | ||
overflow: hidden; | ||
z-index: 1000; | ||
`; | ||
|
||
const MenuItem = styled.button` | ||
width: 100%; | ||
padding: 0.75rem 1rem; | ||
border: none; | ||
background: none; | ||
text-align: left; | ||
font-family: ${theme.typography.fontFamily.korean}; | ||
font-size: ${theme.typography.body2.size}; | ||
color: ${theme.colors.gray[600]}; | ||
cursor: pointer; | ||
transition: background-color 0.2s ease-in-out; | ||
&:hover { | ||
background-color: ${theme.colors.sub}; | ||
} | ||
&:not(:last-child) { | ||
border-bottom: 1px solid ${theme.colors.gray[100]}; | ||
} | ||
`; | ||
|
||
export default KebabMenu; |
Oops, something went wrong.