diff options
Diffstat (limited to 'packages/react-shared')
6 files changed, 32 insertions, 32 deletions
diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json index 83b4cc5c9..5df4648ee 100644 --- a/packages/react-shared/package.json +++ b/packages/react-shared/package.json @@ -9,10 +9,9 @@ "types": "lib/index.d.ts", "scripts": { "lint": "tslint --project .", - "build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts", + "build": "tsc", "watch_without_deps": "tsc -w", - "clean": "shx rm -rf lib scripts", - "manual:postpublish": "yarn build; node ./scripts/postpublish.js" + "clean": "shx rm -rf lib" }, "author": "Fabio Berger", "license": "Apache-2.0", @@ -26,7 +25,6 @@ }, "devDependencies": { "@0xproject/dev-utils": "^1.0.4", - "@0xproject/monorepo-scripts": "^1.0.5", "@0xproject/tslint-config": "^1.0.5", "copyfiles": "^2.0.0", "make-promises-safe": "^1.1.0", @@ -41,7 +39,7 @@ "@types/node": "^8.0.53", "@types/react": "*", "@types/react-dom": "*", - "@types/react-scroll": "0.0.31", + "@types/react-scroll": "1.5.3", "basscss": "^8.0.3", "is-mobile": "^0.2.2", "lodash": "^4.17.5", @@ -50,7 +48,7 @@ "react-dom": "15.6.1", "react-highlight": "0xproject/react-highlight", "react-markdown": "^3.2.2", - "react-scroll": "^1.5.2", + "react-scroll": "0xproject/react-scroll#similar-to-pr-330", "react-tap-event-plugin": "^2.0.1" }, "publishConfig": { diff --git a/packages/react-shared/src/components/anchor_title.tsx b/packages/react-shared/src/components/anchor_title.tsx index 473b994bf..451ba1729 100644 --- a/packages/react-shared/src/components/anchor_title.tsx +++ b/packages/react-shared/src/components/anchor_title.tsx @@ -69,13 +69,13 @@ export class AnchorTitle extends React.Component<AnchorTitleProps, AnchorTitleSt </div> <ScrollLink to={this.props.id} + hashSpy={true} offset={headerSizeToScrollOffset[this.props.headerSize]} duration={constants.DOCS_SCROLL_DURATION_MS} containerId={constants.DOCS_CONTAINER_ID} > <i className="zmdi zmdi-link" - onClick={utils.setUrlHash.bind(utils, this.props.id)} style={{ ...styles.anchor, opacity }} onMouseOver={this._setHoverState.bind(this, true)} onMouseOut={this._setHoverState.bind(this, false)} diff --git a/packages/react-shared/src/components/markdown_section.tsx b/packages/react-shared/src/components/markdown_section.tsx index 3b65b3075..09b214548 100644 --- a/packages/react-shared/src/components/markdown_section.tsx +++ b/packages/react-shared/src/components/markdown_section.tsx @@ -42,7 +42,7 @@ export class MarkdownSection extends React.Component<MarkdownSectionProps, Markd const { sectionName, markdownContent, headerSize, githubLink } = this.props as PropsWithDefaults; const id = utils.getIdFromName(sectionName); - const finalSectionName = utils.convertDashesToSpaces(sectionName); + const finalSectionName = utils.convertCamelCaseToSpaces(sectionName); return ( <div className="md-px1 sm-px2 overflow-hidden" diff --git a/packages/react-shared/src/components/nested_sidebar_menu.tsx b/packages/react-shared/src/components/nested_sidebar_menu.tsx index aa00d5985..c8bddb59a 100644 --- a/packages/react-shared/src/components/nested_sidebar_menu.tsx +++ b/packages/react-shared/src/components/nested_sidebar_menu.tsx @@ -45,7 +45,7 @@ export class NestedSidebarMenu extends React.Component<NestedSidebarMenuProps, N }; public render(): React.ReactNode { const navigation = _.map(this.props.topLevelMenu, (menuItems: string[], sectionName: string) => { - const finalSectionName = utils.convertDashesToSpaces(sectionName); + const finalSectionName = utils.convertCamelCaseToSpaces(sectionName); if (this.props.shouldDisplaySectionHeaders) { // tslint:disable-next-line:no-unused-variable const id = utils.getIdFromName(sectionName); @@ -93,15 +93,12 @@ export class NestedSidebarMenu extends React.Component<NestedSidebarMenuProps, N <ScrollLink key={`menuItem-${menuItemName}`} to={id} - offset={-10} + offset={0} + hashSpy={true} duration={constants.DOCS_SCROLL_DURATION_MS} containerId={constants.DOCS_CONTAINER_ID} > - <MenuItem - onTouchTap={this._onMenuItemClick.bind(this, finalMenuItemName)} - style={menuItemStyles} - innerDivStyle={menuItemInnerDivStyles} - > + <MenuItem style={menuItemStyles} innerDivStyle={menuItemInnerDivStyles}> <span style={{ textTransform: 'capitalize' }}>{finalMenuItemName}</span> </MenuItem> </ScrollLink> @@ -128,12 +125,11 @@ export class NestedSidebarMenu extends React.Component<NestedSidebarMenuProps, N <ScrollLink to={id} offset={0} + hashSpy={true} duration={constants.DOCS_SCROLL_DURATION_MS} containerId={constants.DOCS_CONTAINER_ID} - onTouchTap={this._onMenuItemClick.bind(this, name)} > <MenuItem - onTouchTap={this._onMenuItemClick.bind(this, name)} style={{ minHeight: 35 }} innerDivStyle={{ paddingLeft: 16, @@ -150,11 +146,4 @@ export class NestedSidebarMenu extends React.Component<NestedSidebarMenuProps, N </ul> ); } - private _onMenuItemClick(name: string): void { - const id = utils.getIdFromName(name); - utils.setUrlHash(id); - if (!_.isUndefined(this.props.onMenuItemClick)) { - this.props.onMenuItemClick(); - } - } } diff --git a/packages/react-shared/src/monorepo_scripts/postpublish.ts b/packages/react-shared/src/monorepo_scripts/postpublish.ts deleted file mode 100644 index dcb99d0f7..000000000 --- a/packages/react-shared/src/monorepo_scripts/postpublish.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { postpublishUtils } from '@0xproject/monorepo-scripts'; - -import * as packageJSON from '../package.json'; -import * as tsConfigJSON from '../tsconfig.json'; - -const cwd = `${__dirname}/..`; -// tslint:disable-next-line:no-floating-promises -postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd); diff --git a/packages/react-shared/src/utils/utils.ts b/packages/react-shared/src/utils/utils.ts index 93c7e9f7b..0c0e7722c 100644 --- a/packages/react-shared/src/utils/utils.ts +++ b/packages/react-shared/src/utils/utils.ts @@ -33,6 +33,27 @@ export const utils = { convertDashesToSpaces(text: string): string { return text.replace(/-/g, ' '); }, + convertCamelCaseToSpaces(text: string): string { + const charArray = _.map(text, (char, i) => { + const isNumber = !_.eq(_.parseInt(char), NaN); + const isPrevNumber = i !== 0 && !_.eq(_.parseInt(text[i - 1]), NaN); + if (isNumber && (i == 0 || isPrevNumber)) { + return char; + } + if (char === char.toUpperCase() && i !== 0) { + return ` ${char}`; + } + return char; + }); + let finalText = charArray.join(''); + const exceptions = { 'EIP ': 'E I P', 'ZRX ': 'Z R X', 'ERC ': 'E R C', RPC: 'R P C' }; + _.each(exceptions, (spaced, normal) => { + if (_.includes(finalText, spaced)) { + finalText = finalText.replace(spaced, normal); + } + }); + return finalText; + }, getEtherScanLinkIfExists( addressOrTxHash: string, networkId: number, |