From 67c834841ea0f8fb4d8d194c0f68802f48e764ee Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 2 Mar 2018 14:40:26 +0100 Subject: Update react-markdown, properly scroll to section for wiki internal links, consolidate scrollTo logic and make external links open in new tabs --- .../website/ts/pages/documentation/comment.tsx | 2 +- .../ts/pages/documentation/documentation.tsx | 25 +++++++--------------- 2 files changed, 9 insertions(+), 18 deletions(-) (limited to 'packages/website/ts/pages/documentation') diff --git a/packages/website/ts/pages/documentation/comment.tsx b/packages/website/ts/pages/documentation/comment.tsx index 23cfd96bd..5f177e97e 100644 --- a/packages/website/ts/pages/documentation/comment.tsx +++ b/packages/website/ts/pages/documentation/comment.tsx @@ -15,7 +15,7 @@ const defaultProps = { export const Comment: React.SFC = (props: CommentProps) => { return (
- +
); }; 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 { 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 -
-
+
+
{this._renderDocumentation()}
@@ -325,17 +329,4 @@ export class Documentation extends React.Component ); } - 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', - }); - } } -- cgit