aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/pages/shared/version_drop_down.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/website/ts/pages/shared/version_drop_down.tsx')
-rw-r--r--packages/website/ts/pages/shared/version_drop_down.tsx46
1 files changed, 46 insertions, 0 deletions
diff --git a/packages/website/ts/pages/shared/version_drop_down.tsx b/packages/website/ts/pages/shared/version_drop_down.tsx
new file mode 100644
index 000000000..f29547c9c
--- /dev/null
+++ b/packages/website/ts/pages/shared/version_drop_down.tsx
@@ -0,0 +1,46 @@
+import * as _ from 'lodash';
+import * as React from 'react';
+import MenuItem from 'material-ui/MenuItem';
+import DropDownMenu from 'material-ui/DropDownMenu';
+import {constants} from 'ts/utils/constants';
+import {Docs} from 'ts/types';
+
+interface VersionDropDownProps {
+ selectedVersion: string;
+ versions: string[];
+ doc: Docs;
+}
+
+interface VersionDropDownState {}
+
+export class VersionDropDown extends React.Component<VersionDropDownProps, VersionDropDownState> {
+ public render() {
+ return (
+ <div className="mx-auto" style={{width: 120}}>
+ <DropDownMenu
+ maxHeight={300}
+ value={this.props.selectedVersion}
+ onChange={this.updateSelectedVersion.bind(this)}
+ >
+ {this.renderDropDownItems()}
+ </DropDownMenu>
+ </div>
+ );
+ }
+ private renderDropDownItems() {
+ const items = _.map(this.props.versions, version => {
+ return (
+ <MenuItem
+ key={version}
+ value={version}
+ primaryText={`v${version}`}
+ />
+ );
+ });
+ return items;
+ }
+ private updateSelectedVersion(e: any, index: number, value: string) {
+ const docPath = constants.docToPath[this.props.doc];
+ window.location.href = `${docPath}/${value}${window.location.hash}`;
+ }
+}