aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/pages/wiki/wiki.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/website/ts/pages/wiki/wiki.tsx')
-rw-r--r--packages/website/ts/pages/wiki/wiki.tsx33
1 files changed, 24 insertions, 9 deletions
diff --git a/packages/website/ts/pages/wiki/wiki.tsx b/packages/website/ts/pages/wiki/wiki.tsx
index 4bb6052a2..f6cff51e4 100644
--- a/packages/website/ts/pages/wiki/wiki.tsx
+++ b/packages/website/ts/pages/wiki/wiki.tsx
@@ -1,16 +1,23 @@
+import {
+ colors,
+ constants as sharedConstants,
+ HeaderSizes,
+ MarkdownSection,
+ NestedSidebarMenu,
+ SectionHeader,
+ Styles,
+ utils as sharedUtils,
+} from '@0xproject/react-shared';
import * as _ from 'lodash';
import CircularProgress from 'material-ui/CircularProgress';
import RaisedButton from 'material-ui/RaisedButton';
import * as React from 'react';
import DocumentTitle = require('react-document-title');
import { scroller } from 'react-scroll';
+import { SidebarHeader } from 'ts/components/sidebar_header';
import { TopBar } from 'ts/components/top_bar/top_bar';
-import { MarkdownSection } from 'ts/pages/shared/markdown_section';
-import { NestedSidebarMenu } from 'ts/pages/shared/nested_sidebar_menu';
-import { SectionHeader } from 'ts/pages/shared/section_header';
import { Dispatcher } from 'ts/redux/dispatcher';
-import { Article, ArticlesBySection, HeaderSizes, Styles, WebsitePaths } from 'ts/types';
-import { colors } from 'ts/utils/colors';
+import { Article, ArticlesBySection, WebsitePaths } from 'ts/types';
import { configs } from 'ts/utils/configs';
import { constants } from 'ts/utils/constants';
import { Translate } from 'ts/utils/translate';
@@ -60,6 +67,9 @@ export class Wiki extends React.Component<WikiProps, WikiState> {
isHoveringSidebar: false,
};
}
+ public componentDidMount() {
+ window.addEventListener('hashchange', this._onHashChanged.bind(this), false);
+ }
public componentWillMount() {
// tslint:disable-next-line:no-floating-promises
this._fetchArticlesBySectionAsync();
@@ -67,6 +77,7 @@ export class Wiki extends React.Component<WikiProps, WikiState> {
public componentWillUnmount() {
this._isUnmounted = true;
clearTimeout(this._wikiBackoffTimeoutId);
+ window.removeEventListener('hashchange', this._onHashChanged.bind(this), false);
}
public render() {
const menuSubsectionsBySection = _.isUndefined(this.state.articlesBySection)
@@ -122,7 +133,7 @@ export class Wiki extends React.Component<WikiProps, WikiState> {
<NestedSidebarMenu
topLevelMenu={menuSubsectionsBySection}
menuSubsectionsBySection={menuSubsectionsBySection}
- title="Wiki"
+ sidebarHeader={<SidebarHeader title="Wiki" />}
/>
</div>
</div>
@@ -135,11 +146,11 @@ export class Wiki extends React.Component<WikiProps, WikiState> {
}}
>
<div
- id={configs.SCROLL_CONTAINER_ID}
+ id={sharedConstants.SCROLL_CONTAINER_ID}
style={{ ...mainContainersStyle, overflow: 'auto' }}
className="absolute"
>
- <div id={configs.SCROLL_TOP_ID} />
+ <div id={sharedConstants.SCROLL_TOP_ID} />
<div id="wiki" style={{ paddingRight: 2 }}>
{this._renderWikiArticles()}
</div>
@@ -214,7 +225,7 @@ export class Wiki extends React.Component<WikiProps, WikiState> {
async () => {
await utils.onPageLoadAsync();
const hash = this.props.location.hash.slice(1);
- utils.scrollToHash(hash, configs.SCROLL_CONTAINER_ID);
+ sharedUtils.scrollToHash(hash, sharedConstants.SCROLL_CONTAINER_ID);
},
);
}
@@ -239,4 +250,8 @@ export class Wiki extends React.Component<WikiProps, WikiState> {
isHoveringSidebar: false,
});
}
+ private _onHashChanged(event: any) {
+ const hash = window.location.hash.slice(1);
+ sharedUtils.scrollToHash(hash, sharedConstants.SCROLL_CONTAINER_ID);
+ }
}