-
Notifications
You must be signed in to change notification settings - Fork 25
[한장희] sprint6 #131
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-\uD55C\uC7A5\uD76C-sprint5"
[한장희] sprint6 #131
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { useResponsivePage } from "../../hooks/useResponsivePage"; | ||
| import ProductGrid from "../common/ProductGrid"; | ||
|
|
||
| const BestProducts = ({ products }) => { | ||
| const responsiveValues = useResponsivePage(); | ||
|
|
||
| return ( | ||
| <div className="flex flex-col gap-3 "> | ||
| <h2 className="text-xl font-bold ">베스트 상품</h2> | ||
| <ProductGrid | ||
| products={products} | ||
| gridSize={responsiveValues.bestPicContainerSize} | ||
| picSize={responsiveValues.bestPicSize} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default BestProducts; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import { INPUT_TYPE_STYLE } from "./InputClasses"; | ||
|
|
||
| const Input = ({ | ||
| inputTypeStyle = "basic", | ||
| as, | ||
| type, | ||
| id, | ||
| imgUrl, | ||
| onChange, | ||
| onClick, | ||
| onKeyDown, | ||
| ...props | ||
| }) => { | ||
| const styleClass = INPUT_TYPE_STYLE[inputTypeStyle] || ""; | ||
| const Component = as || "input"; | ||
|
|
||
| return ( | ||
| <div> | ||
| {type === "file" ? ( | ||
| <div className="flex gap-8"> | ||
| <div className="flex flex-col gap-4"> | ||
| <label className={`${styleClass} bg-gray-100 cursor-pointer`}> | ||
| <img src={props.src} alt={props.alt} /> | ||
| <Component | ||
| accept="image/*" | ||
| type={type} | ||
| {...props} | ||
| id={id} | ||
| className="hidden" | ||
| onChange={onChange} | ||
| /> | ||
| </label> | ||
| {imgUrl && ( | ||
| <p className="text-red-400"> | ||
| *이미지 등록은 최대 1개까지 가능합니다 | ||
| </p> | ||
| )} | ||
| </div> | ||
| {imgUrl && ( | ||
| <div className="relative"> | ||
|
Comment on lines
+3
to
+40
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. 오호.
|
||
| <img | ||
| src={imgUrl} | ||
| alt="잠시대기" | ||
| className="h-[282px] rounded-xl object-cover aspect-square" | ||
| /> | ||
| <img | ||
| src="/ic_X.svg" | ||
| alt="X 아이콘" | ||
| className="absolute cursor-pointer top-3 right-3" | ||
| onClick={() => onClick()} | ||
| /> | ||
| </div> | ||
| )} | ||
| </div> | ||
| ) : ( | ||
| <Component | ||
| className={`${styleClass} bg-gray-100`} | ||
| type={type} | ||
| onKeyDown={onKeyDown} | ||
| onChange={onChange} | ||
| {...props} | ||
| /> | ||
| )} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default Input; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| export const INPUT_TYPE_STYLE = { | ||
| basic: "px-6 py-4 rounded-xl h-[56px] w-full", | ||
| textarea: "px-6 py-4 rounded-xl h-[282px] w-full self-start ", | ||
| image: | ||
| "h-[282px] rounded-xl object-cover aspect-square flex items-center justify-center ", | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export const BTN_STYLE_TYPE = { | ||
| active: "rounded-lg px-[23px] py-3 bg-blue-500 text-white", | ||
| inactive: "bg-gray-400 rounded-lg px-[23px] py-3 text-white", | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { BTN_STYLE_TYPE } from "./ButtonClasses"; | ||
|
|
||
| const ButtonLink = ({ btnStyle = "inactive", as, children, ...props }) => { | ||
| const Component = as || "button"; | ||
| const btnTypeClass = BTN_STYLE_TYPE[btnStyle] || ""; | ||
|
|
||
| return ( | ||
| <Component className={`${btnTypeClass}`} {...props}> | ||
| {children} | ||
| </Component> | ||
| ); | ||
| }; | ||
|
|
||
| export default ButtonLink; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { Outlet } from "react-router-dom"; | ||
| import Header from "../common/Header"; | ||
|
|
||
| const Layout = () => { | ||
| return ( | ||
| <div> | ||
| <Header /> | ||
| <main className="max-w-screen-xl px-4 mt-6 md:px-6 md:mx-auto"> | ||
|
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. 크으 ~ 시맨틱 태그도 잊지 않았군요 👍 |
||
| <Outlet /> | ||
| </main> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default Layout; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| export const INPUT_OPTIONS = [ | ||
| { | ||
| id: "product_image", | ||
| title: "상품 이미지", | ||
| inputType: "file", | ||
| inputTypeStyle: "image", | ||
| src: "/ic_plus.svg", | ||
| alt: "십자가 모양 아이콘", | ||
| }, | ||
| { | ||
| id: "product_name", | ||
| title: "상품명", | ||
| inputType: "input", | ||
| placeholder: "상품명을 입력해주세요", | ||
| inputTypeStyle: "basic", | ||
| }, | ||
| { | ||
| id: "product_description", | ||
| title: "상품 소개", | ||
| placeholder: "상품 소개를 입력해주세요", | ||
| inputTypeStyle: "textarea", | ||
| tagName: "textarea", | ||
| }, | ||
| { | ||
| id: "sales_price", | ||
| title: "판매가격", | ||
| inputType: "input", | ||
| placeholder: "판매 가격을 입력해주세요", | ||
| inputTypeStyle: "basic", | ||
| }, | ||
| { | ||
| id: "hashtag", | ||
| title: "태그", | ||
| inputType: "input", | ||
| placeholder: "태그를 입력해주세요", | ||
| inputTypeStyle: "basic", | ||
| }, | ||
| ]; |
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.
(참고만 해도 됩니다 😉)
ProductGrid에gridSize,picSize가 드릴링이 되는 것 같아서 한 번 리팩토링 해봤습니다 !핵심은
ProductGrid의 역할이 프롭스를 전달만 해주는 것 같아서요 !일관적인 스타일 용도로만 사용하도록 바꿔봤습니다 !
참고만 하시고 사용하지 않으셔도 됩니다 😉