Merge pull request #1152 from 0xProject/feature/website/hide-v1-volume

[website] Add expanded and minimized display types to relayer grid
This commit is contained in:
Kadinsky 2018-10-18 11:32:07 +01:00 committed by GitHub
commit bd8ba14bf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 22 deletions

View File

@ -18,7 +18,7 @@ import { Loading } from 'ts/components/portal/loading';
import { Menu, MenuTheme } from 'ts/components/portal/menu'; import { Menu, MenuTheme } from 'ts/components/portal/menu';
import { Section } from 'ts/components/portal/section'; import { Section } from 'ts/components/portal/section';
import { TextHeader } from 'ts/components/portal/text_header'; import { TextHeader } from 'ts/components/portal/text_header';
import { RelayerIndex } from 'ts/components/relayer_index/relayer_index'; import { RelayerIndex, RelayerIndexCellStyle } from 'ts/components/relayer_index/relayer_index';
import { TokenBalances } from 'ts/components/token_balances'; import { TokenBalances } from 'ts/components/token_balances';
import { TopBar, TopBarDisplayType } from 'ts/components/top_bar/top_bar'; import { TopBar, TopBarDisplayType } from 'ts/components/top_bar/top_bar';
import { TradeHistory } from 'ts/components/trade_history/trade_history'; import { TradeHistory } from 'ts/components/trade_history/trade_history';
@ -541,6 +541,7 @@ export class Portal extends React.Component<PortalProps, PortalState> {
} }
private _renderRelayerIndexSection(): React.ReactNode { private _renderRelayerIndexSection(): React.ReactNode {
const isMobile = utils.isMobileWidth(this.props.screenWidth); const isMobile = utils.isMobileWidth(this.props.screenWidth);
// TODO(bmillman): revert RelayerIndex cellStyle to Expanded once data pipeline is tracking v2 volume
return ( return (
<Section <Section
header={!isMobile && <TextHeader labelText="0x Relayers" />} header={!isMobile && <TextHeader labelText="0x Relayers" />}
@ -551,7 +552,11 @@ export class Portal extends React.Component<PortalProps, PortalState> {
{this._renderStartOnboarding()} {this._renderStartOnboarding()}
</Container> </Container>
)} )}
<RelayerIndex networkId={this.props.networkId} screenWidth={this.props.screenWidth} /> <RelayerIndex
networkId={this.props.networkId}
screenWidth={this.props.screenWidth}
cellStyle={RelayerIndexCellStyle.Minimized}
/>
</Container> </Container>
} }
/> />

View File

