Skip to content

Commit

Permalink
Merge pull request #617 from TEAM-TATTOUR/S1/#608-fix-bottom-sheet
Browse files Browse the repository at this point in the history
[S1] 공통 BottomSheet 적용
  • Loading branch information
lydiacho authored Feb 24, 2024
2 parents 9344d7c + 7162566 commit a25717e
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 208 deletions.
94 changes: 94 additions & 0 deletions src/common/BottomSheet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { ReactNode } from 'react';
import Sheet from 'react-modal-sheet';
import { SheetDetent } from 'react-modal-sheet/dist/types';
import styled from 'styled-components';

interface BottomSheetProps {
isOpen: boolean;
onClose: () => void;
detent?: SheetDetent;
disableDrag: boolean;
children: ReactNode;
}

const Header = ({ disableDrag, children }: { disableDrag: boolean; children?: ReactNode }) => {
return <Sheet.Header disableDrag={disableDrag}>{children}</Sheet.Header>;
};
const Content = ({ children }: { children: ReactNode }) => {
return <Sheet.Content>{children}</Sheet.Content>;
};
const Container = ({ children, className }: { children: ReactNode; className?: string }) => {
return <Sheet.Container className={className}>{children}</Sheet.Container>;
};
const Scroller = ({ children }: { children: ReactNode }) => {
return <Sheet.Scroller>{children}</Sheet.Scroller>;
};
const Backdrop = ({ onTap }: { onTap: () => void }) => {
return <Sheet.Backdrop onTap={onTap} />;
};
const BottomSheet = ({ isOpen, onClose, detent, disableDrag, children }: BottomSheetProps) => {
return (
<Sheet
className='react-modal-sheet-wrapper'
isOpen={isOpen}
onClose={onClose}
detent={detent}
disableDrag={disableDrag}
>
<St.SheetWrapper>{children}</St.SheetWrapper>
</Sheet>
);
};

export const CustomSheet = Object.assign(BottomSheet, {
Header,
Content,
Container,
Backdrop,
Scroller,
});

