From 13fed15e0c4a643bb5a80737901c3d85be39e6ee Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 20 Feb 2018 19:53:07 -0800 Subject: Improve homepage and add translations in chinese, russian, korean and spanish --- packages/website/ts/components/footer.tsx | 56 ++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 9 deletions(-) (limited to 'packages/website/ts/components/footer.tsx') diff --git a/packages/website/ts/components/footer.tsx b/packages/website/ts/components/footer.tsx index a5bddc874..d7ebc4ede 100644 --- a/packages/website/ts/components/footer.tsx +++ b/packages/website/ts/components/footer.tsx @@ -1,7 +1,9 @@ import * as _ from 'lodash'; +import DropDownMenu from 'material-ui/DropDownMenu'; +import MenuItem from 'material-ui/MenuItem'; import * as React from 'react'; import { Link } from 'react-router-dom'; -import { Deco, Key, WebsitePaths } from 'ts/types'; +import { Deco, Key, Language, WebsitePaths } from 'ts/types'; import { colors } from 'ts/utils/colors'; import { constants } from 'ts/utils/constants'; import { Translate } from 'ts/utils/translate'; @@ -23,24 +25,33 @@ const linkStyle = { cursor: 'pointer', }; -const titleToIcon: { [title: string]: string } = { - 'Rocket.chat': 'rocketchat.png', - Blog: 'medium.png', - Twitter: 'twitter.png', - Reddit: 'reddit.png', - Forum: 'discourse.png', +const languageToMenuTitle = { + [Language.English]: 'English', + [Language.Russian]: 'Русский', + [Language.Spanish]: 'Español', + [Language.Korean]: '한국어', + [Language.Chinese]: '中文', }; export interface FooterProps { translate?: Translate; + onLanguageSelected?: (language: Language) => void; } -interface FooterState {} +interface FooterState { + selectedLanguage: Language; +} export class Footer extends React.Component { public static defaultProps: Partial = { translate: new Translate(), }; + constructor(props: FooterProps) { + super(); + this.state = { + selectedLanguage: props.translate.getLanguage(), + }; + } public render() { const menuItemsBySection: MenuItemsBySection = { [Key.Documentation]: [ @@ -66,7 +77,7 @@ export class Footer extends React.Component { path: WebsitePaths.Wiki, }, { - title: this.props.translate.get(Key.FAQ, Deco.Cap), + title: this.props.translate.get(Key.Faq, Deco.Cap), path: WebsitePaths.FAQ, }, ], @@ -115,6 +126,9 @@ export class Footer extends React.Component { }, ], }; + const languageMenuItems = _.map(languageToMenuTitle, (menuTitle: string, language: Language) => { + return ; + }); return (
@@ -133,6 +147,15 @@ export class Footer extends React.Component { > © ZeroEx, Intl.
+
+ + {languageMenuItems} + +
@@ -167,6 +190,13 @@ export class Footer extends React.Component { ); } private _renderMenuItem(item: FooterMenuItem) { + const titleToIcon: { [title: string]: string } = { + 'Rocket.chat': 'rocketchat.png', + [this.props.translate.get(Key.Blog, Deco.Cap)]: 'medium.png', + Twitter: 'twitter.png', + Reddit: 'reddit.png', + [this.props.translate.get(Key.Forum, Deco.Cap)]: 'discourse.png', + }; const iconIfExists = titleToIcon[item.title]; return (
@@ -209,4 +239,12 @@ export class Footer extends React.Component {
); } + private _updateLanguage(e: any, index: number, value: Language) { + this.setState({ + selectedLanguage: value, + }); + if (!_.isUndefined(this.props.onLanguageSelected)) { + this.props.onLanguageSelected(value); + } + } } -- cgit