aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/utils
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/utils
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/utils')
-rw-r--r--packages/website/ts/utils/configs.ts9
-rw-r--r--packages/website/ts/utils/utils.ts19
2 files changed, 24 insertions, 4 deletions
diff --git a/packages/website/ts/utils/configs.ts b/packages/website/ts/utils/configs.ts
index 7e9ba69de..44d64e875 100644
--- a/packages/website/ts/utils/configs.ts
+++ b/packages/website/ts/utils/configs.ts
@@ -2,10 +2,8 @@ import * as _ from 'lodash';
import { ContractAddresses, Environments, OutdatedWrappedEtherByNetworkId, PublicNodeUrlsByNetworkId } from 'ts/types';
const BASE_URL = window.location.origin;
-const isDevelopment = _.includes(
- ['https://0xproject.localhost:3572', 'https://localhost:3572', 'https://127.0.0.1'],
- BASE_URL,
-);
+const developmentUrls = ['https://0xproject.localhost:3572', 'https://localhost:3572', 'https://127.0.0.1'];
+const isDevelopment = _.includes(developmentUrls, BASE_URL);
const INFURA_API_KEY = 'T5WSC8cautR4KXyYgsRs';
export const configs = {
@@ -15,6 +13,7 @@ export const configs = {
DEFAULT_DERIVATION_PATH: `44'/60'/0'`,
// WARNING: ZRX & WETH MUST always be default trackedTokens
DEFAULT_TRACKED_TOKEN_SYMBOLS: ['WETH', 'ZRX'],
+ DEVELOPMENT_URLS: developmentUrls,
DOMAIN_STAGING: 'staging-0xproject.s3-website-us-east-1.amazonaws.com',
DOMAIN_DEVELOPMENT: '0xproject.localhost:3572',
DOMAIN_PRODUCTION: '0xproject.com',
@@ -94,6 +93,8 @@ export const configs = {
[3]: [`https://ropsten.infura.io/${INFURA_API_KEY}`],
[4]: [`https://rinkeby.infura.io/${INFURA_API_KEY}`],
} as PublicNodeUrlsByNetworkId,
+ SCROLL_CONTAINER_ID: 'documentation',
+ SCROLL_TOP_ID: 'pageScrollTop',
SHOULD_DEPRECATE_OLD_WETH_TOKEN: true,
SYMBOLS_OF_MINTABLE_KOVAN_TOKENS: ['MKR', 'MLN', 'GNT', 'DGD', 'REP'],
SYMBOLS_OF_MINTABLE_RINKEBY_ROPSTEN_TOKENS: [
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index c38f84c92..4d04d915d 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -4,6 +4,7 @@ import deepEqual = require('deep-equal');
import isMobile = require('is-mobile');
import * as _ from 'lodash';
import * as moment from 'moment';
+import { scroller } from 'react-scroll';
import {
EtherscanLinkSuffixes,
Networks,
@@ -290,4 +291,22 @@ export const utils = {
);
return isTestNetwork;
},
+ getCurrentBaseUrl() {
+ const port = window.location.port;
+ const hasPort = !_.isUndefined(port);
+ const baseUrl = `https://${window.location.hostname}${hasPort ? `:${port}` : ''}`;
+ return baseUrl;
+ },
+ scrollToHash(hashWithPrefix: string, containerId: string): void {
+ let hash = hashWithPrefix.slice(1);
+ if (_.isEmpty(hash)) {
+ hash = configs.SCROLL_TOP_ID; // scroll to the top
+ }
+
+ scroller.scrollTo(hash, {
+ duration: 0,
+ offset: 0,
+ containerId,
+ });
+ },
};