-
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.
[FE] feat: 리뷰 목록/리뷰 모아보기의 공통 UI 및 스위치 컴포넌트, 새 URL 및 디자인 적용 (#776)
* feat: Switch 컴포넌트 제작 * chore: Switch 컴포넌트 이름 변경 * feat: 리뷰 모아보기에 대한 라우팅 추가 및 임시 페이지 구현 * feat: 리뷰 모아보기와 리뷰 목록 페이지의 공통 레이아웃 제작 * refactor: 공통 레이아웃 제작에 따른 ReviewList 리팩토링 * feat: 리뷰 목록 반응형 적용 * feat: OptionSwitch 반응형 적용 * refactor: ReviewDisplayLayout 반응형 수정 * fix: px을 rem으로 수정 * fix: 미디어 쿼리 기준 단위를 px으로 수정 * refactor: 스타일을 위한 속성에 $처리 및 스타일 전용 인터페이스 생성 * fix: 불필요한 상속 제거 * refactor: OptionSwitch 리팩토링 - option 배열을 통한 렌더링 및 시맨틱 태그를사용 * refactor: OptionSwitch 컴포넌트 리팩토링에 따른 ReviewDisplayLayout 컴포넌트 리팩토링 및 훅 분리 * feat: 선택하지 않은 option을 hover한 경우의 추가 배경색 지정 * fix: 리뷰 작성 완료 페이지에서 breadCrumb으로 리뷰 작성 페이지로 이동하는 경로를 절대 URL 경로로 수정
- Loading branch information
1 parent
d3f1eaa
commit a06f159
Showing
20 changed files
with
294 additions
and
81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as S from './styles'; | ||
|
||
export interface OptionSwitchStyleProps { | ||
$isChecked: boolean; | ||
} | ||
|
||
export interface OptionSwitchOption { | ||
label: string; | ||
isChecked: boolean; | ||
handleOptionClick: () => void; | ||
} | ||
|
||
interface OptionSwitchProps { | ||
options: OptionSwitchOption[]; | ||
} | ||
|
||
const OptionSwitch = ({ options }: OptionSwitchProps) => { | ||
const handleSwitchClick = (index: number) => { | ||
const clickedOption = options[index]; | ||
if (clickedOption) clickedOption.handleOptionClick(); | ||
}; | ||
|
||
return ( | ||
<S.OptionSwitchContainer> | ||
{options.map((option, index) => ( | ||
<S.CheckboxWrapper key={option.label} $isChecked={option.isChecked} onClick={() => handleSwitchClick(index)}> | ||
<S.CheckboxButton type="button" $isChecked={option.isChecked}> | ||
{option.label} | ||
</S.CheckboxButton> | ||
</S.CheckboxWrapper> | ||
))} | ||
</S.OptionSwitchContainer> | ||
); | ||
}; | ||
|
||
export default OptionSwitch; |
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,48 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
import media from '@/utils/media'; | ||
|
||
import { OptionSwitchStyleProps } from './index'; | ||
|
||
export const OptionSwitchContainer = styled.ul` | ||
cursor: pointer; | ||
display: flex; | ||
justify-content: space-between; | ||
width: 15rem; | ||
height: 4.5rem; | ||
padding: 0.7rem; | ||
background-color: ${({ theme }) => theme.colors.lightGray}; | ||
border-radius: ${({ theme }) => theme.borderRadius.basic}; | ||
${media.small} { | ||
height: 3.5rem; | ||
font-size: 1.2rem; | ||
} | ||
`; | ||
|
||
export const CheckboxWrapper = styled.li<OptionSwitchStyleProps>` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
width: 50%; | ||
height: 100%; | ||
background-color: ${({ $isChecked, theme }) => ($isChecked ? theme.colors.white : theme.colors.lightGray)}; | ||
border-radius: ${({ theme }) => theme.borderRadius.basic}; | ||
transition: background-color 0.2s ease-out; | ||
&:hover { | ||
background-color: ${({ $isChecked, theme }) => ($isChecked ? theme.colors.white : theme.colors.lightPurple)}; | ||
} | ||
`; | ||
|
||
export const CheckboxButton = styled.button<OptionSwitchStyleProps>` | ||
user-select: none; | ||
font-size: 1.2rem; | ||
color: ${({ $isChecked, theme }) => ($isChecked ? theme.colors.primary : theme.colors.black)}; | ||
`; |
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
35 changes: 35 additions & 0 deletions
35
frontend/src/components/layouts/ReviewDisplayLayout/components/ReviewInfoSection/index.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,35 @@ | ||
import { calculateParticle } from '@/utils'; | ||
|
||
import * as S from './styles'; | ||
|
||
export interface ReviewInfoSectionProps { | ||
revieweeName: string; | ||
isReviewList: boolean; | ||
projectName: string; | ||
reviewCount?: number; | ||
} | ||
|
||
const ReviewInfoSection = ({ projectName, revieweeName, reviewCount, isReviewList }: ReviewInfoSectionProps) => { | ||
const revieweeNameWithParticle = calculateParticle({ | ||
target: revieweeName, | ||
particles: { withFinalConsonant: '이', withoutFinalConsonant: '가' }, | ||
}); | ||
|
||
const getReviewInfoMessage = () => { | ||
return isReviewList | ||
? `${revieweeNameWithParticle} 받은 ${reviewCount}개의 리뷰 목록이에요` | ||
: `${revieweeNameWithParticle} 받은 리뷰를 질문별로 모아봤어요`; | ||
}; | ||
|
||
return ( | ||
<S.ReviewInfoContainer> | ||
<S.ProjectName>{projectName}</S.ProjectName> | ||
<S.RevieweeInfoWrapper> | ||
<S.RevieweeName>{revieweeName}</S.RevieweeName> | ||
{getReviewInfoMessage()} | ||
</S.RevieweeInfoWrapper> | ||
</S.ReviewInfoContainer> | ||
); | ||
}; | ||
|
||
export default ReviewInfoSection; |
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
33 changes: 33 additions & 0 deletions
33
frontend/src/components/layouts/ReviewDisplayLayout/hooks/useReviewDisplayLayoutOptions.ts
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,33 @@ | ||
import { useLocation, useNavigate } from 'react-router'; | ||
|
||
import { OptionSwitchOption } from '@/components/common/OptionSwitch'; | ||
import { ROUTE } from '@/constants/route'; | ||
import { useSearchParamAndQuery } from '@/hooks'; | ||
|
||
const useReviewDisplayLayoutOptions = () => { | ||
const { pathname } = useLocation(); | ||
const navigate = useNavigate(); | ||
|
||
const { param: reviewRequestCode } = useSearchParamAndQuery({ | ||
paramKey: 'reviewRequestCode', | ||
}); | ||
|
||
const isReviewCollection = pathname.includes(ROUTE.reviewCollection); | ||
|
||
const reviewDisplayLayoutOptions: OptionSwitchOption[] = [ | ||
{ | ||
label: '목록보기', | ||
isChecked: !isReviewCollection, | ||
handleOptionClick: () => navigate(`/${ROUTE.reviewList}/${reviewRequestCode}`), | ||
}, | ||
{ | ||
label: '모아보기', | ||
isChecked: isReviewCollection, | ||
handleOptionClick: () => navigate(`/${ROUTE.reviewCollection}/${reviewRequestCode}`), | ||
}, | ||
]; | ||
|
||
return [...reviewDisplayLayoutOptions]; | ||
}; | ||
|
||
export default useReviewDisplayLayoutOptions; |
34 changes: 34 additions & 0 deletions
34
frontend/src/components/layouts/ReviewDisplayLayout/index.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,34 @@ | ||
import { TopButton, OptionSwitch } from '@/components/common'; | ||
import { EssentialPropsWithChildren } from '@/types'; | ||
|
||
import ReviewInfoSection, { ReviewInfoSectionProps } from './components/ReviewInfoSection'; | ||
import useReviewDisplayLayoutOptions from './hooks/useReviewDisplayLayoutOptions'; | ||
import * as S from './styles'; | ||
|
||
const ReviewDisplayLayout = ({ | ||
revieweeName, | ||
projectName, | ||
reviewCount, | ||
isReviewList, | ||
children, | ||
}: EssentialPropsWithChildren<ReviewInfoSectionProps>) => { | ||
const reviewDisplayLayoutOptions = useReviewDisplayLayoutOptions(); | ||
|
||
return ( | ||
<S.ReviewDisplayLayout> | ||
<S.Container> | ||
<ReviewInfoSection | ||
revieweeName={revieweeName} | ||
projectName={projectName} | ||
reviewCount={reviewCount} | ||
isReviewList={isReviewList} | ||
/> | ||
<OptionSwitch options={reviewDisplayLayoutOptions} /> | ||
</S.Container> | ||
<TopButton /> | ||
{children} | ||
</S.ReviewDisplayLayout> | ||
); | ||
}; | ||
|
||
export default ReviewDisplayLayout; |
20 changes: 20 additions & 0 deletions
20
frontend/src/components/layouts/ReviewDisplayLayout/styles.ts
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,20 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const ReviewDisplayLayout = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
width: 90%; | ||
min-height: inherit; | ||
`; | ||
|
||
export const Container = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
@media screen and (max-width: 500px) { | ||
flex-direction: column; | ||
align-items: flex-start; | ||
margin-bottom: 2.5rem; | ||
} | ||
`; |
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
Oops, something went wrong.