diff --git a/packages/synapse-interface/pages/returntomonke/ImageUploader.tsx b/packages/synapse-interface/pages/returntomonke/ImageUploader.tsx new file mode 100644 index 0000000000..b43de67709 --- /dev/null +++ b/packages/synapse-interface/pages/returntomonke/ImageUploader.tsx @@ -0,0 +1,145 @@ +import { useState, useRef, useEffect } from 'react' +import Button from '@tw/Button' + +export default function ImageUploader() { + const [uploadedImage, setUploadedImage] = useState(null) + const [processedImage, setProcessedImage] = useState(null) + + const fileInput = useRef(null) + const imgRef = useRef(null) + + useEffect(() => { + if (uploadedImage) { + applyImageOverlay() + } + }, [uploadedImage]) + + function handleFile(file) { + setUploadedImage(file) + } + + function handleDragOver(event) { + event.preventDefault() + } + + function handleOnDrop(event) { + event.preventDefault() + event.stopPropagation() + handleFile(event.dataTransfer.files[0]) + console.log('File drop was a success') + } + + const applyImageOverlay = () => { + const canvas = imgRef.current + const ctx = canvas.getContext('2d') + + // Clear the canvas + ctx.clearRect(0, 0, canvas.width, canvas.height) + + // Load the uploaded image + const img = new Image() + img.src = URL.createObjectURL(uploadedImage) + img.onload = () => { + if (img.width >= img.height) { + canvas.width = img.width + canvas.height = img.width + } else { + canvas.width = img.height + canvas.height = img.height + } + + // Calculate the start positions to center the image + const startX = (canvas.width - img.width) / 2 + const startY = (canvas.height - img.height) / 2 + + // Draw the uploaded image centered + ctx.drawImage(img, startX, startY) + + // Load the overlay image + const overlay = new Image() + overlay.src = './synpfpborder.png' + overlay.onload = () => { + // Draw the overlay image on top of the uploaded image + ctx.drawImage(overlay, 0, 0, canvas.width, canvas.height) + + // Convert the canvas to a Blob and update the state + canvas.toBlob((blob) => { + setProcessedImage(blob) + }, 'image/jpeg') + } + } + } + + return ( +
+
fileInput.current.click()} + > +

+ {!processedImage && ( + <> + Click to Upload or +
+ Drag and drop image here... + + )} + {processedImage && <>Select different image?} +

+ handleFile(e.target.files[0])} + /> +
+ {processedImage && ( + preview + )} + + {uploadedImage && ( + + )} +
+ ) +} + +function downloadBase64File(dataStr, fileName) { + const downloadLink = document.createElement('a') + downloadLink.href = dataStr + downloadLink.download = fileName + downloadLink.click() + console.log('evolving into a synape') +} diff --git a/packages/synapse-interface/pages/returntomonke/PfpGeneratorCard.tsx b/packages/synapse-interface/pages/returntomonke/PfpGeneratorCard.tsx new file mode 100644 index 0000000000..2b0bc8177a --- /dev/null +++ b/packages/synapse-interface/pages/returntomonke/PfpGeneratorCard.tsx @@ -0,0 +1,20 @@ +import Card from '@tw/Card' + +import ImageUploader from './ImageUploader' + +export default function PfpGeneratorCard() { + return ( + + Choose Synapse + + } + divider={false} + className="rounded-xl min-w-[380px]" + titleClassName="text-center text-white text-opacity-50 font-normal py-2" + > + + + ) +} diff --git a/packages/synapse-interface/pages/returntomonke/index.tsx b/packages/synapse-interface/pages/returntomonke/index.tsx new file mode 100644 index 0000000000..9c94e236dc --- /dev/null +++ b/packages/synapse-interface/pages/returntomonke/index.tsx @@ -0,0 +1,52 @@ +import Grid from '@tw/Grid' +import { useEffect, useState } from 'react' +import { useAccount } from 'wagmi' + +import { DEFAULT_FROM_CHAIN } from '@/constants/swap' +import { LandingPageWrapper } from '@layouts/LandingPageWrapper' +import StandardPageContainer from '@layouts/StandardPageContainer' + +import PfpGeneratorCard from './PfpGeneratorCard' + +const ReturnToMonkePage = () => { + const { address: currentAddress, chain } = useAccount() + const [connectedChainId, setConnectedChainId] = useState(0) + const [address, setAddress] = useState(undefined) + + useEffect(() => { + setConnectedChainId(chain?.id ?? DEFAULT_FROM_CHAIN) + }, [chain]) + + useEffect(() => { + setAddress(currentAddress) + }, [currentAddress]) + return ( + + +
+
+
+ Generate Synaptic Profile Picture +
+
+
+
+ +
+ +
+
+
+
+
+ ) +} + +export default ReturnToMonkePage diff --git a/packages/synapse-interface/public/synpfpborder.png b/packages/synapse-interface/public/synpfpborder.png new file mode 100644 index 0000000000..e507b9a901 Binary files /dev/null and b/packages/synapse-interface/public/synpfpborder.png differ