From 19c73ac33e587c67d2882f6db92e06042febae0c Mon Sep 17 00:00:00 2001 From: Zeke Abshire Date: Fri, 24 Mar 2023 03:15:48 -0500 Subject: [PATCH] Started the New Proposal button dialog --- src/components/ImageInput.tsx | 93 +++++++++++++++++++++++++++ src/components/layouts/MainLayout.tsx | 61 +++++++++++++++++- 2 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 src/components/ImageInput.tsx diff --git a/src/components/ImageInput.tsx b/src/components/ImageInput.tsx new file mode 100644 index 0000000..07a97b3 --- /dev/null +++ b/src/components/ImageInput.tsx @@ -0,0 +1,93 @@ +import { typo } from "@styles/typography"; +import { cva } from "class-variance-authority"; +import type { ChangeEvent } from "react"; +import { useEffect, useRef, useState } from "react"; +import Image from "next/image"; + +const input = cva([ + typo({ tag: "p" }), + "w-full rounded border-[6px] py-2 px-3 md:py-3 md:px-4 leading-tight border-fg placeholder-fg/50 bg-fg/20", + "focus:outline-none", +]); + +interface ImageInputProps { + label: string; + placeholderImage?: string; + onChange?: (file: File) => void; + currentImage?: string; + aspectRatio?: number; +} + +export const ImageInput: React.FC = ({ + label, + placeholderImage, + onChange, + currentImage, + aspectRatio, +}) => { + const [preview, setPreview] = useState(currentImage); + const fileInputRef = useRef(null); + + useEffect(() => { + if (currentImage) { + setPreview(currentImage); + } else { + setPreview(undefined); + } + }, [currentImage]); + + const handleFileInputChange = (e: ChangeEvent) => { + const file = e.target.files?.[0]; + if (file) { + setPreview(URL.createObjectURL(file)); + if (onChange) onChange(file); + } + }; + + const handleImageClick = () => { + fileInputRef.current?.click(); + }; + + return ( +
+ +
+ {preview ? ( +
+ Selected image +
+ ) : ( +
+ {placeholderImage ? ( + Placeholder image + ) : ( + + Click to add image + + )} +
+ )} + +
+
+ ); +}; diff --git a/src/components/layouts/MainLayout.tsx b/src/components/layouts/MainLayout.tsx index cd71476..7df6ed6 100644 --- a/src/components/layouts/MainLayout.tsx +++ b/src/components/layouts/MainLayout.tsx @@ -14,6 +14,11 @@ import { import type { IconType } from "react-icons/lib"; import { Button } from "@components/Button"; import * as DropdownMenu from "@radix-ui/react-dropdown-menu"; +import * as Dialog from "@radix-ui/react-dialog"; +import { cx } from "class-variance-authority"; +import { TextInput } from "@components/TextInput"; +import { Divider } from "@components/Divider"; +import { ImageInput } from "@components/ImageInput"; export const MainLayout: React.FC = ({ children }) => { return ( @@ -72,7 +77,7 @@ export const SidePanel: React.FC = () => { ))} - + @@ -80,6 +85,60 @@ export const SidePanel: React.FC = () => { ); }; +const NewProposalButton: React.FC = () => { + const container = + typeof window !== "undefined" ? document.getElementById("root") : null; + + const FullDivider = () => ( +
+ +
+ ); + + return ( + + + + + + + + + + +

+ Create new proposal +

+
+ + Let others know a little about your project idea. + + +
+ + + +
+ +
+ +
+
+
+
+
+ ); +}; + const MoreMenu: React.FC = () => { const container = typeof window !== "undefined" ? document.getElementById("root") : null;