-
Notifications
You must be signed in to change notification settings - Fork 31
[김승민] Sprint6 #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The head ref may contain hidden characters: "React-\uAE40\uC2B9\uBBFC-sprint6"
[김승민] Sprint6 #121
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { useState } from "react"; | ||
|
|
||
| import IcoClose from "@/assets/icons/ico_close.svg"; | ||
| import IcoPlus from "@/assets/icons/ico_plus.svg"; | ||
|
|
||
| import * as ParentS from "../style"; | ||
| import * as CurrentS from "./style"; | ||
|
|
||
| function FileInput({ title, ...rest }) { | ||
| const [thumbnail, setThumbnail] = useState(""); | ||
| const [warning, setWarning] = useState(""); | ||
|
|
||
| function handleFileUpload(e) { | ||
| let fileArr = e.target.files; | ||
| let image = window.URL.createObjectURL(fileArr[0]); | ||
| setThumbnail(image); | ||
| } | ||
|
|
||
| function handleOnClick(e) { | ||
| if (thumbnail) { | ||
| e.preventDefault(); | ||
| setWarning("*이미지 등록은 최대 1개까지 가능합니다"); | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <ParentS.Label> | ||
| {title} | ||
| <input | ||
| type="file" | ||
| accept=".png, .jpeg, .jpg" | ||
| style={{ display: "none" }} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hidden 속성을 쓰실 수 있어요! :) <input hidden /> |
||
| onChange={handleFileUpload} | ||
| onClick={handleOnClick} | ||
| {...rest} | ||
| /> | ||
| <CurrentS.FileContainer> | ||
| <CurrentS.File> | ||
| <img src={IcoPlus} /> | ||
| <span>이미지 등록</span> | ||
| </CurrentS.File> | ||
| {thumbnail && ( | ||
| <CurrentS.File | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 개인적으로, 사용자 경험상 이미지를 눌렀을 때 지워지는 게 조금은 어색한 거 같아요! 요거는 그냥 참고만 해주세요 :) |
||
| onClick={(e) => { | ||
| e.preventDefault(); | ||
| setThumbnail(""); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 인풋에 올라온 파일도 처리해 주셔야합니다~! |
||
| }} | ||
| > | ||
| <img className="close" src={IcoClose} alt="" /> | ||
| <img className="thumbnail" src={thumbnail} /> | ||
| </CurrentS.File> | ||
| )} | ||
| </CurrentS.FileContainer> | ||
| <span className="warning">{warning}</span> | ||
| </ParentS.Label> | ||
| ); | ||
| } | ||
|
|
||
| export default FileInput; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import styled from "styled-components"; | ||
| import color from "@/utils/color"; | ||
|
|
||
| export const File = styled.div` | ||
| width: 282px; | ||
| height: 282px; | ||
|
|
||
| position: relative; | ||
| border-radius: 12px; | ||
| background: ${color("secondary200")}; | ||
| color: ${color("secondary400")}; | ||
|
|
||
| display: flex; | ||
| flex-direction: column; | ||
| justify-content: center; | ||
| align-items: center; | ||
|
|
||
| overflow: hidden; | ||
|
|
||
| font-size: 16px; | ||
| font-weight: 400; | ||
| transition: all 0.1s ease-out; | ||
|
|
||
| @media (max-width: 1200px) { | ||
| width: 168px; | ||
| height: 168px; | ||
| } | ||
|
|
||
| .thumbnail { | ||
| width: 100%; | ||
| } | ||
|
|
||
| .close { | ||
| position: absolute; | ||
| top: 12px; | ||
| right: 12px; | ||
| } | ||
|
|
||
| &:hover { | ||
| filter: brightness(0.95); | ||
| } | ||
| `; | ||
|
|
||
| export const FileContainer = styled.div` | ||
| display: flex; | ||
| gap: 24px; | ||
|
|
||
| @media (max-width: 1200px) { | ||
| gap: 10px; | ||
| } | ||
| `; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
옆에 빈 공간을 눌러도 파일 업로더가 나옵니다🤣