-
Notifications
You must be signed in to change notification settings - Fork 0
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 #7 from LikeLionHGU/hwan_#6/프로젝트-생성-페이지
Hwan #6/프로젝트 생성 페이지
- Loading branch information
Showing
10 changed files
with
209 additions
and
51 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,12 @@ | ||
export default function Header() { | ||
return ( | ||
<> | ||
<div> | ||
<img /> | ||
</div> | ||
<div> | ||
<input placeholder="책 제목, 작가명" /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React, { useState } from "react"; | ||
import ImgNone from "../imgs/img_none.svg"; | ||
import "../styles/ImgUpLoad.css"; | ||
|
||
export default function ImgUpLoad({ onImageUpload }) { | ||
const [imageSrc, setImageSrc] = useState(`${ImgNone}`); | ||
|
||
const encodeFileToBase64 = (fileBlob) => { | ||
const reader = new FileReader(); | ||
|
||
reader.readAsDataURL(fileBlob); | ||
|
||
return new Promise((resolve) => { | ||
reader.onload = () => { | ||
setImageSrc(reader.result); | ||
resolve(reader.result); // Base64 인코딩된 파일 반환 | ||
}; | ||
}); | ||
}; | ||
|
||
return ( | ||
<main className="img-container"> | ||
<div className="img-preview"> | ||
{imageSrc && ( | ||
<img className="img-image" src={imageSrc} alt="preview-img" /> | ||
)} | ||
</div> | ||
|
||
<input | ||
type="file" | ||
onChange={(e) => { | ||
const file = e.target.files[0]; | ||
encodeFileToBase64(file).then(() => { | ||
onImageUpload(file); // 파일을 부모 컴포넌트로 전달 | ||
}); | ||
}} | ||
/> | ||
</main> | ||
); | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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 @@ | ||
.img-image { | ||
max-width: 200px; | ||
max-height: 275px; | ||
object-fit: "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