-
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.
- Loading branch information
Showing
8 changed files
with
405 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 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,5 @@ | ||
.app { | ||
background-image: url("/path/to/your/image.jpg"); /* 원하는 이미지 경로로 변경 */ | ||
background-repeat: no-repeat; | ||
background-size: cover; | ||
} |
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
Empty file.
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,112 @@ | ||
import React, { useState, useRef } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
const ImageUpload = () => { | ||
const [selectedImage, setSelectedImage] = useState(null); | ||
const navigate = useNavigate(); | ||
const fileInputRef = useRef(null); | ||
|
||
const handleImageChange = (event) => { | ||
const file = event.target.files[0]; | ||
setSelectedImage(URL.createObjectURL(file)); | ||
}; | ||
|
||
const handleDrop = (event) => { | ||
event.preventDefault(); | ||
const file = event.dataTransfer.files[0]; | ||
setSelectedImage(URL.createObjectURL(file)); | ||
}; | ||
|
||
const handleDragOver = (event) => { | ||
event.preventDefault(); | ||
}; | ||
|
||
const handleSubmit = () => { | ||
// 이미지 업로드 후 처리할 내용을 여기에 작성 | ||
}; | ||
|
||
const handleNavigate = () => { | ||
navigate('/mypage'); // '/mypage'로 이동 | ||
}; | ||
|
||
const handleSelectImage = () => { | ||
fileInputRef.current.click(); | ||
}; | ||
|
||
const handleRemoveImage = () => { | ||
setSelectedImage(null); | ||
}; | ||
|
||
return ( | ||
<div style={{ backgroundColor: 'transparent', color: 'white' }}> | ||
<h1>이미지 등록하기</h1> | ||
<div | ||
onDrop={handleDrop} | ||
onDragOver={handleDragOver} | ||
style={{ | ||
width: '1200px', | ||
height: '650px', | ||
border: '2px dashed gray', | ||
borderRadius: '5px', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
margin: '20px 0', | ||
position: 'relative', | ||
overflow: 'hidden', | ||
backgroundColor: 'rgba(255, 255, 255, 0.2)', | ||
}} | ||
> | ||
<input | ||
type="file" | ||
onChange={handleImageChange} | ||
style={{ display: 'none' }} | ||
ref={fileInputRef} | ||
/> | ||
<label htmlFor="file-input"> | ||
{!selectedImage && ( | ||
<p>이미지를 여기로 드래그 앤 드롭하거나 선택하세요.</p> | ||
)} | ||
{!selectedImage && ( | ||
<button type="button" onClick={handleSelectImage}> | ||
이미지 선택 | ||
</button> | ||
)} | ||
</label> | ||
{selectedImage && ( | ||
<div style={{ position: 'relative', width: '100%', height: '100%' }}> | ||
<div | ||
style={{ | ||
position: 'absolute', | ||
top: 0, | ||
bottom: 0, | ||
left: 0, | ||
right: 0, | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}} | ||
> | ||
<img | ||
src={selectedImage} | ||
alt="Preview" | ||
style={{ | ||
width: '100%', | ||
height: '100%', | ||
objectFit: 'cover', | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
{selectedImage && ( | ||
<button type="button" onClick={handleRemoveImage}> | ||
이미지 변경 | ||
</button> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ImageUpload; |
Oops, something went wrong.