Skip to content

Commit dd9add8

Browse files
author
daniel.gomez
committed
Merge remote-tracking branch 'origin/experimental' into experimental
2 parents 5f20693 + 6bda429 commit dd9add8

File tree

2 files changed

+68
-41
lines changed

2 files changed

+68
-41
lines changed

src/components/common/FileInfo.js

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,49 @@
11
import React, { Component, PropTypes } from 'react';
2+
import { Col } from 'react-bootstrap';
23
import filesize from 'filesize';
34

4-
const FileUploadItem = ({ file, height, width }) => {
5-
let image = null;
5+
export default class FileUploadItem extends Component {
6+
static propTypes = {
7+
onClick: PropTypes.func,
8+
file: PropTypes.object.isRequired,
9+
height: PropTypes.string,
10+
width: PropTypes.string
11+
};
612

7-
if (file.type.match(/image/)) {
8-
image = <img height={height} width={width} src={file.preview}/>;
9-
}
13+
static defaultProps = {
14+
height: "150px",
15+
width: "150px"
16+
};
17+
18+
render() {
19+
let { file, height, width } = this.props;
1020

11-
return (
12-
<li>
13-
{image}
14-
<p>{file.name}</p>
15-
<p>{filesize(file.size)}</p>
16-
</li>
17-
);
18-
};
21+
const imgStyle = {
22+
display: 'block',
23+
marginLeft: 'auto',
24+
marginRight: 'auto'
25+
};
1926

20-
FileUploadItem.propTypes = {
21-
file: PropTypes.object.isRequired,
22-
height: PropTypes.string,
23-
width: PropTypes.string
24-
};
27+
let image = null;
2528

26-
FileUploadItem.defaultProps = {
27-
height: "50px",
28-
width: "50px"
29-
};
29+
if (file.type.match(/image/)) {
30+
image = <img height={height} width={width} src={file.preview} style={imgStyle}/>;
31+
}
3032

31-
export default FileUploadItem;
33+
return (
34+
<Col xs={4} md={4}>
35+
<div style={{backgroundColor: "#e0e0e0"}}>
36+
<div>
37+
{image}
38+
</div>
39+
<div>
40+
<p style={{textAlign: 'center'}}>
41+
<a>{file.name}</a>
42+
</p>
43+
<p style={{textAlign: 'right'}}>{filesize(file.size)}</p>
44+
</div>
45+
</div>
46+
</Col>
47+
);
48+
}
49+
};

src/components/field/FileUpload.js

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,42 +43,51 @@ export default class FileUpload extends Component {
4343
let { files } = this.state;
4444

4545
//TODO Think how to manage styles correctly
46-
const styles = {
47-
titleDiv: {
48-
marginTop: "6px",
49-
color: "#616161"
50-
},
51-
div: {
52-
marginTop: "6px"
53-
},
54-
p: {
55-
textAlign: "center",
56-
color: "#616161"
57-
}
46+
const attachmentStyle = {
47+
marginTop: "6px",
48+
color: "#616161"
49+
};
50+
51+
const messageContainerStyle = {
52+
marginTop: "6px"
53+
};
54+
55+
const messageStyle = {
56+
textAlign: "center",
57+
color: "#616161"
5858
};
5959

60+
let rowStyle = {};
61+
62+
//TODO check row
63+
if (files) {
64+
rowStyle = {
65+
padding: "10px"
66+
}
67+
}
68+
6069
return (
6170
<div>
6271
<Row>
6372
<Col xs={2} md={2}>
64-
<div style={styles.titleDiv}>
73+
<div style={attachmentStyle}>
6574
<b>Attachment</b>
6675
</div>
6776
</Col>
6877
<Col xs={10} md={10}>
6978
<DropZone onDrop={this.onDrop}>
70-
<div style={styles.div}>
71-
<p style={styles.p}>
79+
<div style={messageContainerStyle}>
80+
<p style={messageStyle}>
7281
<Glyphicon glyph="cloud-upload"/> Drop files to attach, or <a>browse</a>
7382
</p>
7483
</div>
75-
<div>
76-
<ul>{
84+
<div style={rowStyle}>
85+
<Row>{
7786
files.map((file, index) => (
7887
<FileInfo key={index} file={file}/>
7988
))
8089
}
81-
</ul>
90+
</Row>
8291
</div>
8392
</DropZone>
8493
</Col>

0 commit comments

Comments
 (0)