Spaces:
Running
Running
Download src/components/InstallAppPrompt.tsx from ahmdelbaz28/AHMDRTAP: direct link, hf CLI and curl.
- Browser
- Download file 4.22 kB
-
https://huggingface.co/spaces/ahmdelbaz28/AHMDRTAP/resolve/main/src/components/InstallAppPrompt.tsx
- Command line
-
hf download hf://spaces/ahmdelbaz28/AHMDRTAP/src/components/InstallAppPrompt.tsx
-
curl -L -o InstallAppPrompt.tsx https://huggingface.co/spaces/ahmdelbaz28/AHMDRTAP/resolve/main/src/components/InstallAppPrompt.tsx
4.22 kB
| import { Download, MonitorSmartphone, Share, X } from "lucide-react"; | |
| import { useInstallPrompt } from "@/hooks/useInstallPrompt"; | |
| import { useTranslation } from "@/hooks/useTranslation"; | |
| /** | |
| * Post-login PWA install suggestion. | |
| * | |
| * Owner requirement: after any user signs in, offer installing the platform | |
| * as an app — faster access + notifications that actually arrive. Two flavors: | |
| * - native: fires the browser's real install dialog (Chrome/Edge/Samsung, | |
| * Android + desktop); | |
| * - iOS Safari: step-by-step "Share → Add to Home Screen" card (no native | |
| * event exists there). | |
| * | |
| * The show/hide policy lives in src/lib/pwa-install.ts (pure, unit-tested); | |
| * this component is presentation only. Placement stays clear of the ChatBot | |
| * FAB (bottom-right) and the mobile bottom nav. | |
| */ | |
| export default function InstallAppPrompt() { | |
| const { lang } = useTranslation(); | |
| const { visible, flavor, promptInstall, dismiss } = useInstallPrompt(); | |
| if (!visible) return null; | |
| const title = lang === "ar" ? "ثبّت المنصة على جهازك" : "Install the platform on your device"; | |
| const body = lang === "ar" | |
| ? "وصول أسرع بضغطة واحدة، وإشعارات الكورسات توصلك فوراً حتى وأنت خارج الموقع." | |
| : "One-tap faster access, and course notifications reach you instantly — even outside the site."; | |
| const installLabel = lang === "ar" ? "تثبيت الآن" : "Install now"; | |
| const laterLabel = lang === "ar" ? "ليس الآن" : "Not now"; | |
| const closeLabel = lang === "ar" ? "إغلاق" : "Close"; | |
| return ( | |
| <div | |
| role="dialog" | |
| aria-label={title} | |
| className="fixed inset-x-4 bottom-20 z-40 sm:inset-x-auto sm:bottom-6 sm:left-6 sm:w-[360px] animate-in fade-in slide-in-from-bottom-3 duration-300" | |
| > | |
| <div className="relative rounded-2xl border border-accent/25 bg-card/95 p-4 shadow-[0_20px_60px_rgba(0,0,0,0.45)] backdrop-blur-md"> | |
| <button | |
| type="button" | |
| onClick={dismiss} | |
| aria-label={closeLabel} | |
| className="absolute left-3 top-3 rounded-lg p-1.5 text-text-muted transition-colors hover:bg-primary hover:text-foreground" | |
| > | |
| <X className="h-4 w-4" /> | |
| </button> | |
| <div className="flex items-start gap-3 pl-8"> | |
| <div className="mt-0.5 flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-accent/15 text-accent"> | |
| <MonitorSmartphone className="h-5 w-5" /> | |
| </div> | |
| <div className="min-w-0"> | |
| <p className="text-[14px] font-bold leading-snug text-foreground">{title}</p> | |
| <p className="mt-1 text-[12.5px] leading-relaxed text-text-secondary">{body}</p> | |
| </div> | |
| </div> | |
| {flavor === "ios" ? ( | |
| <div className="mt-3 flex items-center gap-2 rounded-xl border border-border bg-primary px-3 py-2.5 text-[12.5px] text-text-secondary"> | |
| <Share className="h-4 w-4 shrink-0 text-accent" /> | |
| <span> | |
| {lang === "ar" | |
| ? "من Safari: اضغط أيقونة المشاركة ثم «إضافة إلى الشاشة الرئيسية»." | |
| : "In Safari: tap the Share icon, then \"Add to Home Screen\"."} | |
| </span> | |
| </div> | |
| ) : ( | |
| <div className="mt-3 flex items-center gap-2"> | |
| <button | |
| type="button" | |
| onClick={() => { void promptInstall(); }} | |
| className="flex flex-1 items-center justify-center gap-2 rounded-xl bg-accent px-4 py-2.5 text-[13px] font-bold text-[#0a0e17] transition-all hover:brightness-110 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent" | |
| > | |
| <Download className="h-4 w-4" /> | |
| {installLabel} | |
| </button> | |
| <button | |
| type="button" | |
| onClick={dismiss} | |
| className="rounded-xl border border-border px-4 py-2.5 text-[13px] font-medium text-text-secondary transition-colors hover:bg-primary hover:text-foreground" | |
| > | |
| {laterLabel} | |
| </button> | |
| </div> | |
| )} | |
| </div> | |
| </div> | |
| ); | |
| } | |