Skip to content
Snippets Groups Projects
Commit ffb57588 authored by Anthony's avatar Anthony
Browse files

Improve thumbnail preview. Loading only on expanding accordion

parent dfd807a6
Branches
Tags
1 merge request!17WIP thumbnail on accordion.
...@@ -30,6 +30,7 @@ export class AnnotationManifestsAccordion extends Component { ...@@ -30,6 +30,7 @@ export class AnnotationManifestsAccordion extends Component {
const { annotation } = this.props; const { annotation } = this.props;
annotation.manifestsOpen = false;
annotation.manifests = searchManifestInID(annotation.id); annotation.manifests = searchManifestInID(annotation.id);
if (annotation.manifests) { if (annotation.manifests) {
annotation.manifests = annotation.manifests.map(id => ({ id })); annotation.manifests = annotation.manifests.map(id => ({ id }));
...@@ -43,7 +44,10 @@ export class AnnotationManifestsAccordion extends Component { ...@@ -43,7 +44,10 @@ export class AnnotationManifestsAccordion extends Component {
/** */ /** */
// eslint-disable-next-line class-methods-use-this,require-jsdoc // eslint-disable-next-line class-methods-use-this,require-jsdoc
handleOpenAccordion(e) { handleOpenAccordion(e) {
let { annotation } = this.state;
annotation.manifestsOpen = true;
e.stopPropagation(); e.stopPropagation();
this.state = { annotation };
} }
/** */ /** */
...@@ -67,6 +71,8 @@ export class AnnotationManifestsAccordion extends Component { ...@@ -67,6 +71,8 @@ export class AnnotationManifestsAccordion extends Component {
> >
<Typography className={classes.heading}>{t('manifestFound')}</Typography> <Typography className={classes.heading}>{t('manifestFound')}</Typography>
</AccordionSummary> </AccordionSummary>
{
annotation.manifestsOpen && (
<AccordionDetails className={classes.manifestContainer}> <AccordionDetails className={classes.manifestContainer}>
{annotation.manifests.map(manifest => ( {annotation.manifests.map(manifest => (
<AnnotationManifestsItem <AnnotationManifestsItem
...@@ -77,6 +83,8 @@ export class AnnotationManifestsAccordion extends Component { ...@@ -77,6 +83,8 @@ export class AnnotationManifestsAccordion extends Component {
/> />
))} ))}
</AccordionDetails> </AccordionDetails>
)
}
</Accordion> </Accordion>
</div> </div>
); );
...@@ -90,6 +98,7 @@ AnnotationManifestsAccordion.propsTypes = { ...@@ -90,6 +98,7 @@ AnnotationManifestsAccordion.propsTypes = {
content: PropTypes.string, content: PropTypes.string,
id: PropTypes.string, id: PropTypes.string,
manifests: PropTypes.arrayOf(PropTypes.string), manifests: PropTypes.arrayOf(PropTypes.string),
manifestsOpen: PropTypes.boolean,
}, },
), ),
classes: PropTypes.objectOf(PropTypes.string), classes: PropTypes.objectOf(PropTypes.string),
......
...@@ -6,6 +6,7 @@ import { ...@@ -6,6 +6,7 @@ import {
} from '@material-ui/core'; } from '@material-ui/core';
import Button from '@material-ui/core/Button'; import Button from '@material-ui/core/Button';
import Tooltip from '@material-ui/core/Tooltip'; import Tooltip from '@material-ui/core/Tooltip';
import ns from '../config/css-ns';
/** /**
* AnnotationManifestsItem * AnnotationManifestsItem
...@@ -39,7 +40,7 @@ export class AnnotationManifestsItem extends Component { ...@@ -39,7 +40,7 @@ export class AnnotationManifestsItem extends Component {
/** */ /** */
render() { render() {
const { const {
classes, t, language, manifestId, thumbnail classes, t, language, manifestId, thumbnail, title, description
} = this.props; } = this.props;
return ( return (
...@@ -49,16 +50,24 @@ export class AnnotationManifestsItem extends Component { ...@@ -49,16 +50,24 @@ export class AnnotationManifestsItem extends Component {
{ {
thumbnail && ( thumbnail && (
<CardMedia <CardMedia
className={classes.thumbnail}
component="img" component="img"
height="140" height="140"
image={[thumbnail]} image={thumbnail}
alt="green iguana" alt="green iguana"
/> />
)} )
}
<CardContent> <CardContent>
<Typography> <Typography>
{ manifestId } { title || manifestId }
</Typography> </Typography>
{
description && (
<Typography>
{ description }
</Typography>
)}
</CardContent> </CardContent>
</CardActionArea> </CardActionArea>
<CardActions> <CardActions>
...@@ -84,14 +93,15 @@ AnnotationManifestsItem.propsTypes = { ...@@ -84,14 +93,15 @@ AnnotationManifestsItem.propsTypes = {
addResource: PropTypes.func.isRequired, addResource: PropTypes.func.isRequired,
addWindow: PropTypes.func.isRequired, addWindow: PropTypes.func.isRequired,
classes: PropTypes.objectOf(PropTypes.string), classes: PropTypes.objectOf(PropTypes.string),
description: PropTypes.string,
error: PropTypes.string,
fetchManifest: PropTypes.func.isRequired, fetchManifest: PropTypes.func.isRequired,
manifests: PropTypes.arrayOf(PropTypes.string), isFetching: PropTypes.bool,
t: PropTypes.func.isRequired,
manifestLogo: PropTypes.string, manifestLogo: PropTypes.string,
manifests: PropTypes.arrayOf(PropTypes.string),
provider: PropTypes.string, provider: PropTypes.string,
ready: PropTypes.bool, ready: PropTypes.bool,
isFetching: PropTypes.bool, t: PropTypes.func.isRequired,
error: PropTypes.string,
thumbnail: PropTypes.string, thumbnail: PropTypes.string,
title: PropTypes.string, title: PropTypes.string,
}; };
......
...@@ -6,7 +6,7 @@ import { withPlugins } from '../extend/withPlugins'; ...@@ -6,7 +6,7 @@ import { withPlugins } from '../extend/withPlugins';
import * as actions from '../state/actions'; import * as actions from '../state/actions';
import { AnnotationManifestsItem } from '../components/AnnotationManifestsItem'; import { AnnotationManifestsItem } from '../components/AnnotationManifestsItem';
import { import {
getManifest, getManifestLogo, getManifest, getManifestDescription, getManifestLogo,
getManifestProvider, getManifestThumbnail, getManifestTitle, getManifestProvider, getManifestThumbnail, getManifestTitle,
getWindowManifests, getWindowManifests,
} from '../state/selectors'; } from '../state/selectors';
...@@ -16,7 +16,9 @@ const mapStateToProps = (state, { manifestId }) => { ...@@ -16,7 +16,9 @@ const mapStateToProps = (state, { manifestId }) => {
const manifest = getManifest(state, { manifestId }) || {}; const manifest = getManifest(state, { manifestId }) || {};
return { return {
active: getWindowManifests(state).includes(manifestId), active: getWindowManifests(state)
.includes(manifestId),
description: getManifestDescription(state, { manifestId }),
error: manifest.error, error: manifest.error,
isFetching: manifest.isFetching, isFetching: manifest.isFetching,
manifestLogo: getManifestLogo(state, { manifestId }), manifestLogo: getManifestLogo(state, { manifestId }),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment