2020-02-13 09:01:32 +01:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
2020-03-02 00:21:43 +01:00
|
|
|
import createMatrix from '../../utils/createMatrix';
|
|
|
|
|
2020-02-14 17:44:54 +01:00
|
|
|
import Card from '../Card';
|
2020-03-02 00:21:43 +01:00
|
|
|
import Wrapper from './Wrapper';
|
2020-02-14 17:44:54 +01:00
|
|
|
|
2020-03-02 14:33:16 +01:00
|
|
|
const List = ({ data, onChange, selectedItems }) => {
|
2020-03-02 00:21:43 +01:00
|
|
|
const matrix = createMatrix(data);
|
|
|
|
|
2020-02-14 17:44:54 +01:00
|
|
|
return (
|
2020-03-02 00:21:43 +01:00
|
|
|
<Wrapper>
|
|
|
|
{matrix.map(({ key, rowContent }) => {
|
|
|
|
return (
|
|
|
|
<div className="row" key={key}>
|
2020-03-02 14:33:16 +01:00
|
|
|
{rowContent.map(item => {
|
|
|
|
return (
|
2020-03-05 14:34:05 +01:00
|
|
|
<div className="col-xs-12 col-md-6 col-xl-3" key={JSON.stringify(item)}>
|
2020-03-02 14:33:16 +01:00
|
|
|
<Card
|
2020-03-05 14:34:05 +01:00
|
|
|
small
|
2020-03-05 16:13:44 +01:00
|
|
|
checked={selectedItems.includes(item.id)}
|
2020-03-02 14:33:16 +01:00
|
|
|
onChange={onChange}
|
|
|
|
{...item}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
})}
|
2020-03-02 00:21:43 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</Wrapper>
|
2020-02-14 17:44:54 +01:00
|
|
|
);
|
2020-02-13 09:01:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
List.defaultProps = {
|
2020-03-02 00:21:43 +01:00
|
|
|
data: [
|
|
|
|
{
|
2020-03-02 14:33:16 +01:00
|
|
|
id: '0',
|
2020-03-05 16:13:44 +01:00
|
|
|
name: 'Chat paysage',
|
|
|
|
size: 17329,
|
|
|
|
type: 'image/png',
|
|
|
|
url:
|
|
|
|
'https://images.pexels.com/photos/20787/pexels-photo.jpg?auto=compress&cs=tinysrgb&h=350',
|
2020-03-02 00:21:43 +01:00
|
|
|
},
|
|
|
|
{
|
2020-03-02 14:33:16 +01:00
|
|
|
id: '1',
|
2020-03-05 16:13:44 +01:00
|
|
|
name: 'Chat portrait',
|
|
|
|
size: 17329,
|
|
|
|
type: 'image/png',
|
|
|
|
url: 'https://emiliedammedumoulin.com/wp-content/uploads/2018/07/contact-chat-accueil.jpg',
|
2020-03-02 00:21:43 +01:00
|
|
|
},
|
|
|
|
{
|
2020-03-02 14:33:16 +01:00
|
|
|
id: '2',
|
2020-03-05 16:13:44 +01:00
|
|
|
name: 'Gif',
|
|
|
|
size: 17329,
|
|
|
|
type: 'image/png',
|
|
|
|
url:
|
|
|
|
'https://user-images.githubusercontent.com/879561/51321923-54024f00-1a64-11e9-8c37-3308350a59c4.gif',
|
2020-03-02 00:21:43 +01:00
|
|
|
},
|
|
|
|
{
|
2020-03-02 14:33:16 +01:00
|
|
|
id: '3',
|
2020-03-05 16:13:44 +01:00
|
|
|
name: 'Paysage',
|
|
|
|
size: 17329,
|
|
|
|
type: 'image/png',
|
|
|
|
url:
|
|
|
|
'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcSyHCXO8D0QQrPDuGstvH9dEwhhB7Qv-3mDMWGpLExyY1CF84cL',
|
2020-03-02 00:21:43 +01:00
|
|
|
},
|
|
|
|
{
|
2020-03-02 14:33:16 +01:00
|
|
|
id: '4',
|
2020-03-05 16:13:44 +01:00
|
|
|
name: 'That kitten is so beautiful that I am not sure to have the place to describe it',
|
|
|
|
size: 17329,
|
|
|
|
type: 'image/png',
|
|
|
|
url:
|
|
|
|
'https://images.pexels.com/photos/1643457/pexels-photo-1643457.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500',
|
2020-03-02 00:21:43 +01:00
|
|
|
},
|
|
|
|
{
|
2020-03-02 14:33:16 +01:00
|
|
|
id: '5',
|
2020-03-05 16:13:44 +01:00
|
|
|
name: 'pdf file',
|
|
|
|
type: 'pdf',
|
2020-03-02 00:21:43 +01:00
|
|
|
},
|
|
|
|
{
|
2020-03-02 14:33:16 +01:00
|
|
|
id: '6',
|
2020-03-05 16:13:44 +01:00
|
|
|
name: 'Zip file',
|
|
|
|
type: 'zip',
|
2020-03-02 00:21:43 +01:00
|
|
|
},
|
|
|
|
{
|
2020-03-02 14:33:16 +01:00
|
|
|
id: '7',
|
2020-03-05 16:13:44 +01:00
|
|
|
name: 'Doc file',
|
|
|
|
type: 'docx',
|
2020-03-02 00:21:43 +01:00
|
|
|
},
|
|
|
|
],
|
2020-03-02 14:33:16 +01:00
|
|
|
onChange: () => {},
|
|
|
|
selectedItems: [],
|
2020-02-13 09:01:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
List.propTypes = {
|
2020-02-13 10:02:28 +01:00
|
|
|
data: PropTypes.array,
|
2020-03-02 14:33:16 +01:00
|
|
|
onChange: PropTypes.func,
|
|
|
|
selectedItems: PropTypes.array,
|
2020-02-13 09:01:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default List;
|