Skip to content
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
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="ko">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
Expand All @@ -8,7 +8,7 @@
href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css"
/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React</title>
<title>판다마켓</title>
</head>
<body>
<div id="root"></div>
Expand Down
2 changes: 2 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Global } from "@emotion/react";
import Header from "./components/Header/Header";
import MainPage from "./pages/MainPage";
import ItemPage from "./pages/ItemPage";
import AddPage from "./pages/AddPage";
import GlobalStyles from "./styles/GlobalStyles";
import BoardPage from "./pages/BoardPage";

Expand All @@ -14,6 +15,7 @@ function App() {
<Route element={<Header />}>
<Route index element={<MainPage />} />
<Route path="/items" element={<ItemPage />} />
<Route path="/additem" element={<AddPage />} />
<Route path="/board" element={<BoardPage />} />
</Route>
</Routes>
Expand Down
Binary file added src/assets/icons/ic_X.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/icons/ic_plus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions src/components/FormHeader/FormHeader.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as S from './formHeader.styles';
import { titleStyle } from '../../styles/common';

const FormHeader = ({ isFormValid }) => {
return (
<div css={S.formHeaderStyle}>
<h1 css={titleStyle}>상품 등록하기</h1>
<button
css={S.submitButtonStyle}
type="submit"
disabled={!isFormValid}
>
등록
</button>
</div>
);
};

export default FormHeader;
22 changes: 22 additions & 0 deletions src/components/FormHeader/formHeader.styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { css } from "@emotion/react";

export const formHeaderStyle = css`
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 2.4rem;
`;

export const submitButtonStyle = css`
width: 7.4rem;
height: 4.2rem;
border-radius: 0.8rem;
background: #3692ff;
font-size: 1.6rem;
font-weight: 600;
color: #F3F4F6;

&:disabled {
background: #9CA3AF;
}
`;
45 changes: 45 additions & 0 deletions src/components/FormImageUpload/FormImageUpload.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import * as S from './formImageUpload.styles';
import plusImg from '../../assets/icons/ic_plus.png';

const FormImageUpload = ({
imagePreview,
onClick,
onChange,
onRemove,
errorMessage,
fileInputRef
}) => {
return (
<>
<label>상품 이미지</label>
<div css={S.imageContainerStyle}>
<div css={S.formImageBoxStyle} onClick={onClick}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

💊 제안
label 태그가 더 적절합니다~

Suggested change
<div css={S.formImageBoxStyle} onClick={onClick}>
<label css={S.formImageBoxStyle}> // 클릭시 내부의 input이 선택된것과 동일함.

<img src={plusImg} alt="plus" />
<p>이미지 등록</p>
<input
type="file"
accept="image/*"
Copy link
Collaborator

Choose a reason for hiding this comment

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

💊 제안
input의 accept 속성은 유저가 어떤 파일을 올려야하는지에 대한 힌트를 제공하는 속성입니다.
유저는 파일 업로드시 accept의 명시된 확장자 이외의 파일도 올릴 수 있으므로
실제 upload 함수에서 한번더 확장자를 검사해주시는 것이 좋습니다.

(사용자가 업로드창에서 옵션을 열어 확장자를 바꾸면 아래처럼 보입니다)
스크린샷 2025-05-08 오후 5 53 17

https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/accept

ref={fileInputRef}
onChange={onChange}
style={{ display: 'none' }}
/>
</div>

{imagePreview && (
<div css={S.itemPreviewContainerStyle}>
<img src={imagePreview} alt="preview" css={S.previewImageStyle} />
<button
onClick={onRemove}
type="button"
css={S.imageCloseButtonStyle}
/>
</div>
)}
</div>

{errorMessage && <p css={S.errorMessageStyle}>{errorMessage}</p>}
</>
);
};

export default FormImageUpload;
66 changes: 66 additions & 0 deletions src/components/FormImageUpload/formImageUpload.styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { css } from "@emotion/react";
import mq from "../../styles/media";
import { closeButtonStyle } from '../../styles/common';

export const imageContainerStyle = css`
display: flex;
gap: 2.4rem;
`;

export const formImageBoxStyle = css`
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 12px;
width: 16.8rem;
height: 16.8rem;
background-color: #F3F4F6;

p {
font-size: 1.6rem;
font-weight: 400;
color: #9CA3AF;
}

img {
width: 4.8rem;
height: 4.8rem;
}

${mq({
width: ['16.8rem', '16.8rem', '28.2rem', '28.2rem'],
height: ['16.8rem', '16.8rem', '28.2rem', '28.2rem'],
})}
`;

export const itemPreviewContainerStyle = css`
position: relative;
`;

export const previewImageStyle = css`
width: 16.8rem;
height: 16.8rem;
object-fit: cover;
object-position: center;

${mq({
width: ['16.8rem', '16.8rem', '28.2rem', '28.2rem'],
height: ['16.8rem', '16.8rem', '28.2rem', '28.2rem'],
})}
`;

export const imageCloseButtonStyle = css`
${closeButtonStyle};
position: absolute;
top: 3%;
right: 3%;
width: 2.4rem;
height: 2.4rem;
`;

export const errorMessageStyle = css`
color: red;
font-size: 1.6rem;
margin-top: 1.6rem;
`;
34 changes: 34 additions & 0 deletions src/components/FormInputs/FormInputs.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as S from './formInputs.styles';

const FormInputs = ({ name, onNameChange, description, onDescriptionChange, price, onPriceChange }) => {
return (
<>
<label>상품명</label>
<input
css={S.inputStyle}
placeholder="상품명을 입력해주세요"
value={name}
onChange={(e) => onNameChange(e.target.value)}
/>

<label>상품 소개</label>
<textarea
Comment on lines +14 to +15
Copy link
Collaborator

Choose a reason for hiding this comment

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

💊 제안
label 태그 사용하신 것 좋아요! input과 연결도 시켜주시면 더 좋을 것 같아요.

Suggested change
<label>상품 소개</label>
<textarea
<label htmlFor="id">상품 소개</label>
<textarea
id="id"

css={S.areaStyle}
placeholder="상품 소개를 입력해주세요"
value={description}
onChange={(e) => onDescriptionChange(e.target.value)}
/>

<label>판매 가격</label>
<input
type="number"
css={S.inputStyle}
placeholder="판매 가격을 입력해주세요"
value={price}
onChange={(e) => onPriceChange(e.target.value)}
/>
</>
);
};

export default FormInputs;
9 changes: 9 additions & 0 deletions src/components/FormInputs/formInputs.styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { css } from "@emotion/react";

export const inputStyle = css`
height: 5.6rem;
`;

export const areaStyle = css`
height: 28.2rem;
`;
31 changes: 31 additions & 0 deletions src/components/FormTags/FormTags.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as S from './formTags.styles';

const FormTags = ({ tagInput, tags, onTagInputChange, onTagKeyDown, onTagRemove }) => {
return (
<>
<label>태그</label>
<input
css={S.inputStyle}
placeholder="태그를 입력해주세요"
value={tagInput}
onChange={onTagInputChange}
onKeyDown={onTagKeyDown}
/>

<div css={S.tagListContainerStyle}>
{tags.map((tag, index) => (
<div key={index} css={S.tagItemStyle}>
{`#${tag}`}
<button
type="button"
onClick={() => onTagRemove(index)}
css={S.tagButtonStyle}
/>
</div>
))}
</div>
</>
);
};

export default FormTags;
27 changes: 27 additions & 0 deletions src/components/FormTags/formTags.styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { css } from "@emotion/react";
import { closeButtonStyle } from '../../styles/common';

export const tagListContainerStyle = css`
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: 8px;
`;

export const tagItemStyle = css`
display: flex;
justify-content: center;
align-items: center;
gap: 4px;
background-color: #f2f2f2;
padding: 0.6rem 1.2rem;
border-radius: 26px;
font-size: 1.6rem;
font-weight: 400;
`;

export const tagButtonStyle = css`
${closeButtonStyle};
width: 2rem;
height: 2rem;
`;
9 changes: 7 additions & 2 deletions src/components/Nav/Nav.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { NavLink } from "react-router-dom";
import { NavLink, useLocation } from "react-router-dom";
import { ulContainerStyle, navTitleStyle } from "./Nav.styles";
import { css } from "@emotion/react";

const Nav = () => {

const location = useLocation();
const isMarketActive = location.pathname.startsWith("/items") || location.pathname === "/additem";

return (
<nav>
<ul css={ulContainerStyle}>
Expand All @@ -11,7 +16,7 @@ const Nav = () => {
</NavLink>
</li>
<li>
<NavLink to="items" css={navTitleStyle}>
<NavLink to="items" css={[navTitleStyle, isMarketActive && css`color: #3692ff;`]}>
중고마켓
</NavLink>
</li>
Expand Down
2 changes: 2 additions & 0 deletions src/components/ToolBar/TooBar.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export const inputStyle = css`
background-color: #F3F4F6;
padding-left: 4.4rem;
padding-block: 0.9rem;
font-size: 1.6rem;
font-weight: 400;

${mq({
width: ['28.8rem', '24.2rem', '24.2rem', '32.5rem'],
Expand Down
Loading
Loading