2019-02-22 15:21:55 +00:00
|
|
|
import React from "react";
|
|
|
|
import browser from "webextension-polyfill";
|
|
|
|
import openUrl from "src/common/openUrl";
|
2019-02-23 13:43:22 +00:00
|
|
|
import { paypalLink } from "src/common/personalUrls";
|
2019-02-22 15:21:55 +00:00
|
|
|
import HeartIcon from "../icons/heart.svg";
|
|
|
|
import SettingsIcon from "../icons/settings.svg";
|
2019-05-02 14:31:11 +00:00
|
|
|
import Toggle from "react-toggle";
|
|
|
|
import "react-toggle/style.css";
|
2019-02-22 15:21:55 +00:00
|
|
|
import "../styles/header.scss";
|
|
|
|
|
|
|
|
const openPayPal = () => {
|
2019-02-23 13:43:22 +00:00
|
|
|
openUrl(paypalLink);
|
2019-02-22 15:21:55 +00:00
|
|
|
};
|
|
|
|
const openSettings = () => {
|
|
|
|
const url = "../options/index.html#settings";
|
|
|
|
openUrl(url);
|
|
|
|
};
|
|
|
|
|
2019-05-02 14:31:11 +00:00
|
|
|
const getToggleButtonTitle = isEnabled => {
|
|
|
|
return isEnabled
|
|
|
|
? browser.i18n.getMessage("disableOnThisPage")
|
|
|
|
: browser.i18n.getMessage("enableOnThisPage");
|
|
|
|
};
|
|
|
|
|
|
|
|
export default props => (
|
2019-02-22 15:21:55 +00:00
|
|
|
<div id="header">
|
|
|
|
<div className="title">Simple Translate</div>
|
|
|
|
<div className="rightButtons">
|
2019-05-02 14:31:11 +00:00
|
|
|
<div className="toggleButton" title={getToggleButtonTitle(props.isEnabledOnPage)}>
|
|
|
|
<Toggle
|
|
|
|
checked={props.isEnabledOnPage}
|
|
|
|
onChange={props.toggleEnabledOnPage}
|
|
|
|
icons={false}
|
|
|
|
disabled={!props.isConnected}
|
|
|
|
/>
|
|
|
|
</div>
|
2019-02-22 15:21:55 +00:00
|
|
|
<button
|
|
|
|
className="heartButton"
|
|
|
|
onClick={openPayPal}
|
|
|
|
title={browser.i18n.getMessage("donateWithPaypalLabel")}
|
|
|
|
>
|
|
|
|
<HeartIcon />
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
className={"settingsButton"}
|
|
|
|
onClick={openSettings}
|
|
|
|
title={browser.i18n.getMessage("settingsLabel")}
|
|
|
|
>
|
|
|
|
<SettingsIcon />
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|