From b8eee29da920d627ff7a78dad5aafafdde0cae23 Mon Sep 17 00:00:00 2001 From: PikiLee <871565198@qq.com> Date: Sat, 17 Aug 2024 14:06:47 +0800 Subject: [PATCH] feat: Add copy URL functionality to GraphGenerator component --- components/GraphGenerator.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/components/GraphGenerator.tsx b/components/GraphGenerator.tsx index 1871853..94c3c0e 100644 --- a/components/GraphGenerator.tsx +++ b/components/GraphGenerator.tsx @@ -4,9 +4,11 @@ import { useForm } from 'react-hook-form' import { Image, Tooltip } from '@nextui-org/react' import { LuImagePlus } from 'react-icons/lu' import { useEffect, useState } from 'react' +import { IoCopyOutline } from 'react-icons/io5' import AppCheckBox from './AppCheckBox' import GraphColorSelector from './GraphColorSelector' import AppButton from './AppButton' +import { toast } from './ui/use-toast' import type { Tone } from '~/utils/colors' interface Form { @@ -39,10 +41,12 @@ export default function GraphGenerator() { setImageURL(url.toString()) } - useEffect(() => { - const url = new URL(`/v2/username/PikiLee`, window.location.origin) - setImageURL(url.toString()) - }, []) + function copyURL() { + navigator.clipboard.writeText(imageURL) + toast({ + title: 'The URL has been copied to your clipboard.', + }) + } return (
@@ -77,6 +81,11 @@ export default function GraphGenerator() { + {imageURL && ( + + + + )}