Skip to content

Commit 634df54

Browse files
author
jonisaa
committed
#2 Extracted inline styles to a style object, Start to tune FileInfo component
1 parent 77191d7 commit 634df54

File tree

2 files changed

+31
-22
lines changed

2 files changed

+31
-22
lines changed

src/components/common/FileInfo.js

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

45
const FileUploadItem = ({ file, height, width }) => {
@@ -9,11 +10,11 @@ const FileUploadItem = ({ file, height, width }) => {
910
}
1011

1112
return (
12-
<li>
13+
<Col xs={4} md={4}>
1314
{image}
1415
<p>{file.name}</p>
1516
<p>{filesize(file.size)}</p>
16-
</li>
17+
</Col>
1718
);
1819
};
1920

@@ -24,8 +25,8 @@ FileUploadItem.propTypes = {
2425
};
2526

2627
FileUploadItem.defaultProps = {
27-
height: "50px",
28-
width: "50px"
28+
height: "150px",
29+
width: "150px"
2930
};
3031

3132
export default FileUploadItem;

src/components/field/FileUpload.js

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,42 +43,50 @@ 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+
if (files) {
63+
rowStyle = {
64+
padding: "10px"
65+
}
66+
}
67+
6068
return (
6169
<div>
6270
<Row>
6371
<Col xs={2} md={2}>
64-
<div style={styles.titleDiv}>
72+
<div style={attachmentStyle}>
6573
<b>Attachment</b>
6674
</div>
6775
</Col>
6876
<Col xs={10} md={10}>
6977
<DropZone onDrop={this.onDrop}>
70-
<div style={styles.div}>
71-
<p style={styles.p}>
78+
<div style={messageContainerStyle}>
79+
<p style={messageStyle}>
7280
<Glyphicon glyph="cloud-upload"/> Drop files to attach, or <a>browse</a>
7381
</p>
7482
</div>
75-
<div>
76-
<ul>{
83+
<div style={rowStyle}>
84+
<Row>{
7785
files.map((file, index) => (
7886
<FileInfo key={index} file={file}/>
7987
))
8088
}
81-
</ul>
89+
</Row>
8290
</div>
8391
</DropZone>
8492
</Col>

0 commit comments

Comments
 (0)