simple-translate/src/popup/components/Header.js

54 lines
1.5 KiB
JavaScript
Raw Normal View History

2019-02-22 15:21:55 +00:00
import React from "react";
import browser from "webextension-polyfill";
import openUrl from "src/common/openUrl";
2019-10-20 10:24:40 +00:00
import { patreonLink } from "src/common/personalUrls";
2019-02-22 15:21:55 +00:00
import HeartIcon from "../icons/heart.svg";
import SettingsIcon from "../icons/settings.svg";
import Toggle from "react-toggle";
import "react-toggle/style.css";
2019-02-22 15:21:55 +00:00
import "../styles/header.scss";
2019-10-20 10:24:40 +00:00
const openPatreon = () => {
openUrl(patreonLink);
2019-02-22 15:21:55 +00:00
};
const openSettings = () => {
const url = "../options/index.html#settings";
openUrl(url);
};
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">
<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"
2019-10-20 10:24:40 +00:00
onClick={openPatreon}
title={browser.i18n.getMessage("donateLabel")}
2019-02-22 15:21:55 +00:00
>
<HeartIcon />
</button>
<button
className={"settingsButton"}
onClick={openSettings}
title={browser.i18n.getMessage("settingsLabel")}
>
<SettingsIcon />
</button>
</div>
</div>
);