Skip to content

Commit

Permalink
refactor: 상품 상세 페이지 Header 컴포넌트 생성 (#171)
Browse files Browse the repository at this point in the history
- ProductDetailMain에 있던 Header를 분리
  • Loading branch information
aken-you committed Jun 27, 2023
1 parent 0de6001 commit 31c0df7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 21 deletions.
20 changes: 20 additions & 0 deletions fe/src/components/ProductDetail/ProductDetailHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useNavigate } from 'react-router-dom';

import { ICON_NAME } from '@constants/iconName';

import Icon from '@components/common/Icon';
import * as S from './style';

const ProductDetailHeader = () => {
const navigate = useNavigate();
return (
<S.Header>
<button onClick={() => navigate(-1)}>
<Icon name={ICON_NAME.CHEVRON_LEFT} />
</button>
<Icon name={ICON_NAME.ELLIPSIS} />
</S.Header>
);
};

export default ProductDetailHeader;
14 changes: 14 additions & 0 deletions fe/src/components/ProductDetail/ProductDetailHeader/style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import styled from 'styled-components';

const Header = styled.header`
display: flex;
justify-content: space-between;
align-items: center;
position: fixed;
width: 100%;
height: 44px;
padding: 16px;
`;

export { Header };
10 changes: 0 additions & 10 deletions fe/src/components/ProductDetail/ProductDetailMain/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useState } from 'react';
import { useNavigate } from 'react-router-dom';

import { ICON_NAME } from '@constants/index';
import { getTextWithTimeStamp } from '@utils/index';
Expand Down Expand Up @@ -35,17 +34,8 @@ const ProductDetailMain = ({
}: ProductDetailMainProps) => {
const [isModalOpen, setIsModalOpen] = useState(false);

const navigate = useNavigate();

return (
<>
<S.Header>
<button onClick={() => navigate(-1)}>
<Icon name={ICON_NAME.CHEVRON_LEFT} />
</button>
<Icon name={ICON_NAME.ELLIPSIS} />
</S.Header>

<S.Product>
<S.ProductImgListLayout>
<S.ProductImgList>
Expand Down
11 changes: 0 additions & 11 deletions fe/src/components/ProductDetail/ProductDetailMain/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@ import styled, { css } from 'styled-components';

import Button from '@components/common/Button';

const Header = styled.header`
display: flex;
justify-content: space-between;
align-items: center;
position: fixed;
width: 100%;
height: 44px;
padding: 16px;
`;
const Product = styled.section`
overflow-y: scroll;
Expand Down Expand Up @@ -186,7 +176,6 @@ const ChattingDetailButton = styled(Button)`
`;

export {
Header,
Product,
ProductInfo,
ProductImgListLayout,
Expand Down
2 changes: 2 additions & 0 deletions fe/src/pages/ProductDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { REQUEST_URL } from '@constants/index';

import useFetch, { REQUEST_METHOD } from '@hooks/useFetch';

import ProductDetailHeader from '@components/ProductDetail/ProductDetailHeader';
import ProductDetailMain from '@components/ProductDetail/ProductDetailMain';
import ProductDetailToolBar from '@components/ProductDetail/ProductDetailToolBar';

Expand Down Expand Up @@ -107,6 +108,7 @@ const ProductDetail = () => {
{responseState === 'LOADING' && <div>loading</div>}
{responseState === 'SUCCESS' && postData && (
<>
<ProductDetailHeader />
<ProductDetailMain {...postData} interestCount={interestCount} />
<ProductDetailToolBar
isInterested={isInterested}
Expand Down

0 comments on commit 31c0df7

Please sign in to comment.