deploy / deploy (push) Successful in 1m2s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
92 lines
3.2 KiB
TypeScript
92 lines
3.2 KiB
TypeScript
import { Menu, MonitorDown, Plus, Share, SquarePlus, X } from 'lucide-react'
|
|
import { useState, type ReactNode } from 'react'
|
|
import { t, type TKey } from '../i18n'
|
|
import { installPlatform, type InstallPlatform } from '../lib/install'
|
|
|
|
/**
|
|
* Installer Bobinoo sur un appareil Apple : iOS n'a pas de bouton d'installation (menu Partager du navigateur),
|
|
* Safari sur Mac passe par Fichier → Ajouter au Dock, Chrome et Edge par l'icône de la barre d'adresse.
|
|
*/
|
|
const STEPS: Record<InstallPlatform, { icon: ReactNode; key: TKey }[]> = {
|
|
ios: [
|
|
{ icon: <Share size={16} />, key: 'install.step1' },
|
|
{ icon: <SquarePlus size={16} />, key: 'install.step2' },
|
|
{ icon: <Plus size={16} />, key: 'install.step3' },
|
|
],
|
|
'mac-safari': [
|
|
{ icon: <Menu size={16} />, key: 'install.macSafari1' },
|
|
{ icon: <SquarePlus size={16} />, key: 'install.macSafari2' },
|
|
{ icon: <Plus size={16} />, key: 'install.macSafari3' },
|
|
],
|
|
'mac-chrome': [
|
|
{ icon: <MonitorDown size={16} />, key: 'install.macChrome1' },
|
|
{ icon: <Plus size={16} />, key: 'install.macChrome2' },
|
|
],
|
|
}
|
|
|
|
/** Phrase d'introduction : écran d'accueil (iPhone, iPad) ou Dock (Mac). */
|
|
export const installHint = (platform: InstallPlatform) => t(platform === 'ios' ? 'install.hint' : 'install.hintMac')
|
|
|
|
export function InstallSteps({ platform }: { platform: InstallPlatform }) {
|
|
return (
|
|
<ol className="space-y-3">
|
|
{STEPS[platform].map((s) => (
|
|
<li key={s.key} className="flex items-start gap-3 text-sm leading-relaxed text-ink-2">
|
|
<span className="grid size-7 shrink-0 place-items-center rounded-full border border-line-strong text-ink" aria-hidden>
|
|
{s.icon}
|
|
</span>
|
|
<span className="pt-0.5">{t(s.key)}</span>
|
|
</li>
|
|
))}
|
|
</ol>
|
|
)
|
|
}
|
|
|
|
const HIDDEN_KEY = 'azuucine:install-hint'
|
|
|
|
/** Carte de l'accueil, sur un appareil Apple seulement, masquable pour de bon. */
|
|
export function InstallHint() {
|
|
const [platform] = useState(installPlatform)
|
|
const [hidden, setHidden] = useState(() => {
|
|
try {
|
|
return localStorage.getItem(HIDDEN_KEY) === '1'
|
|
} catch {
|
|
return false
|
|
}
|
|
})
|
|
const [open, setOpen] = useState(false)
|
|
if (!platform || hidden) return null
|
|
|
|
const hide = () => {
|
|
setHidden(true)
|
|
try {
|
|
localStorage.setItem(HIDDEN_KEY, '1')
|
|
} catch {
|
|
/* stockage bloqué : la carte reviendra à la prochaine visite */
|
|
}
|
|
}
|
|
|
|
return (
|
|
<section className="card mb-6 p-4" aria-label={t('install.title')}>
|
|
<div className="flex items-start gap-3">
|
|
<div className="min-w-0 flex-1">
|
|
<h2 className="font-semibold">{t('install.title')}</h2>
|
|
<p className="mt-1 text-sm text-ink-2">{installHint(platform)}</p>
|
|
</div>
|
|
<button type="button" onClick={hide} aria-label={t('netPill.hide')} className="-me-1.5 -mt-1.5 grid size-8 shrink-0 place-items-center rounded-full text-ink-3 active:bg-surface-2">
|
|
<X size={16} />
|
|
</button>
|
|
</div>
|
|
{open ? (
|
|
<div className="mt-4">
|
|
<InstallSteps platform={platform} />
|
|
</div>
|
|
) : (
|
|
<button type="button" onClick={() => setOpen(true)} className="btn btn-ghost mt-3 px-3 py-2 text-sm">
|
|
{t('install.how')}
|
|
</button>
|
|
)}
|
|
</section>
|
|
)
|
|
}
|