forked from OurHike/OurHike
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstallPrompt.tsx
More file actions
74 lines (68 loc) · 2.78 KB
/
Copy pathInstallPrompt.tsx
File metadata and controls
74 lines (68 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// "Put this on your home screen", shown on the Downloads screen.
//
// Downloads is the right place for it: it is where someone is already deciding
// to make the map work without signal, and installing is part of that same
// decision rather than a separate ask. It is also where onboarding sends
// people, so it is seen without being pushed.
//
// Nothing here interrupts. It renders inline above the download, and it
// disappears for good once the app is installed - consistent with the rest of
// the app's refusal to manufacture engagement (features/HIKER_SAFETY.md).
import type { InstallPlatform } from '../lib/useInstallPrompt'
import './downloads.css'
export interface InstallPromptProps {
platform: InstallPlatform
canPrompt: boolean
onInstall: () => void
}
export function InstallPrompt({ platform, canPrompt, onInstall }: InstallPromptProps) {
// Already installed, or a desktop browser where installing means little for
// a map meant to be carried.
if (platform === 'installed' || platform === 'other') return null
return (
<section className="install-prompt" aria-labelledby="install-prompt-title">
<h2 className="install-prompt__title" id="install-prompt-title">
Add OurHike to your home screen
</h2>
<p className="install-prompt__body">
Installed, it opens like any other app and the downloaded map stays put. A browser
tab can have its storage cleared without warning.
</p>
{platform === 'android' &&
(canPrompt ? (
<button type="button" className="downloads__primary" onClick={onInstall}>
Install OurHike
</button>
) : (
// The button is shown only once the browser confirms the page really
// qualifies. Until then these steps are the honest answer, rather
// than a button that might do nothing.
<ol className="install-prompt__steps">
<li>
Open Chrome’s <strong>⋮</strong> menu.
</li>
<li>
Tap <strong>Install app</strong>, or <strong>Add to Home screen</strong>.
</li>
</ol>
))}
{platform === 'ios' && (
<>
<ol className="install-prompt__steps">
<li>
Tap <strong>Share</strong> — the square with an arrow out of it.
</li>
<li>
Scroll down and tap <strong>Add to Home Screen</strong>.
</li>
</ol>
<p className="install-prompt__caveat" role="note">
On iPhone this has to be done in Safari; other browsers cannot install it. iOS
can also clear a web app’s storage when space runs short, so check the
map is still here before a trip.
</p>
</>
)}
</section>
)
}