import React, { useRef, useLayoutEffect, useState } from 'react'; import { Copy, Check, Sprout, Leaf, Wind } from 'lucide-react'; import gsap from 'gsap'; import { ScrollTrigger } from 'gsap/ScrollTrigger'; gsap.registerPlugin(ScrollTrigger); interface TerminalBlockProps { code: string; language?: string; } export const TerminalBlock: React.FC = ({ code, language = 'bash' }) => { const [copied, setCopied] = useState(false); const containerRef = useRef(null); const copyBtnRef = useRef(null); const handleCopy = () => { navigator.clipboard.writeText(code); setCopied(true); // Organic "rustle" animation on click if (copyBtnRef.current) { gsap.to(copyBtnRef.current, { rotate: 15, scale: 1.1, duration: 0.1, yoyo: true, repeat: 1, ease: "sine.inOut" }); } setTimeout(() => setCopied(false), 2000); }; useLayoutEffect(() => { const ctx = gsap.context(() => { // Growth animation using a "spring-like" organic entry gsap.fromTo(containerRef.current, { opacity: 0, y: 40, scale: 0.95, skewX: -1 }, { opacity: 1, y: 0, scale: 1, skewX: 0, duration: 1, ease: "elastic.out(1, 0.75)", scrollTrigger: { trigger: containerRef.current, start: "top 92%", } } ); }, containerRef); return () => ctx.revert(); }, []); return (
{/* Texture Overlay from index.html */}
{/* Nature-inspired Gradient Mask */}
{/* Organic Header - "The Pebble" style */}
{/* Organic leaf-shaded dots */}
{language}
{/* Code Area */}
          
            {code.split('\n').map((line, i) => {
                const isComment = line.trim().startsWith('#');
                const isCommand = line.trim().startsWith('git');
                return (
                    
                        {/* Subtle line highlight */}
                        
{line} {'\n'} ); })}
{/* Decorative Organic Elements */}
{/* "Growing" accent line at bottom */}
); };