()
| 12 | const OUTLINE_BUTTON_CLASSES = "border-gray-300 hover:border-primary/60 bg-white/80 backdrop-blur-sm shadow-sm transition-smooth text-gray-900 dark:bg-transparent dark:text-foreground dark:border-primary/30 w-full sm:w-auto"; |
| 13 | |
| 14 | const HeroSection = () => { |
| 15 | const [stars, setStars] = useState<number | null>(null); |
| 16 | const [forks, setForks] = useState<number | null>(null); |
| 17 | const [version, setVersion] = useState(""); |
| 18 | const [copied, setCopied] = useState(false); |
| 19 | |
| 20 | useEffect(() => { |
| 21 | async function fetchVersion() { |
| 22 | try { |
| 23 | const res = await fetch( |
| 24 | "https://raw.githubusercontent.com/CodeGraphContext/CodeGraphContext/main/README.md" |
| 25 | ); |
| 26 | if (!res.ok) throw new Error("Failed to fetch README"); |
| 27 | |
| 28 | const text = await res.text(); |
| 29 | const match = text.match( |
| 30 | /\*\*Version:\*\*\s*([0-9]+\.[0-9]+\.[0-9]+)/i |
| 31 | ); |
| 32 | setVersion(match ? match[1] : "N/A"); |
| 33 | } catch (err) { |
| 34 | console.error(err); |
| 35 | setVersion("N/A"); |
| 36 | } |
| 37 | } |
| 38 | fetchVersion(); |
| 39 | }, []); |
| 40 | |
| 41 | useEffect(() => { |
| 42 | fetch("https://api.github.com/repos/CodeGraphContext/CodeGraphContext") |
| 43 | .then((response) => response.json()) |
| 44 | .then((data) => { |
| 45 | setStars(data.stargazers_count); |
| 46 | setForks(data.forks_count); |
| 47 | }) |
| 48 | .catch((error) => console.error("Error fetching GitHub stats:", error)); |
| 49 | }, []); |
| 50 | |
| 51 | const handleCopy = async () => { |
| 52 | try { |
| 53 | await navigator.clipboard.writeText("pip install codegraphcontext"); |
| 54 | setCopied(true); |
| 55 | toast.success("Copied to clipboard!"); |
| 56 | setTimeout(() => setCopied(false), 2000); |
| 57 | } catch (err) { |
| 58 | toast.error("Failed to copy"); |
| 59 | } |
| 60 | }; |
| 61 | |
| 62 | return ( |
| 63 | <section className="relative min-h-screen flex items-center justify-center overflow-hidden"> |
| 64 | <motion.div |
| 65 | key="hero" |
| 66 | exit={{ opacity: 0, scale: 0.95 }} |
| 67 | transition={{ duration: 0.4 }} |
| 68 | className="absolute inset-0 w-full h-full" |
| 69 | > |
| 70 | {/* Header with Theme Toggle */} |
| 71 | <div className="absolute top-0 left-0 right-0 z-20 p-4" data-aos="fade-down"> |
nothing calls this directly
no test coverage detected