2019-09-11 01:53:01 +02:00
|
|
|
const React = require('react');
|
2020-10-09 19:35:46 +02:00
|
|
|
const bridge = require('electron').remote.require('./bridge').default;
|
2019-09-11 01:53:01 +02:00
|
|
|
const styleSelector = require('./style/ExtensionBadge');
|
2020-11-07 17:59:37 +02:00
|
|
|
const { _ } = require('@joplin/lib/locale');
|
2019-09-11 01:53:01 +02:00
|
|
|
|
|
|
|
function platformAssets(type) {
|
|
|
|
if (type === 'firefox') {
|
|
|
|
return {
|
2019-09-19 23:51:18 +02:00
|
|
|
logoImage: `${bridge().buildDir()}/images/firefox-logo.svg`,
|
2019-09-11 01:53:01 +02:00
|
|
|
locationLabel: _('Firefox Extension'),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type === 'chrome') {
|
|
|
|
return {
|
2019-09-19 23:51:18 +02:00
|
|
|
logoImage: `${bridge().buildDir()}/images/chrome-logo.svg`,
|
2019-09-11 01:53:01 +02:00
|
|
|
locationLabel: _('Chrome Web Store'),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-09-19 23:51:18 +02:00
|
|
|
throw new Error(`Invalid type:${type}`);
|
2019-09-11 01:53:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function ExtensionBadge(props) {
|
|
|
|
const style = styleSelector(null, props);
|
|
|
|
const assets = platformAssets(props.type);
|
|
|
|
|
|
|
|
const onClick = () => {
|
|
|
|
bridge().openExternal(props.url);
|
|
|
|
};
|
|
|
|
|
|
|
|
const rootStyle = props.style ? Object.assign({}, style.root, props.style) : style.root;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<a style={rootStyle} onClick={onClick} href="#">
|
|
|
|
<img style={style.logo} src={assets.logoImage}/>
|
|
|
|
<div style={style.labelGroup} >
|
|
|
|
<div>{_('Get it now:')}</div>
|
|
|
|
<div style={style.locationLabel}>{assets.locationLabel}</div>
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = ExtensionBadge;
|