Spaces:
Paused
Paused
feat: complete HUBAPI overhaul (Security, i18n RTL, Dark/Light Mode, A11y & Performance fixes)
587459d Download components/FloatingCTA.tsx from samirhosninet/HubAPI: direct link, hf CLI and curl.
- Browser
- Download file 2.53 kB
-
https://huggingface.co/spaces/samirhosninet/HubAPI/resolve/main/components/FloatingCTA.tsx
- Command line
-
hf download hf://spaces/samirhosninet/HubAPI/components/FloatingCTA.tsx
-
curl -L -o FloatingCTA.tsx https://huggingface.co/spaces/samirhosninet/HubAPI/resolve/main/components/FloatingCTA.tsx
2.53 kB
| "use client"; | |
| import { useEffect, useState } from "react"; | |
| import { motion, AnimatePresence } from "framer-motion"; | |
| import { ArrowUpRight } from "lucide-react"; | |
| import { useLanguage } from "@/components/LanguageContext"; | |
| import { useSplitFlapAudio } from "@/components/ui/split-flap-text"; | |
| export function FloatingCTA() { | |
| const { t } = useLanguage(); | |
| const audio = useSplitFlapAudio(); | |
| const [isVisible, setIsVisible] = useState(false); | |
| useEffect(() => { | |
| const handleScroll = () => { | |
| // Show button when user scrolls down more than 600px | |
| if (window.scrollY > 600) { | |
| setIsVisible(true); | |
| } else { | |
| setIsVisible(false); | |
| } | |
| }; | |
| window.addEventListener("scroll", handleScroll, { passive: true }); | |
| return () => { | |
| window.removeEventListener("scroll", handleScroll); | |
| }; | |
| }, []); | |
| const handleClick = () => { | |
| // Play satisfying mechanical click sound | |
| if (audio && !audio.isMuted) { | |
| audio.playClick(); | |
| } | |
| // Smooth scroll back to top to the waitlist input | |
| const inputElement = document.getElementById("email-input"); | |
| if (inputElement) { | |
| inputElement.scrollIntoView({ behavior: "smooth", block: "center" }); | |
| setTimeout(() => { | |
| inputElement.focus(); | |
| }, 850); | |
| } else { | |
| window.scrollTo({ top: 0, behavior: "smooth" }); | |
| } | |
| }; | |
| return ( | |
| <AnimatePresence> | |
| {isVisible && ( | |
| <motion.button | |
| initial={{ opacity: 0, scale: 0.8, y: 20 }} | |
| animate={{ opacity: 1, scale: 1, y: 0 }} | |
| exit={{ opacity: 0, scale: 0.8, y: 20 }} | |
| whileHover={{ scale: 1.05 }} | |
| whileTap={{ scale: 0.95 }} | |
| onClick={handleClick} | |
| className="fixed bottom-6 right-6 sm:bottom-8 sm:right-8 z-40 flex items-center gap-2.5 px-5 h-12 rounded-full border border-primary/30 bg-primary/10 backdrop-blur-md text-primary font-mono text-[10px] font-bold tracking-widest shadow-[0_0_15px_var(--primary-glow)] hover:bg-primary/25 hover:border-primary/50 transition-all duration-300 focus-visible:outline-none" | |
| > | |
| <span className="relative flex h-2 w-2"> | |
| <span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-primary opacity-75"></span> | |
| <span className="relative inline-flex rounded-full h-2 w-2 bg-primary"></span> | |
| </span> | |
| <span>{t("accessHubapi")}</span> | |
| <ArrowUpRight className="h-3.5 w-3.5" /> | |
| </motion.button> | |
| )} | |
| </AnimatePresence> | |
| ); | |
| } | |