-
Notifications
You must be signed in to change notification settings - Fork 4
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 #96 from bssm-portfolio/develop
v1.2.0
- Loading branch information
Showing
22 changed files
with
346 additions
and
123 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
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
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,93 @@ | ||
import useFileDrop from "@/hooks/useFileDrop"; | ||
import classNames from "classnames"; | ||
import Image from "next/image"; | ||
import { | ||
Dispatch, | ||
ReactNode, | ||
SetStateAction, | ||
useEffect, | ||
useState, | ||
} from "react"; | ||
|
||
type AcceptType = "image" | "video"; | ||
interface DropFileUploaderProps { | ||
id?: string; | ||
className?: string; | ||
label?: string | ReactNode; | ||
isSingleFile?: boolean; | ||
accept?: AcceptType; | ||
setFileList: Dispatch<SetStateAction<File[]>>; | ||
} | ||
|
||
export default function DropFileUploader({ | ||
id = "", | ||
className = "", | ||
label = "", | ||
isSingleFile = true, | ||
accept = "image", | ||
setFileList, | ||
}: DropFileUploaderProps) { | ||
const [previewFile, setPreviewFile] = useState<File>(); | ||
const { files, inputRef, isDragActive, labelRef } = useFileDrop({ | ||
isSingleFile, | ||
accept: accept === "video" ? "video/*" : "image/*", | ||
}); | ||
|
||
const getFileUploaderBorderCss = () => { | ||
return ` | ||
relative | ||
border | ||
mb-2.5 | ||
flex | ||
flex-col | ||
justify-center | ||
items-center | ||
gap-2.5 | ||
rounded-lg | ||
cursor-pointer | ||
`; | ||
}; | ||
|
||
useEffect(() => { | ||
setFileList(files); | ||
setPreviewFile(files[0]); | ||
}, [files, setFileList]); | ||
|
||
return ( | ||
<label | ||
htmlFor={id} | ||
className={classNames( | ||
className, | ||
getFileUploaderBorderCss(), | ||
"relative w-full h-[11rem]", | ||
{ | ||
"!border-2 !border-blue border-dotted": isDragActive, | ||
}, | ||
)} | ||
ref={labelRef} | ||
> | ||
<input ref={inputRef} type="file" className="hidden" id={id} /> | ||
|
||
{label} | ||
|
||
{previewFile && accept === "image" && ( | ||
<Image | ||
src={URL.createObjectURL(previewFile)} | ||
alt="썸네일" | ||
fill | ||
sizes="20rem" | ||
className="rounded-lg -z-10 opacity-30" | ||
/> | ||
)} | ||
|
||
{previewFile && accept === "video" && ( | ||
<video | ||
src={URL.createObjectURL(previewFile)} | ||
className="w-full h-44 -z-10 absolute object-cover rounded-lg opacity-30" | ||
> | ||
<track kind="captions" src={URL.createObjectURL(previewFile)} /> | ||
</video> | ||
)} | ||
</label> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import useWindow from "@/hooks/useWindow"; | ||
import { ReactPlayerProps } from "react-player"; | ||
import ReactPlayer from "react-player/lazy"; | ||
|
||
interface VideoProps extends ReactPlayerProps { | ||
src?: string | string[]; | ||
} | ||
|
||
export default function Video({ src, ...props }: VideoProps) { | ||
const { isWindow } = useWindow(); | ||
if (!isWindow) return <div />; | ||
|
||
return <ReactPlayer width="100%" url={src} {...props} />; | ||
} |
Oops, something went wrong.
7153ffb
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.
Successfully deployed to the following URLs:
bssm-portfolio – ./
bssm-portfolio-bssm-portfolio.vercel.app
bssm-portfolio.vercel.app
bssm-portfolio-git-main-bssm-portfolio.vercel.app