@ -14,9 +14,15 @@ import { styled } from 'ts/style/theme';
import { WebsiteBackendRelayerInfo } from 'ts/types'; import { WebsiteBackendRelayerInfo } from 'ts/types';
import { utils } from 'ts/utils/utils'; import { utils } from 'ts/utils/utils';
export enum RelayerGridTileStyle {
Expanded = 0,
Minimized,
}
export interface RelayerGridTileProps { export interface RelayerGridTileProps {
relayerInfo: WebsiteBackendRelayerInfo; relayerInfo: WebsiteBackendRelayerInfo;
networkId: number; networkId: number;
style: RelayerGridTileStyle;
} }
const styles: Styles = { const styles: Styles = {
@ -30,10 +36,14 @@ const styles: Styles = {
height: '100%', height: '100%',
boxSizing: 'border-box', boxSizing: 'border-box',
}, },
header: { expandedHeader: {
height: '50%', height: '50%',
width: '100%', width: '100%',
}, },
minimizedHeader: {
height: '100%',
width: '100%',
},
body: { body: {
height: '50%', height: '50%',
width: '100%', width: '100%',
@ -75,10 +85,12 @@ export const RelayerGridTile: React.StatelessComponent<RelayerGridTileProps> = (
!_.isUndefined(headerImageUrl) && !_.isUndefined(props.relayerInfo.primaryColor) !_.isUndefined(headerImageUrl) && !_.isUndefined(props.relayerInfo.primaryColor)
? props.relayerInfo.primaryColor ? props.relayerInfo.primaryColor
: FALLBACK_PRIMARY_COLOR; : FALLBACK_PRIMARY_COLOR;
const isExpanded = props.style === RelayerGridTileStyle.Expanded;
const headerStyle = isExpanded ? styles.expandedHeader : styles.minimizedHeader;
return ( return (
<Island style={styles.root} Component={GridTile}> <Island style={styles.root} Component={GridTile}>
<div style={styles.innerDiv} onClick={onClick}> <div style={styles.innerDiv} onClick={onClick}>
<div className="flex items-center" style={{ ...styles.header, backgroundColor: headerBackgroundColor }}> <div className="flex items-center" style={{ ...headerStyle, backgroundColor: headerBackgroundColor }}>
<Image <Image
className="mx-auto" className="mx-auto"
src={props.relayerInfo.logoImgUrl} src={props.relayerInfo.logoImgUrl}
@ -86,6 +98,7 @@ export const RelayerGridTile: React.StatelessComponent<RelayerGridTileProps> = (
height={RELAYER_ICON_HEIGHT} height={RELAYER_ICON_HEIGHT}
/> />
</div> </div>
{isExpanded && (
<div style={styles.body}> <div style={styles.body}>
<div className="pb1" style={styles.relayerNameLabel}> <div className="pb1" style={styles.relayerNameLabel}>
{props.relayerInfo.name} {props.relayerInfo.name}
@ -101,6 +114,7 @@ export const RelayerGridTile: React.StatelessComponent<RelayerGridTileProps> = (
</Section> </Section>
</Container> </Container>
</div> </div>
)}
</div> </div>
</Island> </Island>
); );

View File

@ -3,14 +3,20 @@ import CircularProgress from 'material-ui/CircularProgress';
import { GridList } from 'material-ui/GridList'; import { GridList } from 'material-ui/GridList';
import * as React from 'react'; import * as React from 'react';
import { RelayerGridTile } from 'ts/components/relayer_index/relayer_grid_tile'; import { RelayerGridTile, RelayerGridTileStyle } from 'ts/components/relayer_index/relayer_grid_tile';
import { Retry } from 'ts/components/ui/retry'; import { Retry } from 'ts/components/ui/retry';
import { ScreenWidths, WebsiteBackendRelayerInfo } from 'ts/types'; import { ScreenWidths, WebsiteBackendRelayerInfo } from 'ts/types';
import { backendClient } from 'ts/utils/backend_client'; import { backendClient } from 'ts/utils/backend_client';
export enum RelayerIndexCellStyle {
Expanded = 0,
Minimized,
}
export interface RelayerIndexProps { export interface RelayerIndexProps {
networkId: number; networkId: number;
screenWidth: ScreenWidths; screenWidth: ScreenWidths;
cellStyle: RelayerIndexCellStyle;
} }
interface RelayerIndexState { interface RelayerIndexState {
@ -18,7 +24,8 @@ interface RelayerIndexState {
error?: Error; error?: Error;
} }
const CELL_HEIGHT = 290; const CELL_HEIGHT_EXPANDED = 290;
const CELL_HEIGHT_MINIMIZED = 225;
const NUMBER_OF_COLUMNS_LARGE = 3; const NUMBER_OF_COLUMNS_LARGE = 3;
const NUMBER_OF_COLUMNS_MEDIUM = 2; const NUMBER_OF_COLUMNS_MEDIUM = 2;
const NUMBER_OF_COLUMNS_SMALL = 2; const NUMBER_OF_COLUMNS_SMALL = 2;
@ -61,15 +68,23 @@ export class RelayerIndex extends React.Component<RelayerIndexProps, RelayerInde
numberOfRelayers, numberOfRelayers,
this._numberOfColumnsForScreenWidth(this.props.screenWidth), this._numberOfColumnsForScreenWidth(this.props.screenWidth),
); );
const isExpanded = this.props.cellStyle === RelayerIndexCellStyle.Expanded;
const cellHeight = isExpanded ? CELL_HEIGHT_EXPANDED : CELL_HEIGHT_MINIMIZED;
const gridTileStyle = isExpanded ? RelayerGridTileStyle.Expanded : RelayerGridTileStyle.Minimized;
return ( return (
<GridList <GridList
cellHeight={CELL_HEIGHT} cellHeight={cellHeight}
cols={numberOfColumns} cols={numberOfColumns}
padding={GRID_PADDING} padding={GRID_PADDING}
style={{ marginTop: -10, marginBottom: 0 }} style={{ marginTop: -10, marginBottom: 0 }}
> >
{this.state.relayerInfos.map((relayerInfo: WebsiteBackendRelayerInfo, index) => ( {this.state.relayerInfos.map((relayerInfo: WebsiteBackendRelayerInfo, index) => (
<RelayerGridTile key={index} relayerInfo={relayerInfo} networkId={this.props.networkId} /> <RelayerGridTile
key={index}
relayerInfo={relayerInfo}
networkId={this.props.networkId}
style={gridTileStyle}
/>
))} ))}
</GridList> </GridList>
); );