From 276854adc0c74dd27a6ac1c5a9c4daaa2845ae17 Mon Sep 17 00:00:00 2001 From: eshanized Date: Thu, 16 Jan 2025 06:42:25 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20feat:=20insert=20copy=20option?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/features/ToolCard.tsx | 29 ++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/components/features/ToolCard.tsx b/src/components/features/ToolCard.tsx index ae3aac82..c387c5ad 100644 --- a/src/components/features/ToolCard.tsx +++ b/src/components/features/ToolCard.tsx @@ -1,5 +1,6 @@ import { motion } from 'framer-motion'; -import { Terminal } from 'lucide-react'; +import { Terminal, Clipboard } from 'lucide-react'; +import { useState } from 'react'; interface ToolCardProps { name: string; @@ -9,6 +10,17 @@ interface ToolCardProps { } export function ToolCard({ name, description, category, command }: ToolCardProps) { + const [copied, setCopied] = useState(false); + + const handleCopyClick = () => { + navigator.clipboard.writeText(command) + .then(() => { + setCopied(true); + setTimeout(() => setCopied(false), 2000); // Reset copied status after 2 seconds + }) + .catch((error) => console.error('Failed to copy: ', error)); + }; + return ( {category} - {command} +
+ {command} + +
);