aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/pages/documentation
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-03-02 21:40:26 +0800
committerFabio Berger <me@fabioberger.com>2018-03-02 21:40:26 +0800
commit67c834841ea0f8fb4d8d194c0f68802f48e764ee (patch)
tree1cea9006d0b572318d1d0784f97eee8b85a413c8 /packages/website/ts/pages/documentation
parentedaa0b0e34f99b0d34405eecb6aee54c1f6d7c7e (diff)
downloaddexon-sol-tools-67c834841ea0f8fb4d8d194c0f68802f48e764ee.tar
dexon-sol-tools-67c834841ea0f8fb4d8d194c0f68802f48e764ee.tar.gz
dexon-sol-tools-67c834841ea0f8fb4d8d194c0f68802f48e764ee.tar.bz2
dexon-sol-tools-67c834841ea0f8fb4d8d194c0f68802f48e764ee.tar.lz
dexon-sol-tools-67c834841ea0f8fb4d8d194c0f68802f48e764ee.tar.xz
dexon-sol-tools-67c834841ea0f8fb4d8d194c0f68802f48e764ee.tar.zst
dexon-sol-tools-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')
-rw-r--r--packages/website/ts/pages/documentation/comment.tsx2
-rw-r--r--packages/website/ts/pages/documentation/documentation.tsx25
2 files changed, 9 insertions, 18 deletions
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<CommentProps> = (props: CommentProps) => {
return (
<div className={`${props.className} comment`}>
- <ReactMarkdown source={props.comment} renderers={{ CodeBlock: MarkdownCodeBlock }} />
+ <ReactMarkdown source={props.comment} renderers={{ code: MarkdownCodeBlock }} />
</div>
);
};
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',
- });
- }
}