Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat/#370] 상세 페이지에서 상세 이미지 뷰 추가 #373

Merged
merged 6 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/pages/gig/Gig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const Gig = () => {
return <Loading />;
}

if (!data) {
if (!isLoading && !data) {
return <NotFound />;
}

Expand All @@ -88,6 +88,7 @@ const Gig = () => {
/>
<Content
description={data?.performanceDescription ?? ""}
performanceImageList={data?.performanceImageList ?? []}
attentionNote={data?.performanceAttentionNote ?? ""}
contact={data?.performanceContact ?? ""}
teamName={data?.performanceTeamName ?? ""}
Expand Down
8 changes: 8 additions & 0 deletions src/pages/gig/components/content/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ export type StaffListType = {
staffPhoto?: string;
};

export interface PerformanceImageList {
performanceImageId?: number;
performanceImage?: string;
}

interface ContentProps {
description: string;
performanceImageList: PerformanceImageList[];
attentionNote: string;
contact: string;
teamName: string;
Expand All @@ -31,6 +37,7 @@ interface ContentProps {

const Content = ({
description,
performanceImageList,
attentionNote,
contact,
teamName,
Expand All @@ -50,6 +57,7 @@ const Content = ({
{activeTab === TAB_TYPE.PERFORMANCE && (
<PerformanceIntroduce
description={description}
performanceImageList={performanceImageList}
attentionNote={attentionNote}
contact={contact}
/>
Expand Down
47 changes: 47 additions & 0 deletions src/pages/gig/components/detailImage/DetailImage.styled.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p5) 여기 작업할 때 px을 사용하신 기준이 궁금합니다!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gap 과 같이 작은 숫자로 표현되는 건,,, 0.8rem 이렇게 쓰는 것보다 px로 쓰는 게 익숙해서 그런 것 같아요!
수정하겠습니다~!

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import styled from "styled-components";

export const Wrapper = styled.div`
position: relative;
display: flex;
flex-direction: column;
`;

export const ImageWrapper = styled.div<{ $showAllImages: boolean; $toggleAvailable: boolean }>`
display: flex;
flex-direction: column;
gap: 1.6rem;
height: ${({ $showAllImages, $toggleAvailable }) =>
$showAllImages ? "auto" : $toggleAvailable && "70rem"};
overflow: ${({ $showAllImages }) =>
$showAllImages ? "visible" : "hidden"}; /* 이미지의 하단 부분을 잘라내도록 설정 */
`;

export const Image = styled.img`
width: 100%;
height: auto;
`;

export const ShowMoreButton = styled.button`
display: flex;
justify-content: space-between;
margin-top: 0.8rem;
padding: 1.6rem 9.1rem;

color: ${({ theme }) => theme.colors.white};
${({ theme }) => theme.fonts["body1-normal-semi"]};

background-color: ${({ theme }) => theme.colors.gray_900};
cursor: pointer;
border: 1px solid ${({ theme }) => theme.colors.gray_700};
border-radius: 0.6rem;
`;

export const Overlay = styled.div`
position: absolute;
bottom: 6.3rem;

width: 100%;
height: 10rem;

background: linear-gradient(180deg, rgb(27 27 27 / 0%) 0%, #1b1b1b 100%);
`;
45 changes: 45 additions & 0 deletions src/pages/gig/components/detailImage/DetailImage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { useState } from "react";
import { IconArrowDown, IconArrowUp } from "@assets/svgs";
import * as S from "./DetailImage.styled";

const DetailImage = ({ performanceImageList }) => {
const toggleAvailable = performanceImageList?.length > 2;
const [showAllImages, setShowAllImages] = useState(false);

const handleDetailImageToggle = () => {
setShowAllImages((prev) => !prev);
};

if (!performanceImageList || performanceImageList.length === 0) {
return null;
}

return (
<S.Wrapper>
<S.ImageWrapper $showAllImages={showAllImages} $toggleAvailable={toggleAvailable}>
{performanceImageList.map((image) => (
<S.Image key={image.performanceImageId} src={image.performanceImage} />
))}
</S.ImageWrapper>

{toggleAvailable && (
<>
{!showAllImages && <S.Overlay />}
<S.ShowMoreButton onClick={handleDetailImageToggle}>
{showAllImages ? (
<>
<span>상세 이미지 접기</span> <IconArrowUp width={"24px"} />
</>
) : (
<>
<span>상세 이미지 더보기</span> <IconArrowDown width={"24px"} />
</>
)}
</S.ShowMoreButton>
</>
)}
</S.Wrapper>
);
};

export default DetailImage;
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const Title = styled.h1`

export const Description = styled.pre`
width: 32.7rem;

${({ theme }) => theme.fonts["body2-long"]};
color: ${({ theme }) => theme.colors.white};
white-space: pre-line;
Expand Down Expand Up @@ -57,12 +58,12 @@ export const Toggle = styled.span`
`;

export const Contact = styled.p`
display: flex;
align-items: center;
justify-content: flex-start;
width: 100%;
padding: 1.2rem 1.2rem 1.2rem 0;
text-decoration-line: underline;
display: flex;
justify-content: flex-start;
align-items: center;

color: ${({ theme }) => theme.colors.white};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { useState } from "react";
import { PerformanceImageList } from "../content/Content";
import Contact from "./Contact";
import * as S from "./PerformanceIntroduce.styled";
import DetailImage from "../detailImage/DetailImage";

interface PerformanceIntroduceProps {
description: string;
performanceImageList: PerformanceImageList[];
attentionNote: string;
contact: string;
}

const PerformanceIntroduce = ({
description,
performanceImageList,
attentionNote,
contact,
}: PerformanceIntroduceProps) => {
Expand All @@ -18,6 +23,7 @@ const PerformanceIntroduce = ({
<S.Title>공연소개</S.Title>
<S.Description>{description}</S.Description>
</S.Container>
<DetailImage performanceImageList={performanceImageList} />
<S.Divider />
<S.Container>
<S.Title>유의사항</S.Title>
Expand Down
1 change: 1 addition & 0 deletions src/pages/register/Register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ const Register = () => {
<Content
description={performanceDescription}
attentionNote={performanceAttentionNote}
performanceImageList={performanceImageList}
contact={performanceContact}
teamName={performanceTeamName}
castList={castList.map((cast, index) => ({
Expand Down
Loading
Loading