From da46eefe2eea9507ae12ed678b15047f1c74366f Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Mon, 18 Jun 2018 12:09:31 -0700 Subject: Create a shared Image component --- .../components/relayer_index/relayer_grid_tile.tsx | 46 ++++++---------------- 1 file changed, 11 insertions(+), 35 deletions(-) (limited to 'packages/website/ts/components/relayer_index') diff --git a/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx b/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx index 0b0e75312..98d6dc0b3 100644 --- a/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx +++ b/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx @@ -5,6 +5,7 @@ import * as React from 'react'; import { TopTokens } from 'ts/components/relayer_index/relayer_top_tokens'; import { Container } from 'ts/components/ui/container'; +import { Image } from 'ts/components/ui/image'; import { Island } from 'ts/components/ui/island'; import { colors } from 'ts/style/colors'; import { WebsiteBackendRelayerInfo } from 'ts/types'; @@ -74,8 +75,16 @@ export const RelayerGridTile: React.StatelessComponent = (
-
- +
+
@@ -112,36 +121,3 @@ const Section = (props: SectionProps) => { }; const NoContent = () =>
{NO_CONTENT_MESSAGE}
; - -interface ImgWithFallbackProps { - src?: string; - fallbackSrc: string; -} -interface ImgWithFallbackState { - imageLoadFailed: boolean; -} -class ImgWithFallback extends React.Component { - constructor(props: ImgWithFallbackProps) { - super(props); - this.state = { - imageLoadFailed: false, - }; - } - public render(): React.ReactNode { - return ( -
- {this._renderImg()} -
- ); - } - private _renderImg(): React.ReactNode { - const src = - this.state.imageLoadFailed || _.isUndefined(this.props.src) ? this.props.fallbackSrc : this.props.src; - return ; - } - private _onError(): void { - this.setState({ - imageLoadFailed: true, - }); - } -} -- cgit v1.2.3