mirror of
https://github.com/strapi/strapi.git
synced 2025-10-17 02:53:22 +00:00
31 lines
568 B
JavaScript
31 lines
568 B
JavaScript
![]() |
import React from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
|
|
||
|
import FileIcon from '../FileIcon';
|
||
|
import Wrapper from './Wrapper';
|
||
|
import Image from './Image';
|
||
|
|
||
|
const CardPreview = ({ url, type }) => {
|
||
|
const renderFile = () => {
|
||
|
if (!url) {
|
||
|
return <FileIcon fileType={type} />;
|
||
|
}
|
||
|
|
||
|
return <Image src={url} />;
|
||
|
};
|
||
|
|
||
|
return <Wrapper isImg={!!url}>{renderFile()}</Wrapper>;
|
||
|
};
|
||
|
|
||
|
CardPreview.defaultProps = {
|
||
|
url: null,
|
||
|
type: null,
|
||
|
};
|
||
|
|
||
|
CardPreview.propTypes = {
|
||
|
url: PropTypes.string,
|
||
|
type: PropTypes.string,
|
||
|
};
|
||
|
|
||
|
export default CardPreview;
|