From b7d001da88ab604762ddf9df8abcf956d4c2de7f Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Sat, 3 Mar 2018 19:58:30 +0100 Subject: Setup initial react-shared sub-package --- packages/react-shared/.gitignore | 4 + packages/react-shared/.npmignore | 5 ++ packages/react-shared/.prettierignore | 2 + packages/react-shared/.prettierrc | 6 ++ packages/react-shared/package.json | 32 ++++++++ packages/react-shared/scripts/postpublish.js | 5 ++ .../src/ts/components/anchor_title.tsx | 87 ++++++++++++++++++++++ packages/react-shared/src/ts/constants.ts | 4 + packages/react-shared/src/ts/globals.d.ts | 0 packages/react-shared/src/ts/index.ts | 6 ++ packages/react-shared/src/ts/types.ts | 9 +++ packages/react-shared/src/ts/utils.ts | 5 ++ packages/react-shared/tsconfig.json | 23 ++++++ packages/react-shared/tslint.json | 9 +++ 14 files changed, 197 insertions(+) create mode 100644 packages/react-shared/.gitignore create mode 100644 packages/react-shared/.npmignore create mode 100644 packages/react-shared/.prettierignore create mode 100644 packages/react-shared/.prettierrc create mode 100644 packages/react-shared/package.json create mode 100644 packages/react-shared/scripts/postpublish.js create mode 100644 packages/react-shared/src/ts/components/anchor_title.tsx create mode 100644 packages/react-shared/src/ts/constants.ts create mode 100644 packages/react-shared/src/ts/globals.d.ts create mode 100644 packages/react-shared/src/ts/index.ts create mode 100644 packages/react-shared/src/ts/types.ts create mode 100644 packages/react-shared/src/ts/utils.ts create mode 100644 packages/react-shared/tsconfig.json create mode 100644 packages/react-shared/tslint.json (limited to 'packages/react-shared') diff --git a/packages/react-shared/.gitignore b/packages/react-shared/.gitignore new file mode 100644 index 000000000..380bff9bb --- /dev/null +++ b/packages/react-shared/.gitignore @@ -0,0 +1,4 @@ +node_modules +yarn.error +lib +src/public/bundle* diff --git a/packages/react-shared/.npmignore b/packages/react-shared/.npmignore new file mode 100644 index 000000000..87bc30436 --- /dev/null +++ b/packages/react-shared/.npmignore @@ -0,0 +1,5 @@ +.* +yarn-error.log +/src/ +/scripts/ +tsconfig.json diff --git a/packages/react-shared/.prettierignore b/packages/react-shared/.prettierignore new file mode 100644 index 000000000..7349ffb70 --- /dev/null +++ b/packages/react-shared/.prettierignore @@ -0,0 +1,2 @@ +lib +package.json diff --git a/packages/react-shared/.prettierrc b/packages/react-shared/.prettierrc new file mode 100644 index 000000000..58a17fac2 --- /dev/null +++ b/packages/react-shared/.prettierrc @@ -0,0 +1,6 @@ +{ + "tabWidth": 4, + "printWidth": 120, + "trailingComma": all, + "singleQuote": true +} diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json new file mode 100644 index 000000000..69d298559 --- /dev/null +++ b/packages/react-shared/package.json @@ -0,0 +1,32 @@ +{ + "name": "@0xproject/react-shared", + "version": "0.0.1", + "description": "0x shared react components", + "main": "lib/index.js", + "scripts": { + "lint": "tslint --project . 'src/ts/**/*.ts' 'src/ts/**/*.tsx'", + "build": "tsc" + }, + "author": "Fabio Berger", + "license": "MIT", + "devDependencies": { + "@0xproject/tslint-config": "^0.4.9", + "@types/lodash": "^4.14.86", + "@types/node": "^8.0.53", + "@types/material-ui": "0.18.0", + "@types/react": "^15.0.15", + "@types/react-dom": "^0.14.23", + "shx": "^0.2.2", + "tslint": "^5.9.1", + "typescript": "2.7.1" + }, + "dependencies": { + "basscss": "^8.0.3", + "material-ui": "^0.17.1", + "react": "15.6.1", + "react-dom": "15.6.1", + "lodash": "^4.17.4", + "react-scroll": "^1.5.2", + "react-tap-event-plugin": "^2.0.1" + } +} diff --git a/packages/react-shared/scripts/postpublish.js b/packages/react-shared/scripts/postpublish.js new file mode 100644 index 000000000..639656c7e --- /dev/null +++ b/packages/react-shared/scripts/postpublish.js @@ -0,0 +1,5 @@ +const postpublish_utils = require('../../../scripts/postpublish_utils'); +const packageJSON = require('../package.json'); + +const subPackageName = packageJSON.name; +postpublish_utils.standardPostPublishAsync(subPackageName); diff --git a/packages/react-shared/src/ts/components/anchor_title.tsx b/packages/react-shared/src/ts/components/anchor_title.tsx new file mode 100644 index 000000000..9b8e6854f --- /dev/null +++ b/packages/react-shared/src/ts/components/anchor_title.tsx @@ -0,0 +1,87 @@ +import * as React from 'react'; +import { Link as ScrollLink } from 'react-scroll'; + +import { constants } from '../constants'; +import { HeaderSizes, Styles } from '../types'; +import { utils } from '../utils'; + +const headerSizeToScrollOffset: { [headerSize: string]: number } = { + h2: -20, + h3: 0, +}; + +interface AnchorTitleProps { + title: string | React.ReactNode; + id: string; + headerSize: HeaderSizes; + shouldShowAnchor: boolean; +} + +interface AnchorTitleState { + isHovering: boolean; +} + +const styles: Styles = { + anchor: { + fontSize: 20, + transform: 'rotate(45deg)', + cursor: 'pointer', + }, + headers: { + WebkitMarginStart: 0, + WebkitMarginEnd: 0, + fontWeight: 'bold', + display: 'block', + }, + h1: { + fontSize: '1.8em', + }, + h2: { + fontSize: '1.5em', + fontWeight: 400, + }, + h3: { + fontSize: '1.17em', + }, +}; + +export class AnchorTitle extends React.Component { + constructor(props: AnchorTitleProps) { + super(props); + this.state = { + isHovering: false, + }; + } + public render() { + let opacity = 0; + if (this.props.shouldShowAnchor) { + opacity = this.state.isHovering ? 0.6 : 1; + } + return ( +
+
+ {this.props.title} +
+ + + +
+ ); + } + private _setHoverState(isHovering: boolean) { + this.setState({ + isHovering, + }); + } +} diff --git a/packages/react-shared/src/ts/constants.ts b/packages/react-shared/src/ts/constants.ts new file mode 100644 index 000000000..20d0c6e92 --- /dev/null +++ b/packages/react-shared/src/ts/constants.ts @@ -0,0 +1,4 @@ +export const constants = { + DOCS_SCROLL_DURATION_MS: 0, + DOCS_CONTAINER_ID: 'documentation', +}; diff --git a/packages/react-shared/src/ts/globals.d.ts b/packages/react-shared/src/ts/globals.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/packages/react-shared/src/ts/index.ts b/packages/react-shared/src/ts/index.ts new file mode 100644 index 000000000..d33638e62 --- /dev/null +++ b/packages/react-shared/src/ts/index.ts @@ -0,0 +1,6 @@ +export { AnchorTitle } from './components/anchor_title'; + +export { HeaderSizes, Styles } from './types'; + +export { utils } from './utils'; +export { constants } from './constants'; diff --git a/packages/react-shared/src/ts/types.ts b/packages/react-shared/src/ts/types.ts new file mode 100644 index 000000000..e4fe7bff9 --- /dev/null +++ b/packages/react-shared/src/ts/types.ts @@ -0,0 +1,9 @@ +export interface Styles { + [name: string]: React.CSSProperties; +} + +export enum HeaderSizes { + H1 = 'h1', + H2 = 'h2', + H3 = 'h3', +} diff --git a/packages/react-shared/src/ts/utils.ts b/packages/react-shared/src/ts/utils.ts new file mode 100644 index 000000000..822b67496 --- /dev/null +++ b/packages/react-shared/src/ts/utils.ts @@ -0,0 +1,5 @@ +export const utils = { + setUrlHash(anchorId: string) { + window.location.hash = anchorId; + }, +}; diff --git a/packages/react-shared/tsconfig.json b/packages/react-shared/tsconfig.json new file mode 100644 index 000000000..69e8cdc20 --- /dev/null +++ b/packages/react-shared/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "lib": ["es2017", "dom"], + "sourceMap": true, + "noImplicitReturns": true, + "allowSyntheticDefaultImports": true, + "outDir": "./lib/", + "jsx": "react", + "baseUrl": "./", + "allowJs": true, + "strictNullChecks": false, + "noImplicitThis": false, + "declaration": false, + "paths": { + "*": ["node_modules/@types/*", "*"] + }, + "pretty": true, + "strict": true + }, + "include": ["./src/ts/**/*"] +} diff --git a/packages/react-shared/tslint.json b/packages/react-shared/tslint.json new file mode 100644 index 000000000..d6a5f5031 --- /dev/null +++ b/packages/react-shared/tslint.json @@ -0,0 +1,9 @@ +{ + "extends": ["@0xproject/tslint-config"], + "rules": { + "no-implicit-dependencies": false, + "no-object-literal-type-assertion": false, + "completed-docs": false, + "prefer-function-over-method": false + } +} -- cgit v1.2.3 From 8782559c33b5b57f643c62569b83bee6cfb7e48b Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Sat, 3 Mar 2018 20:29:07 +0100 Subject: remove top-level configs --- packages/react-shared/.gitignore | 4 ---- packages/react-shared/.prettierignore | 2 -- packages/react-shared/.prettierrc | 6 ------ 3 files changed, 12 deletions(-) delete mode 100644 packages/react-shared/.gitignore delete mode 100644 packages/react-shared/.prettierignore delete mode 100644 packages/react-shared/.prettierrc (limited to 'packages/react-shared') diff --git a/packages/react-shared/.gitignore b/packages/react-shared/.gitignore deleted file mode 100644 index 380bff9bb..000000000 --- a/packages/react-shared/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -node_modules -yarn.error -lib -src/public/bundle* diff --git a/packages/react-shared/.prettierignore b/packages/react-shared/.prettierignore deleted file mode 100644 index 7349ffb70..000000000 --- a/packages/react-shared/.prettierignore +++ /dev/null @@ -1,2 +0,0 @@ -lib -package.json diff --git a/packages/react-shared/.prettierrc b/packages/react-shared/.prettierrc deleted file mode 100644 index 58a17fac2..000000000 --- a/packages/react-shared/.prettierrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "tabWidth": 4, - "printWidth": 120, - "trailingComma": all, - "singleQuote": true -} -- cgit v1.2.3 From bee90abbc47e099d66cb51c684f9f98cbdf6af3f Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Sat, 3 Mar 2018 20:29:17 +0100 Subject: Add changelog and readme --- packages/react-shared/CHANGELOG.md | 3 +++ packages/react-shared/README.md | 47 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 packages/react-shared/CHANGELOG.md create mode 100644 packages/react-shared/README.md (limited to 'packages/react-shared') diff --git a/packages/react-shared/CHANGELOG.md b/packages/react-shared/CHANGELOG.md new file mode 100644 index 000000000..7c3ac2adf --- /dev/null +++ b/packages/react-shared/CHANGELOG.md @@ -0,0 +1,3 @@ +# CHANGELOG + +## vX.X.X - _TBD, 2018_ diff --git a/packages/react-shared/README.md b/packages/react-shared/README.md new file mode 100644 index 000000000..da7ff83af --- /dev/null +++ b/packages/react-shared/README.md @@ -0,0 +1,47 @@ +## @0xproject/react-shared + +Contains React components & frontend types/utils shared between 0x projects. + +## Installation + +```bash +yarn add @0xproject/react-shared +``` + +## Contributing + +We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository. + +Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. + +### Install Dependencies + +If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: + +```bash +yarn config set workspaces-experimental true +``` + +Then install dependencies + +```bash +yarn install +``` + +### Build + +```bash +yarn build +``` + +### Lint + +```bash +yarn lint +``` + +### Run Tests + +```bash +yarn test +``` -- cgit v1.2.3 From e11e26a35274a96fd2d4b7f37e60b89220115994 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Sat, 3 Mar 2018 20:29:24 +0100 Subject: Add clean command --- packages/react-shared/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'packages/react-shared') diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json index 69d298559..835915842 100644 --- a/packages/react-shared/package.json +++ b/packages/react-shared/package.json @@ -5,7 +5,8 @@ "main": "lib/index.js", "scripts": { "lint": "tslint --project . 'src/ts/**/*.ts' 'src/ts/**/*.tsx'", - "build": "tsc" + "build": "tsc", + "clean": "shx rm -rf lib" }, "author": "Fabio Berger", "license": "MIT", -- cgit v1.2.3 From 874e6678491d25aa7db300d68bdcb73863685c62 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 5 Mar 2018 07:10:55 +0100 Subject: Bug fixes --- packages/react-shared/package.json | 1 + packages/react-shared/src/ts/components/anchor_title.tsx | 4 ++-- packages/react-shared/tsconfig.json | 13 ++----------- 3 files changed, 5 insertions(+), 13 deletions(-) (limited to 'packages/react-shared') diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json index 835915842..e1cc2ad8b 100644 --- a/packages/react-shared/package.json +++ b/packages/react-shared/package.json @@ -3,6 +3,7 @@ "version": "0.0.1", "description": "0x shared react components", "main": "lib/index.js", + "types": "lib/index.d.ts", "scripts": { "lint": "tslint --project . 'src/ts/**/*.ts' 'src/ts/**/*.tsx'", "build": "tsc", diff --git a/packages/react-shared/src/ts/components/anchor_title.tsx b/packages/react-shared/src/ts/components/anchor_title.tsx index 9b8e6854f..aa839cac9 100644 --- a/packages/react-shared/src/ts/components/anchor_title.tsx +++ b/packages/react-shared/src/ts/components/anchor_title.tsx @@ -10,14 +10,14 @@ const headerSizeToScrollOffset: { [headerSize: string]: number } = { h3: 0, }; -interface AnchorTitleProps { +export interface AnchorTitleProps { title: string | React.ReactNode; id: string; headerSize: HeaderSizes; shouldShowAnchor: boolean; } -interface AnchorTitleState { +export interface AnchorTitleState { isHovering: boolean; } diff --git a/packages/react-shared/tsconfig.json b/packages/react-shared/tsconfig.json index 69e8cdc20..6e71fb2e4 100644 --- a/packages/react-shared/tsconfig.json +++ b/packages/react-shared/tsconfig.json @@ -1,23 +1,14 @@ { + "extends": "../../tsconfig", "compilerOptions": { - "module": "commonjs", - "target": "es5", - "lib": ["es2017", "dom"], - "sourceMap": true, - "noImplicitReturns": true, - "allowSyntheticDefaultImports": true, "outDir": "./lib/", "jsx": "react", "baseUrl": "./", - "allowJs": true, "strictNullChecks": false, "noImplicitThis": false, - "declaration": false, "paths": { "*": ["node_modules/@types/*", "*"] - }, - "pretty": true, - "strict": true + } }, "include": ["./src/ts/**/*"] } -- cgit v1.2.3 From 5a90fece8020f9be5c0f52f6ccf65dacb824b1cd Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 5 Mar 2018 13:53:13 +0100 Subject: Moved over all pages/shared components and dependencies to react-shared --- packages/react-shared/package.json | 4 +- .../src/ts/components/anchor_title.tsx | 4 +- .../src/ts/components/markdown_code_block.tsx | 25 +++ .../src/ts/components/markdown_link_block.tsx | 47 ++++++ .../src/ts/components/markdown_section.tsx | 87 ++++++++++ .../src/ts/components/nested_sidebar_menu.tsx | 179 +++++++++++++++++++++ .../src/ts/components/section_header.tsx | 65 ++++++++ .../src/ts/components/version_drop_down.tsx | 46 ++++++ packages/react-shared/src/ts/constants.ts | 4 - packages/react-shared/src/ts/globals.d.ts | 1 + packages/react-shared/src/ts/index.ts | 12 +- packages/react-shared/src/ts/types.ts | 4 + packages/react-shared/src/ts/utils.ts | 5 - packages/react-shared/src/ts/utils/colors.ts | 48 ++++++ packages/react-shared/src/ts/utils/constants.ts | 6 + packages/react-shared/src/ts/utils/utils.ts | 32 ++++ 16 files changed, 554 insertions(+), 15 deletions(-) create mode 100644 packages/react-shared/src/ts/components/markdown_code_block.tsx create mode 100644 packages/react-shared/src/ts/components/markdown_link_block.tsx create mode 100644 packages/react-shared/src/ts/components/markdown_section.tsx create mode 100644 packages/react-shared/src/ts/components/nested_sidebar_menu.tsx create mode 100644 packages/react-shared/src/ts/components/section_header.tsx create mode 100644 packages/react-shared/src/ts/components/version_drop_down.tsx delete mode 100644 packages/react-shared/src/ts/constants.ts delete mode 100644 packages/react-shared/src/ts/utils.ts create mode 100644 packages/react-shared/src/ts/utils/colors.ts create mode 100644 packages/react-shared/src/ts/utils/constants.ts create mode 100644 packages/react-shared/src/ts/utils/utils.ts (limited to 'packages/react-shared') diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json index e1cc2ad8b..e96659e47 100644 --- a/packages/react-shared/package.json +++ b/packages/react-shared/package.json @@ -7,6 +7,7 @@ "scripts": { "lint": "tslint --project . 'src/ts/**/*.ts' 'src/ts/**/*.tsx'", "build": "tsc", + "build:watch": "tsc -w", "clean": "shx rm -rf lib" }, "author": "Fabio Berger", @@ -29,6 +30,7 @@ "react-dom": "15.6.1", "lodash": "^4.17.4", "react-scroll": "^1.5.2", - "react-tap-event-plugin": "^2.0.1" + "react-tap-event-plugin": "^2.0.1", + "react-highlight": "0xproject/react-highlight" } } diff --git a/packages/react-shared/src/ts/components/anchor_title.tsx b/packages/react-shared/src/ts/components/anchor_title.tsx index aa839cac9..f44354097 100644 --- a/packages/react-shared/src/ts/components/anchor_title.tsx +++ b/packages/react-shared/src/ts/components/anchor_title.tsx @@ -1,9 +1,9 @@ import * as React from 'react'; import { Link as ScrollLink } from 'react-scroll'; -import { constants } from '../constants'; import { HeaderSizes, Styles } from '../types'; -import { utils } from '../utils'; +import { constants } from '../utils/constants'; +import { utils } from '../utils/utils'; const headerSizeToScrollOffset: { [headerSize: string]: number } = { h2: -20, diff --git a/packages/react-shared/src/ts/components/markdown_code_block.tsx b/packages/react-shared/src/ts/components/markdown_code_block.tsx new file mode 100644 index 000000000..2070bb8e1 --- /dev/null +++ b/packages/react-shared/src/ts/components/markdown_code_block.tsx @@ -0,0 +1,25 @@ +import * as _ from 'lodash'; +import * as React from 'react'; +import * as HighLight from 'react-highlight'; + +export interface MarkdownCodeBlockProps { + value: string; + language: string; +} + +export interface MarkdownCodeBlockState {} + +export class MarkdownCodeBlock extends React.Component { + // Re-rendering a codeblock causes any use selection to become de-selected. This is annoying when trying + // to copy-paste code examples. We therefore noop re-renders on this component if it's props haven't changed. + public shouldComponentUpdate(nextProps: MarkdownCodeBlockProps, nextState: MarkdownCodeBlockState) { + return nextProps.value !== this.props.value || nextProps.language !== this.props.language; + } + public render() { + return ( + + {this.props.value} + + ); + } +} diff --git a/packages/react-shared/src/ts/components/markdown_link_block.tsx b/packages/react-shared/src/ts/components/markdown_link_block.tsx new file mode 100644 index 000000000..8f5862249 --- /dev/null +++ b/packages/react-shared/src/ts/components/markdown_link_block.tsx @@ -0,0 +1,47 @@ +import * as _ from 'lodash'; +import * as React from 'react'; + +import { constants } from '../utils/constants'; +import { utils } from '../utils/utils'; + +export interface MarkdownLinkBlockProps { + href: string; +} + +export interface MarkdownLinkBlockState {} + +export class MarkdownLinkBlock extends React.Component { + // Re-rendering a linkBlock causes it to remain unclickable. + // We therefore noop re-renders on this component if it's props haven't changed. + public shouldComponentUpdate(nextProps: MarkdownLinkBlockProps, nextState: MarkdownLinkBlockState) { + return nextProps.href !== this.props.href; + } + public render() { + const href = this.props.href; + const isLinkToSection = _.startsWith(href, '#'); + // If protocol is http or https, we can open in a new tab, otherwise don't for security reasons + if (_.startsWith(href, 'http') || _.startsWith(href, 'https')) { + return ( + + {this.props.children} + + ); + } else if (isLinkToSection) { + return ( + + {this.props.children} + + ); + } else { + return {this.props.children}; + } + } + private _onHashUrlClick(href: string) { + const hash = href.split('#')[1]; + utils.scrollToHash(hash, constants.SCROLL_CONTAINER_ID); + utils.setUrlHash(hash); + } +} diff --git a/packages/react-shared/src/ts/components/markdown_section.tsx b/packages/react-shared/src/ts/components/markdown_section.tsx new file mode 100644 index 000000000..682b6ef8f --- /dev/null +++ b/packages/react-shared/src/ts/components/markdown_section.tsx @@ -0,0 +1,87 @@ +import * as _ from 'lodash'; +import RaisedButton from 'material-ui/RaisedButton'; +import * as React from 'react'; +import * as ReactMarkdown from 'react-markdown'; +import { Element as ScrollElement } from 'react-scroll'; + +import { HeaderSizes } from '../types'; +import { colors } from '../utils/colors'; +import { utils } from '../utils/utils'; + +import { AnchorTitle } from './anchor_title'; +import { MarkdownCodeBlock } from './markdown_code_block'; +import { MarkdownLinkBlock } from './markdown_link_block'; + +export interface MarkdownSectionProps { + sectionName: string; + markdownContent: string; + headerSize?: HeaderSizes; + githubLink?: string; +} + +export interface MarkdownSectionState { + shouldShowAnchor: boolean; +} + +export class MarkdownSection extends React.Component { + public static defaultProps: Partial = { + headerSize: HeaderSizes.H3, + }; + constructor(props: MarkdownSectionProps) { + super(props); + this.state = { + shouldShowAnchor: false, + }; + } + public render() { + const sectionName = this.props.sectionName; + const id = utils.getIdFromName(sectionName); + return ( +
+ +
+
+ + + +
+
+ {!_.isUndefined(this.props.githubLink) && ( + + Edit on Github + + )} +
+
+
+ +
+
+ ); + } + private _setAnchorVisibility(shouldShowAnchor: boolean) { + this.setState({ + shouldShowAnchor, + }); + } +} diff --git a/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx b/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx new file mode 100644 index 000000000..2506124af --- /dev/null +++ b/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx @@ -0,0 +1,179 @@ +import * as _ from 'lodash'; +import MenuItem from 'material-ui/MenuItem'; +import * as React from 'react'; +import { Link as ScrollLink } from 'react-scroll'; + +import { MenuSubsectionsBySection, Styles } from '../types'; +import { colors } from '../utils/colors'; +import { constants } from '../utils/constants'; +import { utils } from '../utils/utils'; + +import { VersionDropDown } from './version_drop_down'; + +export interface NestedSidebarMenuProps { + topLevelMenu: { [topLevel: string]: string[] }; + menuSubsectionsBySection: MenuSubsectionsBySection; + title: string; + shouldDisplaySectionHeaders?: boolean; + onMenuItemClick?: () => void; + selectedVersion?: string; + versions?: string[]; +} + +export interface NestedSidebarMenuState {} + +const styles: Styles = { + menuItemWithHeaders: { + minHeight: 0, + }, + menuItemWithoutHeaders: { + minHeight: 48, + }, + menuItemInnerDivWithHeaders: { + color: colors.grey800, + fontSize: 14, + lineHeight: 2, + padding: 0, + }, +}; + +const titleToIcon: { [title: string]: string } = { + '0x.js': 'zeroExJs.png', + '0x Connect': 'connect.png', + '0x Smart Contracts': 'contracts.png', + Wiki: 'wiki.png', +}; + +export class NestedSidebarMenu extends React.Component { + public static defaultProps: Partial = { + shouldDisplaySectionHeaders: true, + onMenuItemClick: _.noop, + }; + public render() { + const navigation = _.map(this.props.topLevelMenu, (menuItems: string[], sectionName: string) => { + const finalSectionName = sectionName.replace(/-/g, ' '); + if (this.props.shouldDisplaySectionHeaders) { + const id = utils.getIdFromName(sectionName); + return ( +
+
+ {finalSectionName.toUpperCase()} +
+ {this._renderMenuItems(menuItems)} +
+ ); + } else { + return
{this._renderMenuItems(menuItems)}
; + } + }); + return ( +
+ {this._renderEmblem()} + {!_.isUndefined(this.props.versions) && + !_.isUndefined(this.props.selectedVersion) && ( + + )} +
{navigation}
+
+ ); + } + private _renderEmblem() { + return ( +
+
+
+ 0x +
+
+ docs +
+
+
+ | +
+
+
+ +
+
+ {this.props.title} +
+
+
+ ); + } + private _renderMenuItems(menuItemNames: string[]): React.ReactNode[] { + const menuItemStyles = this.props.shouldDisplaySectionHeaders + ? styles.menuItemWithHeaders + : styles.menuItemWithoutHeaders; + const menuItemInnerDivStyles = this.props.shouldDisplaySectionHeaders ? styles.menuItemInnerDivWithHeaders : {}; + const menuItems = _.map(menuItemNames, menuItemName => { + const id = utils.getIdFromName(menuItemName); + return ( +
+ + + {menuItemName} + + + {this._renderMenuItemSubsections(menuItemName)} +
+ ); + }); + return menuItems; + } + private _renderMenuItemSubsections(menuItemName: string): React.ReactNode { + if (_.isUndefined(this.props.menuSubsectionsBySection[menuItemName])) { + return null; + } + return this._renderMenuSubsectionsBySection(menuItemName, this.props.menuSubsectionsBySection[menuItemName]); + } + private _renderMenuSubsectionsBySection(menuItemName: string, entityNames: string[]): React.ReactNode { + return ( +
    + {_.map(entityNames, entityName => { + const name = `${menuItemName}-${entityName}`; + const id = utils.getIdFromName(name); + return ( +
  • + + + {entityName} + + +
  • + ); + })} +
+ ); + } + private _onMenuItemClick(name: string): void { + const id = utils.getIdFromName(name); + utils.setUrlHash(id); + this.props.onMenuItemClick(); + } +} diff --git a/packages/react-shared/src/ts/components/section_header.tsx b/packages/react-shared/src/ts/components/section_header.tsx new file mode 100644 index 000000000..90fabf9ff --- /dev/null +++ b/packages/react-shared/src/ts/components/section_header.tsx @@ -0,0 +1,65 @@ +import * as React from 'react'; +import { Element as ScrollElement } from 'react-scroll'; + +import { HeaderSizes } from '../types'; +import { colors } from '../utils/colors'; +import { utils } from '../utils/utils'; + +import { AnchorTitle } from './anchor_title'; + +export interface SectionHeaderProps { + sectionName: string; + headerSize?: HeaderSizes; +} + +export interface SectionHeaderState { + shouldShowAnchor: boolean; +} + +export class SectionHeader extends React.Component { + public static defaultProps: Partial = { + headerSize: HeaderSizes.H2, + }; + constructor(props: SectionHeaderProps) { + super(props); + this.state = { + shouldShowAnchor: false, + }; + } + public render() { + const sectionName = this.props.sectionName.replace(/-/g, ' '); + const id = utils.getIdFromName(sectionName); + return ( +
+ + + {sectionName} + + } + id={id} + shouldShowAnchor={this.state.shouldShowAnchor} + /> + +
+ ); + } + private _setAnchorVisibility(shouldShowAnchor: boolean) { + this.setState({ + shouldShowAnchor, + }); + } +} diff --git a/packages/react-shared/src/ts/components/version_drop_down.tsx b/packages/react-shared/src/ts/components/version_drop_down.tsx new file mode 100644 index 000000000..86fe43507 --- /dev/null +++ b/packages/react-shared/src/ts/components/version_drop_down.tsx @@ -0,0 +1,46 @@ +import * as _ from 'lodash'; +import DropDownMenu from 'material-ui/DropDownMenu'; +import MenuItem from 'material-ui/MenuItem'; +import * as React from 'react'; + +import { utils } from '../utils/utils'; + +export interface VersionDropDownProps { + selectedVersion: string; + versions: string[]; +} + +export interface VersionDropDownState {} + +export class VersionDropDown extends React.Component { + public render() { + return ( +
+ + {this._renderDropDownItems()} + +
+ ); + } + private _renderDropDownItems() { + const items = _.map(this.props.versions, version => { + return ; + }); + return items; + } + private _updateSelectedVersion(e: any, index: number, semver: string) { + let path = window.location.pathname; + const lastChar = path[path.length - 1]; + if (_.isFinite(_.parseInt(lastChar))) { + const pathSections = path.split('/'); + pathSections.pop(); + path = pathSections.join('/'); + } + const baseUrl = utils.getCurrentBaseUrl(); + window.location.href = `${baseUrl}${path}/${semver}${window.location.hash}`; + } +} diff --git a/packages/react-shared/src/ts/constants.ts b/packages/react-shared/src/ts/constants.ts deleted file mode 100644 index 20d0c6e92..000000000 --- a/packages/react-shared/src/ts/constants.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const constants = { - DOCS_SCROLL_DURATION_MS: 0, - DOCS_CONTAINER_ID: 'documentation', -}; diff --git a/packages/react-shared/src/ts/globals.d.ts b/packages/react-shared/src/ts/globals.d.ts index e69de29bb..875721533 100644 --- a/packages/react-shared/src/ts/globals.d.ts +++ b/packages/react-shared/src/ts/globals.d.ts @@ -0,0 +1 @@ +declare module 'react-highlight'; diff --git a/packages/react-shared/src/ts/index.ts b/packages/react-shared/src/ts/index.ts index d33638e62..dde77b7b9 100644 --- a/packages/react-shared/src/ts/index.ts +++ b/packages/react-shared/src/ts/index.ts @@ -1,6 +1,12 @@ export { AnchorTitle } from './components/anchor_title'; +export { MarkdownLinkBlock } from './components/markdown_link_block'; +export { MarkdownCodeBlock } from './components/markdown_code_block'; +export { MarkdownSection } from './components/markdown_section'; +export { NestedSidebarMenu } from './components/nested_sidebar_menu'; +export { SectionHeader } from './components/section_header'; -export { HeaderSizes, Styles } from './types'; +export { HeaderSizes, Styles, MenuSubsectionsBySection } from './types'; -export { utils } from './utils'; -export { constants } from './constants'; +export { utils } from './utils/utils'; +export { constants } from './utils/constants'; +export { colors } from './utils/colors'; diff --git a/packages/react-shared/src/ts/types.ts b/packages/react-shared/src/ts/types.ts index e4fe7bff9..f9d561d1a 100644 --- a/packages/react-shared/src/ts/types.ts +++ b/packages/react-shared/src/ts/types.ts @@ -7,3 +7,7 @@ export enum HeaderSizes { H2 = 'h2', H3 = 'h3', } + +export interface MenuSubsectionsBySection { + [section: string]: string[]; +} diff --git a/packages/react-shared/src/ts/utils.ts b/packages/react-shared/src/ts/utils.ts deleted file mode 100644 index 822b67496..000000000 --- a/packages/react-shared/src/ts/utils.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const utils = { - setUrlHash(anchorId: string) { - window.location.hash = anchorId; - }, -}; diff --git a/packages/react-shared/src/ts/utils/colors.ts b/packages/react-shared/src/ts/utils/colors.ts new file mode 100644 index 000000000..2eead95c7 --- /dev/null +++ b/packages/react-shared/src/ts/utils/colors.ts @@ -0,0 +1,48 @@ +import { colors as materialUiColors } from 'material-ui/styles'; + +export const colors = { + ...materialUiColors, + gray40: '#F8F8F8', + grey50: '#FAFAFA', + grey100: '#F5F5F5', + lightestGrey: '#F0F0F0', + greyishPink: '#E6E5E5', + grey300: '#E0E0E0', + beigeWhite: '#E4E4E4', + grey350: '#cacaca', + grey400: '#BDBDBD', + lightGrey: '#BBBBBB', + grey500: '#9E9E9E', + grey: '#A5A5A5', + darkGrey: '#818181', + landingLinkGrey: '#919191', + grey700: '#616161', + grey750: '#515151', + grey800: '#424242', + darkerGrey: '#393939', + heroGrey: '#404040', + projectsGrey: '#343333', + darkestGrey: '#272727', + dharmaDarkGrey: '#252525', + lightBlue: '#60A4F4', + lightBlueA700: '#0091EA', + linkBlue: '#1D5CDE', + darkBlue: '#4D5481', + turquois: '#058789', + lightPurple: '#A81CA6', + purple: '#690596', + red200: '#EF9A9A', + red: '#E91751', + red500: '#F44336', + red600: '#E53935', + limeGreen: '#66DE75', + lightGreen: '#4DC55C', + lightestGreen: '#89C774', + brightGreen: '#00C33E', + green400: '#66BB6A', + green: '#4DA24B', + amber600: '#FFB300', + orange: '#E69D00', + amber800: '#FF8F00', + darkYellow: '#caca03', +}; diff --git a/packages/react-shared/src/ts/utils/constants.ts b/packages/react-shared/src/ts/utils/constants.ts new file mode 100644 index 000000000..79d1d9ca3 --- /dev/null +++ b/packages/react-shared/src/ts/utils/constants.ts @@ -0,0 +1,6 @@ +export const constants = { + DOCS_SCROLL_DURATION_MS: 0, + DOCS_CONTAINER_ID: 'documentation', + SCROLL_CONTAINER_ID: 'documentation', + SCROLL_TOP_ID: 'pageScrollTop', +}; diff --git a/packages/react-shared/src/ts/utils/utils.ts b/packages/react-shared/src/ts/utils/utils.ts new file mode 100644 index 000000000..7498342b6 --- /dev/null +++ b/packages/react-shared/src/ts/utils/utils.ts @@ -0,0 +1,32 @@ +import * as _ from 'lodash'; +import { scroller } from 'react-scroll'; + +import { constants } from './constants'; + +export const utils = { + setUrlHash(anchorId: string) { + window.location.hash = anchorId; + }, + scrollToHash(hash: string, containerId: string): void { + let finalHash = hash; + if (_.isEmpty(hash)) { + finalHash = constants.SCROLL_TOP_ID; // scroll to the top + } + + scroller.scrollTo(finalHash, { + duration: 0, + offset: 0, + containerId, + }); + }, + getIdFromName(name: string) { + const id = name.replace(/ /g, '-'); + return id; + }, + getCurrentBaseUrl() { + const port = window.location.port; + const hasPort = !_.isUndefined(port); + const baseUrl = `https://${window.location.hostname}${hasPort ? `:${port}` : ''}`; + return baseUrl; + }, +}; -- cgit v1.2.3 From 0b1ba9f9971bea9003dfb30fca535c17ce62ad08 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 6 Mar 2018 16:31:55 +0100 Subject: Move Documentation to the `@0xproject/react-docs` package --- packages/react-shared/package.json | 1 + packages/react-shared/src/ts/globals.d.ts | 6 ++++++ packages/react-shared/src/ts/index.ts | 2 +- packages/react-shared/src/ts/types.ts | 12 ++++++++++++ packages/react-shared/src/ts/utils/constants.ts | 14 ++++++++++++++ packages/react-shared/src/ts/utils/utils.ts | 15 +++++++++++++++ 6 files changed, 49 insertions(+), 1 deletion(-) (limited to 'packages/react-shared') diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json index e96659e47..4b9055e60 100644 --- a/packages/react-shared/package.json +++ b/packages/react-shared/package.json @@ -25,6 +25,7 @@ }, "dependencies": { "basscss": "^8.0.3", + "is-mobile": "^0.2.2", "material-ui": "^0.17.1", "react": "15.6.1", "react-dom": "15.6.1", diff --git a/packages/react-shared/src/ts/globals.d.ts b/packages/react-shared/src/ts/globals.d.ts index 875721533..9b0bcf845 100644 --- a/packages/react-shared/src/ts/globals.d.ts +++ b/packages/react-shared/src/ts/globals.d.ts @@ -1 +1,7 @@ declare module 'react-highlight'; + +// is-mobile declarations +declare function isMobile(): boolean; +declare module 'is-mobile' { + export = isMobile; +} diff --git a/packages/react-shared/src/ts/index.ts b/packages/react-shared/src/ts/index.ts index dde77b7b9..3b50c0117 100644 --- a/packages/react-shared/src/ts/index.ts +++ b/packages/react-shared/src/ts/index.ts @@ -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'; diff --git a/packages/react-shared/src/ts/types.ts b/packages/react-shared/src/ts/types.ts index f9d561d1a..88fadcc09 100644 --- a/packages/react-shared/src/ts/types.ts +++ b/packages/react-shared/src/ts/types.ts @@ -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', +} diff --git a/packages/react-shared/src/ts/utils/constants.ts b/packages/react-shared/src/ts/utils/constants.ts index 79d1d9ca3..562ab776b 100644 --- a/packages/react-shared/src/ts/utils/constants.ts +++ b/packages/react-shared/src/ts/utils/constants.ts @@ -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 }, }; diff --git a/packages/react-shared/src/ts/utils/utils.ts b/packages/react-shared/src/ts/utils/utils.ts index 7498342b6..0d2e045b8 100644 --- a/packages/react-shared/src/ts/utils/utils.ts +++ b/packages/react-shared/src/ts/utils/utils.ts @@ -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}`; + }, }; -- cgit v1.2.3 From 01e505a5f4b514d285eedc6456d819d0649032d4 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 6 Mar 2018 20:14:55 +0100 Subject: Add publishConfig to package.json so that packages are published as public under the @0xproject namespace --- packages/react-shared/package.json | 3 +++ 1 file changed, 3 insertions(+) (limited to 'packages/react-shared') diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json index 4b9055e60..46dad47aa 100644 --- a/packages/react-shared/package.json +++ b/packages/react-shared/package.json @@ -33,5 +33,8 @@ "react-scroll": "^1.5.2", "react-tap-event-plugin": "^2.0.1", "react-highlight": "0xproject/react-highlight" + }, + "publishConfig": { + "access": "public" } } -- cgit v1.2.3 From f8b8a10b8f914d05edfbc57081a40dccc8f464de Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 6 Mar 2018 20:38:45 +0100 Subject: Make sidebar header configurable --- .../src/ts/components/nested_sidebar_menu.tsx | 36 ++-------------------- 1 file changed, 2 insertions(+), 34 deletions(-) (limited to 'packages/react-shared') diff --git a/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx b/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx index 2506124af..f907022d6 100644 --- a/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx +++ b/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx @@ -13,7 +13,7 @@ import { VersionDropDown } from './version_drop_down'; export interface NestedSidebarMenuProps { topLevelMenu: { [topLevel: string]: string[] }; menuSubsectionsBySection: MenuSubsectionsBySection; - title: string; + sidebarHeader?: React.ReactNode; shouldDisplaySectionHeaders?: boolean; onMenuItemClick?: () => void; selectedVersion?: string; @@ -37,13 +37,6 @@ const styles: Styles = { }, }; -const titleToIcon: { [title: string]: string } = { - '0x.js': 'zeroExJs.png', - '0x Connect': 'connect.png', - '0x Smart Contracts': 'contracts.png', - Wiki: 'wiki.png', -}; - export class NestedSidebarMenu extends React.Component { public static defaultProps: Partial = { shouldDisplaySectionHeaders: true, @@ -68,7 +61,7 @@ export class NestedSidebarMenu extends React.Component - {this._renderEmblem()} + {this.props.sidebarHeader} {!_.isUndefined(this.props.versions) && !_.isUndefined(this.props.selectedVersion) && ( @@ -77,31 +70,6 @@ export class NestedSidebarMenu extends React.Component ); } - private _renderEmblem() { - return ( -
-
-
- 0x -
-
- docs -
-
-
- | -
-
-
- -
-
- {this.props.title} -
-
-
- ); - } private _renderMenuItems(menuItemNames: string[]): React.ReactNode[] { const menuItemStyles = this.props.shouldDisplaySectionHeaders ? styles.menuItemWithHeaders -- cgit v1.2.3 From f191ba6e6990fec3f973ee78f75547e5a828785a Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 7 Mar 2018 10:50:51 +0100 Subject: hide sidebar scrollbar unless onHover --- packages/react-shared/src/ts/components/nested_sidebar_menu.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'packages/react-shared') diff --git a/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx b/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx index f907022d6..6a3cf2615 100644 --- a/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx +++ b/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx @@ -59,12 +59,18 @@ export class NestedSidebarMenu extends React.Component{this._renderMenuItems(menuItems)}; } }); + const maxWidthWithScrollbar = 307; return (
{this.props.sidebarHeader} {!_.isUndefined(this.props.versions) && !_.isUndefined(this.props.selectedVersion) && ( - +
+ +
)}
{navigation}
-- cgit v1.2.3 From 6f8a70834b72d678cd9d171d7bb0a3a2cfb4134d Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 7 Mar 2018 13:25:15 +0100 Subject: Add onSelectedVersion callback so it can be handled in any way the caller wishes --- .../react-shared/src/ts/components/nested_sidebar_menu.tsx | 2 ++ packages/react-shared/src/ts/components/version_drop_down.tsx | 11 ++--------- packages/react-shared/src/ts/utils/utils.ts | 6 ------ 3 files changed, 4 insertions(+), 15 deletions(-) (limited to 'packages/react-shared') diff --git a/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx b/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx index 6a3cf2615..f562b3113 100644 --- a/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx +++ b/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx @@ -18,6 +18,7 @@ export interface NestedSidebarMenuProps { onMenuItemClick?: () => void; selectedVersion?: string; versions?: string[]; + onVersionSelected?: (semver: string) => void; } export interface NestedSidebarMenuState {} @@ -69,6 +70,7 @@ export class NestedSidebarMenu extends React.Component )} diff --git a/packages/react-shared/src/ts/components/version_drop_down.tsx b/packages/react-shared/src/ts/components/version_drop_down.tsx index 86fe43507..d9e49b205 100644 --- a/packages/react-shared/src/ts/components/version_drop_down.tsx +++ b/packages/react-shared/src/ts/components/version_drop_down.tsx @@ -8,6 +8,7 @@ import { utils } from '../utils/utils'; export interface VersionDropDownProps { selectedVersion: string; versions: string[]; + onVersionSelected: (semver: string) => void; } export interface VersionDropDownState {} @@ -33,14 +34,6 @@ export class VersionDropDown extends React.Component Date: Thu, 8 Mar 2018 15:56:49 +0100 Subject: remove no-implicit-this --- packages/react-shared/tsconfig.json | 1 - 1 file changed, 1 deletion(-) (limited to 'packages/react-shared') diff --git a/packages/react-shared/tsconfig.json b/packages/react-shared/tsconfig.json index 6e71fb2e4..44055a037 100644 --- a/packages/react-shared/tsconfig.json +++ b/packages/react-shared/tsconfig.json @@ -5,7 +5,6 @@ "jsx": "react", "baseUrl": "./", "strictNullChecks": false, - "noImplicitThis": false, "paths": { "*": ["node_modules/@types/*", "*"] } -- cgit v1.2.3 From a0030c7bdb8384962160db44030c2904f5e0bb98 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 8 Mar 2018 15:56:56 +0100 Subject: update license --- packages/react-shared/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/react-shared') diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json index 46dad47aa..acef63fc6 100644 --- a/packages/react-shared/package.json +++ b/packages/react-shared/package.json @@ -11,7 +11,7 @@ "clean": "shx rm -rf lib" }, "author": "Fabio Berger", - "license": "MIT", + "license": "Apache-2.0", "devDependencies": { "@0xproject/tslint-config": "^0.4.9", "@types/lodash": "^4.14.86", -- cgit v1.2.3 From f9ec8a0828b7f75276491e496a4ae62e5301a6f3 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 8 Mar 2018 16:00:15 +0100 Subject: remove ability to have implicit dependencies and add missing deps --- packages/react-shared/package.json | 2 ++ packages/react-shared/tslint.json | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'packages/react-shared') diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json index acef63fc6..b5f15bad3 100644 --- a/packages/react-shared/package.json +++ b/packages/react-shared/package.json @@ -19,6 +19,7 @@ "@types/material-ui": "0.18.0", "@types/react": "^15.0.15", "@types/react-dom": "^0.14.23", + "@types/react-scroll": "0.0.31", "shx": "^0.2.2", "tslint": "^5.9.1", "typescript": "2.7.1" @@ -30,6 +31,7 @@ "react": "15.6.1", "react-dom": "15.6.1", "lodash": "^4.17.4", + "react-markdown": "^3.2.2", "react-scroll": "^1.5.2", "react-tap-event-plugin": "^2.0.1", "react-highlight": "0xproject/react-highlight" diff --git a/packages/react-shared/tslint.json b/packages/react-shared/tslint.json index d6a5f5031..ee918e360 100644 --- a/packages/react-shared/tslint.json +++ b/packages/react-shared/tslint.json @@ -1,7 +1,6 @@ { "extends": ["@0xproject/tslint-config"], "rules": { - "no-implicit-dependencies": false, "no-object-literal-type-assertion": false, "completed-docs": false, "prefer-function-over-method": false -- cgit v1.2.3 From 8057f4a678f5e4c00241ec9b15bd9d4dfc3588df Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 8 Mar 2018 16:19:39 +0100 Subject: Add back strict null checks to react-shared package and fix issues --- .../react-shared/src/ts/components/markdown_section.tsx | 17 ++++++++++++----- .../src/ts/components/nested_sidebar_menu.tsx | 7 +++++-- .../react-shared/src/ts/components/section_header.tsx | 16 ++++++++++++---- packages/react-shared/src/ts/utils/utils.ts | 2 +- packages/react-shared/tsconfig.json | 1 - 5 files changed, 30 insertions(+), 13 deletions(-) (limited to 'packages/react-shared') diff --git a/packages/react-shared/src/ts/components/markdown_section.tsx b/packages/react-shared/src/ts/components/markdown_section.tsx index 682b6ef8f..95dc83eaf 100644 --- a/packages/react-shared/src/ts/components/markdown_section.tsx +++ b/packages/react-shared/src/ts/components/markdown_section.tsx @@ -19,6 +19,12 @@ export interface MarkdownSectionProps { githubLink?: string; } +interface DefaultMarkdownSectionProps { + headerSize: HeaderSizes; +} + +type PropsWithDefaults = MarkdownSectionProps & DefaultMarkdownSectionProps; + export interface MarkdownSectionState { shouldShowAnchor: boolean; } @@ -34,7 +40,8 @@ export class MarkdownSection extends React.Component
- {!_.isUndefined(this.props.githubLink) && ( + {!_.isUndefined(githubLink) && ( @@ -68,7 +75,7 @@ export class MarkdownSection extends React.Component
{this.props.sidebarHeader} {!_.isUndefined(this.props.versions) && - !_.isUndefined(this.props.selectedVersion) && ( + !_.isUndefined(this.props.selectedVersion) && + !_.isUndefined(this.props.onVersionSelected) && (
- {sectionName} + {finalSectionName} } id={id} diff --git a/packages/react-shared/src/ts/utils/utils.ts b/packages/react-shared/src/ts/utils/utils.ts index ebe896bbc..9e848392f 100644 --- a/packages/react-shared/src/ts/utils/utils.ts +++ b/packages/react-shared/src/ts/utils/utils.ts @@ -30,7 +30,7 @@ export const utils = { const id = name.replace(/ /g, '-'); return id; }, - getEtherScanLinkIfExists(addressOrTxHash: string, networkId: number, suffix: EtherscanLinkSuffixes): string { + getEtherScanLinkIfExists(addressOrTxHash: string, networkId: number, suffix: EtherscanLinkSuffixes): string|undefined { const networkName = constants.NETWORK_NAME_BY_ID[networkId]; if (_.isUndefined(networkName)) { return undefined; diff --git a/packages/react-shared/tsconfig.json b/packages/react-shared/tsconfig.json index 44055a037..de87aa45b 100644 --- a/packages/react-shared/tsconfig.json +++ b/packages/react-shared/tsconfig.json @@ -4,7 +4,6 @@ "outDir": "./lib/", "jsx": "react", "baseUrl": "./", - "strictNullChecks": false, "paths": { "*": ["node_modules/@types/*", "*"] } -- cgit v1.2.3 From 2a24f6e2ea9bc4f879c9dff2a60c92dec0e1cc48 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 8 Mar 2018 16:47:49 +0100 Subject: Fix prettier issues --- packages/react-shared/src/ts/components/markdown_section.tsx | 2 +- packages/react-shared/src/ts/components/section_header.tsx | 2 +- packages/react-shared/src/ts/utils/utils.ts | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'packages/react-shared') diff --git a/packages/react-shared/src/ts/components/markdown_section.tsx b/packages/react-shared/src/ts/components/markdown_section.tsx index 95dc83eaf..d24a43dcb 100644 --- a/packages/react-shared/src/ts/components/markdown_section.tsx +++ b/packages/react-shared/src/ts/components/markdown_section.tsx @@ -20,7 +20,7 @@ export interface MarkdownSectionProps { } interface DefaultMarkdownSectionProps { - headerSize: HeaderSizes; + headerSize: HeaderSizes; } type PropsWithDefaults = MarkdownSectionProps & DefaultMarkdownSectionProps; diff --git a/packages/react-shared/src/ts/components/section_header.tsx b/packages/react-shared/src/ts/components/section_header.tsx index e782783f3..ee34a6c09 100644 --- a/packages/react-shared/src/ts/components/section_header.tsx +++ b/packages/react-shared/src/ts/components/section_header.tsx @@ -13,7 +13,7 @@ export interface SectionHeaderProps { } interface DefaultSectionHeaderProps { - headerSize: HeaderSizes; + headerSize: HeaderSizes; } type PropsWithDefaults = SectionHeaderProps & DefaultSectionHeaderProps; diff --git a/packages/react-shared/src/ts/utils/utils.ts b/packages/react-shared/src/ts/utils/utils.ts index 9e848392f..b3acb081e 100644 --- a/packages/react-shared/src/ts/utils/utils.ts +++ b/packages/react-shared/src/ts/utils/utils.ts @@ -30,7 +30,11 @@ export const utils = { const id = name.replace(/ /g, '-'); return id; }, - getEtherScanLinkIfExists(addressOrTxHash: string, networkId: number, suffix: EtherscanLinkSuffixes): string|undefined { + getEtherScanLinkIfExists( + addressOrTxHash: string, + networkId: number, + suffix: EtherscanLinkSuffixes, + ): string | undefined { const networkName = constants.NETWORK_NAME_BY_ID[networkId]; if (_.isUndefined(networkName)) { return undefined; -- cgit v1.2.3 From c71b710d7ea194095ddeba9e882c023f97a30338 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Thu, 8 Mar 2018 10:14:51 -0800 Subject: Updated CHANGELOGs --- packages/react-shared/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/react-shared') diff --git a/packages/react-shared/CHANGELOG.md b/packages/react-shared/CHANGELOG.md index 7c3ac2adf..43b92d58a 100644 --- a/packages/react-shared/CHANGELOG.md +++ b/packages/react-shared/CHANGELOG.md @@ -1,3 +1,3 @@ # CHANGELOG -## vX.X.X - _TBD, 2018_ +## v0.0.1 - _March 8, 2018_ -- cgit v1.2.3 From 8e5a876b37990656bc19c873c926dd2c434e2ead Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Thu, 8 Mar 2018 10:20:46 -0800 Subject: Publish - 0x.js@0.33.1 - @0xproject/abi-gen@0.2.5 - @0xproject/assert@0.2.0 - @0xproject/base-contract@0.0.3 - @0xproject/connect@0.6.3 - contracts@2.1.15 - @0xproject/deployer@0.2.1 - @0xproject/dev-utils@0.2.1 - @0xproject/json-schemas@0.7.14 - @0xproject/react-docs@0.0.1 - @0xproject/react-shared@0.0.1 - @0xproject/sra-report@0.0.1 - @0xproject/subproviders@0.7.0 - @0xproject/testnet-faucets@1.0.16 - @0xproject/types@0.3.1 - @0xproject/utils@0.4.1 - @0xproject/web3-wrapper@0.2.1 - @0xproject/website@0.0.18 --- packages/react-shared/package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'packages/react-shared') diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json index b5f15bad3..368e1acc9 100644 --- a/packages/react-shared/package.json +++ b/packages/react-shared/package.json @@ -15,8 +15,8 @@ "devDependencies": { "@0xproject/tslint-config": "^0.4.9", "@types/lodash": "^4.14.86", - "@types/node": "^8.0.53", "@types/material-ui": "0.18.0", + "@types/node": "^8.0.53", "@types/react": "^15.0.15", "@types/react-dom": "^0.14.23", "@types/react-scroll": "0.0.31", @@ -27,14 +27,14 @@ "dependencies": { "basscss": "^8.0.3", "is-mobile": "^0.2.2", + "lodash": "^4.17.4", "material-ui": "^0.17.1", "react": "15.6.1", "react-dom": "15.6.1", - "lodash": "^4.17.4", + "react-highlight": "0xproject/react-highlight", "react-markdown": "^3.2.2", "react-scroll": "^1.5.2", - "react-tap-event-plugin": "^2.0.1", - "react-highlight": "0xproject/react-highlight" + "react-tap-event-plugin": "^2.0.1" }, "publishConfig": { "access": "public" -- cgit v1.2.3