aboutsummaryrefslogtreecommitdiffstats
path: root/packages/react-shared
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-08-14 09:42:09 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-08-14 09:42:09 +0800
commit88766a02c7e6688e72d5c4c69ce68028b322f154 (patch)
treefa06552a80249e7998691b64df6b3b2827f9f947 /packages/react-shared
parent8162394797342cef268cc8072fc860326974e269 (diff)
parentfadd292ecf367e42154856509d0ea0c20b23f2f1 (diff)
downloaddexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.tar
dexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.tar.gz
dexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.tar.bz2
dexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.tar.lz
dexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.tar.xz
dexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.tar.zst
dexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.zip
Merge branch 'development'
Diffstat (limited to 'packages/react-shared')
-rw-r--r--packages/react-shared/CHANGELOG.json156
-rw-r--r--packages/react-shared/CHANGELOG.md70
-rw-r--r--packages/react-shared/README.md22
-rw-r--r--packages/react-shared/package.json25
-rw-r--r--packages/react-shared/src/components/anchor_title.tsx23
-rw-r--r--packages/react-shared/src/components/markdown_code_block.tsx5
-rw-r--r--packages/react-shared/src/components/markdown_link_block.tsx6
-rw-r--r--packages/react-shared/src/components/markdown_section.tsx5
-rw-r--r--packages/react-shared/src/components/nested_sidebar_menu.tsx5
-rw-r--r--packages/react-shared/src/components/section_header.tsx6
-rw-r--r--packages/react-shared/src/components/version_drop_down.tsx8
-rw-r--r--packages/react-shared/src/globals.d.ts8
-rw-r--r--packages/react-shared/src/utils/colors.ts15
-rw-r--r--packages/react-shared/src/utils/utils.ts6
-rw-r--r--packages/react-shared/tslint.json3
15 files changed, 289 insertions, 74 deletions
diff --git a/packages/react-shared/CHANGELOG.json b/packages/react-shared/CHANGELOG.json
index 248b740bc..1268bcc7b 100644
--- a/packages/react-shared/CHANGELOG.json
+++ b/packages/react-shared/CHANGELOG.json
@@ -1,5 +1,158 @@
[
{
+ "timestamp": 1534210131,
+ "version": "1.0.6",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
+ "timestamp": 1532619515,
+ "version": "1.0.5",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
+ "timestamp": 1532614997,
+ "version": "1.0.4",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
+ "timestamp": 1532605697,
+ "version": "1.0.3",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
+ "timestamp": 1532551340,
+ "version": "1.0.2",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
+ "timestamp": 1532357734,
+ "version": "1.0.1",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
+ "timestamp": 1532043000,
+ "version": "1.0.0",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
+ "timestamp": 1531919263,
+ "version": "0.2.3",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
+ "timestamp": 1531149657,
+ "version": "0.2.2",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
+ "timestamp": 1529397769,
+ "version": "0.2.1",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
+ "timestamp": 1525477860,
+ "version": "0.2.0",
+ "changes": [
+ {
+ "note": "Removed portal specific colors"
+ }
+ ]
+ },
+ {
+ "timestamp": 1525477860,
+ "version": "0.1.6",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
+ "timestamp": 1525466747,
+ "version": "0.1.5",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
+ "timestamp": 1525428773,
+ "version": "0.1.4",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
+ "timestamp": 1524044013,
+ "version": "0.1.3",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
+ "timestamp": 1523462196,
+ "version": "0.1.2",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
+ "timestamp": 1522673609,
+ "version": "0.1.1",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"version": "0.1.0",
"changes": [
{
@@ -13,7 +166,6 @@
"note": "Reorganized colors and added new ones"
}
],
- "timestamp": 1522658513,
- "isPublished": true
+ "timestamp": 1522658513
}
]
diff --git a/packages/react-shared/CHANGELOG.md b/packages/react-shared/CHANGELOG.md
index 36e8097a8..cfbaf6c70 100644
--- a/packages/react-shared/CHANGELOG.md
+++ b/packages/react-shared/CHANGELOG.md
@@ -1,10 +1,78 @@
<!--
-This file is auto-generated using the monorepo-scripts package. Don't edit directly.
+changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
Edit the package's CHANGELOG.json file only.
-->
CHANGELOG
+## v1.0.6 - _August 13, 2018_
+
+ * Dependencies updated
+
+## v1.0.5 - _July 26, 2018_
+
+ * Dependencies updated
+
+## v1.0.4 - _July 26, 2018_
+
+ * Dependencies updated
+
+## v1.0.3 - _July 26, 2018_
+
+ * Dependencies updated
+
+## v1.0.2 - _July 25, 2018_
+
+ * Dependencies updated
+
+## v1.0.1 - _July 23, 2018_
+
+ * Dependencies updated
+
+## v1.0.0 - _July 19, 2018_
+
+ * Dependencies updated
+
+## v0.2.3 - _July 18, 2018_
+
+ * Dependencies updated
+
+## v0.2.2 - _July 9, 2018_
+
+ * Dependencies updated
+
+## v0.2.1 - _June 19, 2018_
+
+ * Dependencies updated
+
+## v0.2.0 - _May 4, 2018_
+
+ * Removed portal specific colors
+
+## v0.1.6 - _May 4, 2018_
+
+ * Dependencies updated
+
+## v0.1.5 - _May 4, 2018_
+
+ * Dependencies updated
+
+## v0.1.4 - _May 4, 2018_
+
+ * Dependencies updated
+
+## v0.1.3 - _April 18, 2018_
+
+ * Dependencies updated
+
+## v0.1.2 - _April 11, 2018_
+
+ * Dependencies updated
+
+## v0.1.1 - _April 2, 2018_
+
+ * Dependencies updated
+
## v0.1.0 - _April 2, 2018_
* Added new colors (#468)
diff --git a/packages/react-shared/README.md b/packages/react-shared/README.md
index 9165cf78d..88e6f18ae 100644
--- a/packages/react-shared/README.md
+++ b/packages/react-shared/README.md
@@ -18,11 +18,11 @@ If your project is in [TypeScript](https://www.typescriptlang.org/), add the fol
## 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.
+We welcome improvements and fixes from the wider community! 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
+### Install dependencies
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
@@ -38,18 +38,26 @@ yarn install
### Build
+To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
+
```bash
-yarn build
+PKG=@0xproject/react-shared yarn build
```
-### Lint
+Or continuously rebuild on change:
```bash
-yarn lint
+PKG=@0xproject/react-shared yarn watch
```
-### Run Tests
+### Clean
```bash
-yarn test
+yarn clean
+```
+
+### Lint
+
+```bash
+yarn lint
```
diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json
index 3a6d6a24e..9761c246e 100644
--- a/packages/react-shared/package.json
+++ b/packages/react-shared/package.json
@@ -1,13 +1,16 @@
{
"name": "@0xproject/react-shared",
- "version": "0.1.0",
+ "version": "1.0.6",
+ "engines": {
+ "node": ">=6.12"
+ },
"description": "0x shared react components",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
- "lint": "tslint --project . 'src/**/*.ts' 'src/**/*.tsx'",
+ "lint": "tslint --project .",
"build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts",
- "build:watch": "tsc -w",
+ "watch_without_deps": "tsc -w",
"clean": "shx rm -rf lib scripts",
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
},
@@ -22,24 +25,26 @@
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"devDependencies": {
- "@0xproject/dev-utils": "^0.3.3",
- "@0xproject/monorepo-scripts": "^0.1.15",
- "@0xproject/tslint-config": "^0.4.13",
+ "@0xproject/dev-utils": "^1.0.4",
+ "@0xproject/monorepo-scripts": "^1.0.5",
+ "@0xproject/tslint-config": "^1.0.5",
"copyfiles": "^1.2.0",
+ "make-promises-safe": "^1.1.0",
"shx": "^0.2.2",
"tslint": "^5.9.1",
- "typescript": "2.7.1"
+ "typescript": "2.9.2"
},
"dependencies": {
+ "@types/is-mobile": "0.3.0",
"@types/lodash": "4.14.104",
"@types/material-ui": "0.18.0",
"@types/node": "^8.0.53",
- "@types/react": "^16.0.34",
- "@types/react-dom": "^16.0.3",
+ "@types/react": "*",
+ "@types/react-dom": "*",
"@types/react-scroll": "0.0.31",
"basscss": "^8.0.3",
"is-mobile": "^0.2.2",
- "lodash": "^4.17.4",
+ "lodash": "^4.17.5",
"material-ui": "^0.17.1",
"react": "15.6.1",
"react-dom": "15.6.1",
diff --git a/packages/react-shared/src/components/anchor_title.tsx b/packages/react-shared/src/components/anchor_title.tsx
index f44354097..473b994bf 100644
--- a/packages/react-shared/src/components/anchor_title.tsx
+++ b/packages/react-shared/src/components/anchor_title.tsx
@@ -27,12 +27,6 @@ const styles: Styles = {
transform: 'rotate(45deg)',
cursor: 'pointer',
},
- headers: {
- WebkitMarginStart: 0,
- WebkitMarginEnd: 0,
- fontWeight: 'bold',
- display: 'block',
- },
h1: {
fontSize: '1.8em',
},
@@ -52,13 +46,24 @@ export class AnchorTitle extends React.Component<AnchorTitleProps, AnchorTitleSt
isHovering: false,
};
}
- public render() {
+ public render(): React.ReactNode {
let opacity = 0;
if (this.props.shouldShowAnchor) {
opacity = this.state.isHovering ? 0.6 : 1;
}
return (
- <div className="relative flex" style={{ ...styles[this.props.headerSize], ...styles.headers }}>
+ <div
+ className="relative flex"
+ style={
+ {
+ ...styles[this.props.headerSize],
+ fontWeight: 'bold',
+ display: 'block',
+ WebkitMarginStart: 0,
+ WebkitMarginEnd: 0,
+ } as any
+ }
+ >
<div className="inline-block" style={{ paddingRight: 4 }}>
{this.props.title}
</div>
@@ -79,7 +84,7 @@ export class AnchorTitle extends React.Component<AnchorTitleProps, AnchorTitleSt
</div>
);
}
- private _setHoverState(isHovering: boolean) {
+ private _setHoverState(isHovering: boolean): void {
this.setState({
isHovering,
});
diff --git a/packages/react-shared/src/components/markdown_code_block.tsx b/packages/react-shared/src/components/markdown_code_block.tsx
index 2070bb8e1..3b28424cd 100644
--- a/packages/react-shared/src/components/markdown_code_block.tsx
+++ b/packages/react-shared/src/components/markdown_code_block.tsx
@@ -1,4 +1,3 @@
-import * as _ from 'lodash';
import * as React from 'react';
import * as HighLight from 'react-highlight';
@@ -12,10 +11,10 @@ export interface MarkdownCodeBlockState {}
export class MarkdownCodeBlock extends React.Component<MarkdownCodeBlockProps, MarkdownCodeBlockState> {
// 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) {
+ public shouldComponentUpdate(nextProps: MarkdownCodeBlockProps, _nextState: MarkdownCodeBlockState): boolean {
return nextProps.value !== this.props.value || nextProps.language !== this.props.language;
}
- public render() {
+ public render(): React.ReactNode {
return (
<span style={{ fontSize: 14 }}>
<HighLight className={this.props.language || 'javascript'}>{this.props.value}</HighLight>
diff --git a/packages/react-shared/src/components/markdown_link_block.tsx b/packages/react-shared/src/components/markdown_link_block.tsx
index 8f5862249..f083a91cf 100644
--- a/packages/react-shared/src/components/markdown_link_block.tsx
+++ b/packages/react-shared/src/components/markdown_link_block.tsx
@@ -13,10 +13,10 @@ export interface MarkdownLinkBlockState {}
export class MarkdownLinkBlock extends React.Component<MarkdownLinkBlockProps, MarkdownLinkBlockState> {
// 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) {
+ public shouldComponentUpdate(nextProps: MarkdownLinkBlockProps, _nextState: MarkdownLinkBlockState): boolean {
return nextProps.href !== this.props.href;
}
- public render() {
+ public render(): React.ReactNode {
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
@@ -39,7 +39,7 @@ export class MarkdownLinkBlock extends React.Component<MarkdownLinkBlockProps, M
return <a href={href}>{this.props.children}</a>;
}
}
- private _onHashUrlClick(href: string) {
+ private _onHashUrlClick(href: string): void {
const hash = href.split('#')[1];
utils.scrollToHash(hash, constants.SCROLL_CONTAINER_ID);
utils.setUrlHash(hash);
diff --git a/packages/react-shared/src/components/markdown_section.tsx b/packages/react-shared/src/components/markdown_section.tsx
index 449e8a045..3b65b3075 100644
--- a/packages/react-shared/src/components/markdown_section.tsx
+++ b/packages/react-shared/src/components/markdown_section.tsx
@@ -1,5 +1,4 @@
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';
@@ -39,7 +38,7 @@ export class MarkdownSection extends React.Component<MarkdownSectionProps, Markd
shouldShowAnchor: false,
};
}
- public render() {
+ public render(): React.ReactNode {
const { sectionName, markdownContent, headerSize, githubLink } = this.props as PropsWithDefaults;
const id = utils.getIdFromName(sectionName);
@@ -87,7 +86,7 @@ export class MarkdownSection extends React.Component<MarkdownSectionProps, Markd
</div>
);
}
- private _setAnchorVisibility(shouldShowAnchor: boolean) {
+ private _setAnchorVisibility(shouldShowAnchor: boolean): void {
this.setState({
shouldShowAnchor,
});
diff --git a/packages/react-shared/src/components/nested_sidebar_menu.tsx b/packages/react-shared/src/components/nested_sidebar_menu.tsx
index f49d6fcf7..aa00d5985 100644
--- a/packages/react-shared/src/components/nested_sidebar_menu.tsx
+++ b/packages/react-shared/src/components/nested_sidebar_menu.tsx
@@ -41,12 +41,13 @@ const styles: Styles = {
export class NestedSidebarMenu extends React.Component<NestedSidebarMenuProps, NestedSidebarMenuState> {
public static defaultProps: Partial<NestedSidebarMenuProps> = {
shouldDisplaySectionHeaders: true,
- onMenuItemClick: _.noop,
+ onMenuItemClick: _.noop.bind(_),
};
- public render() {
+ public render(): React.ReactNode {
const navigation = _.map(this.props.topLevelMenu, (menuItems: string[], sectionName: string) => {
const finalSectionName = utils.convertDashesToSpaces(sectionName);
if (this.props.shouldDisplaySectionHeaders) {
+ // tslint:disable-next-line:no-unused-variable
const id = utils.getIdFromName(sectionName);
return (
<div key={`section-${sectionName}`} className="py1" style={{ color: colors.grey800 }}>
diff --git a/packages/react-shared/src/components/section_header.tsx b/packages/react-shared/src/components/section_header.tsx
index 0224c2127..137b63765 100644
--- a/packages/react-shared/src/components/section_header.tsx
+++ b/packages/react-shared/src/components/section_header.tsx
@@ -32,8 +32,8 @@ export class SectionHeader extends React.Component<SectionHeaderProps, SectionHe
shouldShowAnchor: false,
};
}
- public render() {
- const { sectionName, headerSize } = this.props as PropsWithDefaults;
+ public render(): React.ReactNode {
+ const { headerSize } = this.props as PropsWithDefaults;
const finalSectionName = utils.convertDashesToSpaces(this.props.sectionName);
const id = utils.getIdFromName(finalSectionName);
@@ -65,7 +65,7 @@ export class SectionHeader extends React.Component<SectionHeaderProps, SectionHe
</div>
);
}
- private _setAnchorVisibility(shouldShowAnchor: boolean) {
+ private _setAnchorVisibility(shouldShowAnchor: boolean): void {
this.setState({
shouldShowAnchor,
});
diff --git a/packages/react-shared/src/components/version_drop_down.tsx b/packages/react-shared/src/components/version_drop_down.tsx
index d9e49b205..e41590957 100644
--- a/packages/react-shared/src/components/version_drop_down.tsx
+++ b/packages/react-shared/src/components/version_drop_down.tsx
@@ -3,8 +3,6 @@ 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[];
@@ -14,7 +12,7 @@ export interface VersionDropDownProps {
export interface VersionDropDownState {}
export class VersionDropDown extends React.Component<VersionDropDownProps, VersionDropDownState> {
- public render() {
+ public render(): React.ReactNode {
return (
<div className="mx-auto" style={{ width: 120 }}>
<DropDownMenu
@@ -27,13 +25,13 @@ export class VersionDropDown extends React.Component<VersionDropDownProps, Versi
</div>
);
}
- private _renderDropDownItems() {
+ private _renderDropDownItems(): React.ReactNode[] {
const items = _.map(this.props.versions, version => {
return <MenuItem key={version} value={version} primaryText={`v${version}`} />;
});
return items;
}
- private _updateSelectedVersion(e: any, index: number, semver: string) {
+ private _updateSelectedVersion(_e: any, _index: number, semver: string): void {
this.props.onVersionSelected(semver);
}
}
diff --git a/packages/react-shared/src/globals.d.ts b/packages/react-shared/src/globals.d.ts
index 525563e23..94e63a32d 100644
--- a/packages/react-shared/src/globals.d.ts
+++ b/packages/react-shared/src/globals.d.ts
@@ -1,11 +1,3 @@
-declare module 'react-highlight';
-
-// is-mobile declarations
-declare function isMobile(): boolean;
-declare module 'is-mobile' {
- export = isMobile;
-}
-
declare module '*.json' {
const json: any;
/* tslint:disable */
diff --git a/packages/react-shared/src/utils/colors.ts b/packages/react-shared/src/utils/colors.ts
index 7613414ae..7d047a50e 100644
--- a/packages/react-shared/src/utils/colors.ts
+++ b/packages/react-shared/src/utils/colors.ts
@@ -22,12 +22,12 @@ const baseColors = {
heroGrey: '#404040',
projectsGrey: '#343333',
darkestGrey: '#272727',
- dharmaDarkGrey: '#252525',
lightBlue: '#60A4F4',
lightBlueA700: '#0091EA',
linkBlue: '#1D5CDE',
mediumBlue: '#488AEA',
darkBlue: '#4D5481',
+ lightTurquois: '#aefcdc',
turquois: '#058789',
lightPurple: '#A81CA6',
purple: '#690596',
@@ -47,20 +47,7 @@ const baseColors = {
darkYellow: '#caca03',
};
-const appColors = {
- // wallet specific colors
- walletBoxShadow: 'rgba(56, 59, 137, 0.2)',
- walletBorder: '#ededee',
- walletDefaultItemBackground: '#fbfbfc',
- walletFocusedItemBackground: '#f0f1f4',
- allowanceToggleShadow: 'rgba(0, 0, 0, 0)',
- allowanceToggleOffTrack: '#adadad',
- allowanceToggleOnTrack: baseColors.mediumBlue,
- wrapEtherConfirmationButton: baseColors.mediumBlue,
-};
-
export const colors = {
...materialUiColors,
...baseColors,
- ...appColors,
};
diff --git a/packages/react-shared/src/utils/utils.ts b/packages/react-shared/src/utils/utils.ts
index 1538dd087..93c7e9f7b 100644
--- a/packages/react-shared/src/utils/utils.ts
+++ b/packages/react-shared/src/utils/utils.ts
@@ -7,7 +7,7 @@ import { EtherscanLinkSuffixes, Networks } from '../types';
import { constants } from './constants';
export const utils = {
- setUrlHash(anchorId: string) {
+ setUrlHash(anchorId: string): void {
window.location.hash = anchorId;
},
scrollToHash(hash: string, containerId: string): void {
@@ -26,11 +26,11 @@ export const utils = {
const isUserOnMobile = isMobile();
return isUserOnMobile;
},
- getIdFromName(name: string) {
+ getIdFromName(name: string): string {
const id = name.replace(/ /g, '-');
return id;
},
- convertDashesToSpaces(text: string) {
+ convertDashesToSpaces(text: string): string {
return text.replace(/-/g, ' ');
},
getEtherScanLinkIfExists(
diff --git a/packages/react-shared/tslint.json b/packages/react-shared/tslint.json
index ee918e360..c78434416 100644
--- a/packages/react-shared/tslint.json
+++ b/packages/react-shared/tslint.json
@@ -3,6 +3,7 @@
"rules": {
"no-object-literal-type-assertion": false,
"completed-docs": false,
- "prefer-function-over-method": false
+ "prefer-function-over-method": false,
+ "custom-no-magic-numbers": false
}
}