2020-02-14 17:44:54 +01:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
2020-03-05 14:38:51 +01:00
|
|
|
import Text from '../Text';
|
2020-02-14 17:44:54 +01:00
|
|
|
import CardImgWrapper from '../CardImgWrapper';
|
2020-03-02 00:21:43 +01:00
|
|
|
import CardPreview from '../CardPreview';
|
2020-02-14 17:44:54 +01:00
|
|
|
import Wrapper from './Wrapper';
|
|
|
|
import Title from './Title';
|
|
|
|
|
2020-03-05 16:13:44 +01:00
|
|
|
// TODO - adapt with the real data
|
2020-03-06 17:19:20 +01:00
|
|
|
const Card = ({
|
|
|
|
checked,
|
|
|
|
children,
|
|
|
|
errorMessage,
|
|
|
|
hasError,
|
|
|
|
mime,
|
|
|
|
name,
|
|
|
|
onChange,
|
|
|
|
small,
|
|
|
|
size,
|
|
|
|
type,
|
|
|
|
url,
|
|
|
|
}) => {
|
2020-02-14 17:44:54 +01:00
|
|
|
return (
|
|
|
|
<Wrapper>
|
|
|
|
<div>
|
2020-03-06 17:19:20 +01:00
|
|
|
<CardImgWrapper small={small} checked={checked} hasError={hasError}>
|
|
|
|
<CardPreview type={mime || type} url={url} />
|
|
|
|
{children}
|
2020-02-14 17:44:54 +01:00
|
|
|
</CardImgWrapper>
|
2020-03-05 14:38:51 +01:00
|
|
|
<Title fontSize="md" fontWeight="bold" ellipsis>
|
2020-03-05 11:21:23 +01:00
|
|
|
{name}
|
|
|
|
</Title>
|
2020-03-09 19:12:21 +01:00
|
|
|
<Text color="grey" fontSize="xs" ellipsis>{`${type} - ${size}`}</Text>
|
2020-03-06 17:19:20 +01:00
|
|
|
{hasError && <p style={{ marginBottom: 14 }}>{errorMessage}</p>}
|
2020-02-14 17:44:54 +01:00
|
|
|
</div>
|
|
|
|
</Wrapper>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
Card.defaultProps = {
|
2020-03-05 16:13:44 +01:00
|
|
|
checked: false,
|
2020-03-06 17:19:20 +01:00
|
|
|
children: null,
|
|
|
|
hasError: false,
|
2020-03-05 16:13:44 +01:00
|
|
|
name: null,
|
2020-03-02 14:33:16 +01:00
|
|
|
onChange: () => {},
|
2020-03-05 16:13:44 +01:00
|
|
|
size: 0,
|
2020-03-05 14:34:05 +01:00
|
|
|
small: false,
|
2020-03-05 16:13:44 +01:00
|
|
|
type: null,
|
|
|
|
url: null,
|
2020-02-14 17:44:54 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
Card.propTypes = {
|
2020-03-05 16:13:44 +01:00
|
|
|
checked: PropTypes.bool,
|
2020-03-06 17:19:20 +01:00
|
|
|
children: PropTypes.node,
|
|
|
|
hasError: PropTypes.bool,
|
2020-03-05 16:13:44 +01:00
|
|
|
name: PropTypes.string,
|
2020-03-02 14:33:16 +01:00
|
|
|
onChange: PropTypes.func,
|
2020-03-05 16:13:44 +01:00
|
|
|
size: PropTypes.number,
|
2020-03-05 14:34:05 +01:00
|
|
|
small: PropTypes.bool,
|
2020-03-05 16:13:44 +01:00
|
|
|
type: PropTypes.string,
|
|
|
|
url: PropTypes.string,
|
2020-02-14 17:44:54 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Card;
|