diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx index 2469e5aa..96332a81 100644 --- a/.storybook/preview.tsx +++ b/.storybook/preview.tsx @@ -4,6 +4,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import React from "react"; import { Decorator } from "@storybook/react"; import { useRouter } from "next/navigation"; +import "./storybook.css"; const queryClient = new QueryClient(); diff --git a/.storybook/storybook.css b/.storybook/storybook.css new file mode 100644 index 00000000..97b0236b --- /dev/null +++ b/.storybook/storybook.css @@ -0,0 +1,17 @@ +* { + cursor: auto !important; +} + +html, +body { + cursor: auto !important; +} + +a, +button, +[role="button"], +input, +select, +textarea { + cursor: auto !important; +} diff --git a/src/app/components/input/file/ImageInput/ImageInput.tsx b/src/app/components/input/file/ImageInput/ImageInput.tsx deleted file mode 100644 index aa45e1a2..00000000 --- a/src/app/components/input/file/ImageInput/ImageInput.tsx +++ /dev/null @@ -1,131 +0,0 @@ -"use client"; -import { HiUpload } from "react-icons/hi"; -import { forwardRef, useState, useEffect } from "react"; -import { toast } from "react-hot-toast"; -import { DragDropContext, Droppable, Draggable, DropResult } from "react-beautiful-dnd"; -import PreviewItem from "./PreviewItem"; -import { cn } from "@/lib/tailwindUtil"; -import { ImageInputType } from "@/types/addform"; -import React from "react"; - -interface ImageInputProps { - name: string; - onChange?: (files: File[] | string[]) => void; - onDelete?: (id: string) => void; - initialImageList: ImageInputType[]; -} - -const ImageInput = forwardRef((props, ref) => { - const [imageList, setImageList] = useState(props.initialImageList || []); - - useEffect(() => { - if (props.initialImageList?.length > 0) { - setImageList(props.initialImageList); - } - }, [props.initialImageList]); - - const handleFileChange = (selectedFiles: FileList | null) => { - if (selectedFiles) { - const filesArray = Array.from(selectedFiles); // FileList를 배열로 변환 - const validFiles = filesArray.filter((file) => file.type.startsWith("image/")); - - if (validFiles.length + imageList.length > 3) { - toast.error("이미지는 최대 3개까지 업로드할 수 있습니다."); - return; - } - - if (validFiles.length === 0) { - toast.error("이미지 파일만 업로드할 수 있습니다."); - return; - } - - // 선택된 파일을 상위 컴포넌트로 전달 - props.onChange?.(validFiles); - } - }; - - const handleDeleteImage = (targetUrl: string) => { - const newImageList = imageList.filter((image) => image.url !== targetUrl); - setImageList(newImageList); - props.onDelete?.(targetUrl); - }; - - const handleOpenFileSelector = () => { - if (typeof ref === "function") { - const fileInput = document.querySelector(`input[name="${props.name}"]`); - if (fileInput) { - (fileInput as HTMLInputElement).click(); - } - } else if (ref && "current" in ref) { - ref.current?.click(); - } - }; - - const colorStyle = { - bgColor: "bg-background-200", - borderColor: "border-[0.5px] border-transparent", - hoverColor: "hover:border-grayscale-200 hover:bg-background-300", - innerHoverColor: "hover:bg-background-300", - }; - - const handleDragEnd = (result: DropResult) => { - if (!result.destination) return; - - const items = Array.from(imageList); - const [reorderedItem] = items.splice(result.source.index, 1); - items.splice(result.destination.index, 0, reorderedItem); - - setImageList(items); - // 상위 컴포넌트에 변경된 이미지 URL 배열 전달 - props.onChange?.(items.map((item) => item.url)); - }; - - return ( - -
-
- handleFileChange(e.target.files)} - className="hidden" - multiple - /> -
- -
-
- - {(provided) => ( -
- {imageList.map((image, index) => ( - - {(provided) => ( -
- -
- )} -
- ))} - {provided.placeholder} -
- )} -
-
-
- ); -}); - -ImageInput.displayName = "ImageInput"; - -export default ImageInput; diff --git a/src/app/stories/design-system/components/input/picker/DatePicker.stories.tsx b/src/app/stories/design-system/components/input/picker/DatePicker.stories.tsx index 196df6b0..ef2072f4 100644 --- a/src/app/stories/design-system/components/input/picker/DatePicker.stories.tsx +++ b/src/app/stories/design-system/components/input/picker/DatePicker.stories.tsx @@ -1,7 +1,7 @@ -import DatePickerInput from "@/app/components/input/dateTimeDaypicker/DatePickerInput"; import "react-datepicker/dist/react-datepicker.css"; import { Meta, StoryObj } from "@storybook/react"; import { FormProvider, useForm } from "react-hook-form"; +import DatePickerInput from "@/app/components/input/dateTimeDaypicker/DatePickerInput"; const meta = { title: "Design System/Components/Date-Time-Day Picker/DatePicker", @@ -28,8 +28,8 @@ type Story = StoryObj; export const DatePicker: Story = { render: () => ( {}} />