Skip to content

Commit

Permalink
Message File feature added.
Browse files Browse the repository at this point in the history
  • Loading branch information
abdurrahmanekr committed Aug 10, 2017
1 parent 331266e commit ce96e49
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 19 deletions.
Binary file modified public/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions src/ChatItem/ChatItem.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
user-select: none;
max-width: 100%;
overflow: hidden;
min-width: 240px;
}

.rce-citem:hover {
Expand Down
56 changes: 55 additions & 1 deletion src/MessageBox/MessageBox.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
border-top-right-radius: 0px;
margin-right: 20px;
margin-top: 5px;
display: inline-block;
display: flex;
flex-direction: column;
margin-bottom: 5px;
padding: 6px 9px 8px 9px;
Expand Down Expand Up @@ -106,4 +106,58 @@

.rce-mbox-photo--download:active {
opacity: .3;
}

.rce-mbox-file {
background: #e9e9e9;
display: flex;
border-radius: 5px;
margin-top: -3px;
margin-right: -6px;
margin-left: -6px;
align-items: center;
min-height: 52px;
max-width: 500px;
padding: 5px 0;
cursor: pointer;
user-select: none;
outline: none;
border:none;
}

.rce-mbox-file > * {
padding: 0px 10px;
}

.rce-mbox-file--icon {
font-size: 30px;
align-items: center;
display: flex;
flex-direction: column;
}

.rce-mbox-file--size {
font-size: 10px;
margin-top: 3px;
max-width: 52px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.rce-mbox-file--text {
font-size: 13.6px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.rce-mbox-file--buttons {
font-size: 30px;
align-items: center;
display: flex;
}

.rce-mbox-file--loading {
font-size: 15px;
}
39 changes: 39 additions & 0 deletions src/MessageBox/MessageBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from 'react';
import './MessageBox.css';

import FaCloudDownload from 'react-icons/lib/fa/cloud-download';
import FaFile from 'react-icons/lib/fa/file';

const classNames = require('classnames');
const ProgressBar = require('react-progressbar.js');
Expand All @@ -26,6 +27,10 @@ export class MessageBox extends Component {
circle.setText(value);
}
};
var fileProgressOptions = Object.assign({}, progressOptions);
fileProgressOptions.strokeWidth = 5;
fileProgressOptions.color = '#333';
fileProgressOptions.trailWidth = 5;

return (
<div className="rce-container-mbox">
Expand Down Expand Up @@ -74,6 +79,40 @@ export class MessageBox extends Component {
</div>
</div>
}
{
this.props.type === 'file' &&
<button className="rce-mbox-file">
<div className="rce-mbox-file--icon">
<FaFile
color='#aaa'/>
<div className="rce-mbox-file--size">
1024mB
</div>
</div>
<div className="rce-mbox-file--text">
{this.props.text}
</div>
<div className="rce-mbox-file--buttons">
{
!this.props.data.status.click &&
<FaCloudDownload
color='#aaa'/>
}
{
this.props.data.status.loading !== 0 &&
<Circle
progress={this.props.data.status.loading}
options={fileProgressOptions}
initialAnimate={true}
containerStyle={{
width: '40px',
height: '40px',
}}
containerClassName={'rce-mbox-file--loading'} />
}
</div>
</button>
}
<div className="rce-mbox-time rce-mbox-right">
12:30
</div>
Expand Down
5 changes: 5 additions & 0 deletions src/assets/style.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
body {
font-family: verdana, ubuntu;
background: navajowhite;
}

input,
button {
font-family: verdana, ubuntu;
}
42 changes: 24 additions & 18 deletions src/example/App.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import React, { Component } from 'react';
import MessageBox from '../MessageBox/MessageBox';
import ChatItem from '../ChatItem/ChatItem';

const loremIpsum = require('lorem-ipsum');

export class App extends Component {
random() {
return {
unread: parseInt(Math.random() * 10 % 2),
title: loremIpsum({count: 1, units: 'sentences'}),
avatar: 'https://avatars0.githubusercontent.com/u/15075759?v=4',
subtitle: loremIpsum({count: 1, units: 'sentences'}),
date: new Date().setDate(1),
position: (parseInt(Math.random() * 10 % 2) && 'right'),
type: (parseInt(Math.random() * 10 % 2) ? 'file' : 'photo'),
text: loremIpsum({count: 1, units: 'sentences'}),
data: {
uri: 'https://user-images.githubusercontent.com/15075759/29005175-1d023bea-7ade-11e7-86d5-21f87225ef56.png',
status: {
click: true,
loading: 1,
}
},
date: new Date(),
};
}

Expand All @@ -22,20 +27,21 @@ export class App extends Component {
{
arr.map((x, i) => {
var tmp = this.random();
return <ChatItem
key={i}
title={tmp.title}
subtitle={tmp.subtitle}
avatar={tmp.avatar}
unread={tmp.unread}
date={tmp.date}/>;

// return <MessageBox
// return <ChatItem
// key={i}
// type={tmp.type}
// text={tmp.text}
// data={tmp.data}
// position={tmp.position}/>;
// title={tmp.title}
// subtitle={tmp.subtitle}
// avatar={tmp.avatar}
// unread={tmp.unread}
// date={tmp.date}/>;

return <MessageBox
key={i}
type={tmp.type}
text={tmp.text}
data={tmp.data}
position={tmp.position}/>
})
}
</div>
Expand Down

0 comments on commit ce96e49

Please sign in to comment.