|
1 | 1 | // app/components/Hero.tsx |
2 | 2 | "use client"; |
3 | 3 |
|
4 | | -import { FC } from "react"; |
| 4 | +import { FC, useState, useRef, useEffect } from "react"; |
5 | 5 | import Link from "next/link"; |
6 | 6 | import { Button } from "@/components/ui/button"; |
7 | 7 | import { motion } from "framer-motion"; |
| 8 | +import { FaApple, FaGooglePlay } from "react-icons/fa"; |
8 | 9 |
|
9 | | -export const Hero: FC = () => ( |
10 | | - <motion.section |
11 | | - className="min-h-screen bg-white flex flex-col items-center justify-center text-center px-6" |
12 | | - initial={{ opacity: 0 }} |
13 | | - animate={{ opacity: 1 }} // typo fixed here |
14 | | - transition={{ duration: 1, ease: "easeOut" }} |
15 | | - > |
16 | | - <motion.h1 |
17 | | - className="text-6xl font-extrabold text-gray-900 leading-tight max-w-3xl" |
18 | | - initial={{ opacity: 0, y: -30 }} |
19 | | - animate={{ opacity: 1, y: 0 }} |
20 | | - transition={{ duration: 1.2, ease: "easeOut" }} |
21 | | - > |
22 | | - Pure. Clean. Private. |
23 | | - </motion.h1> |
24 | | - |
25 | | - <motion.p |
26 | | - className="mt-4 text-2xl text-gray-700 max-w-2xl" |
27 | | - initial={{ opacity: 0, scale: 0.9 }} |
28 | | - animate={{ opacity: 1, scale: 1 }} |
29 | | - transition={{ duration: 1, ease: "easeOut", delay: 0.5 }} |
30 | | - > |
31 | | - Educational Books and Apps |
32 | | - </motion.p> |
33 | | - |
34 | | - <motion.p |
35 | | - className="mt-4 text-xl text-gray-600 max-w-2xl" |
36 | | - initial={{ opacity: 0, scale: 0.9 }} |
37 | | - animate={{ opacity: 1, scale: 1 }} |
38 | | - transition={{ duration: 1, ease: "easeOut", delay: 0.7 }} |
| 10 | +export const Hero: FC = () => { |
| 11 | + const [appsOpen, setAppsOpen] = useState(false); |
| 12 | + const chooserRef = useRef<HTMLDivElement>(null); |
| 13 | + |
| 14 | + // Close pop-up if clicking outside |
| 15 | + useEffect(() => { |
| 16 | + function onClick(e: MouseEvent) { |
| 17 | + if (chooserRef.current && !chooserRef.current.contains(e.target as Node)) { |
| 18 | + setAppsOpen(false); |
| 19 | + } |
| 20 | + } |
| 21 | + document.addEventListener("mousedown", onClick); |
| 22 | + return () => document.removeEventListener("mousedown", onClick); |
| 23 | + }, []); |
| 24 | + |
| 25 | + return ( |
| 26 | + <motion.section |
| 27 | + className="min-h-screen bg-white flex flex-col items-center justify-center text-center px-6" |
| 28 | + initial={{ opacity: 0 }} |
| 29 | + animate={{ opacity: 1 }} |
| 30 | + transition={{ duration: 1, ease: "easeOut" }} |
39 | 31 | > |
40 | | - No tracking. No ads. No wasted time. |
41 | | - </motion.p> |
42 | | - |
43 | | - <div className="mt-8 flex flex-wrap justify-center gap-4"> |
44 | | - {/* Primary CTA */} |
45 | | - <Button size="lg" asChild> |
46 | | - <Link href="https://shop.encorpora.io">Explore Books</Link> |
47 | | - </Button> |
48 | | - |
49 | | - {/* Secondary CTA */} |
50 | | - <Button variant="outline" size="lg" asChild> |
51 | | - <Link href="/apps">Expore Apps</Link> |
52 | | - </Button> |
53 | | - |
54 | | - </div> |
55 | | - </motion.section> |
56 | | -); |
| 32 | + <motion.h1 |
| 33 | + className="text-6xl font-extrabold text-gray-900 leading-tight max-w-3xl" |
| 34 | + initial={{ opacity: 0, y: -30 }} |
| 35 | + animate={{ opacity: 1, y: 0 }} |
| 36 | + transition={{ duration: 1.2, ease: "easeOut" }} |
| 37 | + > |
| 38 | + Pure. Clean. Private. |
| 39 | + </motion.h1> |
| 40 | + |
| 41 | + <motion.p |
| 42 | + className="mt-4 text-2xl text-gray-700 max-w-2xl" |
| 43 | + initial={{ opacity: 0, scale: 0.9 }} |
| 44 | + animate={{ opacity: 1, scale: 1 }} |
| 45 | + transition={{ duration: 1, ease: "easeOut", delay: 0.5 }} |
| 46 | + > |
| 47 | + Educational Books and Apps |
| 48 | + </motion.p> |
| 49 | + |
| 50 | + <motion.p |
| 51 | + className="mt-4 text-xl text-gray-600 max-w-2xl" |
| 52 | + initial={{ opacity: 0, scale: 0.9 }} |
| 53 | + animate={{ opacity: 1, scale: 1 }} |
| 54 | + transition={{ duration: 1, ease: "easeOut", delay: 0.7 }} |
| 55 | + > |
| 56 | + No tracking. No ads. No wasted time. |
| 57 | + </motion.p> |
| 58 | + |
| 59 | + <div className="mt-8 flex flex-wrap justify-center gap-4"> |
| 60 | + {/* Primary CTA */} |
| 61 | + <Button size="lg" asChild> |
| 62 | + <Link href="https://shop.encorpora.io">Explore Books</Link> |
| 63 | + </Button> |
| 64 | + |
| 65 | + {/* Apps chooser */} |
| 66 | + <div className="relative" ref={chooserRef}> |
| 67 | + <Button |
| 68 | + variant="outline" |
| 69 | + size="lg" |
| 70 | + onClick={() => setAppsOpen((o) => !o)} |
| 71 | + > |
| 72 | + Explore Apps |
| 73 | + </Button> |
| 74 | + |
| 75 | + {appsOpen && ( |
| 76 | + <motion.div |
| 77 | + className="absolute right-0 mt-2 w-48 bg-white rounded-lg shadow-lg ring-1 ring-gray-200 overflow-hidden z-10" |
| 78 | + initial={{ opacity: 0, y: -10 }} |
| 79 | + animate={{ opacity: 1, y: 0 }} |
| 80 | + transition={{ duration: 0.2 }} |
| 81 | + > |
| 82 | + <Link |
| 83 | + href="https://play.google.com/store/apps/developer?id=Corpora+Inc" |
| 84 | + target="_blank" |
| 85 | + rel="noopener noreferrer" |
| 86 | + className="flex items-center gap-2 px-4 py-3 hover:bg-gray-50" |
| 87 | + > |
| 88 | + <FaGooglePlay size={20} /> Google Play |
| 89 | + </Link> |
| 90 | + {/* TODO: get url for publisher |
| 91 | + curl https://itunes.apple.com/lookup\?id\=6744656859 */} |
| 92 | + <Link |
| 93 | + href="https://apps.apple.com/developer/corpora-inc/idYOUR_DEVELOPER_ID" |
| 94 | + target="_blank" |
| 95 | + rel="noopener noreferrer" |
| 96 | + className="flex items-center gap-2 px-4 py-3 hover:bg-gray-50" |
| 97 | + > |
| 98 | + <FaApple size={20} /> Coming Soon! |
| 99 | + </Link> |
| 100 | + </motion.div> |
| 101 | + )} |
| 102 | + </div> |
| 103 | + </div> |
| 104 | + </motion.section> |
| 105 | + ); |
| 106 | +}; |
0 commit comments