-
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.
- Loading branch information
Showing
9 changed files
with
126 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
"use client"; | ||
import Button from "@/components/ui/component/Button"; | ||
import FileInput from "@/components/ui/form/File"; | ||
import { useState } from "react"; | ||
|
||
import FileInput from "@/components/ui/form/File"; | ||
import { cn } from "@/lib/utils"; | ||
|
||
export default function File() { | ||
const [file, setFile] = useState<File[]>([]); | ||
|
||
return ( | ||
<FileInput file={file} setFile={setFile} name="file" preview="file"> | ||
<Button text="Click here" /> | ||
<p>or drag and drop</p> | ||
<div | ||
className={cn(`h-20 flex items-center flex-col justify-center p-2`, {})} | ||
> | ||
<p>Click here</p> | ||
<p>or drag and drop here</p> | ||
</div> | ||
</FileInput> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,14 +1,25 @@ | ||
"use client"; | ||
import Button from "@/components/ui/component/Button"; | ||
import FileInput from "@/components/ui/form/File"; | ||
import { useState } from "react"; | ||
|
||
import FileInput from "@/components/ui/form/File"; | ||
import { cn } from "@/lib/utils"; | ||
|
||
export default function Image() { | ||
const [file, setFile] = useState<File[]>([]); | ||
return ( | ||
<FileInput file={file} setFile={setFile} name="file" preview="img" isMultiple> | ||
<Button text="Click here" /> | ||
<p>or drag and drop</p> | ||
<FileInput | ||
file={file} | ||
setFile={setFile} | ||
name="file" | ||
preview="img" | ||
isMultiple | ||
> | ||
<div | ||
className={cn(`h-20 flex items-center flex-col justify-center p-2`, {})} | ||
> | ||
<p>Click here</p> | ||
<p>or drag and drop here</p> | ||
</div> | ||
</FileInput> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,13 +1,19 @@ | ||
"use client"; | ||
import Button from "@/components/ui/component/Button"; | ||
import FileInput from "@/components/ui/form/File"; | ||
import { useState } from "react"; | ||
|
||
import FileInput from "@/components/ui/form/File"; | ||
import { cn } from "@/lib/utils"; | ||
|
||
export default function Image() { | ||
const [file, setFile] = useState<File[]>([]); | ||
return ( | ||
<FileInput file={file} setFile={setFile} name="file" preview="img" accept="file"> | ||
<p>or drag and drop</p> | ||
<div | ||
className={cn(`h-20 flex items-center flex-col justify-center p-2`, {})} | ||
> | ||
<p>Click here</p> | ||
<p>or drag and drop here</p> | ||
</div> | ||
</FileInput> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,14 +1,28 @@ | ||
import { convertSizeBytes } from "@/lib/utils"; | ||
import { FaFile } from "react-icons/fa"; | ||
import { MdClose } from "react-icons/md"; | ||
|
||
export default function PreviewFile({ file }: { file: File }) { | ||
export default function PreviewFile({ | ||
file, | ||
handleDelete, | ||
}: { | ||
file: File; | ||
handleDelete: () => void; | ||
}) { | ||
return ( | ||
<div className="flex justify-start w-full items-center gap-4 p-1 px-2 rounded-lg bg-dark-400"> | ||
<FaFile size={35} /> | ||
<div> | ||
<p>{file?.name}</p> | ||
<p className="text-xs">{convertSizeBytes(file?.size)}</p> | ||
<div className="flex justify-between h-16 w-full items-center rounded-lg !p-0 bg-dark-400"> | ||
<div className="p-1 px-2 flex justify-start items-center gap-4"> | ||
<FaFile size={35} /> | ||
<div> | ||
<p>{file?.name}</p> | ||
<p className="text-xs">{convertSizeBytes(file?.size)}</p> | ||
</div> | ||
</div> | ||
<MdClose | ||
size={20} | ||
className="cursor-pointer h-full w-14 px-5 transition-colors hover:bg-red-500 rounded-tr-lg" | ||
onClick={handleDelete} | ||
/> | ||
</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 |
---|---|---|
@@ -1,17 +1,29 @@ | ||
import Image from "next/image"; | ||
import { MdClose } from "react-icons/md"; | ||
|
||
export default function PreviewImg({ file }: { file: File|null }) { | ||
if(!file) return null | ||
export default function PreviewImg({ | ||
file, | ||
handleDelete, | ||
}: { | ||
file: File | null; | ||
handleDelete: () => void; | ||
}) { | ||
if (!file) return null; | ||
|
||
return ( | ||
<div> | ||
<div className="relative size-40 bg-dark-400 rounded-lg"> | ||
<Image | ||
src={URL?.createObjectURL(file)} | ||
alt={file?.name} | ||
className="size-40 rounded-lg object-cover" | ||
className="size-40 object-cover" | ||
width={40} | ||
height={40} | ||
/> | ||
<MdClose | ||
className="size-6 absolute top-0 right-0 cursor-pointer transition-colors bg-red-500 rounded-bl-lg rounded-tr-lg" | ||
size={15} | ||
onClick={handleDelete} | ||
/> | ||
</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