MyCrypto/common/components/ElectronNav/LanguageSelect.tsx
William O'Beirne aa0f9cd455 Electron Redesign (#1505)
* Frameless Electron. Separate electron template. Generecize navigation link. Move nav info to config.

* Add controls for language and node, network status to sidebar.

* Sticky headers

* Move custom node modal into standalone component. Render modals via portal. Add custom node modal opening to electron node list.

* Conditional styling based on environment.

* Fix active node highlight

* Add frame back in, draggable only on OSX, fix sidebar scroll.

* Remove panel content after delay.

* Adjust window sizes

* Style desktop help nav icon

* Remove unused var

* Move style to param

* Remove unused

* Update snapshot

* Fix oversized stretching, zindex fighting

* Make electron work better with various screen sizes

* Remove not-working https option for electron

* Add beta banner

* Fix web footer

* Address changes
2018-04-16 18:30:58 -05:00

59 lines
1.4 KiB
TypeScript

import React from 'react';
import classnames from 'classnames';
import { connect } from 'react-redux';
import { languages } from 'config';
import { TChangeLanguage, changeLanguage } from 'actions/config';
import { getLanguageSelection } from 'selectors/config';
import { AppState } from 'reducers';
import './LanguageSelect.scss';
interface OwnProps {
closePanel(): void;
}
interface StateProps {
languageSelection: string;
}
interface DispatchProps {
changeLanguage: TChangeLanguage;
}
type Props = OwnProps & StateProps & DispatchProps;
class LanguageSelect extends React.Component<Props> {
public render() {
const { languageSelection } = this.props;
return (
<div className="LanguageSelect">
{Object.entries(languages).map(lang => (
<button
key={lang[0]}
className={classnames({
'LanguageSelect-language': true,
'is-selected': languageSelection === lang[0]
})}
onClick={() => this.handleLanguageSelect(lang[0])}
>
{lang[1]}
</button>
))}
</div>
);
}
private handleLanguageSelect = (lang: string) => {
this.props.changeLanguage(lang);
this.props.closePanel();
};
}
export default connect(
(state: AppState): StateProps => ({
languageSelection: getLanguageSelection(state)
}),
{
changeLanguage
}
)(LanguageSelect);