const St = {
SheetWrapper: styled.div`
.react-modal-sheet-backdrop {
max-width: 43rem;
left: auto !important;
background-color: rgba(0, 0, 0, 0.6) !important;
}
.react-modal-sheet-container {
max-width: 43rem;
border-radius: 1rem 1rem 0 0;
}
.text-bottom-sheet {
padding: 2.5rem 2.4rem 0rem 2.4rem;
height: calc(100% - 10.6rem) !important;
left: initial !important;
& > div:first-child {
display: flex;
justify-content: space-between !important;
}
}
.detail-bottom-sheet {
padding: 2.5rem 0rem 7rem 0rem;
left: initial !important;
& > div:first-child {
display: flex;
justify-content: space-between !important;
margin-bottom: 2.8rem;
padding: 0rem 2.4rem 0rem 2.4rem;
}
}
.react-modal-sheet-header {
height: 1.6rem !important;
}
.react-modal-sheet-scroller {
padding-bottom: 6rem;
}
.react-modal-sheet-drag-indicator {
display: none;
}
`,
};
50 changes: 10 additions & 40 deletions src/components/Custom/Common/Select/SelectCustomPolicyBottom.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { styled } from 'styled-components';
import Sheet from 'react-modal-sheet';
import { IcCancelDark } from '../../../../assets/icon';
import { REFUND_CUSTOM_POLICY } from '../../../../assets/data/REFUND_CUSTOM_POLICY';
import { CustomSheet } from '../../../../common/BottomSheet';
interface PrePointPolicyProps {
isSheetOpen: boolean;
setSheetOpen: React.Dispatch<React.SetStateAction<boolean>>;
Expand All @@ -10,18 +10,18 @@ interface PrePointPolicyProps {
const SelectCustomPolicyBottom = ({ isSheetOpen, setSheetOpen }: PrePointPolicyProps) => {
return (
<CustomSheet isOpen={isSheetOpen} onClose={() => setSheetOpen(false)} disableDrag={true}>
<Sheet.Container>
<Sheet.Header disableDrag={false}>
<CustomSheet.Container className='text-bottom-sheet'>
<CustomSheet.Header disableDrag={false}>
<St.SheetTitle>커스텀 도안 환불 정책</St.SheetTitle>
<IcCancelDark onClick={() => setSheetOpen(false)} />
</Sheet.Header>
<Sheet.Content>
<Sheet.Scroller>
</CustomSheet.Header>
<CustomSheet.Content>
<CustomSheet.Scroller>
<St.SheetText> {REFUND_CUSTOM_POLICY}</St.SheetText>
</Sheet.Scroller>
</Sheet.Content>
</Sheet.Container>
<Sheet.Backdrop onTap={() => setSheetOpen(false)} />
</CustomSheet.Scroller>
</CustomSheet.Content>
</CustomSheet.Container>
<CustomSheet.Backdrop onTap={() => setSheetOpen(false)} />
</CustomSheet>
);
};
Expand All @@ -43,33 +43,3 @@ const St = {
white-space: pre-wrap;
`,
};

const CustomSheet = styled(Sheet)`
display: flex;
justify-content: center;
.react-modal-sheet-backdrop {
background-color: rgba(0, 0, 0, 0.6) !important;
}
.react-modal-sheet-container {
left: initial !important;
max-width: 43rem;
height: calc(90% - env(safe-area-inset-top) - 34px) !important;
padding: 2.5rem 2.4rem 0rem 2.4rem;
border-radius: 1rem 1rem 0rem 0rem !important;
}
// .react-modal-sheet-header
.react-modal-sheet-container > div {
display: flex;
justify-content: space-between !important;
}
.react-modal-sheet-scroller {
padding-bottom: 6rem;
}
.react-modal-sheet-drag-indicator {
display: none;
}
`;
41 changes: 15 additions & 26 deletions src/components/Custom/HaveDesign/Reference/PaintBottomSheet.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useEffect, useState } from 'react';
import Sheet from 'react-modal-sheet';
import { styled } from 'styled-components';
import Canvas from './Canvas';
import PaintBottomHeader from './PaintBottomHeader';
import { CustomSheet } from '../../../../common/BottomSheet';

interface PaintBottomProps {
isBottomOpen: boolean;
Expand All @@ -12,6 +12,7 @@ interface PaintBottomProps {
}

const PaintBottomSheet = ({
isBottomOpen,
setBottomOpen,
setDrawingImageUrl,
drawingImageUrl,
Expand All @@ -32,25 +33,30 @@ const PaintBottomSheet = ({
};

return (
<CustomSheet isOpen={true} onClose={closeBottom} detent='content-height' disableDrag={true}>
<Sheet.Container>
<CustomSheet
isOpen={isBottomOpen}
onClose={closeBottom}
detent='content-height'
disableDrag={true}
>
<CustomSheet.Container>
<St.BottomSheetWrapper>
<Sheet.Header disableDrag={true}>
<CustomSheet.Header disableDrag={true}>
<PaintBottomHeader onClose={closeBottom} />
</Sheet.Header>
<Sheet.Content>
</CustomSheet.Header>
<CustomSheet.Content>
<St.ContentWrapper>
<Canvas setCanvasState={setCanvasState} />
</St.ContentWrapper>
</Sheet.Content>
</CustomSheet.Content>
</St.BottomSheetWrapper>
<St.Footer>
<St.Button type='button' onClick={onClickSubmitImage}>
레퍼런스로 제출하기
</St.Button>
</St.Footer>
</Sheet.Container>
<Sheet.Backdrop onTap={closeBottom} />
</CustomSheet.Container>
<CustomSheet.Backdrop onTap={closeBottom} />
</CustomSheet>
);
};
Expand Down Expand Up @@ -81,21 +87,4 @@ const St = {
`,
};

const CustomSheet = styled(Sheet)`
max-width: 43rem;
margin: 0 auto;
.react-modal-sheet-backdrop {
background-color: rgba(0, 0, 0, 0.6) !important;
}
.react-modal-sheet-container {
border-radius: 1rem !important;
}
.react-modal-sheet-header {
height: 1.6rem !important;
}
.react-modal-sheet-drag-indicator {
display: none;
}
`;

export default PaintBottomSheet;
51 changes: 10 additions & 41 deletions src/components/Custom/PublicBottomSheet.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled from 'styled-components';
import Sheet from 'react-modal-sheet';
import { IcCancelDark } from '../../assets/icon';
import { CUSTOM_COPYRIGHT_POLICY } from '../../assets/data/CUSTOM_COPYRIGHT_POLICY';
import { CustomSheet } from '../../common/BottomSheet';

interface PublicBottomProps {
isSheetOpen: boolean;
Expand All @@ -11,18 +11,18 @@ interface PublicBottomProps {
const PublicBottomSheet = ({ isSheetOpen, setSheetOpen }: PublicBottomProps) => {
return (
<CustomSheet isOpen={isSheetOpen} onClose={() => setSheetOpen(false)} disableDrag={true}>
<Sheet.Container>
<Sheet.Header disableDrag={false}>
<CustomSheet.Container className='text-bottom-sheet'>
<CustomSheet.Header disableDrag={false}>
<St.Title>저작권 정책</St.Title>
<IcCancelDark onClick={() => setSheetOpen(false)} />
</Sheet.Header>
<Sheet.Content>
<Sheet.Scroller>
</CustomSheet.Header>
<CustomSheet.Content>
<CustomSheet.Scroller>
<St.Text>{CUSTOM_COPYRIGHT_POLICY}</St.Text>
</Sheet.Scroller>
</Sheet.Content>
</Sheet.Container>
<Sheet.Backdrop onTap={() => setSheetOpen(false)} />
</CustomSheet.Scroller>
</CustomSheet.Content>
</CustomSheet.Container>
<CustomSheet.Backdrop onTap={() => setSheetOpen(false)} />
</CustomSheet>
);
};
Expand All @@ -42,34 +42,3 @@ const St = {
white-space: pre-wrap;
`,
};

const CustomSheet = styled(Sheet)`
display: flex;
justify-content: center;
.react-modal-sheet-backdrop {
background-color: rgba(0, 0, 0, 0.6) !important;
}
.react-modal-sheet-container {
padding: 2.5rem 2.4rem 0rem 2.4rem;
// 모달 높이 낮추기
height: calc(100% - 10.6rem) !important;
left: initial !important;
max-width: 43rem;
border-radius: 1rem 1rem 0rem 0rem !important;
}
.react-modal-sheet-container > div {
display: flex;
justify-content: space-between !important;
}
.react-modal-sheet-scroller {
padding-bottom: 6rem;
}
.react-modal-sheet-drag-indicator {
display: none;
}
`;
43 changes: 8 additions & 35 deletions src/components/Detail/DetailBottom.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import styled from 'styled-components';
import Sheet from 'react-modal-sheet';
import { IcCancelDark, IcMinus, IcMinusOneunder, IcPlus } from '../../assets/icon';
import DetailFooter from './DetailFooter';
import { useEffect, useState } from 'react';
import { CustomSheet } from '../../common/BottomSheet';

interface DetailBottomProps {
id: number;
Expand Down Expand Up @@ -38,13 +38,12 @@ const DetailBottom = ({
detent='content-height'
disableDrag={true}
>
{}
<Sheet.Container>
<Sheet.Header disableDrag={true}>
<CustomSheet.Container className='detail-bottom-sheet'>
<CustomSheet.Header disableDrag={true}>
<St.Title>수량</St.Title>
<IcCancelDark onClick={() => setSheetOpen(false)} />
</Sheet.Header>
<Sheet.Content>
</CustomSheet.Header>
<CustomSheet.Content>
<St.FullBox>
<St.Wrapper>
<St.Stepper>
Expand Down Expand Up @@ -81,9 +80,9 @@ const DetailBottom = ({
shippingFee={3000} // 배송비도 여기에 추가하기
setCartToast={setCartToast}
/>
</Sheet.Content>
</Sheet.Container>
<Sheet.Backdrop onTap={() => setSheetOpen(false)} />
</CustomSheet.Content>
</CustomSheet.Container>
<CustomSheet.Backdrop onTap={() => setSheetOpen(false)} />
</CustomSheet>
);
};
Expand Down Expand Up @@ -163,29 +162,3 @@ const St = {
color: ${({ theme }) => theme.colors.gray7};
`,
};

const CustomSheet = styled(Sheet)`
height: 100%;
display: flex;
justify-content: center;
.react-modal-sheet-backdrop {
background-color: rgba(0, 0, 0, 0.6) !important;
}
.react-modal-sheet-container {
padding: 2.5rem 0rem 7rem 0rem;
border-radius: 1rem !important;
left: initial !important;
max-width: 43rem;
}
// .react-modal-sheet-header
.react-modal-sheet-container > div:nth-child(1) {
display: flex;
justify-content: space-between !important;
margin-bottom: 2.8rem;
padding: 0rem 2.4rem 0rem 2.4rem;
}
.react-modal-sheet-drag-indicator {
display: none;
}
`;
Loading

0 comments on commit a25717e

Please sign in to comment.