-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstallButton.js
50 lines (47 loc) · 1.45 KB
/
installButton.js
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
import Button from "./button";
import Bowser from "bowser";
export default function Install({ children, compact }) {
const supported = {
chrome: {
eventName: 'install: chrome',
text: "Install for Google Chrome",
url:
"https://chrome.google.com/webstore/detail/octo-linker/jlmafbaeoofdegohdhinkhilhclaklkp"
},
firefox: {
eventName: 'install: firefox',
text: "Install for Mozilla Firefox",
url: "https://addons.mozilla.org/en-US/firefox/addon/octolinker/"
},
opera: {
eventName: 'install: opera',
text: "Install for Opera",
url: "https://addons.opera.com/en/extensions/details/octolinker/"
},
'microsoft edge': {
eventName: 'install: edge',
text: "Install for Microsoft Edge",
url: "https://microsoftedge.microsoft.com/addons/detail/lbbanfffjfmfdahnfbklminikafhcjjb"
},
'safari': {
eventName: 'install: safari',
text: "Install for Safari",
url: "https://apps.apple.com/app/octolinker/id1549308269"
}
};
const browser = Bowser.getParser(window.navigator.userAgent);
const details = supported[browser.getBrowser().name.toLowerCase()] || supported.chrome;
const buttonUrl = details.url;
const buttonLabel = compact ? "Install" : details.text;
return (
<Button
compact={compact}
href={buttonUrl}
onClick={function() {
window.plausible(details.eventName)
}}
>
{buttonLabel}
</Button>
);
}