MyCrypto/common/components/Header/index.jsx

119 lines
3.6 KiB
React
Raw Normal View History

2017-05-23 23:06:01 +00:00
// @flow
import React, { Component } from 'react';
import Navigation from './components/Navigation';
import GasPriceDropdown from './components/GasPriceDropdown';
2017-05-23 23:06:01 +00:00
import { Link } from 'react-router';
2017-06-26 22:27:55 +00:00
import { Dropdown } from 'components/ui';
import {
languages,
NODES,
VERSION,
ANNOUNCEMENT_TYPE,
ANNOUNCEMENT_MESSAGE
} from '../../config/data';
import logo from 'assets/images/logo-myetherwallet.svg';
2017-04-12 05:04:27 +00:00
import './index.scss';
2017-04-12 05:04:27 +00:00
export default class Header extends Component {
2017-07-04 03:21:19 +00:00
props: {
location: {},
2017-07-04 03:21:19 +00:00
languageSelection: string,
nodeSelection: string,
gasPriceGwei: number,
2017-06-18 19:56:12 +00:00
2017-07-04 03:21:19 +00:00
changeLanguage: (sign: string) => any,
changeNode: (key: string) => any,
changeGasPrice: (price: number) => any
2017-07-02 05:49:06 +00:00
};
2017-04-12 05:04:27 +00:00
2017-07-02 05:49:06 +00:00
render() {
2017-07-04 03:21:19 +00:00
const { languageSelection, changeNode, nodeSelection } = this.props;
const selectedLanguage =
languages.find(l => l.sign === languageSelection) || languages[0];
const selectedNode = NODES[nodeSelection];
2017-07-02 05:49:06 +00:00
return (
<div className="Header">
{ANNOUNCEMENT_MESSAGE &&
<div
className={`Header-announcement is-${ANNOUNCEMENT_TYPE}`}
dangerouslySetInnerHTML={{
__html: ANNOUNCEMENT_MESSAGE
}}
/>}
<section className="Header-branding">
<section className="Header-branding-inner container">
<Link
to={'/'}
className="Header-branding-title"
aria-label="Go to homepage"
>
{/* TODO - don't hardcode image path*/}
<img
className="Header-branding-title-logo"
src={logo}
height="64px"
width="245px"
alt="MyEtherWallet"
/>
2017-07-02 05:49:06 +00:00
</Link>
<div className="Header-branding-title-tagline">
<span className="Header-branding-title-tagline-version">
Open-Source & Client-Side Ether Wallet · v{VERSION}
2017-07-02 05:49:06 +00:00
</span>
<GasPriceDropdown
value={this.props.gasPriceGwei}
onChange={this.props.changeGasPrice}
/>
2017-07-02 05:49:06 +00:00
<Dropdown
2017-07-04 03:21:19 +00:00
ariaLabel={`change language. current language ${selectedLanguage.name}`}
2017-07-02 05:49:06 +00:00
options={languages}
formatTitle={o => o.name}
2017-07-04 03:21:19 +00:00
value={selectedLanguage}
2017-07-02 05:49:06 +00:00
extra={[
<li key={'separator'} role="separator" className="divider" />,
<li key={'disclaimer'}>
<a data-toggle="modal" data-target="#disclaimerModal">
Disclaimer
</a>
</li>
]}
2017-07-04 03:21:19 +00:00
onChange={this.changeLanguage}
2017-07-02 05:49:06 +00:00
/>
2017-07-02 05:49:06 +00:00
<Dropdown
2017-07-04 03:21:19 +00:00
ariaLabel={`change node. current node ${selectedNode.network} node by ${selectedNode.service}`}
options={Object.keys(NODES)}
2017-07-02 05:49:06 +00:00
formatTitle={o => [
2017-07-04 03:21:19 +00:00
NODES[o].network,
2017-07-02 05:49:06 +00:00
' ',
2017-07-04 03:21:19 +00:00
<small key="service">
({NODES[o].service})
</small>
2017-07-02 05:49:06 +00:00
]}
value={nodeSelection}
extra={
<li>
2017-07-04 03:21:19 +00:00
<a onClick={() => {}}>Add Custom Node</a>
2017-07-02 05:49:06 +00:00
</li>
}
onChange={changeNode}
/>
</div>
</section>
</section>
2017-04-18 23:36:29 +00:00
<Navigation location={this.props.location} />
2017-07-02 05:49:06 +00:00
</div>
);
}
2017-07-04 01:25:01 +00:00
2017-07-04 03:21:19 +00:00
changeLanguage = (value: { sign: string }) => {
this.props.changeLanguage(value.sign);
};
2017-04-12 05:04:27 +00:00
}