diff --git a/src/app/example/page.tsx b/src/app/example/page.tsx index 3174402d..d555b01f 100644 --- a/src/app/example/page.tsx +++ b/src/app/example/page.tsx @@ -9,6 +9,7 @@ import { TextInput, } from "@/components"; import Profile from "@/components/profile/profile"; +import WineImg from "@/components/wine-img/wine-img"; import React, { ChangeEvent } from "react"; const Page = () => { @@ -103,6 +104,12 @@ const Page = () => { +
+
+ + +
+
); diff --git a/src/components/wine-img/wine-img.stories.tsx b/src/components/wine-img/wine-img.stories.tsx new file mode 100644 index 00000000..80def2d9 --- /dev/null +++ b/src/components/wine-img/wine-img.stories.tsx @@ -0,0 +1,32 @@ +import { Meta, StoryObj } from "@storybook/nextjs"; +import WineImg from "./wine-img"; + +const meta: Meta = { + title: "Components/WineImg", + component: WineImg, + parameters: { + layout: "centered", + docs: { + description: { + component: "와인 등록 시 사용되는 이미지 업로드 컴포넌트 입니다.", + }, + }, + }, + tags: ["autodocs"], + argTypes: { + isError: { control: { type: "boolean" } }, + errorMsg: { control: { type: "text" } }, + }, +}; + +export default meta; + +type Story = StoryObj; + +export const UploadWineImg: Story = { + args: {}, +}; + +export const ErrorWineImg: Story = { + args: { isError: true, errorMsg: "와인 사진은 필수 입력이에요" }, +}; diff --git a/src/components/wine-img/wine-img.tsx b/src/components/wine-img/wine-img.tsx new file mode 100644 index 00000000..ca141c9f --- /dev/null +++ b/src/components/wine-img/wine-img.tsx @@ -0,0 +1,53 @@ +import { cn } from "@/lib/utils"; +import Icon from "../icon/icon"; +import { ComponentProps } from "react"; + +interface WineImgProps extends ComponentProps<"input"> { + isError?: boolean; + errorMsg?: string; +} + +/** + * 와인 이미지 등록 컴포넌트 + * @author hwitae + * @param isError 오류 여부 + * @param errorMsg 표시할 에러 메시지 + * @returns + */ +const WineImg = ({ isError, errorMsg, ...props }: WineImgProps) => { + return ( +
+ + {isError && ( +

+ {errorMsg} +

+ )} + +
+ ); +}; + +export default WineImg;