11import { motion } from 'framer-motion' ;
2- import { Terminal } from 'lucide-react' ;
2+ import { Terminal , Clipboard } from 'lucide-react' ;
3+ import { useState } from 'react' ;
34
45interface ToolCardProps {
56 name : string ;
@@ -9,6 +10,17 @@ interface ToolCardProps {
910}
1011
1112export function ToolCard ( { name, description, category, command } : ToolCardProps ) {
13+ const [ copied , setCopied ] = useState ( false ) ;
14+
15+ const handleCopyClick = ( ) => {
16+ navigator . clipboard . writeText ( command )
17+ . then ( ( ) => {
18+ setCopied ( true ) ;
19+ setTimeout ( ( ) => setCopied ( false ) , 2000 ) ; // Reset copied status after 2 seconds
20+ } )
21+ . catch ( ( error ) => console . error ( 'Failed to copy: ' , error ) ) ;
22+ } ;
23+
1224 return (
1325 < motion . div
1426 initial = { { opacity : 0 , y : 20 } }
@@ -28,7 +40,20 @@ export function ToolCard({ name, description, category, command }: ToolCardProps
2840
2941 < div className = "flex items-center justify-between mt-4" >
3042 < span className = "text-sm font-medium text-cornflower-blue" > { category } </ span >
31- < code className = "text-sm bg-gray-100 px-3 py-1 rounded text-gray-800" > { command } </ code >
43+ < div className = "flex items-center gap-2" >
44+ < code className = "text-sm bg-gray-100 px-3 py-1 rounded text-gray-800" > { command } </ code >
45+ < button
46+ onClick = { handleCopyClick }
47+ className = "p-2 bg-cornflower-blue/20 rounded-full hover:bg-cornflower-blue/30 transition-all"
48+ aria-label = "Copy command"
49+ >
50+ { copied ? (
51+ < span className = "text-sm text-cornflower-blue" > Copied!</ span >
52+ ) : (
53+ < Clipboard className = "h-5 w-5 text-cornflower-blue" />
54+ ) }
55+ </ button >
56+ </ div >
3257 </ div >
3358 </ motion . div >
3459 ) ;
0 commit comments