spee.ch/client/components/AssetPreview/view.jsx

43 lines
1.1 KiB
React
Raw Normal View History

import React from 'react';
import { Link } from 'react-router-dom';
const AssetPreview = ({ defaultThumbnail, claimData: { name, claimId, fileExt, contentType, thumbnail } }) => {
2018-01-31 19:40:26 +01:00
const directSourceLink = `${claimId}/${name}.${fileExt}`;
2018-02-23 20:04:17 +01:00
const showUrlLink = `/${claimId}/${name}`;
return (
<div className='asset-holder'>
<Link to={showUrlLink} >
{(() => {
switch (contentType) {
case 'image/jpeg':
case 'image/jpg':
case 'image/png':
case 'image/gif':
return (
2018-03-02 18:36:28 +01:00
<img
className={'asset-preview'}
src={directSourceLink}
alt={name}
/>
);
case 'video/mp4':
return (
2018-03-02 18:36:28 +01:00
<img
2018-03-04 21:17:03 +01:00
className={'asset-preview video'}
2018-03-02 18:36:28 +01:00
src={thumbnail || defaultThumbnail}
alt={name}
/>
);
default:
return (
<p>unsupported file type</p>
);
}
})()}
</Link>
</div>
);
};
export default AssetPreview;