From a0ea0415ddd2fb2b9b23ad249d5c0230314260c4 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Mon, 10 Dec 2018 09:16:15 -0800 Subject: fix(instant): Don't update heartbeat if amount is 0 --- packages/instant/src/redux/async_data.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'packages/instant') diff --git a/packages/instant/src/redux/async_data.ts b/packages/instant/src/redux/async_data.ts index c67b222d1..932eb93e9 100644 --- a/packages/instant/src/redux/async_data.ts +++ b/packages/instant/src/redux/async_data.ts @@ -97,6 +97,7 @@ export const asyncData = { if ( !_.isUndefined(selectedAssetUnitAmount) && !_.isUndefined(selectedAsset) && + selectedAssetUnitAmount.greaterThan(BIG_NUMBER_ZERO) && buyOrderState.processState === OrderProcessState.None && selectedAsset.metaData.assetProxyId === AssetProxyId.ERC20 ) { -- cgit v1.2.3 From 6e54514013702fa8ca9a6b69c04f4d2468cd8b66 Mon Sep 17 00:00:00 2001 From: fragosti Date: Mon, 10 Dec 2018 17:30:32 -0800 Subject: feat: change input to number input --- packages/instant/src/components/scaling_input.tsx | 1 + packages/instant/src/components/ui/input.tsx | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'packages/instant') diff --git a/packages/instant/src/components/scaling_input.tsx b/packages/instant/src/components/scaling_input.tsx index 791692257..2c5567dc1 100644 --- a/packages/instant/src/components/scaling_input.tsx +++ b/packages/instant/src/components/scaling_input.tsx @@ -135,6 +135,7 @@ export class ScalingInput extends React.Component props.theme[props.fontColor || 'white']} !important; opacity: 0.5 !important; } + &::-webkit-outer-spin-button, &::-webkit-inner-spin-button { + -webkit-appearance: none; + margin: 0; + } } `; -- cgit v1.2.3 From 96b8100a787d00142dcf875d940c9125571cbde6 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 11 Dec 2018 15:38:43 -0800 Subject: Publish - 0x.js@2.0.7 - @0x/abi-gen@1.0.18 - @0x/abi-gen-wrappers@2.0.1 - @0x/assert@1.0.19 - @0x/asset-buyer@3.0.3 - @0x/base-contract@3.0.9 - @0x/connect@3.0.9 - @0x/contract-wrappers@4.1.2 - @0x/dev-tools-pages@0.0.9 - @0x/dev-utils@1.0.20 - ethereum-types@1.1.3 - @0x/fill-scenarios@1.0.15 - @0x/instant@1.0.3 - @0x/json-schemas@2.1.3 - @0x/metacoin@0.0.31 - @0x/migrations@2.2.1 - @0x/monorepo-scripts@1.0.15 - @0x/order-utils@3.0.6 - @0x/order-watcher@2.2.7 - @0x/pipeline@1.0.1 - @0x/react-docs@1.0.21 - @0x/react-shared@1.0.24 - @0x/sol-compiler@1.1.15 - @0x/sol-cov@2.1.15 - @0x/sol-doc@1.0.10 - @0x/sol-resolver@1.1.0 - @0x/sra-spec@1.0.12 - @0x/subproviders@2.1.7 - @0x/testnet-faucets@1.0.59 - @0x/types@1.4.0 - @0x/typescript-typings@3.0.5 - @0x/utils@2.0.7 - @0x/web3-wrapper@3.2.0 - @0x/website@0.0.62 - @0x/contracts-examples@1.0.1 - @0x/contracts-extensions@1.0.1 - @0x/contracts-interfaces@1.0.1 - @0x/contracts-libs@1.0.1 - @0x/contracts-multisig@1.0.1 - @0x/contracts-protocol@2.1.57 - @0x/contracts-test-utils@1.0.1 - @0x/contracts-tokens@1.0.1 - @0x/contracts-utils@1.0.1 --- packages/instant/package.json | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'packages/instant') diff --git a/packages/instant/package.json b/packages/instant/package.json index 9303276b4..7a519f460 100644 --- a/packages/instant/package.json +++ b/packages/instant/package.json @@ -1,6 +1,6 @@ { "name": "@0x/instant", - "version": "1.0.2", + "version": "1.0.3", "engines": { "node": ">=6.12" }, @@ -24,7 +24,10 @@ }, "config": { "postpublish": { - "assets": ["packages/instant/umd/instant.js", "packages/instant/umd/instant.js.map"] + "assets": [ + "packages/instant/umd/instant.js", + "packages/instant/umd/instant.js.map" + ] } }, "repository": { @@ -38,18 +41,18 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/instant/README.md", "dependencies": { - "@0x/assert": "^1.0.18", - "@0x/asset-buyer": "^3.0.2", - "@0x/json-schemas": "^2.1.2", - "@0x/order-utils": "^3.0.4", - "@0x/subproviders": "^2.1.6", - "@0x/types": "^1.3.0", - "@0x/typescript-typings": "^3.0.4", - "@0x/utils": "^2.0.6", - "@0x/web3-wrapper": "^3.1.6", + "@0x/assert": "^1.0.19", + "@0x/asset-buyer": "^3.0.3", + "@0x/json-schemas": "^2.1.3", + "@0x/order-utils": "^3.0.6", + "@0x/subproviders": "^2.1.7", + "@0x/types": "^1.4.0", + "@0x/typescript-typings": "^3.0.5", + "@0x/utils": "^2.0.7", + "@0x/web3-wrapper": "^3.2.0", "bowser": "^1.9.4", "copy-to-clipboard": "^3.0.8", - "ethereum-types": "^1.1.2", + "ethereum-types": "^1.1.3", "lodash": "^4.17.5", "polished": "^2.2.0", "react": "^16.5.2", -- cgit v1.2.3 From 33c6e40b7026858be52f804c726b9a1ef41647d3 Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 13 Dec 2018 12:45:38 -0800 Subject: simplify scaling input logic --- .../src/components/scaling_amount_input.tsx | 1 + packages/instant/src/components/scaling_input.tsx | 65 ++++++---------------- packages/instant/src/components/ui/input.tsx | 2 +- 3 files changed, 18 insertions(+), 50 deletions(-) (limited to 'packages/instant') diff --git a/packages/instant/src/components/scaling_amount_input.tsx b/packages/instant/src/components/scaling_amount_input.tsx index 86aca5a65..4feb0502d 100644 --- a/packages/instant/src/components/scaling_amount_input.tsx +++ b/packages/instant/src/components/scaling_amount_input.tsx @@ -58,6 +58,7 @@ export class ScalingAmountInput extends React.Component { +export class ScalingInput extends React.Component { public static defaultProps = { onChange: util.boundNoop, onFontSizeChange: util.boundNoop, @@ -54,9 +49,6 @@ export class ScalingInput extends React.Component(); public static getPhase(textLengthThreshold: number, value: string): ScalingInputPhase { if (value.length <= textLengthThreshold) { @@ -93,36 +85,15 @@ export class ScalingInput extends React.Component { return ScalingInput.calculateFontSizeFromProps(this.props, phase); @@ -178,4 +137,12 @@ export class ScalingInput extends React.Component): void => { + const value = event.target.value; + const { maxLength } = this.props; + if (!_.isUndefined(value) && !_.isUndefined(maxLength) && value.length > maxLength) { + return; + } + this.props.onChange(event); + }; } diff --git a/packages/instant/src/components/ui/input.tsx b/packages/instant/src/components/ui/input.tsx index 1e476bed3..697bfaf0f 100644 --- a/packages/instant/src/components/ui/input.tsx +++ b/packages/instant/src/components/ui/input.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { ColorOption, styled } from '../../style/theme'; -export interface InputProps { +export interface InputProps extends React.HTMLAttributes { tabIndex?: number; className?: string; value?: string; -- cgit v1.2.3 From 9cd859a68a94e90eb9891c5b9a4ec7518b7fb64d Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 13 Dec 2018 13:03:45 -0800 Subject: run linter --- packages/instant/src/components/scaling_input.tsx | 39 ++++++++++++++++------- packages/instant/src/components/ui/input.tsx | 6 ++-- 2 files changed, 31 insertions(+), 14 deletions(-) (limited to 'packages/instant') diff --git a/packages/instant/src/components/scaling_input.tsx b/packages/instant/src/components/scaling_input.tsx index 78c83115a..00aea37da 100644 --- a/packages/instant/src/components/scaling_input.tsx +++ b/packages/instant/src/components/scaling_input.tsx @@ -1,3 +1,4 @@ +import { ObjectMap } from '@0x/types'; import * as _ from 'lodash'; import * as React from 'react'; @@ -13,6 +14,11 @@ export enum ScalingInputPhase { export interface ScalingSettings { percentageToReduceFontSizePerCharacter: number; + // 1ch = the width of the 0 chararacter. + // Allow to customize 'char' length for different characters. + characterWidthOverrides: ObjectMap; + // How much room to leave to the right of the scaling input. + additionalInputSpaceInCh: number; } export interface ScalingInputProps { @@ -38,13 +44,18 @@ export interface ScalingInputSnapshot { // These are magic numbers that were determined experimentally. const defaultScalingSettings: ScalingSettings = { percentageToReduceFontSizePerCharacter: 0.1, + characterWidthOverrides: { + '1': 0.7, + '.': 0.4, + }, + additionalInputSpaceInCh: 0.4, }; export class ScalingInput extends React.Component { public static defaultProps = { onChange: util.boundNoop, onFontSizeChange: util.boundNoop, - maxLength: 7, + maxLength: 9, scalingSettings: defaultScalingSettings, isDisabled: false, hasAutofocus: false, @@ -102,7 +113,7 @@ export class ScalingInput extends React.Component { } } public render(): React.ReactNode { - const { type, hasAutofocus, isDisabled, fontColor, onChange, placeholder, value, maxLength } = this.props; + const { type, hasAutofocus, isDisabled, fontColor, placeholder, value, maxLength } = this.props; const phase = ScalingInput.getPhaseFromProps(this.props); return ( { ); } private readonly _calculateWidth = (phase: ScalingInputPhase): string => { - const { value, textLengthThreshold, scalingSettings } = this.props; + const { value, scalingSettings } = this.props; if (_.isEmpty(value)) { return `${this.props.emptyInputWidthCh}ch`; } - return `${value.length}ch`; + const lengthInCh = _.reduce( + value.split(''), + (sum, char) => { + const widthOverride = scalingSettings.characterWidthOverrides[char]; + if (!_.isUndefined(widthOverride)) { + // tslint is confused + // tslint:disable-next-line:restrict-plus-operands + return sum + widthOverride; + } + return sum + 1; + }, + scalingSettings.additionalInputSpaceInCh, + ); + return `${lengthInCh}ch`; }; private readonly _calculateFontSize = (phase: ScalingInputPhase): number => { return ScalingInput.calculateFontSizeFromProps(this.props, phase); }; - private readonly _getInputWidthInPx = (): number => { - const ref = this._inputRef.current; - if (!ref) { - return 0; - } - return ref.getBoundingClientRect().width; - }; private readonly _handleChange = (event: React.ChangeEvent): void => { const value = event.target.value; const { maxLength } = this.props; diff --git a/packages/instant/src/components/ui/input.tsx b/packages/instant/src/components/ui/input.tsx index 697bfaf0f..53c43ea0b 100644 --- a/packages/instant/src/components/ui/input.tsx +++ b/packages/instant/src/components/ui/input.tsx @@ -32,9 +32,9 @@ export const Input = color: ${props => props.theme[props.fontColor || 'white']} !important; opacity: 0.5 !important; } - &::-webkit-outer-spin-button, &::-webkit-inner-spin-button { - -webkit-appearance: none; - margin: 0; + &::-webkit-outer-spin-button, &::-webkit-inner-spin-button { + -webkit-appearance: none; + margin: 0; } } `; -- cgit v1.2.3 From 2abd8fe4ee860e5a4008a9f92f6d29239d14b2bc Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 13 Dec 2018 14:28:27 -0800 Subject: Publish - 0x.js@2.0.8 - @0x/abi-gen@1.0.19 - @0x/abi-gen-wrappers@2.0.2 - @0x/assert@1.0.20 - @0x/asset-buyer@3.0.4 - @0x/base-contract@3.0.10 - @0x/connect@3.0.10 - @0x/contract-wrappers@4.1.3 - @0x/dev-tools-pages@0.0.10 - @0x/dev-utils@1.0.21 - ethereum-types@1.1.4 - @0x/fill-scenarios@1.0.16 - @0x/instant@1.0.4 - @0x/json-schemas@2.1.4 - @0x/metacoin@0.0.32 - @0x/migrations@2.2.2 - @0x/order-utils@3.0.7 - @0x/order-watcher@2.2.8 - @0x/pipeline@1.0.2 - @0x/react-docs@1.0.22 - @0x/react-shared@1.0.25 - @0x/sol-compiler@1.1.16 - @0x/sol-cov@2.1.16 - @0x/sol-doc@1.0.11 - @0x/sol-resolver@1.1.1 - @0x/sra-spec@1.0.13 - @0x/subproviders@2.1.8 - @0x/testnet-faucets@1.0.60 - @0x/tslint-config@2.0.0 - @0x/types@1.4.1 - @0x/typescript-typings@3.0.6 - @0x/utils@2.0.8 - @0x/web3-wrapper@3.2.1 - @0x/website@0.0.63 - @0x/contracts-examples@1.0.1 - @0x/contracts-extensions@1.0.1 - @0x/contracts-interfaces@1.0.1 - @0x/contracts-libs@1.0.1 - @0x/contracts-multisig@1.0.1 - @0x/contracts-protocol@2.1.58 - @0x/contracts-test-utils@1.0.2 - @0x/contracts-tokens@1.0.1 - @0x/contracts-utils@1.0.1 --- packages/instant/package.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'packages/instant') diff --git a/packages/instant/package.json b/packages/instant/package.json index 7a519f460..0a5e152ca 100644 --- a/packages/instant/package.json +++ b/packages/instant/package.json @@ -1,6 +1,6 @@ { "name": "@0x/instant", - "version": "1.0.3", + "version": "1.0.4", "engines": { "node": ">=6.12" }, @@ -41,18 +41,18 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/instant/README.md", "dependencies": { - "@0x/assert": "^1.0.19", - "@0x/asset-buyer": "^3.0.3", - "@0x/json-schemas": "^2.1.3", - "@0x/order-utils": "^3.0.6", - "@0x/subproviders": "^2.1.7", - "@0x/types": "^1.4.0", - "@0x/typescript-typings": "^3.0.5", - "@0x/utils": "^2.0.7", - "@0x/web3-wrapper": "^3.2.0", + "@0x/assert": "^1.0.20", + "@0x/asset-buyer": "^3.0.4", + "@0x/json-schemas": "^2.1.4", + "@0x/order-utils": "^3.0.7", + "@0x/subproviders": "^2.1.8", + "@0x/types": "^1.4.1", + "@0x/typescript-typings": "^3.0.6", + "@0x/utils": "^2.0.8", + "@0x/web3-wrapper": "^3.2.1", "bowser": "^1.9.4", "copy-to-clipboard": "^3.0.8", - "ethereum-types": "^1.1.3", + "ethereum-types": "^1.1.4", "lodash": "^4.17.5", "polished": "^2.2.0", "react": "^16.5.2", @@ -65,7 +65,7 @@ "ts-optchain": "^0.1.1" }, "devDependencies": { - "@0x/tslint-config": "^1.0.10", + "@0x/tslint-config": "^2.0.0", "@static/discharge": "https://github.com/0xProject/discharge.git", "@types/enzyme": "^3.1.14", "@types/enzyme-adapter-react-16": "^1.0.3", -- cgit v1.2.3