Skip to content

Commit

Permalink
Merge pull request #220 from itscold96/React-김민찬-sprint7
Browse files Browse the repository at this point in the history
[김민찬] Sprint7
  • Loading branch information
arthurkimdev authored Jul 8, 2024
2 parents b7c69ca + 1ac69d4 commit 76a73f3
Show file tree
Hide file tree
Showing 60 changed files with 809 additions and 156 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 1 addition & 1 deletion src/ constants/infomations/addItemList.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IAddItemFeildset } from 'types/@shared/addItemTypes';
import { IAddItemFeildset } from 'types/@shared/addProductTypes';

export const ADDITEM_FEIELDSET_LIST: IAddItemFeildset[] = [
{
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/ constants/queryKeys/queryKeys.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const PRODUCTS_QUERY_KEY = 'products';
export const PRODUCT_COMMENTS_QUERY_KEY = 'comments';
10 changes: 7 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import Home from 'pages/Home';
import Login from 'pages/Login';
import Signup from 'pages/Signup';
import Market from 'pages/Market';
import AddItem from 'pages/AddItem';
import AddProduct from 'pages/AddProduct';
import ProductInfo from 'pages/ProductInfo';

function App() {
const queryClient = new QueryClient();
Expand All @@ -22,8 +23,11 @@ function App() {
<Route index element={<Home />} />
<Route path="/login" element={<Login />} />
<Route path="/signup" element={<Signup />} />
<Route path="/items" element={<Market />} />
<Route path="/additem" element={<AddItem />} />
<Route path="/items">
<Route index element={<Market />} />
<Route path=":id" element={<ProductInfo />} />
</Route>
<Route path="/additem" element={<AddProduct />} />
<Route path="*" element={<div>해당 페이지는 없는 페이지입니다.</div>} />
</Route>
</Routes>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file modified src/assets/images/market/like-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/productDetail/back-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/productDetail/inquiry-empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/productDetail/profile-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/components/@shared/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { SNS_LINKS } from ' constants/infomations/snsLinks';
import styled from 'styled-components';
import Image from './Image';
import { MOBILE_MAX_WIDTH } from ' constants/infomations/mediaQuerySize';

function Footer() {
return (
Expand Down Expand Up @@ -54,7 +55,7 @@ const StyledFooter = styled.footer`
gap: 1.2rem;
}
@media all and (max-width: 767px) {
@media all and (max-width: ${MOBILE_MAX_WIDTH}px) {
position: relative;
padding: 3.2rem;
& .footer-company {
Expand Down
5 changes: 3 additions & 2 deletions src/components/@shared/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import styled from 'styled-components';
import Button from './Button';
import { PATH_LOGIN } from ' constants/paths/paths';
import HeaderLinkSection from './HeaderLinkSection';
import { MOBILE_MAX_WIDTH, TABLET_MAX_WIDTH } from ' constants/infomations/mediaQuerySize';

function Header() {
const { navigateTo } = useNavigateTo();
Expand Down Expand Up @@ -43,10 +44,10 @@ const StyledHeader = styled.header`
background-color: var(--white);
border-bottom: 1px solid var(--border-gray);
@media all and (min-width: 768px) and (max-width: 1199px) {
@media all and (min-width: ${MOBILE_MAX_WIDTH}px) and (max-width: ${TABLET_MAX_WIDTH}px) {
padding: 0 2.4rem;
}
@media all and (max-width: 767px) {
@media all and (max-width: ${MOBILE_MAX_WIDTH}px) {
padding: 0 1.6rem;
& button {
width: 6rem;
Expand Down
9 changes: 5 additions & 4 deletions src/components/@shared/HeaderLinkSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { PATH_HOME, PATH_BOARDS, PATH_ITEMS, PATH_ADD_ITEM } from ' constants/pa
import styled from 'styled-components';
import useNavigateTo from 'hooks/useNavigateTo';
import useWindowSize from 'hooks/useWindowSize';
import { MOBILE_MAX_WIDTH } from ' constants/infomations/mediaQuerySize';

function HeaderLinkSection() {
const { innerWidth } = useWindowSize();
Expand All @@ -28,7 +29,7 @@ function HeaderLinkSection() {
<StyledLink to={PATH_BOARDS} $isPageMatch={PATH_BOARDS === pathname}>
자유게시판
</StyledLink>
<StyledLink to={PATH_ITEMS} $isPageMatch={[PATH_ITEMS, PATH_ADD_ITEM].includes(pathname)}>
<StyledLink to={`${PATH_ITEMS}?page=1`} $isPageMatch={[PATH_ITEMS, PATH_ADD_ITEM].includes(pathname)}>
중고마켓
</StyledLink>
</section>
Expand All @@ -49,7 +50,7 @@ const StyledLinkSection = styled.section`
cursor: pointer;
}
@media (max-width: 768px) {
@media (max-width: ${MOBILE_MAX_WIDTH}px) {
gap: 1.5rem;
}
`;
Expand All @@ -62,12 +63,12 @@ const StyledLink = styled(Link)<{ $isPageMatch: boolean }>`
&:not(:last-child) {
margin-right: 3.2rem;
@media (max-width: 768px) {
@media (max-width: ${MOBILE_MAX_WIDTH}px) {
margin-right: 0.8rem;
}
}
@media (max-width: 768px) {
@media (max-width: ${MOBILE_MAX_WIDTH}px) {
font-size: 1.6rem;
line-height: 1.909rem;
}
Expand Down
13 changes: 10 additions & 3 deletions src/components/@shared/Image.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import { SyntheticEvent } from 'react';
import styled from 'styled-components';
import noImage from 'assets/images/@shared/no-image-placeholder.png';

interface ImageProps {
src: string;
alt: string;
width: string;
height: string;
width?: string;
height?: string;
radius?: string;
className?: string;
aspectRatio?: string;
onClick?: () => void;
}

function Image({ src, alt, width, height, radius, className, onClick, aspectRatio }: ImageProps) {
function Image({ src, alt, width = 'auto', height = 'auto', radius, className, onClick, aspectRatio }: ImageProps) {
const handleImageError = (e: SyntheticEvent<HTMLImageElement, Event>) => {
(e.target as HTMLImageElement).src = noImage;
};

return (
<StyledImage
src={src}
Expand All @@ -22,6 +28,7 @@ function Image({ src, alt, width, height, radius, className, onClick, aspectRati
className={className || ''}
$aspectRatio={aspectRatio || ''}
onClick={onClick}
onError={handleImageError}
/>
);
}
Expand Down
15 changes: 8 additions & 7 deletions src/components/@shared/Pagination.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import usePageSize from 'hooks/usePageSize';
import React, { useState } from 'react';
import { SetURLSearchParams } from 'react-router-dom';
import styled from 'styled-components';

interface PaginationProps {
totalCount: number;
currentPage: number;
setCurrentPageCount: React.Dispatch<React.SetStateAction<number>>;
totalCount: number;
setSearchParams: SetURLSearchParams;
}

const MAX_PAGE_BUTTONS = 3; // 화면에 최대 보여줄 페이지 버튼 수
const MAX_PAGE_BUTTONS = 5; // 화면에 최대 보여줄 페이지 버튼 수

function Pagination({ totalCount, currentPage, setCurrentPageCount }: PaginationProps) {
function Pagination({ currentPage, totalCount, setSearchParams }: PaginationProps) {
const pageSize = usePageSize('forSale');

// 현재 페이지 그룹의 시작 페이지 번호
Expand All @@ -34,15 +35,15 @@ function Pagination({ totalCount, currentPage, setCurrentPageCount }: Pagination
// 이전 페이지로 이동할 경우, 이전 페이지 그룹으로 넘어가야 하는 지 확인
setStartPage(startPage - MAX_PAGE_BUTTONS);
}
setCurrentPageCount(prevState => Math.max(prevState - 1, 1)); // 이전 페이지로 이동
setSearchParams({ page: Math.max(currentPage - 1, 1).toString() }); // 이전 페이지로 이동
} else if (value === 'nextPage') {
if (endPage < currentPage + 1) {
// 다음 페이지로 이동할 경우, 다음 페이지 그룹으로 넘어가야 하는 지 확인
setStartPage(endPage + 1);
}
setCurrentPageCount(prevState => Math.min(prevState + 1, lastPage)); // 다음 페이지로 이동
setSearchParams({ page: Math.min(currentPage + 1, lastPage).toString() }); // 다음 페이지로 이동
} else {
setCurrentPageCount(parseInt(value)); // 선택한 페이지로 이동
setSearchParams({ page: parseInt(value).toString() }); // 선택한 페이지로 이동
}
};

Expand Down
32 changes: 32 additions & 0 deletions src/components/@shared/Spacer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import styled from 'styled-components';

interface SpacerProps {
$topHeight: string;
$bottomHeight: string;
$needLine: boolean;
}

function Spacer({ $topHeight = '0rem', $bottomHeight = '0rem', $needLine = false }: SpacerProps) {
return (
<StyledSpacer $topHeight={$topHeight} $bottomHeight={$bottomHeight} $needLine={$needLine}>
<div className={'spacer-top'} />
<div className={'spacer-line'} />
<div className={'spacer-bottom'} />
</StyledSpacer>
);
}

export default Spacer;

const StyledSpacer = styled.div<SpacerProps>`
& .spacer-top {
height: ${({ $topHeight }) => $topHeight};
}
& .spacer-line {
// border로 하면 네모 테두리를 그리게 되므로 1px로 설정해도 2px가 되어버림
border-bottom: ${({ $needLine }) => $needLine && 'var(--border-200)'};
}
& .spacer-bottom {
height: ${({ $bottomHeight }) => $bottomHeight};
}
`;
13 changes: 7 additions & 6 deletions src/components/addItem/ImageRegistration.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import styled from 'styled-components';
import { inputStyle, placeholderStyle } from 'styles/auth/formStyles';
import plusIcon from 'assets/images/addItem/plus-icon.png';
import plusIcon from 'assets/images/addProduct/plus-icon.png';
import { ALLOW_FILE_EXTENSION } from ' constants/infomations/fileExtension';
import { StyledAddItemSubTitle } from 'styles/addItem/textStyles';
import { StyledAddItemSubTitle } from 'styles/addProduct/textStyles';
import React from 'react';
import Image from 'components/@shared/Image';
import PreviewList from './PreviewList';
import { IPreview } from 'types/@shared/addItemTypes';
import { IPreview } from 'types/@shared/addProductTypes';
import { MOBILE_MAX_WIDTH, TABLET_MAX_WIDTH } from ' constants/infomations/mediaQuerySize';

interface ImageRegistrationProps {
previewList: IPreview[];
Expand Down Expand Up @@ -48,13 +49,13 @@ const StyledItemRegistSection = styled.section`
width: var(--container-width);
height: 28.2rem;
@media (max-width: 1200px) {
@media (max-width: ${TABLET_MAX_WIDTH}px) {
height: 16.2rem;
max-width: calc(100vw - 5.2rem);
overflow-y: hidden;
overflow-x: auto;
}
@media (max-width: 768px) {
@media (max-width: ${MOBILE_MAX_WIDTH}px) {
max-width: calc(100vw - 3.2rem);
}
Expand All @@ -73,7 +74,7 @@ const StyledItemRegistSection = styled.section`
cursor: pointer;
@media (max-width: 1200px) {
@media (max-width: ${TABLET_MAX_WIDTH}px) {
width: 16.2rem;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/addItem/InputSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { ADDITEM_FEIELDSET_LIST } from ' constants/infomations/addItemList';
import React from 'react';
import { Fragment } from 'react/jsx-runtime';
import styled from 'styled-components';
import { StyledAddItemSubTitle, smallTextStyle } from 'styles/addItem/textStyles';
import { StyledAddItemSubTitle, smallTextStyle } from 'styles/addProduct/textStyles';
import { inputStyle, placeholderStyle } from 'styles/auth/formStyles';
import TagList from './TagList';
import { IFormValue, ITag } from 'types/@shared/addItemTypes';
import { IFormValue, ITag } from 'types/@shared/addProductTypes';

interface InputSectionProps {
formValue: IFormValue;
Expand Down
4 changes: 2 additions & 2 deletions src/components/addItem/PreviewList.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import styled from 'styled-components';

import React from 'react';
import { StyledRemoveButton } from 'styles/addItem/buttonStyles';
import { StyledRemoveButton } from 'styles/addProduct/buttonStyles';
import Image from 'components/@shared/Image';
import { IPreview } from 'types/@shared/addItemTypes';
import { IPreview } from 'types/@shared/addProductTypes';

interface PreviewListProps {
previewList: IPreview[];
Expand Down
11 changes: 6 additions & 5 deletions src/components/addItem/TagList.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import styled from 'styled-components';
import { smallTextStyle } from 'styles/addItem/textStyles';
import { smallTextStyle } from 'styles/addProduct/textStyles';

import { StyledRemoveButton } from 'styles/addItem/buttonStyles';
import { ITag } from 'types/@shared/addItemTypes';
import { StyledRemoveButton } from 'styles/addProduct/buttonStyles';
import { ITag } from 'types/@shared/addProductTypes';
import { MOBILE_MAX_WIDTH, TABLET_MAX_WIDTH } from ' constants/infomations/mediaQuerySize';

interface TagListProps {
tagList: ITag[];
Expand Down Expand Up @@ -36,10 +37,10 @@ const StyledTagList = styled.ul`
${smallTextStyle};
@media (max-width: 1200px) {
@media (max-width: ${TABLET_MAX_WIDTH}px) {
max-width: calc(100vw - 5.2rem);
}
@media (max-width: 768px) {
@media (max-width: ${MOBILE_MAX_WIDTH}px) {
max-width: calc(100vw - 3.2rem);
}
`;
Expand Down
1 change: 0 additions & 1 deletion src/components/auth/login/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ function LoginForm() {

const handleSubmitClick = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
console.log(form);
navigateTo(PATH_ITEMS);
};

Expand Down
1 change: 0 additions & 1 deletion src/components/auth/signup/ SignupForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ function SignupForm() {

const handleSubmitClick = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
console.log(form);
navigateTo('/');
};

Expand Down
3 changes: 2 additions & 1 deletion src/components/home/BrandBottom.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { TABLET_MAX_WIDTH } from ' constants/infomations/mediaQuerySize';
import BrandContainer from './BrandContainer';
import brandBottomImg from 'assets/images/home/home_bottom.png';
import Image from 'components/@shared/Image';
Expand All @@ -17,7 +18,7 @@ function BrandBottom() {
export default BrandBottom;

const StyledBrandBottom = styled.div`
@media all and (max-width: 1199px) {
@media all and (max-width: ${TABLET_MAX_WIDTH}px) {
padding: 12.1rem 0 5.9rem;
}
`;
13 changes: 7 additions & 6 deletions src/components/home/BrandContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { MOBILE_MAX_WIDTH, TABLET_MAX_WIDTH } from ' constants/infomations/mediaQuerySize';
import { ReactNode } from 'react';
import styled from 'styled-components';

Expand All @@ -22,7 +23,7 @@ const StyledBrandContainer = styled.article`
height: 54rem;
background-color: var(--pale-blue);
@media all and (max-width: 1199px) {
@media all and (max-width: ${TABLET_MAX_WIDTH}px) {
height: 100%;
}
`;
Expand All @@ -34,7 +35,7 @@ const StyledBrandWrapper = styled.div`
display: flex;
align-items: center;
@media all and (max-width: 1199px) {
@media all and (max-width: ${TABLET_MAX_WIDTH}px) {
flex-direction: column;
/* 이미지가 잘려도 되도록 hidden 속성 부여*/
overflow-x: hidden;
Expand All @@ -50,16 +51,16 @@ const StyledBrandWrapper = styled.div`
color: var(--cool-gray);
white-space: pre-line;
@media all and (max-width: 1199px) {
@media all and (max-width: ${TABLET_MAX_WIDTH}px) {
text-align: center;
}
@media all and (min-width: 768px) and (max-width: 1199px) {
@media all and (min-width: ${MOBILE_MAX_WIDTH}px) and (max-width: ${TABLET_MAX_WIDTH}px) {
width: 100%;
white-space: normal;
}
@media all and (min-width: 375px) and (max-width: 767px) {
@media all and (min-width: 375px) and (max-width: ${MOBILE_MAX_WIDTH}px) {
font-size: 3.2rem;
line-height: 4.48rem;
Expand All @@ -72,7 +73,7 @@ const StyledBrandWrapper = styled.div`
left: 35rem; /* 뷰포트 너비에 구애 받지 않아야 하므로 .container를 기준으로 피그마를 참고해 다시 계산한 값 */
bottom: 0;
@media all and (max-width: 1199px) {
@media all and (max-width: ${TABLET_MAX_WIDTH}px) {
position: static;
/* 이미지가 확대 되어 필요 이상으로 잘리지 않도록 max-width 지정*/
max-width: 135%;
Expand Down
Loading

0 comments on commit 76a73f3

Please sign in to comment.