Move Documentation to the @0xproject/react-docs
package
This commit is contained in:
6
packages/react-shared/src/ts/globals.d.ts
vendored
6
packages/react-shared/src/ts/globals.d.ts
vendored
@@ -1 +1,7 @@
|
||||
declare module 'react-highlight';
|
||||
|
||||
// is-mobile declarations
|
||||
declare function isMobile(): boolean;
|
||||
declare module 'is-mobile' {
|
||||
export = isMobile;
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ export { MarkdownSection } from './components/markdown_section';
|
||||
export { NestedSidebarMenu } from './components/nested_sidebar_menu';
|
||||
export { SectionHeader } from './components/section_header';
|
||||
|
||||
export { HeaderSizes, Styles, MenuSubsectionsBySection } from './types';
|
||||
export { HeaderSizes, Styles, MenuSubsectionsBySection, EtherscanLinkSuffixes, Networks } from './types';
|
||||
|
||||
export { utils } from './utils/utils';
|
||||
export { constants } from './utils/constants';
|
||||
|
@@ -11,3 +11,15 @@ export enum HeaderSizes {
|
||||
export interface MenuSubsectionsBySection {
|
||||
[section: string]: string[];
|
||||
}
|
||||
|
||||
export enum EtherscanLinkSuffixes {
|
||||
Address = 'address',
|
||||
Tx = 'tx',
|
||||
}
|
||||
|
||||
export enum Networks {
|
||||
Mainnet = 'Mainnet',
|
||||
Kovan = 'Kovan',
|
||||
Ropsten = 'Ropsten',
|
||||
Rinkeby = 'Rinkeby',
|
||||
}
|
||||
|
@@ -1,6 +1,20 @@
|
||||
import { Networks } from '../types';
|
||||
|
||||
export const constants = {
|
||||
DOCS_SCROLL_DURATION_MS: 0,
|
||||
DOCS_CONTAINER_ID: 'documentation',
|
||||
SCROLL_CONTAINER_ID: 'documentation',
|
||||
SCROLL_TOP_ID: 'pageScrollTop',
|
||||
NETWORK_NAME_BY_ID: {
|
||||
1: Networks.Mainnet,
|
||||
3: Networks.Ropsten,
|
||||
4: Networks.Rinkeby,
|
||||
42: Networks.Kovan,
|
||||
} as { [symbol: number]: string },
|
||||
NETWORK_ID_BY_NAME: {
|
||||
[Networks.Mainnet]: 1,
|
||||
[Networks.Ropsten]: 3,
|
||||
[Networks.Rinkeby]: 4,
|
||||
[Networks.Kovan]: 42,
|
||||
} as { [networkName: string]: number },
|
||||
};
|
||||
|
@@ -1,6 +1,9 @@
|
||||
import isMobile = require('is-mobile');
|
||||
import * as _ from 'lodash';
|
||||
import { scroller } from 'react-scroll';
|
||||
|
||||
import { EtherscanLinkSuffixes, Networks } from '../types';
|
||||
|
||||
import { constants } from './constants';
|
||||
|
||||
export const utils = {
|
||||
@@ -19,6 +22,10 @@ export const utils = {
|
||||
containerId,
|
||||
});
|
||||
},
|
||||
isUserOnMobile(): boolean {
|
||||
const isUserOnMobile = isMobile();
|
||||
return isUserOnMobile;
|
||||
},
|
||||
getIdFromName(name: string) {
|
||||
const id = name.replace(/ /g, '-');
|
||||
return id;
|
||||
@@ -29,4 +36,12 @@ export const utils = {
|
||||
const baseUrl = `https://${window.location.hostname}${hasPort ? `:${port}` : ''}`;
|
||||
return baseUrl;
|
||||
},
|
||||
getEtherScanLinkIfExists(addressOrTxHash: string, networkId: number, suffix: EtherscanLinkSuffixes): string {
|
||||
const networkName = constants.NETWORK_NAME_BY_ID[networkId];
|
||||
if (_.isUndefined(networkName)) {
|
||||
return undefined;
|
||||
}
|
||||
const etherScanPrefix = networkName === Networks.Mainnet ? '' : `${networkName.toLowerCase()}.`;
|
||||
return `https://${etherScanPrefix}etherscan.io/${suffix}/${addressOrTxHash}`;
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user