|
@@ -1,10 +1,44 @@
|
1
|
1
|
import React from 'react'
|
|
2
|
+import PropTypes from 'prop-types'
|
2
|
3
|
import classnames from 'classnames'
|
3
|
|
-import imgProfil from '../../img/imgProfil.png'
|
4
|
|
-import imgProfilReverse from '../../img/imgProfil-reverse.png'
|
5
|
4
|
|
6
|
5
|
require('./Timeline.styl')
|
7
|
6
|
|
|
7
|
+const Message = props => (
|
|
8
|
+ <li className={classnames(
|
|
9
|
+ `${props.customClass}__messagelist__item`,
|
|
10
|
+ 'timeline__messagelist__item',
|
|
11
|
+ {
|
|
12
|
+ 'sended': props.fromMe,
|
|
13
|
+ 'received': !props.fromMe
|
|
14
|
+ }
|
|
15
|
+ )}>
|
|
16
|
+ <div className={classnames(`${props.customClass}__messagelist__item__avatar`, 'timeline__messagelist__item__avatar')}>
|
|
17
|
+ <img src={props.avatar} alt='avatar' />
|
|
18
|
+ </div>
|
|
19
|
+ <div
|
|
20
|
+ className={classnames(`${props.customClass}__messagelist__item__createhour`, 'timeline__messagelist__item__createhour')}>
|
|
21
|
+ {props.createdAt.day} à {props.createdAt.hour}
|
|
22
|
+ </div>
|
|
23
|
+ <div
|
|
24
|
+ className={classnames(`${props.customClass}__messagelist__item__content`, 'timeline__messagelist__item__content')}>
|
|
25
|
+ {props.text}
|
|
26
|
+ </div>
|
|
27
|
+ </li>
|
|
28
|
+)
|
|
29
|
+
|
|
30
|
+const Version = props => (
|
|
31
|
+ <li className={classnames(`${props.customClass}__messagelist__version`, 'timeline__messagelist__version')}>
|
|
32
|
+ <div className={classnames(`${props.customClass}__messagelist__version__btn`, 'timeline__messagelist__version__btn btn')}>
|
|
33
|
+ <i className='fa fa-code-fork' />
|
|
34
|
+ version {props.number}
|
|
35
|
+ </div>
|
|
36
|
+ <div className={classnames(`${props.customClass}__messagelist__version__date`, 'timeline__messagelist__version__date')}>
|
|
37
|
+ Créer le {props.createdAt.day}
|
|
38
|
+ </div>
|
|
39
|
+ </li>
|
|
40
|
+)
|
|
41
|
+
|
8
|
42
|
const Timeline = props => {
|
9
|
43
|
return (
|
10
|
44
|
<div className='timeline'>
|
|
@@ -13,82 +47,29 @@ const Timeline = props => {
|
13
|
47
|
</div>
|
14
|
48
|
|
15
|
49
|
<ul className={classnames(`${props.customClass}__messagelist`, 'timeline__messagelist')}>
|
|
50
|
+ { props.timelineData.map(content => {
|
|
51
|
+ switch (content.type) {
|
|
52
|
+ case 'message':
|
|
53
|
+ return <Message
|
|
54
|
+ customClass={props.customClass}
|
|
55
|
+ avatar={content.author.avatar}
|
|
56
|
+ createdAt={content.createdAt}
|
|
57
|
+ text={content.text}
|
|
58
|
+ fromMe={props.loggedUser.id === content.author.id}
|
|
59
|
+ key={content.id}
|
|
60
|
+ />
|
16
|
61
|
|
17
|
|
- <li className={classnames(`${props.customClass}__messagelist__item`, 'timeline__messagelist__item sended')}>
|
18
|
|
- <div className={classnames(`${props.customClass}__messagelist__item__avatar`, 'timeline__messagelist__item__avatar')}>
|
19
|
|
- <img src={imgProfil} alt='avatar' />
|
20
|
|
- </div>
|
21
|
|
- <div
|
22
|
|
- className={classnames(`${props.customClass}__messagelist__item__createhour`, 'timeline__messagelist__item__createhour')}>
|
23
|
|
- 27/11/17 à 11h45
|
24
|
|
- </div>
|
25
|
|
- <div
|
26
|
|
- className={classnames(`${props.customClass}__messagelist__item__content`, 'timeline__messagelist__item__content')}>
|
27
|
|
- Proident esse laboris in sed officia exercitation ut anim ea.
|
28
|
|
- </div>
|
29
|
|
- </li>
|
30
|
|
-
|
31
|
|
- <li className={classnames(`${props.customClass}__messagelist__item`, 'timeline__messagelist__item received')}>
|
32
|
|
- <div className={classnames(`${props.customClass}__messagelist__item__avatar`, 'timeline__messagelist__item__avatar')}>
|
33
|
|
- <img src={imgProfilReverse} alt='avatar' />
|
34
|
|
- </div>
|
35
|
|
- <div
|
36
|
|
- className={classnames(`${props.customClass}__messagelist__item__createhour`, 'timeline__messagelist__item__createhour')}>
|
37
|
|
- 27/11/17 à 11h47
|
38
|
|
- </div>
|
39
|
|
- <div
|
40
|
|
- className={classnames(`${props.customClass}__messagelist__item__content`, 'timeline__messagelist__item__content')}>
|
41
|
|
- Proident esse laboris in sed officia exercitation ut anim ea.
|
42
|
|
- Proident esse laboris in sed officia exercitation ut anim ea.
|
43
|
|
- Proident esse laboris in sed officia exercitation ut anim ea.
|
44
|
|
- Proident esse laboris in sed officia exercitation ut anim ea.
|
45
|
|
- Proident esse laboris in sed officia exercitation ut anim ea.
|
46
|
|
- </div>
|
47
|
|
- </li>
|
48
|
|
-
|
49
|
|
- <li className={classnames(`${props.customClass}__messagelist__version`, 'timeline__messagelist__version')}>
|
50
|
|
- <div className={classnames(`${props.customClass}__messagelist__version__btn`, 'timeline__messagelist__version__btn btn')}>
|
51
|
|
- <i className='fa fa-code-fork' />
|
52
|
|
- version 3
|
53
|
|
- </div>
|
54
|
|
- <div className={classnames(`${props.customClass}__messagelist__version__date`, 'timeline__messagelist__version__date')}>
|
55
|
|
- Créer le 22/11/17
|
56
|
|
- </div>
|
57
|
|
- </li>
|
58
|
|
-
|
59
|
|
- <li className={classnames(`${props.customClass}__messagelist__item`, 'timeline__messagelist__item sended')}>
|
60
|
|
- <div className={classnames(`${props.customClass}__messagelist__item__avatar`, 'timeline__messagelist__item__avatar')}>
|
61
|
|
- <img src={imgProfil} alt='avatar' />
|
62
|
|
- </div>
|
63
|
|
- <div
|
64
|
|
- className={classnames(`${props.customClass}__messagelist__item__createhour`, 'timeline__messagelist__item__createhour')}>
|
65
|
|
- 27/11/17 à 11h45
|
66
|
|
- </div>
|
67
|
|
- <div
|
68
|
|
- className={classnames(`${props.customClass}__messagelist__item__content`, 'timeline__messagelist__item__content')}>
|
69
|
|
- Proident esse laboris in sed officia exercitation ut anim ea.
|
70
|
|
- </div>
|
71
|
|
- </li>
|
72
|
|
-
|
73
|
|
- <li className={classnames(`${props.customClass}__messagelist__item`, 'timeline__messagelist__item received')}>
|
74
|
|
- <div className={classnames(`${props.customClass}__messagelist__item__avatar`, 'timeline__messagelist__item__avatar')}>
|
75
|
|
- <img src={imgProfilReverse} alt='avatar' />
|
76
|
|
- </div>
|
77
|
|
- <div
|
78
|
|
- className={classnames(`${props.customClass}__messagelist__item__createhour`, 'timeline__messagelist__item__createhour')}>
|
79
|
|
- 27/11/17 à 11h47
|
80
|
|
- </div>
|
81
|
|
- <div
|
82
|
|
- className={classnames(`${props.customClass}__messagelist__item__content`, 'timeline__messagelist__item__content')}>
|
83
|
|
- Proident esse laboris in sed officia exercitation ut anim ea.
|
84
|
|
- Proident esse laboris in sed officia exercitation ut anim ea.
|
85
|
|
- Proident esse laboris in sed officia exercitation ut anim ea.
|
86
|
|
- Proident esse laboris in sed officia exercitation ut anim ea.
|
87
|
|
- Proident esse laboris in sed officia exercitation ut anim ea.
|
88
|
|
- </div>
|
89
|
|
- </li>
|
90
|
|
-
|
|
62
|
+ case 'version':
|
|
63
|
+ return <Version
|
|
64
|
+ customClass={props.customClas}
|
|
65
|
+ createdAt={content.createdAt}
|
|
66
|
+ number={content.number}
|
|
67
|
+ key={content.id}
|
|
68
|
+ />
|
|
69
|
+ }
|
|
70
|
+ })}
|
91
|
71
|
</ul>
|
|
72
|
+
|
92
|
73
|
<form className={classnames(`${props.customClass}__texteditor`, 'timeline__texteditor')}>
|
93
|
74
|
<div
|
94
|
75
|
className={classnames(`${props.customClass}__texteditor__simpletext`, 'timeline__texteditor__simpletext input-group')}>
|
|
@@ -122,3 +103,19 @@ const Timeline = props => {
|
122
|
103
|
}
|
123
|
104
|
|
124
|
105
|
export default Timeline
|
|
106
|
+
|
|
107
|
+Timeline.propTypes = {
|
|
108
|
+ customClass: PropTypes.string,
|
|
109
|
+ loggedUser: PropTypes.object,
|
|
110
|
+ timelineData: PropTypes.array
|
|
111
|
+}
|
|
112
|
+
|
|
113
|
+Timeline.defaultProps = {
|
|
114
|
+ customClass: '',
|
|
115
|
+ loggedUser: {
|
|
116
|
+ id: '',
|
|
117
|
+ name: '',
|
|
118
|
+ avatar: ''
|
|
119
|
+ },
|
|
120
|
+ timelineData: []
|
|
121
|
+}
|