feat(pwa): implement PWA installation banner and context provider
- Add `generate-icons.ts` script to generate PWA icons from SVG. - Create `InstallBanner` component for prompting users to install the app. - Implement `PwaProvider` to manage PWA installation state and events. - Export `PwaProvider` and `InstallBanner` from the PWA feature index.
This commit is contained in:
50
apps/web/src/features/pwa/InstallBanner.tsx
Normal file
50
apps/web/src/features/pwa/InstallBanner.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
import { Download, X } from 'lucide-react'
|
||||
import { Button } from '../../components/ui'
|
||||
import { cn } from '../../lib/utils'
|
||||
|
||||
type InstallBannerProps = {
|
||||
visible: boolean
|
||||
onInstall: () => void
|
||||
onDismiss: () => void
|
||||
}
|
||||
|
||||
export function InstallBanner({ visible, onInstall, onDismiss }: InstallBannerProps) {
|
||||
if (!visible) return null
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
'fixed inset-x-0 z-30 px-4 lg:left-auto lg:right-6 lg:w-96 lg:px-0',
|
||||
// Encima de BottomNav en móvil; abajo a la derecha en desktop.
|
||||
'bottom-[calc(4.5rem+env(safe-area-inset-bottom))] lg:bottom-6',
|
||||
)}
|
||||
>
|
||||
<div className="flex items-start gap-3 rounded-xl border border-border bg-surface p-4 shadow-lg">
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-sm font-semibold text-primary">Instalá Gruperly</p>
|
||||
<p className="mt-0.5 text-xs leading-relaxed text-foreground/70">
|
||||
Abrila directo desde tu pantalla de inicio, sin barra de navegador.
|
||||
</p>
|
||||
<div className="mt-3 flex items-center gap-2">
|
||||
<Button variant="primary" size="sm" onClick={onInstall}>
|
||||
<Download className="size-4" strokeWidth={2} />
|
||||
Instalar app
|
||||
</Button>
|
||||
<Button variant="ghost" size="sm" onClick={onDismiss}>
|
||||
Ahora no
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={onDismiss}
|
||||
aria-label="Cerrar aviso de instalación"
|
||||
className="shrink-0 rounded-lg p-1 text-foreground/40 transition-colors hover:bg-primary-soft hover:text-foreground"
|
||||
>
|
||||
<X className="size-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user