-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from bsideproject/moon
[feat] react-images-uploading 추가 및 step3 수정
- Loading branch information
Showing
5 changed files
with
3,408 additions
and
4,404 deletions.
There are no files selected for viewing
This file contains 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,59 @@ | ||
import React, { forwardRef, useEffect, useImperativeHandle } from "react"; | ||
import ImageUploading, { ImageListType } from "react-images-uploading"; | ||
import Rectangle from '@/public/icons/rectangle.svg'; | ||
import RectangleCamera from '@/public/icons/rectangleCamera.svg'; | ||
|
||
|
||
export default function FileUpload() { | ||
const [images, setImages] = React.useState<ImageListType>([]); | ||
const maxNumber = 5; | ||
|
||
const onChange = (imageList: ImageListType, addUpdateIndex: number[] | undefined) => { | ||
console.log(imageList, addUpdateIndex); | ||
setImages(imageList); | ||
|
||
}; | ||
|
||
return ( | ||
<div className="App"> | ||
{ | ||
<ImageUploading | ||
multiple | ||
value={images} | ||
onChange={onChange} | ||
maxNumber={maxNumber} | ||
> | ||
{({ | ||
imageList, | ||
onImageUpload, | ||
onImageRemoveAll, | ||
onImageUpdate, | ||
onImageRemove, | ||
isDragging, | ||
dragProps | ||
}) => ( | ||
// write your building UI | ||
<div className="upload__image-wrapper"> | ||
<div className="relative w-[120px] h-[110px] mt-[8px]" style={isDragging ? { color: "red" } : undefined} {...dragProps}> | ||
<Rectangle className="z-0" /> | ||
<RectangleCamera className="absolute z-10 top-[45px] left-[55px] transform -translate-x-1/2 -translate-y-1/2 hover:cursor-pointer" onClick={onImageUpload}/> | ||
<span className="absolute z-10 top-[67px] left-[55px] transform -translate-x-1/2 -translate-y-1/2 text-g4 semibold text-[12px]">3/5</span> | ||
</div> | ||
| ||
{/* <button onClick={onImageRemoveAll}>Remove all images</button> */} | ||
{imageList.map((image, index) => ( | ||
<div key={index} className="image-item"> | ||
<img src={image.dataURL} alt="" width="100" /> | ||
<div className="image-item__btn-wrapper"> | ||
{/* <button onClick={() => onImageUpdate(index)}>Update</button> */} | ||
<button onClick={() => onImageRemove(index)}>Remove</button> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
)} | ||
</ImageUploading> | ||
} | ||
</div> | ||
); | ||
} |
This file contains 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 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 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
Oops, something went wrong.