Skip to content
Snippets Groups Projects
Commit 35c78f0d authored by Chris Beer's avatar Chris Beer
Browse files

Use react-image to provide placeholder images (in case there is no image url,...

Use react-image to provide placeholder images (in case there is no image url, the image doesn't load, etc)

Fixes #1966
parent 3d1ad37f
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ import Grid from '@material-ui/core/Grid'; ...@@ -6,6 +6,7 @@ import Grid from '@material-ui/core/Grid';
import Typography from '@material-ui/core/Typography'; import Typography from '@material-ui/core/Typography';
import ReactPlaceholder from 'react-placeholder'; import ReactPlaceholder from 'react-placeholder';
import { TextBlock, TextRow, RectShape } from 'react-placeholder/lib/placeholders'; import { TextBlock, TextRow, RectShape } from 'react-placeholder/lib/placeholders';
import Img from 'react-image';
import ManifestListItemError from '../containers/ManifestListItemError'; import ManifestListItemError from '../containers/ManifestListItemError';
import ns from '../config/css-ns'; import ns from '../config/css-ns';
import 'react-placeholder/lib/reactPlaceholder.css'; import 'react-placeholder/lib/reactPlaceholder.css';
...@@ -94,16 +95,18 @@ export class ManifestListItem extends React.Component { ...@@ -94,16 +95,18 @@ export class ManifestListItem extends React.Component {
> >
<Grid container spacing={24} className={classes.label}> <Grid container spacing={24} className={classes.label}>
<Grid item xs={4} sm={3}> <Grid item xs={4} sm={3}>
{ <Img
<ReactPlaceholder ready={!!thumbnail} type="rect" style={{ width: 120, height: 80 }}>
<img
className={ns('manifest-list-item-thumb')} className={ns('manifest-list-item-thumb')}
src={thumbnail} src={[thumbnail]}
alt="" alt=""
height="80" height="80"
unloader={(
<RectShape
className={classes.placeholder}
style={{ width: 120, height: 80 }}
/>
)}
/> />
</ReactPlaceholder>
}
</Grid> </Grid>
<Grid item xs={8} sm={9}> <Grid item xs={8} sm={9}>
<Typography component="span" variant="h6"> <Typography component="span" variant="h6">
...@@ -119,16 +122,15 @@ export class ManifestListItem extends React.Component { ...@@ -119,16 +122,15 @@ export class ManifestListItem extends React.Component {
</Grid> </Grid>
<Grid item xs={4} sm={2}> <Grid item xs={4} sm={2}>
{ <Img
<ReactPlaceholder ready={!!manifestLogo} type="rect" style={{ width: 60, height: 60 }}> src={[manifestLogo]}
<img
src={manifestLogo}
alt="" alt=""
role="presentation" role="presentation"
className={classes.logo} className={classes.logo}
/> unloader={
</ReactPlaceholder> <RectShape className={classes.placeholder} style={{ width: 60, height: 60 }} />
} }
/>
</Grid> </Grid>
</Grid> </Grid>
</ReactPlaceholder> </ReactPlaceholder>
......
...@@ -48,6 +48,9 @@ const styles = theme => ({ ...@@ -48,6 +48,9 @@ const styles = theme => ({
height: '2.5rem', height: '2.5rem',
paddingRight: 8, paddingRight: 8,
}, },
placeholder: {
backgroundColor: theme.palette.grey[300],
},
}); });
const enhance = compose( const enhance = compose(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment