-
Notifications
You must be signed in to change notification settings - Fork 39
[이태식] sprint6 #212
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
The head ref may contain hidden characters: "React-\uC774\uD0DC\uC2DD-sprint6"
[이태식] sprint6 #212
Changes from all commits
9570b0d
0980966
b0d1ebe
497c57d
8a9e0a6
78685f0
55025e8
01e7d68
9213eea
89aa6de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,11 @@ | ||||||
| const Input = ({ placeholder, className, value, onChange }) => { | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💊 제안
Suggested change
|
||||||
| return ( | ||||||
| <input | ||||||
| value={value} | ||||||
| placeholder={placeholder} | ||||||
| className={`font-regular focus:outline-primary-100 text-secondary-800 placeholder:text-secondary-400 bg-secondary-100 rounded-[12px] px-24 py-15 text-lg ${className}`} | ||||||
| onChange={onChange} | ||||||
| /> | ||||||
| ); | ||||||
| }; | ||||||
| export default Input; | ||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,13 @@ | ||||||
| import XIcon from "../assets/icons/icon-X.png"; | ||||||
|
|
||||||
| const Tag = ({ children, onDelete }) => { | ||||||
| return ( | ||||||
| <div className="bg-secondary-100 text-secondary-800 font-regular flex items-center justify-between gap-8 rounded-[26px] py-5 pr-12 pl-16 text-lg"> | ||||||
| {children} | ||||||
| <button onClick={() => onDelete(children)} className="cursor-pointer"> | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❗️ 수정요청
Suggested change
|
||||||
| <img src={XIcon} alt="x아이콘" className="size-20" /> | ||||||
| </button> | ||||||
| </div> | ||||||
| ); | ||||||
| }; | ||||||
| export default Tag; | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { useState } from "react"; | ||
| import Input from "./Input"; | ||
| import Tag from "./Tag"; | ||
|
|
||
| const TagInput = ({ value, onChange }) => { | ||
| const [tagList, setTagList] = useState(["#티셔츠", "#상의"]); | ||
| const onDelete = (deleteTag) => { | ||
| setTagList(tagList.filter((tag) => tag !== deleteTag)); | ||
| }; | ||
| return ( | ||
| <> | ||
| <Input | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❗️ 수정요청 |
||
| value={value} | ||
| placeholder="태그를 입력해주세요" | ||
| onChange={onChange} | ||
| /> | ||
| <ul className="flex flex-wrap gap-12"> | ||
| {tagList.map((tag) => { | ||
| return ( | ||
| <li key={tag}> | ||
| <Tag onDelete={onDelete}>{tag}</Tag> | ||
| </li> | ||
| ); | ||
| })} | ||
| </ul> | ||
| </> | ||
| ); | ||
| }; | ||
| export default TagInput; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| const TextArea = ({ placeholder, className, value, onChange }) => { | ||
| return ( | ||
| <textarea | ||
| value={value} | ||
| placeholder={placeholder} | ||
| className={`font-regular focus:outline-primary-100 text-secondary-800 placeholder:text-secondary-400 bg-secondary-100 resize-none rounded-[12px] px-24 py-15 text-lg ${className}`} | ||
| onChange={onChange} | ||
| /> | ||
| ); | ||
| }; | ||
| export default TextArea; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import { useState } from "react"; | ||
| import PlusIcon from "../assets/icons/icon-plus.png"; | ||
| import XIcon from "../assets/icons/icon-X.png"; | ||
|
|
||
| const UploadImage = () => { | ||
| const [preview, setPreview] = useState(null); | ||
| const [isError, setIsError] = useState(false); | ||
| const uploadImage = (e) => { | ||
| const file = e.target.files[0]; | ||
| if (!file) return; | ||
| const imageUrl = URL.createObjectURL(file); | ||
| setPreview(imageUrl); | ||
| }; | ||
| const showError = () => { | ||
| if (preview) setIsError(true); | ||
| }; | ||
| const onDelete = () => { | ||
| setPreview(null); | ||
| setIsError(false); | ||
| }; | ||
| return ( | ||
| <> | ||
| <div className="pc:gap-24 flex gap-10"> | ||
| <label | ||
| className="bg-secondary-100 pc:size-282 font-regular text-secondary-400 flex size-168 cursor-pointer flex-col items-center justify-center gap-12 rounded-[12px] text-lg" | ||
| onClick={showError} | ||
| > | ||
| <img src={PlusIcon} alt="더하기" className="size-48" /> | ||
| 이미지 등록 | ||
| {!preview && ( | ||
| <input type="file" className="hidden" onChange={uploadImage} /> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💊 제안 |
||
| )} | ||
| </label> | ||
| {preview && ( | ||
| <div className="relative"> | ||
| <img | ||
| src={preview} | ||
| alt="미리보기" | ||
| className="pc:size-282 size-168 rounded-[12px] object-cover" | ||
| /> | ||
| <button | ||
| className="absolute top-12 right-12 size-24 cursor-pointer" | ||
| onClick={onDelete} | ||
| > | ||
| <img src={XIcon} alt="x버튼" /> | ||
| </button> | ||
| </div> | ||
| )} | ||
| </div> | ||
| {isError && ( | ||
| <p className="text-error-red font-regular font-lg"> | ||
| *이미지 등록은 최대 1개까지 가능합니다. | ||
| </p> | ||
| )} | ||
| </> | ||
| ); | ||
| }; | ||
| export default UploadImage; | ||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,6 +1,8 @@ | ||||
| import { NavLink } from "react-router"; | ||||
| import { NavLink, useLocation } from "react-router"; | ||||
|
|
||||
| const Navbar = () => { | ||||
| const location = useLocation(); | ||||
| console.log(location); | ||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❗️ 수정요청
Suggested change
|
||||
| return ( | ||||
| <ul className="tablet:text-2lg tablet:gap-30 text-secondary-600 flex grow gap-8 text-lg font-bold"> | ||||
| <li> | ||||
|
|
@@ -9,7 +11,11 @@ const Navbar = () => { | |||
| <li> | ||||
| <NavLink | ||||
| to="/items" | ||||
| className={({ isActive }) => (isActive ? "text-primary-100" : "")} | ||||
| className={({ isActive }) => | ||||
| isActive || location.pathname === "/additem" | ||||
| ? "text-primary-100" | ||||
| : "" | ||||
| } | ||||
| > | ||||
| 중고마켓 | ||||
| </NavLink> | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,61 @@ | ||||||||||||||||||||||||||||
| import { useEffect, useState } from "react"; | ||||||||||||||||||||||||||||
| import Button from "../components/Button"; | ||||||||||||||||||||||||||||
| import Input from "../components/Input"; | ||||||||||||||||||||||||||||
| import TagInput from "../components/TagInput"; | ||||||||||||||||||||||||||||
| import TextArea from "../components/TextArea"; | ||||||||||||||||||||||||||||
| import UploadImage from "../components/UploadImage"; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const AddItemPage = () => { | ||||||||||||||||||||||||||||
| const [isDisable, setIsDisable] = useState(true); | ||||||||||||||||||||||||||||
| const [name, setName] = useState(""); | ||||||||||||||||||||||||||||
| const [description, setDescription] = useState(""); | ||||||||||||||||||||||||||||
| const [price, setPrice] = useState(""); | ||||||||||||||||||||||||||||
| const [tag, setTag] = useState(""); | ||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||
| if (name && description && price && tag) setIsDisable(false); | ||||||||||||||||||||||||||||
| else setIsDisable(true); | ||||||||||||||||||||||||||||
| }, [name, description, price, tag]); | ||||||||||||||||||||||||||||
|
Comment on lines
+14
to
+17
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💊 제안
Suggested change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❗️ 수정요청 |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||
| <div className="tablet:pt-16 tablet:pb-78 tablet:px-24 text-secondary-800 mx-auto flex max-w-1200 flex-col gap-24 px-15 pt-24 pb-70 font-bold"> | ||||||||||||||||||||||||||||
| <div className="flex justify-between"> | ||||||||||||||||||||||||||||
| <h1 className="text-xl">상품 등록하기</h1> | ||||||||||||||||||||||||||||
| <Button isDisable={isDisable}>등록</Button> | ||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||
| <div className="flex flex-col gap-16"> | ||||||||||||||||||||||||||||
| <h2 className="text-2lg">상품 이미지</h2> | ||||||||||||||||||||||||||||
| <UploadImage /> | ||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||
| <div className="flex flex-col gap-16"> | ||||||||||||||||||||||||||||
| <h2 className="text-2lg">상품명</h2> | ||||||||||||||||||||||||||||
| <Input | ||||||||||||||||||||||||||||
| value={name} | ||||||||||||||||||||||||||||
| placeholder="상품명을 입력해주세요" | ||||||||||||||||||||||||||||
| onChange={(e) => setName(e.target.value)} | ||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||
|
Comment on lines
+30
to
+35
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💊 제안
Suggested change
|
||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||
| <div className="flex flex-col gap-16"> | ||||||||||||||||||||||||||||
| <h2 className="text-2lg">상품 소개</h2> | ||||||||||||||||||||||||||||
| <TextArea | ||||||||||||||||||||||||||||
| value={description} | ||||||||||||||||||||||||||||
| placeholder="상품 소개를 입력해주세요" | ||||||||||||||||||||||||||||
| className="h-282" | ||||||||||||||||||||||||||||
| onChange={(e) => setDescription(e.target.value)} | ||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||
| <div className="flex flex-col gap-16"> | ||||||||||||||||||||||||||||
| <h2 className="text-2lg">판매가격</h2> | ||||||||||||||||||||||||||||
| <Input | ||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💊 제안 |
||||||||||||||||||||||||||||
| value={price} | ||||||||||||||||||||||||||||
| placeholder="판매 가격을 입력해주세요" | ||||||||||||||||||||||||||||
| onChange={(e) => setPrice(e.target.value)} | ||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||
| <div className="flex flex-col gap-16"> | ||||||||||||||||||||||||||||
| <h2 className="text-2lg">태그</h2> | ||||||||||||||||||||||||||||
| <TagInput value={tag} onChange={(e) => setTag(e.target.value)} /> | ||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
| export default AddItemPage; | ||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💊 제안
공통 컴포넌트는 다양하게 사용될 수 있어야 합니다!
Input의 type 속성도 받을 수 있으면 좋을 것 같아요~