-
Notifications
You must be signed in to change notification settings - Fork 2
[#8] 와인 타입 선택 컴포넌트 제작 #22
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
1e377eb
Merge branch 'develop' of https://github.com/Team-3-2/Wine into develop
huuitae 260c7c1
Merge branch 'develop' of https://github.com/Team-3-2/Wine into develop
huuitae 7165c61
design: text input 컴포넌트 제작
huuitae fe5c030
design: 와인 타입 선택 컴포넌트 제작
huuitae ef99fc3
design: 와인 타입 선택 컴포넌트 제작
huuitae c207fb1
refactor: 와인 타입 컴포넌트 이벤트 핸들러 props 수정
huuitae f21293f
design: 타입 선택 이름 수정
huuitae 8786a2e
Merge branch 'develop' of https://github.com/Team-3-2/Wine into develop
huuitae c00c950
design: text input 컴포넌트 제작
huuitae e1a55ac
design: 와인 타입 선택 컴포넌트 제작
huuitae e9efd5e
design: 와인 타입 선택 컴포넌트 제작
huuitae fcafba3
refactor: 와인 타입 컴포넌트 이벤트 핸들러 props 수정
huuitae fe9465b
design: 타입 선택 이름 수정
huuitae d4bfb45
Merge branch 'design/type-select' of https://github.com/Team-3-2/Wine…
huuitae ca040aa
style: 코드 리뷰 내용 반영
huuitae 9f9981e
Merge branch 'develop' of https://github.com/Team-3-2/Wine into develop
huuitae eec6a79
design: text input 컴포넌트 제작
huuitae c8848c0
design: 와인 타입 선택 컴포넌트 제작
huuitae f3aee94
design: 와인 타입 선택 컴포넌트 제작
huuitae d3d0624
refactor: 와인 타입 컴포넌트 이벤트 핸들러 props 수정
huuitae 84a5937
design: 타입 선택 이름 수정
huuitae 4984bd1
design: text input 컴포넌트 제작
huuitae 1c36fd1
design: 와인 타입 선택 컴포넌트 제작
huuitae 0e6ed13
style: 코드 리뷰 내용 반영
huuitae 15286e3
Merge branch 'design/type-select' of https://github.com/Team-3-2/Wine…
huuitae 647f82c
chore: 변경된 색상 코드에 맞게 수정
huuitae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| export { default as Gnb } from "./gnb/Gnb"; | ||
| export { default as Header } from "./header/Header"; | ||
| export { TextInput, ModalTextInput } from "./text-input/text-input"; | ||
| export { default as SelectType } from "./select-type/select-type"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { Meta, StoryObj } from "@storybook/nextjs"; | ||
| import SelectType from "./select-type"; | ||
|
|
||
| const meta: Meta<typeof SelectType> = { | ||
| title: "Components/type-select", | ||
| component: SelectType, | ||
| parameters: { | ||
| layout: "centered", | ||
| }, | ||
| argTypes: {}, | ||
| }; | ||
|
|
||
| export default meta; | ||
|
|
||
| type Story = StoryObj<typeof SelectType>; | ||
|
|
||
| export const WineTypeSelect: Story = { | ||
| args: {}, | ||
| }; | ||
|
|
||
| export const WineTypeSelectError: Story = { | ||
| args: { | ||
| isError: true, | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import { cn } from "@/lib/utils"; | ||
| import Image from "next/image"; | ||
| import redWine from "../../../public/images/wine-type/red.jpg"; | ||
| import whiteWine from "../../../public/images/wine-type/white.jpg"; | ||
| import sparklingWine from "../../../public/images/wine-type/sparkling.jpg"; | ||
|
|
||
| const imgMap = { | ||
| Red: redWine, | ||
| White: whiteWine, | ||
| Sparkling: sparklingWine, | ||
| } as const; | ||
|
|
||
| type WineType = keyof typeof imgMap; | ||
|
|
||
| const TypeInput = ({ name }: { name: WineType }) => { | ||
| const imgSrc = imgMap[name] || ""; | ||
|
|
||
| return ( | ||
| <div | ||
| className={cn( | ||
| "h-[38px]", | ||
| "rounded-full border border-border-secondary", | ||
| "flex items-center", | ||
| "bg-white", | ||
| "pc:h-[48px]" | ||
| )} | ||
| > | ||
| <input | ||
| type="radio" | ||
| id={name} | ||
| value={name} | ||
| name="wine-type" | ||
| className="peer hidden" | ||
| /> | ||
| <label | ||
| htmlFor={name} | ||
| className={cn( | ||
| "py-[7px] pl-2 pr-3", | ||
| "flex items-center justify-center gap-[6px]", | ||
| "cursor-pointer rounded-full", | ||
| "text-default hover:bg-gray100", | ||
| "peer peer-checked:bg-gray800 peer-checked:text-white" | ||
| )} | ||
| > | ||
| <Image | ||
| className={cn("h-6 rounded-full object-cover", "pc:h-8 pc:w-8")} | ||
| src={imgSrc} | ||
| width={24} | ||
| height={24} | ||
| alt="레드와인" | ||
| draggable={false} | ||
| /> | ||
| <span className="text-body-sm tracking-[-0.02em] pc:text-body-md"> | ||
| {name} | ||
| </span> | ||
| </label> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| const SelectType = ({ isError }: { isError: boolean }) => { | ||
| return ( | ||
| <div className="flex flex-col gap-2"> | ||
| <div className="flex items-center gap-2"> | ||
| <p className="text-body-sm tracking-[-0.02em] text-default">타입</p> | ||
| {isError && ( | ||
| <p className="text-component-notes-md tracking-[-0.02em] text-danger"> | ||
| 와인 타입은 필수 입력이에요 | ||
| </p> | ||
| )} | ||
| </div> | ||
| <div className="flex gap-[10px]"> | ||
| <TypeInput name="Red" /> | ||
| <TypeInput name="White" /> | ||
| <TypeInput name="Sparkling" /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default SelectType; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { Meta, StoryObj } from "@storybook/nextjs"; | ||
| import { ModalTextInput, TextInput } from "./text-input"; | ||
|
|
||
| const meta: Meta<typeof TextInput> = { | ||
| title: "Components/text-input", | ||
| component: TextInput, | ||
| parameters: { | ||
| layout: "centered", | ||
| }, | ||
| argTypes: { | ||
| title: { control: { type: "text" } }, | ||
| placeholder: { control: { type: "text" } }, | ||
| }, | ||
| }; | ||
|
|
||
| export default meta; | ||
|
|
||
| type Story = StoryObj<typeof TextInput>; | ||
|
|
||
| export const NoContent: Story = { | ||
| args: { | ||
| title: "", | ||
| placeholder: "", | ||
| }, | ||
| }; | ||
|
|
||
| export const InputError: Story = { | ||
| args: { | ||
| title: "", | ||
| placeholder: "", | ||
| errorMsg: "에러가 발생했습니다", | ||
| }, | ||
| }; | ||
|
|
||
| export const LongText: Story = { | ||
| args: { | ||
| title: | ||
| "여긴 긴 제목이 들어가는 곳 입니다. 여긴 긴 제목이 들어가는 곳 입니다. 여긴 긴 제목이 들어가는 곳 입니다.", | ||
| placeholder: | ||
| "긴 placeholder를 입력해주세요 긴 placeholder를 입력해주세요 긴 placeholder를 입력해주세요", | ||
| }, | ||
| }; | ||
|
|
||
| export const ModalInputError: Story = { | ||
| render: (args) => <ModalTextInput {...args} />, | ||
| args: { | ||
| errorMsg: "에러가 발생했습니다", | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import { cn } from "@/lib/utils"; | ||
|
|
||
| interface InputValue { | ||
| placeholder: string; | ||
| errorMsg: string; | ||
| } | ||
|
|
||
| interface TextInputValue extends InputValue { | ||
|
Member
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. 두 인터페이스를 합쳐서 title 값만 옵셔널로 지정하는건 어떤가요? |
||
| title: string; | ||
| } | ||
|
|
||
| /** | ||
| * 기본 Input | ||
| * @param placeholder input의 placeholder | ||
| * @param errorMsg 표출할 에러 메시지 | ||
| * @returns | ||
| */ | ||
| const Input = ({ placeholder, errorMsg }: InputValue) => { | ||
| { | ||
| /* TODO(휘태): 에러 아이콘 넣기 */ | ||
| } | ||
| return ( | ||
| <input | ||
| id="text-input" | ||
| className={cn( | ||
| "w-[303px]", | ||
| "px-4 py-3", | ||
| "rounded border border-gray-300", | ||
| "text-[14px] leading-5 tracking-[0.02em] text-default", | ||
| "placeholder:text-body-sm placeholder:font-normal placeholder:text-tertiary", | ||
| "focus:outline-none", | ||
| "pc:w-[400px] pc:text-[16px] pc:leading-6 pc:placeholder:text-body-md pc:placeholder:font-normal", | ||
| errorMsg && "border-2 border-danger" | ||
| )} | ||
| type="text" | ||
| placeholder={placeholder ? placeholder : "내용을 입력해주세요"} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| /** | ||
| * 기본 입력 창 | ||
| * @param title 제목 | ||
| * @param placeholder input의 placeholder | ||
| * @param errorMsg 표출할 에러 메시지 | ||
| * @returns input | ||
| */ | ||
| const TextInput = ({ title, placeholder, errorMsg }: TextInputValue) => { | ||
| return ( | ||
| <> | ||
| <div className={cn("flex flex-col gap-2")}> | ||
| <p className={"text-body-sm font-bold tracking-[0.02em] text-gray-800"}> | ||
| {title ? title : "제목"} | ||
| </p> | ||
| <Input placeholder={placeholder} errorMsg={errorMsg} /> | ||
| </div> | ||
| {errorMsg && <p className="mt-1 text-body-sm text-danger">{errorMsg}</p>} | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| /** | ||
| * 모달 창에서 사용할 입력 창 | ||
| * @param title | ||
| * @param placeholder | ||
| * @param errorMsg | ||
| * @returns modal input | ||
| */ | ||
| const ModalTextInput = ({ title, placeholder, errorMsg }: TextInputValue) => { | ||
| return ( | ||
| <div className={cn("flex flex-col gap-2")}> | ||
| <div className="flex gap-2"> | ||
| <p className={"text-body-sm font-bold tracking-[0.02em] text-gray-800"}> | ||
| {title ? title : "제목"} | ||
| </p> | ||
| {errorMsg && <p className="text-body-sm text-danger">{errorMsg}</p>} | ||
| </div> | ||
| <Input placeholder={placeholder} errorMsg={errorMsg} /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export { TextInput, ModalTextInput }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
"flex items-center justify-center" -> "flex-center" 으로 변경해도 좋을 것 같아요!