| author | ymh <ymh.work@gmail.com> |
| Tue, 04 Dec 2018 18:17:56 +0100 | |
| changeset 191 | 3f71ad81a5a9 |
| parent 190 | 01ad654237d5 |
| permissions | -rw-r--r-- |
|
125
c653f49fabfb
remove unecessary dependencies to Redux
ymh <ymh.work@gmail.com>
parents:
124
diff
changeset
|
1 |
import React from 'react'; |
|
63
4088f8dc6b52
Improve session page layout, introduce summary.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
2 |
import _ from 'lodash'; |
| 174 | 3 |
import Color from 'color'; |
|
74
043477fd5c5c
add api call to save notes. internally use ts for time data for notes and session
ymh <ymh.work@gmail.com>
parents:
73
diff
changeset
|
4 |
import {formatTimestamp} from '../utils'; |
|
63
4088f8dc6b52
Improve session page layout, introduce summary.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
5 |
|
|
125
c653f49fabfb
remove unecessary dependencies to Redux
ymh <ymh.work@gmail.com>
parents:
124
diff
changeset
|
6 |
const SessionSummary = ({notes}) => ( |
| 174 | 7 |
<div className="session-summary-list"> |
8 |
<ul className="list-group sticky-left"> |
|
9 |
{notes.map((note) => { |
|
|
190
01ad654237d5
Correct color background display in session summary
ymh <ymh.work@gmail.com>
parents:
174
diff
changeset
|
10 |
let bgColor = "transparent"; |
|
01ad654237d5
Correct color background display in session summary
ymh <ymh.work@gmail.com>
parents:
174
diff
changeset
|
11 |
if(note.categories.length > 0) { |
|
01ad654237d5
Correct color background display in session summary
ymh <ymh.work@gmail.com>
parents:
174
diff
changeset
|
12 |
const hsl = Color(note.categories[0].color).hsl(); |
|
01ad654237d5
Correct color background display in session summary
ymh <ymh.work@gmail.com>
parents:
174
diff
changeset
|
13 |
const l = hsl.lightness(); |
|
01ad654237d5
Correct color background display in session summary
ymh <ymh.work@gmail.com>
parents:
174
diff
changeset
|
14 |
bgColor = hsl.lighten(50.0/l-0.5).hex(); |
|
01ad654237d5
Correct color background display in session summary
ymh <ymh.work@gmail.com>
parents:
174
diff
changeset
|
15 |
} |
| 174 | 16 |
return ( |
17 |
<li className="list-group-item border-0 py-1" key={note._id}> |
|
18 |
<a href={'#note-' + note._id}> |
|
19 |
<small className="note-time text-irinotes-time px-1 bg-irinotes-headers border-0 text-center">{formatTimestamp(note.startedAt)}</small> |
|
20 |
<small className="note-length font-weight-bold text-muted text-center badge" style={{ backgroundColor: bgColor }}>{_.words(note.plain).length} mots</small> |
|
21 |
<small className="note-time text-irinotes-time px-1 bg-irinotes-headers border-0 text-center">{formatTimestamp(note.finishedAt)}</small> |
|
22 |
</a> |
|
23 |
</li> |
|
24 |
) |
|
25 |
})} |
|
26 |
</ul> |
|
27 |
</div> |
|
|
125
c653f49fabfb
remove unecessary dependencies to Redux
ymh <ymh.work@gmail.com>
parents:
124
diff
changeset
|
28 |
) |
|
63
4088f8dc6b52
Improve session page layout, introduce summary.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
29 |
|
|
125
c653f49fabfb
remove unecessary dependencies to Redux
ymh <ymh.work@gmail.com>
parents:
124
diff
changeset
|
30 |
export default SessionSummary; |