From 1053aed74d2dcb5018a9647f21dd05e2902528fd Mon Sep 17 00:00:00 2001 From: Remco Bloemen Date: Thu, 16 Aug 2018 12:54:23 -0700 Subject: Set curstom inspect printer in BigNumber --- packages/utils/src/configured_bignumber.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'packages') diff --git a/packages/utils/src/configured_bignumber.ts b/packages/utils/src/configured_bignumber.ts index 2b22b6938..977042f1e 100644 --- a/packages/utils/src/configured_bignumber.ts +++ b/packages/utils/src/configured_bignumber.ts @@ -11,4 +11,15 @@ BigNumber.config({ DECIMAL_PLACES: 78, }); +// Set a debug print function for NodeJS +if (typeof window === 'undefined') { // Check if running in NodeJS + const util = require('util'); + + // Set a custom util.inspect function + (BigNumber.prototype as any)[util.inspect.custom] = function() { + // Return the readable string representation + return this.toString(); + }; +} + export { BigNumber }; -- cgit v1.2.3 From 71a61a4dc331912cc015347d5cd22691ef9cd51b Mon Sep 17 00:00:00 2001 From: Remco Bloemen Date: Tue, 21 Aug 2018 14:28:21 -0700 Subject: Use detect-node --- packages/utils/src/configured_bignumber.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'packages') diff --git a/packages/utils/src/configured_bignumber.ts b/packages/utils/src/configured_bignumber.ts index 977042f1e..f97452337 100644 --- a/packages/utils/src/configured_bignumber.ts +++ b/packages/utils/src/configured_bignumber.ts @@ -12,7 +12,8 @@ BigNumber.config({ }); // Set a debug print function for NodeJS -if (typeof window === 'undefined') { // Check if running in NodeJS +import isNode = require('detect-node'); +if (!isNode) { const util = require('util'); // Set a custom util.inspect function -- cgit v1.2.3 From 9b4f5dfddae9defbd797dbd416868aa381c44b2c Mon Sep 17 00:00:00 2001 From: Remco Bloemen Date: Tue, 21 Aug 2018 14:32:31 -0700 Subject: Fix tslint issues --- packages/utils/src/configured_bignumber.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'packages') diff --git a/packages/utils/src/configured_bignumber.ts b/packages/utils/src/configured_bignumber.ts index f97452337..a838b1e3b 100644 --- a/packages/utils/src/configured_bignumber.ts +++ b/packages/utils/src/configured_bignumber.ts @@ -14,11 +14,12 @@ BigNumber.config({ // Set a debug print function for NodeJS import isNode = require('detect-node'); if (!isNode) { - const util = require('util'); + import util = require('util'); // Set a custom util.inspect function - (BigNumber.prototype as any)[util.inspect.custom] = function() { + (BigNumber.prototype as any)[util.inspect.custom] = function(): string { // Return the readable string representation + // tslint:disable-next-line: no-invalid-this return this.toString(); }; } -- cgit v1.2.3 From ad0fe2f0799100e305f437c38e657f668d74670b Mon Sep 17 00:00:00 2001 From: Remco Bloemen Date: Tue, 21 Aug 2018 14:45:14 -0700 Subject: Use const require instead of import --- packages/utils/src/configured_bignumber.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'packages') diff --git a/packages/utils/src/configured_bignumber.ts b/packages/utils/src/configured_bignumber.ts index a838b1e3b..b7de1b1fc 100644 --- a/packages/utils/src/configured_bignumber.ts +++ b/packages/utils/src/configured_bignumber.ts @@ -14,7 +14,11 @@ BigNumber.config({ // Set a debug print function for NodeJS import isNode = require('detect-node'); if (!isNode) { - import util = require('util'); + // Dynamically load a NodeJS specific module. + // Typescript requires all imports to be global, so we need to use + // `const` here and disable the tslint warning. + // tslint:disable-next-line: no-var-requires + const util = require('util'); // Set a custom util.inspect function (BigNumber.prototype as any)[util.inspect.custom] = function(): string { -- cgit v1.2.3 From e40a4addc9998d637896d6f7145bef8f77a512ca Mon Sep 17 00:00:00 2001 From: Remco Bloemen Date: Tue, 21 Aug 2018 15:00:13 -0700 Subject: Add upstream issue --- packages/utils/src/configured_bignumber.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'packages') diff --git a/packages/utils/src/configured_bignumber.ts b/packages/utils/src/configured_bignumber.ts index b7de1b1fc..56e925c41 100644 --- a/packages/utils/src/configured_bignumber.ts +++ b/packages/utils/src/configured_bignumber.ts @@ -12,6 +12,7 @@ BigNumber.config({ }); // Set a debug print function for NodeJS +// Upstream issue: https://github.com/MikeMcl/bignumber.js/issues/188 import isNode = require('detect-node'); if (!isNode) { // Dynamically load a NodeJS specific module. -- cgit v1.2.3 From e4f9ae6ad5a3d6040e4f8c9c8b7a4a05cf22fb51 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Mon, 5 Nov 2018 16:29:44 -0800 Subject: fix(instant): fix provided orders --- packages/instant/public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages') diff --git a/packages/instant/public/index.html b/packages/instant/public/index.html index 92c8a6c21..cf9e0eda0 100644 --- a/packages/instant/public/index.html +++ b/packages/instant/public/index.html @@ -87,7 +87,7 @@ }; } const renderOptionsOverrides = { - orderSource: orderSourceOverride === 'provided' ? [providedOrder] : orderSourceOverride, + orderSource: orderSourceOverride === 'provided' ? providedOrders : orderSourceOverride, networkId: +queryParams.getQueryParamValue('networkId') || undefined, defaultAssetBuyAmount: +queryParams.getQueryParamValue('defaultAssetBuyAmount') || undefined, availableAssetDatas: availableAssetDatasString ? JSON.parse(availableAssetDatasString) : undefined, -- cgit v1.2.3 From ecae3f9c4852ba488ab5a0777dae2f7a9c45ddc0 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Mon, 5 Nov 2018 17:19:37 -0800 Subject: wip: full display of mobile hard coded --- packages/instant/public/index.html | 2 +- packages/instant/src/components/order_details.tsx | 2 +- packages/instant/src/components/ui/container.tsx | 3 +++ packages/instant/src/components/ui/flex.tsx | 2 ++ packages/instant/src/components/ui/overlay.tsx | 4 ++-- packages/instant/src/components/zero_ex_instant_container.tsx | 6 ++++-- 6 files changed, 13 insertions(+), 6 deletions(-) (limited to 'packages') diff --git a/packages/instant/public/index.html b/packages/instant/public/index.html index cf9e0eda0..418e6261f 100644 --- a/packages/instant/public/index.html +++ b/packages/instant/public/index.html @@ -13,7 +13,7 @@ display: flex; justify-content: center; align-items: center; - height: 100vh; + /*height: 100vh;*/ } body { diff --git a/packages/instant/src/components/order_details.tsx b/packages/instant/src/components/order_details.tsx index 704009d89..2d98adf7e 100644 --- a/packages/instant/src/components/order_details.tsx +++ b/packages/instant/src/components/order_details.tsx @@ -23,7 +23,7 @@ export class OrderDetails extends React.Component { const ethTokenFee = buyQuoteAccessor.feeEthAmount(); const totalEthAmount = buyQuoteAccessor.totalEthAmount(); return ( - + ` box-sizing: border-box; + ${props => cssRuleIfExists(props, 'flex-grow')} ${props => cssRuleIfExists(props, 'display')} ${props => cssRuleIfExists(props, 'position')} ${props => cssRuleIfExists(props, 'top')} diff --git a/packages/instant/src/components/ui/flex.tsx b/packages/instant/src/components/ui/flex.tsx index 29c6511bb..57abd8b5b 100644 --- a/packages/instant/src/components/ui/flex.tsx +++ b/packages/instant/src/components/ui/flex.tsx @@ -10,6 +10,7 @@ export interface FlexProps { height?: string; backgroundColor?: ColorOption; inline?: boolean; + flexGrow?: number | string; } export const Flex = @@ -19,6 +20,7 @@ export const Flex = display: ${props => (props.inline ? 'inline-flex' : 'flex')}; flex-direction: ${props => props.direction}; flex-wrap: ${props => props.flexWrap}; + ${props => cssRuleIfExists(props, 'flexGrow')} justify-content: ${props => props.justify}; align-items: ${props => props.align}; ${props => cssRuleIfExists(props, 'width')} diff --git a/packages/instant/src/components/ui/overlay.tsx b/packages/instant/src/components/ui/overlay.tsx index f1706c874..e930ffacd 100644 --- a/packages/instant/src/components/ui/overlay.tsx +++ b/packages/instant/src/components/ui/overlay.tsx @@ -14,11 +14,11 @@ export interface OverlayProps { } const PlainOverlay: React.StatelessComponent = ({ children, className, onClose }) => ( - + -
{children}
+ {children}
); export const Overlay = styled(PlainOverlay)` diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx index c1bd17502..cf7a04554 100644 --- a/packages/instant/src/components/zero_ex_instant_container.tsx +++ b/packages/instant/src/components/zero_ex_instant_container.tsx @@ -14,6 +14,7 @@ import { zIndex } from '../style/z_index'; import { SlideAnimationState } from './animations/slide_animation'; import { SlidingPanel } from './sliding_panel'; import { Container, Flex } from './ui'; + export interface ZeroExInstantContainerProps {} export interface ZeroExInstantContainerState { tokenSelectionPanelAnimationState: SlideAnimationState; @@ -25,7 +26,7 @@ export class ZeroExInstantContainer extends React.Component + @@ -36,8 +37,9 @@ export class ZeroExInstantContainer extends React.Component - + -- cgit v1.2.3 From 188e317504ba788c8a287d4b8da2ed2d6745f97e Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Mon, 5 Nov 2018 17:23:09 -0800 Subject: wip: height 100% --- packages/instant/src/components/ui/overlay.tsx | 4 +++- packages/instant/src/components/zero_ex_instant_container.tsx | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'packages') diff --git a/packages/instant/src/components/ui/overlay.tsx b/packages/instant/src/components/ui/overlay.tsx index e930ffacd..c4778363d 100644 --- a/packages/instant/src/components/ui/overlay.tsx +++ b/packages/instant/src/components/ui/overlay.tsx @@ -18,7 +18,9 @@ const PlainOverlay: React.StatelessComponent = ({ children, classN - {children} + + {children} + ); export const Overlay = styled(PlainOverlay)` diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx index cf7a04554..39b2c9c05 100644 --- a/packages/instant/src/components/zero_ex_instant_container.tsx +++ b/packages/instant/src/components/zero_ex_instant_container.tsx @@ -26,7 +26,7 @@ export class ZeroExInstantContainer extends React.Component + -- cgit v1.2.3 From f6487122d1ed3dea731adcb6a08165b44c887282 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Tue, 6 Nov 2018 09:26:45 -0800 Subject: Putting back in old heights as not necessary for full bleed --- packages/instant/public/index.html | 2 +- packages/instant/src/components/ui/overlay.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'packages') diff --git a/packages/instant/public/index.html b/packages/instant/public/index.html index 418e6261f..cf9e0eda0 100644 --- a/packages/instant/public/index.html +++ b/packages/instant/public/index.html @@ -13,7 +13,7 @@ display: flex; justify-content: center; align-items: center; - /*height: 100vh;*/ + height: 100vh; } body { diff --git a/packages/instant/src/components/ui/overlay.tsx b/packages/instant/src/components/ui/overlay.tsx index c4778363d..11496e895 100644 --- a/packages/instant/src/components/ui/overlay.tsx +++ b/packages/instant/src/components/ui/overlay.tsx @@ -14,7 +14,7 @@ export interface OverlayProps { } const PlainOverlay: React.StatelessComponent = ({ children, className, onClose }) => ( - + -- cgit v1.2.3 From a2bc62b17a773625220817c79265c017cb61979f Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Tue, 6 Nov 2018 10:26:39 -0800 Subject: feat(instant): when on mobile, show mobile specific styling that takes up whole screen --- packages/instant/src/components/ui/container.tsx | 17 +++++++++++++++++ packages/instant/src/components/ui/flex.tsx | 18 ++++++++++++++++++ packages/instant/src/components/ui/overlay.tsx | 2 +- .../src/components/zero_ex_instant_container.tsx | 6 +++--- packages/instant/src/style/media.ts | 19 +++++++++++++++++++ 5 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 packages/instant/src/style/media.ts (limited to 'packages') diff --git a/packages/instant/src/components/ui/container.tsx b/packages/instant/src/components/ui/container.tsx index 228085f51..36d7cf2ec 100644 --- a/packages/instant/src/components/ui/container.tsx +++ b/packages/instant/src/components/ui/container.tsx @@ -1,5 +1,7 @@ +import * as _ from 'lodash'; import { darken } from 'polished'; +import { media } from '../../style/media'; import { ColorOption, styled } from '../../style/theme'; import { cssRuleIfExists } from '../../style/util'; @@ -34,8 +36,22 @@ export interface ContainerProps { overflow?: string; darkenOnHover?: boolean; flexGrow?: string | number; + + smallWidth?: string; + smallHeight?: string; } +const mediaStyles = (props: ContainerProps) => { + if (!_.some([props.smallWidth, props.smallHeight])) { + return ''; + } + + return media.small` + width: ${props.smallWidth || props.width || 'auto'} + height: ${props.smallHeight || props.height || 'auto'} + `; +}; + // TODO Dont commit flex grow export const Container = styled.div < @@ -68,6 +84,7 @@ export const Container = ${props => cssRuleIfExists(props, 'cursor')} ${props => cssRuleIfExists(props, 'overflow')} ${props => (props.hasBoxShadow ? `box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.1)` : '')}; + ${props => mediaStyles(props)} background-color: ${props => (props.backgroundColor ? props.theme[props.backgroundColor] : 'none')}; border-color: ${props => (props.borderColor ? props.theme[props.borderColor] : 'none')}; &:hover { diff --git a/packages/instant/src/components/ui/flex.tsx b/packages/instant/src/components/ui/flex.tsx index 57abd8b5b..f85d45e36 100644 --- a/packages/instant/src/components/ui/flex.tsx +++ b/packages/instant/src/components/ui/flex.tsx @@ -1,3 +1,6 @@ +import * as _ from 'lodash'; + +import { media } from '../../style/media'; import { ColorOption, styled } from '../../style/theme'; import { cssRuleIfExists } from '../../style/util'; @@ -11,8 +14,22 @@ export interface FlexProps { backgroundColor?: ColorOption; inline?: boolean; flexGrow?: number | string; + + smallWidth?: string; + smallHeight?: string; } +const mediaStyles = (props: FlexProps) => { + if (!_.some([props.smallWidth, props.smallHeight])) { + return ''; + } + + return media.small` + width: ${props.smallWidth || props.width || 'auto'} + height: ${props.smallHeight || props.height || 'auto'} + `; +}; + export const Flex = styled.div < FlexProps > @@ -26,6 +43,7 @@ export const Flex = ${props => cssRuleIfExists(props, 'width')} ${props => cssRuleIfExists(props, 'height')} background-color: ${props => (props.backgroundColor ? props.theme[props.backgroundColor] : 'none')}; + ${props => mediaStyles(props)} `; Flex.defaultProps = { diff --git a/packages/instant/src/components/ui/overlay.tsx b/packages/instant/src/components/ui/overlay.tsx index 11496e895..12bde1f2b 100644 --- a/packages/instant/src/components/ui/overlay.tsx +++ b/packages/instant/src/components/ui/overlay.tsx @@ -18,7 +18,7 @@ const PlainOverlay: React.StatelessComponent = ({ children, classN - + {children} diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx index 39b2c9c05..88c838567 100644 --- a/packages/instant/src/components/zero_ex_instant_container.tsx +++ b/packages/instant/src/components/zero_ex_instant_container.tsx @@ -26,7 +26,7 @@ export class ZeroExInstantContainer extends React.Component + @@ -37,9 +37,9 @@ export class ZeroExInstantContainer extends React.Component - + diff --git a/packages/instant/src/style/media.ts b/packages/instant/src/style/media.ts new file mode 100644 index 000000000..fa7571077 --- /dev/null +++ b/packages/instant/src/style/media.ts @@ -0,0 +1,19 @@ +import { css } from './theme'; + +export enum ScreenWidths { + Sm = 40, + Md = 52, + Lg = 64, +} + +const generateMediaWrapper = (screenWidth: ScreenWidths) => (...args: any[]) => css` + @media (max-width: ${screenWidth}em) { + ${css.apply(css, args)}; + } +`; + +export const media = { + small: generateMediaWrapper(ScreenWidths.Sm), + medium: generateMediaWrapper(ScreenWidths.Md), + large: generateMediaWrapper(ScreenWidths.Lg), +}; -- cgit v1.2.3 From f90486c99c7acf95f3b95fdc73ee125dd3f9086e Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Tue, 6 Nov 2018 11:34:04 -0800 Subject: wip: mediachoice experiment --- packages/instant/src/components/sandbox.tsx | 22 ++++++++++++++++++++++ .../src/components/zero_ex_instant_container.tsx | 2 ++ packages/instant/src/style/media.ts | 13 +++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 packages/instant/src/components/sandbox.tsx (limited to 'packages') diff --git a/packages/instant/src/components/sandbox.tsx b/packages/instant/src/components/sandbox.tsx new file mode 100644 index 000000000..04e4c7935 --- /dev/null +++ b/packages/instant/src/components/sandbox.tsx @@ -0,0 +1,22 @@ +import * as React from 'react'; + +import { MediaChoice, stylesForMedia } from '../style/media'; +import { styled } from '../style/theme'; + +// export const Sandbox: React.StatelessComponent<{}> = props => { +// return
Hi
; +// }; + +// TODO: handle string too +interface SandboxProps { + width: MediaChoice; +} +export const Sandbox = + styled.div < + SandboxProps > + ` + display: block; + border: 1px solid black; + background-color: yellow; + ${props => stylesForMedia(props.width)} + `; diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx index 88c838567..8fd4d56c3 100644 --- a/packages/instant/src/components/zero_ex_instant_container.tsx +++ b/packages/instant/src/components/zero_ex_instant_container.tsx @@ -12,6 +12,7 @@ import { ColorOption } from '../style/theme'; import { zIndex } from '../style/z_index'; import { SlideAnimationState } from './animations/slide_animation'; +import { Sandbox } from './sandbox'; import { SlidingPanel } from './sliding_panel'; import { Container, Flex } from './ui'; @@ -27,6 +28,7 @@ export class ZeroExInstantContainer extends React.Component + Test diff --git a/packages/instant/src/style/media.ts b/packages/instant/src/style/media.ts index fa7571077..5a0cba668 100644 --- a/packages/instant/src/style/media.ts +++ b/packages/instant/src/style/media.ts @@ -1,3 +1,5 @@ +import { InterpolationValue } from 'styled-components'; + import { css } from './theme'; export enum ScreenWidths { @@ -17,3 +19,14 @@ export const media = { medium: generateMediaWrapper(ScreenWidths.Md), large: generateMediaWrapper(ScreenWidths.Lg), }; + +/// media helper +export interface MediaChoice { + sm: string; + md?: string; + lg?: string; +} +// TODO: handle string too +export const stylesForMedia = (choice: MediaChoice): InterpolationValue[] => { + return media.small`width: ${choice.sm}`; +}; -- cgit v1.2.3 From e8814ecbe70b97dfa0de0f51b6a3b7e7fcd89ea2 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Tue, 6 Nov 2018 13:52:16 -0800 Subject: proof of concept working --- packages/instant/src/components/sandbox.tsx | 5 ----- .../src/components/zero_ex_instant_container.tsx | 3 ++- packages/instant/src/style/media.ts | 23 +++++++++++++++++++--- 3 files changed, 22 insertions(+), 9 deletions(-) (limited to 'packages') diff --git a/packages/instant/src/components/sandbox.tsx b/packages/instant/src/components/sandbox.tsx index 04e4c7935..b574fd35c 100644 --- a/packages/instant/src/components/sandbox.tsx +++ b/packages/instant/src/components/sandbox.tsx @@ -3,11 +3,6 @@ import * as React from 'react'; import { MediaChoice, stylesForMedia } from '../style/media'; import { styled } from '../style/theme'; -// export const Sandbox: React.StatelessComponent<{}> = props => { -// return
Hi
; -// }; - -// TODO: handle string too interface SandboxProps { width: MediaChoice; } diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx index 8fd4d56c3..c60a9c40e 100644 --- a/packages/instant/src/components/zero_ex_instant_container.tsx +++ b/packages/instant/src/components/zero_ex_instant_container.tsx @@ -28,7 +28,8 @@ export class ZeroExInstantContainer extends React.Component - Test + {/* Test */} + Test diff --git a/packages/instant/src/style/media.ts b/packages/instant/src/style/media.ts index 5a0cba668..84b85a2a8 100644 --- a/packages/instant/src/style/media.ts +++ b/packages/instant/src/style/media.ts @@ -21,12 +21,29 @@ export const media = { }; /// media helper -export interface MediaChoice { - sm: string; +export interface ScreenSpecifications { + default: string; + sm?: string; md?: string; lg?: string; } +export type MediaChoice = string | ScreenSpecifications; // TODO: handle string too export const stylesForMedia = (choice: MediaChoice): InterpolationValue[] => { - return media.small`width: ${choice.sm}`; + let res: InterpolationValue[]; + if (typeof choice === 'string') { + res = css` + width: ${choice}; + `; + } else { + res = css` + width: ${choice.default}; + ${choice.lg && media.large`width: ${choice.lg}`} + ${choice.md && media.medium`width: ${choice.md}`} + ${choice.sm && media.small`width: ${choice.sm}`} + `; + } + + console.log(res.toString()); + return res; }; -- cgit v1.2.3 From 88c7d907fa97f7918b82df8c1759b43c28c7273b Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Tue, 6 Nov 2018 13:56:29 -0800 Subject: better function definiton --- packages/instant/src/components/sandbox.tsx | 2 +- .../src/components/zero_ex_instant_container.tsx | 3 +-- packages/instant/src/style/media.ts | 23 +++++++++------------- 3 files changed, 11 insertions(+), 17 deletions(-) (limited to 'packages') diff --git a/packages/instant/src/components/sandbox.tsx b/packages/instant/src/components/sandbox.tsx index b574fd35c..b2c64efd3 100644 --- a/packages/instant/src/components/sandbox.tsx +++ b/packages/instant/src/components/sandbox.tsx @@ -13,5 +13,5 @@ export const Sandbox = display: block; border: 1px solid black; background-color: yellow; - ${props => stylesForMedia(props.width)} + ${props => stylesForMedia('width', props.width)} `; diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx index c60a9c40e..2d8c5bdb0 100644 --- a/packages/instant/src/components/zero_ex_instant_container.tsx +++ b/packages/instant/src/components/zero_ex_instant_container.tsx @@ -28,8 +28,7 @@ export class ZeroExInstantContainer extends React.Component - {/* Test */} - Test + Test diff --git a/packages/instant/src/style/media.ts b/packages/instant/src/style/media.ts index 84b85a2a8..4bcbd608f 100644 --- a/packages/instant/src/style/media.ts +++ b/packages/instant/src/style/media.ts @@ -28,22 +28,17 @@ export interface ScreenSpecifications { lg?: string; } export type MediaChoice = string | ScreenSpecifications; -// TODO: handle string too -export const stylesForMedia = (choice: MediaChoice): InterpolationValue[] => { - let res: InterpolationValue[]; +export const stylesForMedia = (cssPropertyName: string, choice: MediaChoice): InterpolationValue[] => { if (typeof choice === 'string') { - res = css` - width: ${choice}; - `; - } else { - res = css` - width: ${choice.default}; - ${choice.lg && media.large`width: ${choice.lg}`} - ${choice.md && media.medium`width: ${choice.md}`} - ${choice.sm && media.small`width: ${choice.sm}`} + return css` + ${cssPropertyName}: ${choice}; `; } - console.log(res.toString()); - return res; + return css` + ${cssPropertyName}: ${choice.default}; + ${choice.lg && media.large`${cssPropertyName}: ${choice.lg}`} + ${choice.md && media.medium`${cssPropertyName}: ${choice.md}`} + ${choice.sm && media.small`${cssPropertyName}: ${choice.sm}`} + `; }; -- cgit v1.2.3 From 006a13448fc5d79aa8f6d04ac3f471e430dcfa89 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Tue, 6 Nov 2018 14:05:49 -0800 Subject: new MediaChoice approach for setting conditional css properties --- packages/instant/src/components/sandbox.tsx | 17 ---------------- packages/instant/src/components/ui/container.tsx | 23 +++++----------------- packages/instant/src/components/ui/flex.tsx | 23 +++++----------------- packages/instant/src/components/ui/overlay.tsx | 2 +- .../src/components/zero_ex_instant_container.tsx | 12 ++++++----- packages/instant/src/style/media.ts | 3 +-- 6 files changed, 19 insertions(+), 61 deletions(-) delete mode 100644 packages/instant/src/components/sandbox.tsx (limited to 'packages') diff --git a/packages/instant/src/components/sandbox.tsx b/packages/instant/src/components/sandbox.tsx deleted file mode 100644 index b2c64efd3..000000000 --- a/packages/instant/src/components/sandbox.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import * as React from 'react'; - -import { MediaChoice, stylesForMedia } from '../style/media'; -import { styled } from '../style/theme'; - -interface SandboxProps { - width: MediaChoice; -} -export const Sandbox = - styled.div < - SandboxProps > - ` - display: block; - border: 1px solid black; - background-color: yellow; - ${props => stylesForMedia('width', props.width)} - `; diff --git a/packages/instant/src/components/ui/container.tsx b/packages/instant/src/components/ui/container.tsx index 36d7cf2ec..0e518be88 100644 --- a/packages/instant/src/components/ui/container.tsx +++ b/packages/instant/src/components/ui/container.tsx @@ -1,7 +1,7 @@ import * as _ from 'lodash'; import { darken } from 'polished'; -import { media } from '../../style/media'; +import { MediaChoice, stylesForMedia } from '../../style/media'; import { ColorOption, styled } from '../../style/theme'; import { cssRuleIfExists } from '../../style/util'; @@ -12,8 +12,8 @@ export interface ContainerProps { right?: string; bottom?: string; left?: string; - width?: string; - height?: string; + width?: MediaChoice; + height?: MediaChoice; maxWidth?: string; margin?: string; marginTop?: string; @@ -36,22 +36,8 @@ export interface ContainerProps { overflow?: string; darkenOnHover?: boolean; flexGrow?: string | number; - - smallWidth?: string; - smallHeight?: string; } -const mediaStyles = (props: ContainerProps) => { - if (!_.some([props.smallWidth, props.smallHeight])) { - return ''; - } - - return media.small` - width: ${props.smallWidth || props.width || 'auto'} - height: ${props.smallHeight || props.height || 'auto'} - `; -}; - // TODO Dont commit flex grow export const Container = styled.div < @@ -84,7 +70,8 @@ export const Container = ${props => cssRuleIfExists(props, 'cursor')} ${props => cssRuleIfExists(props, 'overflow')} ${props => (props.hasBoxShadow ? `box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.1)` : '')}; - ${props => mediaStyles(props)} + ${props => stylesForMedia('width', props.width || 'auto')} + ${props => stylesForMedia('height', props.height || 'auto')} background-color: ${props => (props.backgroundColor ? props.theme[props.backgroundColor] : 'none')}; border-color: ${props => (props.borderColor ? props.theme[props.borderColor] : 'none')}; &:hover { diff --git a/packages/instant/src/components/ui/flex.tsx b/packages/instant/src/components/ui/flex.tsx index f85d45e36..c3d643a79 100644 --- a/packages/instant/src/components/ui/flex.tsx +++ b/packages/instant/src/components/ui/flex.tsx @@ -1,6 +1,6 @@ import * as _ from 'lodash'; -import { media } from '../../style/media'; +import { MediaChoice, stylesForMedia } from '../../style/media'; import { ColorOption, styled } from '../../style/theme'; import { cssRuleIfExists } from '../../style/util'; @@ -9,27 +9,13 @@ export interface FlexProps { flexWrap?: 'wrap' | 'nowrap'; justify?: 'flex-start' | 'center' | 'space-around' | 'space-between' | 'space-evenly' | 'flex-end'; align?: 'flex-start' | 'center' | 'space-around' | 'space-between' | 'space-evenly' | 'flex-end'; - width?: string; - height?: string; + width?: MediaChoice; + height?: MediaChoice; backgroundColor?: ColorOption; inline?: boolean; flexGrow?: number | string; - - smallWidth?: string; - smallHeight?: string; } -const mediaStyles = (props: FlexProps) => { - if (!_.some([props.smallWidth, props.smallHeight])) { - return ''; - } - - return media.small` - width: ${props.smallWidth || props.width || 'auto'} - height: ${props.smallHeight || props.height || 'auto'} - `; -}; - export const Flex = styled.div < FlexProps > @@ -43,7 +29,8 @@ export const Flex = ${props => cssRuleIfExists(props, 'width')} ${props => cssRuleIfExists(props, 'height')} background-color: ${props => (props.backgroundColor ? props.theme[props.backgroundColor] : 'none')}; - ${props => mediaStyles(props)} + ${props => stylesForMedia('width', props.width || 'auto')} + ${props => stylesForMedia('height', props.height || 'auto')} `; Flex.defaultProps = { diff --git a/packages/instant/src/components/ui/overlay.tsx b/packages/instant/src/components/ui/overlay.tsx index 12bde1f2b..0fde995e0 100644 --- a/packages/instant/src/components/ui/overlay.tsx +++ b/packages/instant/src/components/ui/overlay.tsx @@ -18,7 +18,7 @@ const PlainOverlay: React.StatelessComponent = ({ children, classN - + {children}
diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx index 2d8c5bdb0..679ca793f 100644 --- a/packages/instant/src/components/zero_ex_instant_container.tsx +++ b/packages/instant/src/components/zero_ex_instant_container.tsx @@ -12,7 +12,6 @@ import { ColorOption } from '../style/theme'; import { zIndex } from '../style/z_index'; import { SlideAnimationState } from './animations/slide_animation'; -import { Sandbox } from './sandbox'; import { SlidingPanel } from './sliding_panel'; import { Container, Flex } from './ui'; @@ -27,8 +26,11 @@ export class ZeroExInstantContainer extends React.Component - Test + @@ -39,9 +41,9 @@ export class ZeroExInstantContainer extends React.Component - + diff --git a/packages/instant/src/style/media.ts b/packages/instant/src/style/media.ts index 4bcbd608f..beabbac46 100644 --- a/packages/instant/src/style/media.ts +++ b/packages/instant/src/style/media.ts @@ -14,13 +14,12 @@ const generateMediaWrapper = (screenWidth: ScreenWidths) => (...args: any[]) => } `; -export const media = { +const media = { small: generateMediaWrapper(ScreenWidths.Sm), medium: generateMediaWrapper(ScreenWidths.Md), large: generateMediaWrapper(ScreenWidths.Lg), }; -/// media helper export interface ScreenSpecifications { default: string; sm?: string; -- cgit v1.2.3 From 897c15fd2850d987e7fae8e578cf86e85b697e1f Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Tue, 6 Nov 2018 14:07:55 -0800 Subject: Get rid of unused properties --- packages/instant/src/components/ui/container.tsx | 2 -- packages/instant/src/components/ui/flex.tsx | 2 -- 2 files changed, 4 deletions(-) (limited to 'packages') diff --git a/packages/instant/src/components/ui/container.tsx b/packages/instant/src/components/ui/container.tsx index 0e518be88..d276e0603 100644 --- a/packages/instant/src/components/ui/container.tsx +++ b/packages/instant/src/components/ui/container.tsx @@ -51,8 +51,6 @@ export const Container = ${props => cssRuleIfExists(props, 'right')} ${props => cssRuleIfExists(props, 'bottom')} ${props => cssRuleIfExists(props, 'left')} - ${props => cssRuleIfExists(props, 'width')} - ${props => cssRuleIfExists(props, 'height')} ${props => cssRuleIfExists(props, 'max-width')} ${props => cssRuleIfExists(props, 'margin')} ${props => cssRuleIfExists(props, 'margin-top')} diff --git a/packages/instant/src/components/ui/flex.tsx b/packages/instant/src/components/ui/flex.tsx index c3d643a79..ef005db40 100644 --- a/packages/instant/src/components/ui/flex.tsx +++ b/packages/instant/src/components/ui/flex.tsx @@ -26,8 +26,6 @@ export const Flex = ${props => cssRuleIfExists(props, 'flexGrow')} justify-content: ${props => props.justify}; align-items: ${props => props.align}; - ${props => cssRuleIfExists(props, 'width')} - ${props => cssRuleIfExists(props, 'height')} background-color: ${props => (props.backgroundColor ? props.theme[props.backgroundColor] : 'none')}; ${props => stylesForMedia('width', props.width || 'auto')} ${props => stylesForMedia('height', props.height || 'auto')} -- cgit v1.2.3 From eb3fda059a2d72ee9bfeb1bae39a3c4f6a724e99 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Tue, 6 Nov 2018 14:21:23 -0800 Subject: Fix mobile view of selecting assets --- packages/instant/src/components/erc20_token_selector.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages') diff --git a/packages/instant/src/components/erc20_token_selector.tsx b/packages/instant/src/components/erc20_token_selector.tsx index 481778495..6960f89e7 100644 --- a/packages/instant/src/components/erc20_token_selector.tsx +++ b/packages/instant/src/components/erc20_token_selector.tsx @@ -31,7 +31,7 @@ export class ERC20TokenSelector extends React.Component value={this.state.searchQuery} onChange={this._handleSearchInputChange} /> - + {_.map(tokens, token => { if (!this._isTokenQueryMatch(token)) { return null; -- cgit v1.2.3 From d941901e3281fdb2fd0f9a9b3b23947f05b1c56e Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Tue, 6 Nov 2018 14:26:15 -0800 Subject: Hide X when small --- packages/instant/src/components/ui/container.tsx | 4 ++-- packages/instant/src/components/ui/overlay.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'packages') diff --git a/packages/instant/src/components/ui/container.tsx b/packages/instant/src/components/ui/container.tsx index d276e0603..9ec875cf3 100644 --- a/packages/instant/src/components/ui/container.tsx +++ b/packages/instant/src/components/ui/container.tsx @@ -6,7 +6,7 @@ import { ColorOption, styled } from '../../style/theme'; import { cssRuleIfExists } from '../../style/util'; export interface ContainerProps { - display?: string; + display?: MediaChoice; position?: string; top?: string; right?: string; @@ -45,7 +45,6 @@ export const Container = ` box-sizing: border-box; ${props => cssRuleIfExists(props, 'flex-grow')} - ${props => cssRuleIfExists(props, 'display')} ${props => cssRuleIfExists(props, 'position')} ${props => cssRuleIfExists(props, 'top')} ${props => cssRuleIfExists(props, 'right')} @@ -68,6 +67,7 @@ export const Container = ${props => cssRuleIfExists(props, 'cursor')} ${props => cssRuleIfExists(props, 'overflow')} ${props => (props.hasBoxShadow ? `box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.1)` : '')}; + ${props => stylesForMedia('display', props.display || 'initial')} ${props => stylesForMedia('width', props.width || 'auto')} ${props => stylesForMedia('height', props.height || 'auto')} background-color: ${props => (props.backgroundColor ? props.theme[props.backgroundColor] : 'none')}; diff --git a/packages/instant/src/components/ui/overlay.tsx b/packages/instant/src/components/ui/overlay.tsx index 0fde995e0..7110ee70f 100644 --- a/packages/instant/src/components/ui/overlay.tsx +++ b/packages/instant/src/components/ui/overlay.tsx @@ -15,7 +15,7 @@ export interface OverlayProps { const PlainOverlay: React.StatelessComponent = ({ children, className, onClose }) => ( - + -- cgit v1.2.3 From 9cc7090e28e3b26886f11d8e894073f69f30b854 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Tue, 6 Nov 2018 14:56:42 -0800 Subject: remove old comment --- packages/instant/src/components/ui/container.tsx | 1 - 1 file changed, 1 deletion(-) (limited to 'packages') diff --git a/packages/instant/src/components/ui/container.tsx b/packages/instant/src/components/ui/container.tsx index 9ec875cf3..ce35971f1 100644 --- a/packages/instant/src/components/ui/container.tsx +++ b/packages/instant/src/components/ui/container.tsx @@ -38,7 +38,6 @@ export interface ContainerProps { flexGrow?: string | number; } -// TODO Dont commit flex grow export const Container = styled.div < ContainerProps > -- cgit v1.2.3 From d1444f228d20807382d7ae2eb87db998f5b878fc Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Tue, 6 Nov 2018 14:57:15 -0800 Subject: remove unused import --- packages/instant/src/components/ui/flex.tsx | 2 -- 1 file changed, 2 deletions(-) (limited to 'packages') diff --git a/packages/instant/src/components/ui/flex.tsx b/packages/instant/src/components/ui/flex.tsx index ef005db40..fd218b0cd 100644 --- a/packages/instant/src/components/ui/flex.tsx +++ b/packages/instant/src/components/ui/flex.tsx @@ -1,5 +1,3 @@ -import * as _ from 'lodash'; - import { MediaChoice, stylesForMedia } from '../../style/media'; import { ColorOption, styled } from '../../style/theme'; import { cssRuleIfExists } from '../../style/util'; -- cgit v1.2.3 From d59027f0bc3a906ba2ba542eaa6aa98042993216 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Tue, 6 Nov 2018 15:02:44 -0800 Subject: remove unused dependecny --- packages/instant/src/components/ui/container.tsx | 1 - 1 file changed, 1 deletion(-) (limited to 'packages') diff --git a/packages/instant/src/components/ui/container.tsx b/packages/instant/src/components/ui/container.tsx index ce35971f1..cbb6a3a15 100644 --- a/packages/instant/src/components/ui/container.tsx +++ b/packages/instant/src/components/ui/container.tsx @@ -1,4 +1,3 @@ -import * as _ from 'lodash'; import { darken } from 'polished'; import { MediaChoice, stylesForMedia } from '../../style/media'; -- cgit v1.2.3 From 6861cd746290c076f066cb6e56ecd3ef3f60f607 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Tue, 6 Nov 2018 15:09:00 -0800 Subject: Take out unneeded conditionals --- packages/instant/src/components/zero_ex_instant_container.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages') diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx index f73f9db8b..6d3c6cb27 100644 --- a/packages/instant/src/components/zero_ex_instant_container.tsx +++ b/packages/instant/src/components/zero_ex_instant_container.tsx @@ -42,9 +42,9 @@ export class ZeroExInstantContainer extends React.Component - + -- cgit v1.2.3 From 42c441fafa0a0c2de45904a2f67293152dd954b2 Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 6 Nov 2018 15:12:25 -0800 Subject: feat: add faux externall css file --- packages/instant/public/external.css | 21 +++++++++++++++++++++ packages/instant/public/index.html | 1 + 2 files changed, 22 insertions(+) create mode 100644 packages/instant/public/external.css (limited to 'packages') diff --git a/packages/instant/public/external.css b/packages/instant/public/external.css new file mode 100644 index 000000000..b0d05f618 --- /dev/null +++ b/packages/instant/public/external.css @@ -0,0 +1,21 @@ +/* + CSS file meant to represent an external (integrators) stylesheet and + help ensure that instant looks consistent accross environments. +*/ + +button { + font-size: 50px; + height: 200px; + background-color: red; +} + +input { + padding: 100px; + font-size: 50px; + height: 100px; +} + +p { + background-color: green; + margin: 10px; +} diff --git a/packages/instant/public/index.html b/packages/instant/public/index.html index 033a125a4..f6c809e33 100644 --- a/packages/instant/public/index.html +++ b/packages/instant/public/index.html @@ -5,6 +5,7 @@ 0x Instant Dev Environment + -- cgit v1.2.3 From c30dca69619bf87ed198cf375d21593213798113 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 6 Nov 2018 15:42:54 -0800 Subject: chore(instant): update OrderState enum to follow capitalization conventions --- .../instant/src/components/buy_order_progress.tsx | 8 ++++---- .../src/components/buy_order_state_buttons.tsx | 8 ++++---- .../instant/src/components/instant_heading.tsx | 14 ++++++------- .../containers/latest_buy_quote_order_details.ts | 2 +- .../selected_asset_buy_order_state_buttons.ts | 6 +++--- .../selected_erc20_asset_amount_input.ts | 2 +- packages/instant/src/redux/reducer.ts | 24 +++++++++++----------- packages/instant/src/types.ts | 22 ++++++++++---------- 8 files changed, 43 insertions(+), 43 deletions(-) (limited to 'packages') diff --git a/packages/instant/src/components/buy_order_progress.tsx b/packages/instant/src/components/buy_order_progress.tsx index 7fe4e77e9..bc7319423 100644 --- a/packages/instant/src/components/buy_order_progress.tsx +++ b/packages/instant/src/components/buy_order_progress.tsx @@ -14,12 +14,12 @@ export const BuyOrderProgress: React.StatelessComponent = const { buyOrderState } = props; if ( - buyOrderState.processState === OrderProcessState.PROCESSING || - buyOrderState.processState === OrderProcessState.SUCCESS || - buyOrderState.processState === OrderProcessState.FAILURE + buyOrderState.processState === OrderProcessState.Processing || + buyOrderState.processState === OrderProcessState.Success || + buyOrderState.processState === OrderProcessState.Failure ) { const progress = buyOrderState.progress; - const hasEnded = buyOrderState.processState !== OrderProcessState.PROCESSING; + const hasEnded = buyOrderState.processState !== OrderProcessState.Processing; const expectedTimeMs = progress.expectedEndTimeUnix - progress.startTimeUnix; return ( diff --git a/packages/instant/src/components/buy_order_state_buttons.tsx b/packages/instant/src/components/buy_order_state_buttons.tsx index 0d54d3187..2759ba341 100644 --- a/packages/instant/src/components/buy_order_state_buttons.tsx +++ b/packages/instant/src/components/buy_order_state_buttons.tsx @@ -28,7 +28,7 @@ export interface BuyOrderStateButtonProps { } export const BuyOrderStateButtons: React.StatelessComponent = props => { - if (props.buyOrderProcessingState === OrderProcessState.FAILURE) { + if (props.buyOrderProcessingState === OrderProcessState.Failure) { return ( ); } diff --git a/packages/instant/src/components/buy_order_state_buttons.tsx b/packages/instant/src/components/buy_order_state_buttons.tsx index 0d54d3187..dcac3b62f 100644 --- a/packages/instant/src/components/buy_order_state_buttons.tsx +++ b/packages/instant/src/components/buy_order_state_buttons.tsx @@ -31,10 +31,8 @@ export const BuyOrderStateButtons: React.StatelessComponent - Details diff --git a/packages/instant/src/components/css_reset.tsx b/packages/instant/src/components/css_reset.tsx new file mode 100644 index 000000000..1e47a244a --- /dev/null +++ b/packages/instant/src/components/css_reset.tsx @@ -0,0 +1,34 @@ +import { styled } from '../style/theme'; + +export interface CSSResetProps {} + +export const CSSReset = + styled.div < + CSSResetProps > + ` + /* + * Derived from + * https://github.com/jtrost/Complete-CSS-Reset + */ + + a, abbr, area, article, aside, audio, b, bdo, blockquote, body, button, + canvas, caption, cite, code, col, colgroup, command, datalist, dd, del, + details, dialog, dfn, div, dl, dt, em, embed, fieldset, figure, form, + h1, h2, h3, h4, h5, h6, head, header, hgroup, hr, html, i, iframe, img, + input, ins, keygen, kbd, label, legend, li, map, mark, menu, meter, nav, + noscript, object, ol, optgroup, option, output, p, param, pre, progress, + q, rp, rt, ruby, samp, section, select, small, span, strong, sub, sup, + table, tbody, td, textarea, tfoot, th, thead, time, tr, ul, var, video { + background: transparent; + border: 0; + font-size: 100%; + font: inherit; + margin: 0; + outline: none; + padding: 0; + text-align: left; + text-decoration: none; + vertical-align: baseline; + z-index: 1; + } +`; diff --git a/packages/instant/src/components/placing_order_button.tsx b/packages/instant/src/components/placing_order_button.tsx index 4232e6c22..1aa73c428 100644 --- a/packages/instant/src/components/placing_order_button.tsx +++ b/packages/instant/src/components/placing_order_button.tsx @@ -8,12 +8,10 @@ import { Spinner } from './ui/spinner'; import { Text } from './ui/text'; export const PlacingOrderButton: React.StatelessComponent<{}> = props => ( - ); diff --git a/packages/instant/src/components/secondary_button.tsx b/packages/instant/src/components/secondary_button.tsx index 583058b5b..a6ba0cf9e 100644 --- a/packages/instant/src/components/secondary_button.tsx +++ b/packages/instant/src/components/secondary_button.tsx @@ -16,11 +16,11 @@ export const SecondaryButton: React.StatelessComponent = p borderColor={ColorOption.lightGrey} width={props.width} onClick={props.onClick} + fontColor={ColorOption.primaryColor} + fontSize="16px" {...buttonProps} > - - {props.children} - + {props.children} ); }; diff --git a/packages/instant/src/components/ui/button.tsx b/packages/instant/src/components/ui/button.tsx index 5274d835b..fe0b7e6c7 100644 --- a/packages/instant/src/components/ui/button.tsx +++ b/packages/instant/src/components/ui/button.tsx @@ -6,6 +6,8 @@ import { ColorOption, styled } from '../../style/theme'; export interface ButtonProps { backgroundColor?: ColorOption; borderColor?: ColorOption; + fontColor?: ColorOption; + fontSize?: string; width?: string; padding?: string; type?: string; @@ -24,29 +26,40 @@ const darkenOnHoverAmount = 0.1; const darkenOnActiveAmount = 0.2; const saturateOnFocusAmount = 0.2; export const Button = styled(PlainButton)` - cursor: ${props => (props.isDisabled ? 'default' : 'pointer')}; - transition: background-color, opacity 0.5s ease; - padding: ${props => props.padding}; - border-radius: 3px; - outline: none; - width: ${props => props.width}; - background-color: ${props => (props.backgroundColor ? props.theme[props.backgroundColor] : 'none')}; - border: ${props => (props.borderColor ? `1px solid ${props.theme[props.borderColor]}` : 'none')}; - &:hover { - background-color: ${props => - !props.isDisabled - ? darken(darkenOnHoverAmount, props.theme[props.backgroundColor || 'white']) - : ''} !important; - } - &:active { - background-color: ${props => - !props.isDisabled ? darken(darkenOnActiveAmount, props.theme[props.backgroundColor || 'white']) : ''}; - } - &:disabled { - opacity: 0.5; - } - &:focus { - background-color: ${props => saturate(saturateOnFocusAmount, props.theme[props.backgroundColor || 'white'])}; + && { + all: initial; + box-sizing: border-box; + font-size: 15px; + font-family: 'Inter UI', sans-serif; + font-weight: 600; + font-size: ${props => props.fontSize}; + color: ${props => props.fontColor && props.theme[props.fontColor]}; + cursor: ${props => (props.isDisabled ? 'default' : 'pointer')}; + transition: background-color, opacity 0.5s ease; + padding: ${props => props.padding}; + border-radius: 3px; + text-align: center; + outline: none; + width: ${props => props.width}; + background-color: ${props => (props.backgroundColor ? props.theme[props.backgroundColor] : 'none')}; + border: ${props => (props.borderColor ? `1px solid ${props.theme[props.borderColor]}` : 'none')}; + &:hover { + background-color: ${props => + !props.isDisabled + ? darken(darkenOnHoverAmount, props.theme[props.backgroundColor || 'white']) + : ''} !important; + } + &:active { + background-color: ${props => + !props.isDisabled ? darken(darkenOnActiveAmount, props.theme[props.backgroundColor || 'white']) : ''}; + } + &:disabled { + opacity: 0.5; + } + &:focus { + background-color: ${props => + saturate(saturateOnFocusAmount, props.theme[props.backgroundColor || 'white'])}; + } } `; @@ -55,7 +68,8 @@ Button.defaultProps = { borderColor: ColorOption.primaryColor, width: 'auto', isDisabled: false, - padding: '1em 2.2em', + padding: '.6em 1.2em', + fontSize: '15px', }; Button.displayName = 'Button'; diff --git a/packages/instant/src/components/ui/circle.tsx b/packages/instant/src/components/ui/circle.tsx index eec2777d2..26764ec71 100644 --- a/packages/instant/src/components/ui/circle.tsx +++ b/packages/instant/src/components/ui/circle.tsx @@ -9,10 +9,12 @@ export const Circle = styled.div < CircleProps > ` - width: ${props => props.diameter}px; - height: ${props => props.diameter}px; - background-color: ${props => props.fillColor}; - border-radius: 50%; + && { + width: ${props => props.diameter}px; + height: ${props => props.diameter}px; + background-color: ${props => props.fillColor}; + border-radius: 50%; + } `; Circle.displayName = 'Circle'; diff --git a/packages/instant/src/components/ui/container.tsx b/packages/instant/src/components/ui/container.tsx index a0a187e5f..db3f32f92 100644 --- a/packages/instant/src/components/ui/container.tsx +++ b/packages/instant/src/components/ui/container.tsx @@ -39,41 +39,44 @@ export const Container = styled.div < ContainerProps > ` - box-sizing: border-box; - ${props => cssRuleIfExists(props, 'display')} - ${props => cssRuleIfExists(props, 'position')} - ${props => cssRuleIfExists(props, 'top')} - ${props => cssRuleIfExists(props, 'right')} - ${props => cssRuleIfExists(props, 'bottom')} - ${props => cssRuleIfExists(props, 'left')} - ${props => cssRuleIfExists(props, 'width')} - ${props => cssRuleIfExists(props, 'height')} - ${props => cssRuleIfExists(props, 'max-width')} - ${props => cssRuleIfExists(props, 'margin')} - ${props => cssRuleIfExists(props, 'margin-top')} - ${props => cssRuleIfExists(props, 'margin-right')} - ${props => cssRuleIfExists(props, 'margin-bottom')} - ${props => cssRuleIfExists(props, 'margin-left')} - ${props => cssRuleIfExists(props, 'padding')} - ${props => cssRuleIfExists(props, 'border-radius')} - ${props => cssRuleIfExists(props, 'border')} - ${props => cssRuleIfExists(props, 'border-top')} - ${props => cssRuleIfExists(props, 'border-bottom')} - ${props => cssRuleIfExists(props, 'z-index')} - ${props => cssRuleIfExists(props, 'white-space')} - ${props => cssRuleIfExists(props, 'opacity')} - ${props => cssRuleIfExists(props, 'cursor')} - ${props => cssRuleIfExists(props, 'overflow')} - ${props => (props.hasBoxShadow ? `box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.1)` : '')}; - background-color: ${props => (props.backgroundColor ? props.theme[props.backgroundColor] : 'none')}; - border-color: ${props => (props.borderColor ? props.theme[props.borderColor] : 'none')}; - &:hover { - ${props => - props.darkenOnHover - ? `background-color: ${ - props.backgroundColor ? darken(0.05, props.theme[props.backgroundColor]) : 'none' - }` - : ''}; + && { + all: initial; + box-sizing: border-box; + ${props => cssRuleIfExists(props, 'display')} + ${props => cssRuleIfExists(props, 'position')} + ${props => cssRuleIfExists(props, 'top')} + ${props => cssRuleIfExists(props, 'right')} + ${props => cssRuleIfExists(props, 'bottom')} + ${props => cssRuleIfExists(props, 'left')} + ${props => cssRuleIfExists(props, 'width')} + ${props => cssRuleIfExists(props, 'height')} + ${props => cssRuleIfExists(props, 'max-width')} + ${props => cssRuleIfExists(props, 'margin')} + ${props => cssRuleIfExists(props, 'margin-top')} + ${props => cssRuleIfExists(props, 'margin-right')} + ${props => cssRuleIfExists(props, 'margin-bottom')} + ${props => cssRuleIfExists(props, 'margin-left')} + ${props => cssRuleIfExists(props, 'padding')} + ${props => cssRuleIfExists(props, 'border-radius')} + ${props => cssRuleIfExists(props, 'border')} + ${props => cssRuleIfExists(props, 'border-top')} + ${props => cssRuleIfExists(props, 'border-bottom')} + ${props => cssRuleIfExists(props, 'z-index')} + ${props => cssRuleIfExists(props, 'white-space')} + ${props => cssRuleIfExists(props, 'opacity')} + ${props => cssRuleIfExists(props, 'cursor')} + ${props => cssRuleIfExists(props, 'overflow')} + ${props => (props.hasBoxShadow ? `box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.1)` : '')}; + background-color: ${props => (props.backgroundColor ? props.theme[props.backgroundColor] : 'none')}; + border-color: ${props => (props.borderColor ? props.theme[props.borderColor] : 'none')}; + &:hover { + ${props => + props.darkenOnHover + ? `background-color: ${ + props.backgroundColor ? darken(0.05, props.theme[props.backgroundColor]) : 'none' + }` + : ''}; + } } `; diff --git a/packages/instant/src/components/ui/flex.tsx b/packages/instant/src/components/ui/flex.tsx index 29c6511bb..1ec8d1f92 100644 --- a/packages/instant/src/components/ui/flex.tsx +++ b/packages/instant/src/components/ui/flex.tsx @@ -16,14 +16,17 @@ export const Flex = styled.div < FlexProps > ` - display: ${props => (props.inline ? 'inline-flex' : 'flex')}; - flex-direction: ${props => props.direction}; - flex-wrap: ${props => props.flexWrap}; - justify-content: ${props => props.justify}; - align-items: ${props => props.align}; - ${props => cssRuleIfExists(props, 'width')} - ${props => cssRuleIfExists(props, 'height')} - background-color: ${props => (props.backgroundColor ? props.theme[props.backgroundColor] : 'none')}; + && { + all: initial; + display: ${props => (props.inline ? 'inline-flex' : 'flex')}; + flex-direction: ${props => props.direction}; + flex-wrap: ${props => props.flexWrap}; + justify-content: ${props => props.justify}; + align-items: ${props => props.align}; + ${props => cssRuleIfExists(props, 'width')} + ${props => cssRuleIfExists(props, 'height')} + background-color: ${props => (props.backgroundColor ? props.theme[props.backgroundColor] : 'none')}; + } `; Flex.defaultProps = { diff --git a/packages/instant/src/components/ui/icon.tsx b/packages/instant/src/components/ui/icon.tsx index 94ea26900..2679dad1a 100644 --- a/packages/instant/src/components/ui/icon.tsx +++ b/packages/instant/src/components/ui/icon.tsx @@ -101,15 +101,17 @@ const PlainIcon: React.StatelessComponent = props => { }; export const Icon = withTheme(styled(PlainIcon)` - cursor: ${props => (!_.isUndefined(props.onClick) ? 'pointer' : 'default')}; - transition: opacity 0.5s ease; - padding: ${props => props.padding}; - opacity: ${props => (!_.isUndefined(props.onClick) ? 0.7 : 1)}; - &:hover { - opacity: 1; - } - &:active { - opacity: 1; + && { + cursor: ${props => (!_.isUndefined(props.onClick) ? 'pointer' : 'default')}; + transition: opacity 0.5s ease; + padding: ${props => props.padding}; + opacity: ${props => (!_.isUndefined(props.onClick) ? 0.7 : 1)}; + &:hover { + opacity: 1; + } + &:active { + opacity: 1; + } } `); diff --git a/packages/instant/src/components/ui/input.tsx b/packages/instant/src/components/ui/input.tsx index a884ff7cb..2fb408db4 100644 --- a/packages/instant/src/components/ui/input.tsx +++ b/packages/instant/src/components/ui/input.tsx @@ -16,17 +16,20 @@ export const Input = styled.input < InputProps > ` - font-size: ${props => props.fontSize}; - width: ${props => props.width}; - padding: 0.1em 0em; - font-family: 'Inter UI'; - color: ${props => props.theme[props.fontColor || 'white']}; - background: transparent; - outline: none; - border: none; - &::placeholder { + && { + all: initial; + font-size: ${props => props.fontSize}; + width: ${props => props.width}; + padding: 0.1em 0em; + font-family: 'Inter UI'; color: ${props => props.theme[props.fontColor || 'white']}; - opacity: 0.5; + background: transparent; + outline: none; + border: none; + &::placeholder { + color: ${props => props.theme[props.fontColor || 'white']}; + opacity: 0.5; + } } `; diff --git a/packages/instant/src/components/ui/overlay.tsx b/packages/instant/src/components/ui/overlay.tsx index f1706c874..deb16a0e8 100644 --- a/packages/instant/src/components/ui/overlay.tsx +++ b/packages/instant/src/components/ui/overlay.tsx @@ -22,13 +22,15 @@ const PlainOverlay: React.StatelessComponent = ({ children, classN ); export const Overlay = styled(PlainOverlay)` - position: fixed; - top: 0; - right: 0; - bottom: 0; - left: 0; - z-index: ${props => props.zIndex} - background-color: ${overlayBlack}; + && { + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + z-index: ${props => props.zIndex} + background-color: ${overlayBlack}; + } `; Overlay.defaultProps = { diff --git a/packages/instant/src/components/ui/text.tsx b/packages/instant/src/components/ui/text.tsx index cba6e7b20..c6a76ff18 100644 --- a/packages/instant/src/components/ui/text.tsx +++ b/packages/instant/src/components/ui/text.tsx @@ -27,25 +27,28 @@ export const Text = styled.div < TextProps > ` - font-family: ${props => props.fontFamily}; - font-style: ${props => props.fontStyle}; - font-weight: ${props => props.fontWeight}; - font-size: ${props => props.fontSize}; - opacity: ${props => props.opacity}; - text-decoration-line: ${props => props.textDecorationLine}; - ${props => (props.lineHeight ? `line-height: ${props.lineHeight}` : '')}; - ${props => (props.center ? 'text-align: center' : '')}; - color: ${props => props.fontColor && props.theme[props.fontColor]}; - ${props => (props.minHeight ? `min-height: ${props.minHeight}` : '')}; - ${props => (props.onClick ? 'cursor: pointer' : '')}; - transition: color 0.5s ease; - ${props => (props.noWrap ? 'white-space: nowrap' : '')}; - ${props => (props.display ? `display: ${props.display}` : '')}; - ${props => (props.letterSpacing ? `letter-spacing: ${props.letterSpacing}` : '')}; - ${props => (props.textTransform ? `text-transform: ${props.textTransform}` : '')}; - &:hover { - ${props => - props.onClick ? `color: ${darken(darkenOnHoverAmount, props.theme[props.fontColor || 'white'])}` : ''}; + && { + all: initial; + font-family: 'Inter UI', sans-serif; + font-style: ${props => props.fontStyle}; + font-weight: ${props => props.fontWeight}; + font-size: ${props => props.fontSize}; + opacity: ${props => props.opacity}; + text-decoration-line: ${props => props.textDecorationLine}; + ${props => (props.lineHeight ? `line-height: ${props.lineHeight}` : '')}; + ${props => (props.center ? 'text-align: center' : '')}; + color: ${props => props.fontColor && props.theme[props.fontColor]}; + ${props => (props.minHeight ? `min-height: ${props.minHeight}` : '')}; + ${props => (props.onClick ? 'cursor: pointer' : '')}; + transition: color 0.5s ease; + ${props => (props.noWrap ? 'white-space: nowrap' : '')}; + ${props => (props.display ? `display: ${props.display}` : '')}; + ${props => (props.letterSpacing ? `letter-spacing: ${props.letterSpacing}` : '')}; + ${props => (props.textTransform ? `text-transform: ${props.textTransform}` : '')}; + &:hover { + ${props => + props.onClick ? `color: ${darken(darkenOnHoverAmount, props.theme[props.fontColor || 'white'])}` : ''}; + } } `; @@ -61,14 +64,3 @@ Text.defaultProps = { }; Text.displayName = 'Text'; - -export const Title: React.StatelessComponent = props => ; - -Title.defaultProps = { - fontSize: '20px', - fontWeight: 600, - opacity: 1, - fontColor: ColorOption.primaryColor, -}; - -Title.displayName = 'Title'; diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx index 851dfa2db..efcb263ba 100644 --- a/packages/instant/src/components/zero_ex_instant_container.tsx +++ b/packages/instant/src/components/zero_ex_instant_container.tsx @@ -12,6 +12,7 @@ import { ColorOption } from '../style/theme'; import { zIndex } from '../style/z_index'; import { SlideAnimationState } from './animations/slide_animation'; +import { CSSReset } from './css_reset'; import { SlidingPanel } from './sliding_panel'; import { Container } from './ui/container'; import { Flex } from './ui/flex'; @@ -27,35 +28,37 @@ export class ZeroExInstantContainer extends React.Component - - - - - - - - - - - - - + + + + + - - + + + + + + + + + + + + - + ); } private readonly _handleSymbolClick = (): void => { diff --git a/packages/instant/src/style/theme.ts b/packages/instant/src/style/theme.ts index d10c9b72c..8dada2d28 100644 --- a/packages/instant/src/style/theme.ts +++ b/packages/instant/src/style/theme.ts @@ -1,6 +1,6 @@ import * as styledComponents from 'styled-components'; -const { default: styled, css, keyframes, withTheme, ThemeProvider } = styledComponents; +const { default: styled, css, keyframes, withTheme, createGlobalStyle, ThemeProvider } = styledComponents; export type Theme = { [key in ColorOption]: string }; @@ -33,4 +33,4 @@ export const theme: Theme = { export const transparentWhite = 'rgba(255,255,255,0.3)'; export const overlayBlack = 'rgba(0, 0, 0, 0.6)'; -export { styled, css, keyframes, withTheme, ThemeProvider }; +export { styled, css, keyframes, withTheme, createGlobalStyle, ThemeProvider }; -- cgit v1.2.3 From 4cf6fbc6a3638d21a3e5631cdd7260e12e02e221 Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 6 Nov 2018 16:05:12 -0800 Subject: fix: use fontSize prop in button --- packages/instant/src/components/ui/button.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'packages') diff --git a/packages/instant/src/components/ui/button.tsx b/packages/instant/src/components/ui/button.tsx index fe0b7e6c7..b90221bf4 100644 --- a/packages/instant/src/components/ui/button.tsx +++ b/packages/instant/src/components/ui/button.tsx @@ -29,10 +29,9 @@ export const Button = styled(PlainButton)` && { all: initial; box-sizing: border-box; - font-size: 15px; + font-size: ${props => props.fontSize}; font-family: 'Inter UI', sans-serif; font-weight: 600; - font-size: ${props => props.fontSize}; color: ${props => props.fontColor && props.theme[props.fontColor]}; cursor: ${props => (props.isDisabled ? 'default' : 'pointer')}; transition: background-color, opacity 0.5s ease; -- cgit v1.2.3 From cab71fd4d177dc89431a36e33a43e9cd7f0e7071 Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 6 Nov 2018 16:16:01 -0800 Subject: fix: progress bar --- packages/instant/public/external.css | 2 +- packages/instant/src/components/timed_progress_bar.tsx | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'packages') diff --git a/packages/instant/public/external.css b/packages/instant/public/external.css index c8b3df0d5..cab11112a 100644 --- a/packages/instant/public/external.css +++ b/packages/instant/public/external.css @@ -1,6 +1,6 @@ /* CSS file meant to represent an external (integrators) stylesheet and - help ensure that instant looks consistent accross environments. + help ensure that instant looks consistent across environments. */ button { diff --git a/packages/instant/src/components/timed_progress_bar.tsx b/packages/instant/src/components/timed_progress_bar.tsx index f2a6f5745..aee97eea5 100644 --- a/packages/instant/src/components/timed_progress_bar.tsx +++ b/packages/instant/src/components/timed_progress_bar.tsx @@ -70,9 +70,11 @@ export const TimedProgress = styled.div < TimedProgressProps > ` - background-color: ${props => props.theme[ColorOption.primaryColor]}; - border-radius: 6px; - height: 6px; - animation: ${props => expandingWidthKeyframes(props.fromWidth, props.toWidth)} - ${props => props.timeMs}ms linear 1 forwards; - `; + && { + background-color: ${props => props.theme[ColorOption.primaryColor]}; + border-radius: 6px; + height: 6px; + animation: ${props => expandingWidthKeyframes(props.fromWidth, props.toWidth)} + ${props => props.timeMs}ms linear 1 forwards; + `; + } -- cgit v1.2.3 From d1186e08b458191f578e406997c2b51567a5b49f Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 6 Nov 2018 16:31:52 -0800 Subject: chore: linter --- packages/instant/src/components/buy_button.tsx | 1 - packages/instant/src/components/buy_order_state_buttons.tsx | 1 - packages/instant/src/components/css_reset.tsx | 10 +++++----- packages/instant/src/components/placing_order_button.tsx | 1 - packages/instant/src/components/secondary_button.tsx | 1 - packages/instant/src/components/timed_progress_bar.tsx | 2 +- 6 files changed, 6 insertions(+), 10 deletions(-) (limited to 'packages') diff --git a/packages/instant/src/components/buy_button.tsx b/packages/instant/src/components/buy_button.tsx index 803cdf18d..57b3d108e 100644 --- a/packages/instant/src/components/buy_button.tsx +++ b/packages/instant/src/components/buy_button.tsx @@ -13,7 +13,6 @@ import { gasPriceEstimator } from '../util/gas_price_estimator'; import { util } from '../util/util'; import { Button } from './ui/button'; -import { Text } from './ui/text'; export interface BuyButtonProps { buyQuote?: BuyQuote; diff --git a/packages/instant/src/components/buy_order_state_buttons.tsx b/packages/instant/src/components/buy_order_state_buttons.tsx index dcac3b62f..45ff890b4 100644 --- a/packages/instant/src/components/buy_order_state_buttons.tsx +++ b/packages/instant/src/components/buy_order_state_buttons.tsx @@ -10,7 +10,6 @@ import { SecondaryButton } from './secondary_button'; import { Button } from './ui/button'; import { Flex } from './ui/flex'; -import { Text } from './ui/text'; export interface BuyOrderStateButtonProps { buyQuote?: BuyQuote; diff --git a/packages/instant/src/components/css_reset.tsx b/packages/instant/src/components/css_reset.tsx index 1e47a244a..891c95e4d 100644 --- a/packages/instant/src/components/css_reset.tsx +++ b/packages/instant/src/components/css_reset.tsx @@ -6,18 +6,18 @@ export const CSSReset = styled.div < CSSResetProps > ` - /* + /* * Derived from * https://github.com/jtrost/Complete-CSS-Reset */ - a, abbr, area, article, aside, audio, b, bdo, blockquote, body, button, - canvas, caption, cite, code, col, colgroup, command, datalist, dd, del, + a, abbr, area, article, aside, audio, b, bdo, blockquote, body, button, + canvas, caption, cite, code, col, colgroup, command, datalist, dd, del, details, dialog, dfn, div, dl, dt, em, embed, fieldset, figure, form, - h1, h2, h3, h4, h5, h6, head, header, hgroup, hr, html, i, iframe, img, + h1, h2, h3, h4, h5, h6, head, header, hgroup, hr, html, i, iframe, img, input, ins, keygen, kbd, label, legend, li, map, mark, menu, meter, nav, noscript, object, ol, optgroup, option, output, p, param, pre, progress, - q, rp, rt, ruby, samp, section, select, small, span, strong, sub, sup, + q, rp, rt, ruby, samp, section, select, small, span, strong, sub, sup, table, tbody, td, textarea, tfoot, th, thead, time, tr, ul, var, video { background: transparent; border: 0; diff --git a/packages/instant/src/components/placing_order_button.tsx b/packages/instant/src/components/placing_order_button.tsx index 1aa73c428..d774d7d27 100644 --- a/packages/instant/src/components/placing_order_button.tsx +++ b/packages/instant/src/components/placing_order_button.tsx @@ -5,7 +5,6 @@ import { ColorOption } from '../style/theme'; import { Button } from './ui/button'; import { Container } from './ui/container'; import { Spinner } from './ui/spinner'; -import { Text } from './ui/text'; export const PlacingOrderButton: React.StatelessComponent<{}> = props => (