From 7abc9fc1c97ba49cfca50d491698d1e440f21287 Mon Sep 17 00:00:00 2001 From: Chinedu Okeke Date: Fri, 21 Feb 2025 05:40:28 +0100 Subject: [PATCH 1/3] ADD: new-idea-screen --- CryptoHackAI-web/public/Image.svg | 3 + .../src/app/components/ImageUpload.tsx | 72 ++++++++++ CryptoHackAI-web/src/app/globals.css | 7 + CryptoHackAI-web/src/app/new-idea/page.tsx | 127 ++++++++++++++++++ 4 files changed, 209 insertions(+) create mode 100644 CryptoHackAI-web/public/Image.svg create mode 100644 CryptoHackAI-web/src/app/components/ImageUpload.tsx create mode 100644 CryptoHackAI-web/src/app/new-idea/page.tsx diff --git a/CryptoHackAI-web/public/Image.svg b/CryptoHackAI-web/public/Image.svg new file mode 100644 index 0000000..394ad3f --- /dev/null +++ b/CryptoHackAI-web/public/Image.svg @@ -0,0 +1,3 @@ + + + diff --git a/CryptoHackAI-web/src/app/components/ImageUpload.tsx b/CryptoHackAI-web/src/app/components/ImageUpload.tsx new file mode 100644 index 0000000..f2bb297 --- /dev/null +++ b/CryptoHackAI-web/src/app/components/ImageUpload.tsx @@ -0,0 +1,72 @@ +"use client" +import Image from 'next/image'; +import React, { useState, ChangeEvent } from 'react'; + +interface ImageUploadProps { + onImageChange: (file: File | null) => void; +} + +const ImageUpload: React.FC = ({ onImageChange }) => { + const [image, setImage] = useState(null); + + const handleImageChange = (event: ChangeEvent) => { + const file = event.target.files?.[0]; + if (file) { + const reader = new FileReader(); + reader.onloadend = () => { + setImage(reader.result as string); + }; + reader.readAsDataURL(file); + onImageChange(file); + } else { + setImage(null); + onImageChange(null); + } + }; + + return ( +
+ image-upload + + + {image && Preview} +
+ ); +}; + +const styles: { [key: string]: React.CSSProperties } = { + uploadContainer: { + width: '120px', + padding: '20px', + textAlign: 'start', + display: 'flex', + flexDirection: 'column', + alignItems: 'center', + justifyContent: 'center' + }, + uploadLabel: { + fontSize: '12px', + color: '#333', + cursor: 'pointer', + }, + uploadInput: { + display: 'none', + }, + imagePreview: { + width: '100px', + marginTop: '10px', + height: '100px', + objectPosition: 'center', + objectFit: 'cover' + }, +}; + +export default ImageUpload; diff --git a/CryptoHackAI-web/src/app/globals.css b/CryptoHackAI-web/src/app/globals.css index 6b717ad..7f99c8c 100644 --- a/CryptoHackAI-web/src/app/globals.css +++ b/CryptoHackAI-web/src/app/globals.css @@ -19,3 +19,10 @@ body { background: var(--background); font-family: Arial, Helvetica, sans-serif; } +.scrollbar-hide::-webkit-scrollbar { + display: none; +} +.scrollbar-hide { + scrollbar-width: none; + -ms-overflow-style: none; +} diff --git a/CryptoHackAI-web/src/app/new-idea/page.tsx b/CryptoHackAI-web/src/app/new-idea/page.tsx new file mode 100644 index 0000000..6f9cb5e --- /dev/null +++ b/CryptoHackAI-web/src/app/new-idea/page.tsx @@ -0,0 +1,127 @@ +"use client" +import { type FormEvent, useState } from "react" +import type React from "react" + +import ImageUpload from "../components/ImageUpload" + +const Page = () => { + const [formData, setFormData] = useState({ + description: "", + impact: "", + uniqueness: "", + image: null as File | null, + }) + + const handleShare = (e: FormEvent) => { + e.preventDefault() + console.log(formData) + setFormData({ + description: "", + impact: "", + uniqueness: "", + image: null, + }) + } + + const handleChange = (e: React.ChangeEvent) => { + const { name, value } = e.target + setFormData({ + ...formData, + [name]: value, + }) + } + + const handleImageChange = (file: File | null) => { + setFormData({ + ...formData, + image: file, + }) + } + + const deleteData = () => { + setFormData({ + description: "", + impact: "", + uniqueness: "", + image: null, + }) + } + + return ( +
+
+

Idea Name

+ +
+ +
+ +
+ + +
+
+ +
+
+

Description

+ +
+