diff options
author | Fabio Berger <me@fabioberger.com> | 2018-03-02 21:40:26 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-03-02 21:40:26 +0800 |
commit | 67c834841ea0f8fb4d8d194c0f68802f48e764ee (patch) | |
tree | 1cea9006d0b572318d1d0784f97eee8b85a413c8 /packages/website/ts/pages/documentation/documentation.tsx | |
parent | edaa0b0e34f99b0d34405eecb6aee54c1f6d7c7e (diff) | |
download | dexon-0x-contracts-67c834841ea0f8fb4d8d194c0f68802f48e764ee.tar dexon-0x-contracts-67c834841ea0f8fb4d8d194c0f68802f48e764ee.tar.gz dexon-0x-contracts-67c834841ea0f8fb4d8d194c0f68802f48e764ee.tar.bz2 dexon-0x-contracts-67c834841ea0f8fb4d8d194c0f68802f48e764ee.tar.lz dexon-0x-contracts-67c834841ea0f8fb4d8d194c0f68802f48e764ee.tar.xz dexon-0x-contracts-67c834841ea0f8fb4d8d194c0f68802f48e764ee.tar.zst dexon-0x-contracts-67c834841ea0f8fb4d8d194c0f68802f48e764ee.zip |
Update react-markdown, properly scroll to section for wiki internal links, consolidate scrollTo logic and make external links open in new tabs
Diffstat (limited to 'packages/website/ts/pages/documentation/documentation.tsx')
-rw-r--r-- | packages/website/ts/pages/documentation/documentation.tsx | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/packages/website/ts/pages/documentation/documentation.tsx b/packages/website/ts/pages/documentation/documentation.tsx index 7eed78fc3..5963fe851 100644 --- a/packages/website/ts/pages/documentation/documentation.tsx +++ b/packages/website/ts/pages/documentation/documentation.tsx @@ -29,11 +29,11 @@ import { TypescriptMethod, } from 'ts/types'; import { colors } from 'ts/utils/colors'; +import { configs } from 'ts/utils/configs'; import { constants } from 'ts/utils/constants'; import { utils } from 'ts/utils/utils'; const TOP_BAR_HEIGHT = 60; -const SCROLL_TOP_ID = 'docsScrollTop'; const networkNameToColor: { [network: string]: string } = { [Networks.Kovan]: colors.purple, @@ -76,7 +76,7 @@ const styles: Styles = { export class Documentation extends React.Component<DocumentationProps, DocumentationState> { public componentDidUpdate(prevProps: DocumentationProps, prevState: DocumentationState) { if (!_.isEqual(prevProps.docAgnosticFormat, this.props.docAgnosticFormat)) { - this._scrollToHash(); + utils.scrollToHash(this.props.location.hash, configs.SCROLL_CONTAINER_ID); } } public render() { @@ -115,8 +115,12 @@ export class Documentation extends React.Component<DocumentationProps, Documenta className="relative col lg-col-9 md-col-9 sm-col-12 col-12" style={{ backgroundColor: colors.white }} > - <div id="documentation" style={styles.mainContainers} className="absolute px1"> - <div id={SCROLL_TOP_ID} /> + <div + id={configs.SCROLL_CONTAINER_ID} + style={styles.mainContainers} + className="absolute px1" + > + <div id={configs.SCROLL_TOP_ID} /> {this._renderDocumentation()} </div> </div> @@ -325,17 +329,4 @@ export class Documentation extends React.Component<DocumentationProps, Documenta /> ); } - private _scrollToHash(): void { - const hashWithPrefix = this.props.location.hash; - let hash = hashWithPrefix.slice(1); - if (_.isEmpty(hash)) { - hash = SCROLL_TOP_ID; // scroll to the top - } - - scroller.scrollTo(hash, { - duration: 0, - offset: 0, - containerId: 'documentation', - }); - } } |