From d029ff81e6711201a63a9402076a819e189bbcdf Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Thu, 24 Jul 2025 11:03:39 -0400 Subject: update copy to clip button visual feedback --- src/components/SmartClipboardButton.tsx | 44 ++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/components/SmartClipboardButton.tsx b/src/components/SmartClipboardButton.tsx index 098b53d..7be3b2f 100644 --- a/src/components/SmartClipboardButton.tsx +++ b/src/components/SmartClipboardButton.tsx @@ -1,12 +1,24 @@ -import { useState } from "react"; +import { useState, useEffect } from "react"; import { PanelSectionRow, ButtonItem } from "@decky/ui"; -import { FaClipboard } from "react-icons/fa"; +import { FaClipboard, FaCheck } from "react-icons/fa"; import { getLaunchOption } from "../api/lsfgApi"; -import { showClipboardSuccessToast, showClipboardErrorToast, showSuccessToast } from "../utils/toastUtils"; +import { showClipboardErrorToast } from "../utils/toastUtils"; import { copyWithVerification } from "../utils/clipboardUtils"; export function SmartClipboardButton() { const [isLoading, setIsLoading] = useState(false); + const [showSuccess, setShowSuccess] = useState(false); + + // Reset success state after 3 seconds + useEffect(() => { + if (showSuccess) { + const timer = setTimeout(() => { + setShowSuccess(false); + }, 3000); + return () => clearTimeout(timer); + } + return undefined; + }, [showSuccess]); const getLaunchOptionText = async (): Promise => { try { @@ -18,7 +30,7 @@ export function SmartClipboardButton() { }; const copyToClipboard = async () => { - if (isLoading) return; + if (isLoading || showSuccess) return; setIsLoading(true); try { @@ -26,10 +38,11 @@ export function SmartClipboardButton() { const { success, verified } = await copyWithVerification(text); if (success) { - if (verified) { - showClipboardSuccessToast(); - } else { - showSuccessToast("Copied to Clipboard!", "Launch option copied (verification unavailable)"); + // Show success feedback in the button instead of toast + setShowSuccess(true); + if (!verified) { + // Copy worked but verification failed - still show success + console.log('Copy verification failed but copy likely worked'); } } else { showClipboardErrorToast(); @@ -47,10 +60,14 @@ export function SmartClipboardButton() {
- {isLoading ? ( + {showSuccess ? ( + + ) : isLoading ? ( )} -
{isLoading ? "Copying..." : "Copy Launch Option"}
+
+ {showSuccess ? "Copied to clipboard" : isLoading ? "Copying..." : "Copy Launch Option"} +