Skip to content

Commit

Permalink
add logo
Browse files Browse the repository at this point in the history
  • Loading branch information
Mat-icon committed Jul 30, 2024
1 parent 088f90f commit 49dde83
Showing 1 changed file with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"use client";

import Image from "next/image";
import React, { useState } from "react";

const AddLogo: React.FC = () => {
const [selectedImage, setSelectedImage] = useState<
string | ArrayBuffer | undefined
>();

const handleImageChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const file = event.target.files?.[0];
if (file) {
const reader = new FileReader();
reader.onloadend = () => {
setSelectedImage(reader.result ?? undefined);
};
reader.readAsDataURL(file);
}
};

return (
<div className="h-52 w-4/5 rounded-sm border bg-white p-4 shadow-md hover:border-orange-500">
<label className="flex flex-col items-center">
<div className="mb-4 flex h-44 w-48 cursor-pointer items-center justify-center bg-gray-50">
{selectedImage ? (
<Image
src={selectedImage as string}
alt="Selected"
className="h-full w-full object-contain"
width={192}
height={192}
/>
) : (
<span className="text-gray-400">Add your logo</span>
)}
</div>
<input
type="file"
accept="image/*"
onChange={handleImageChange}
className="hidden"
/>
</label>
</div>
);
};

export default AddLogo;

0 comments on commit 49dde83

Please sign in to comment.