client/src/components/SessionSummary.js
author ymh <ymh.work@gmail.com>
Tue, 29 Mar 2022 11:23:56 +0200
changeset 211 244a90638e80
parent 191 3f71ad81a5a9
permissions -rw-r--r--
Added tag 0.2.3 for changeset 3de92ddba2de
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
     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
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
     7
  <div className="session-summary-list">
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
     8
    <ul className="list-group sticky-left">
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
     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
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    16
        return (
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    17
        <li className="list-group-item border-0 py-1" key={note._id}>
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    18
            <a href={'#note-' + note._id}>
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    19
              <small className="note-time text-irinotes-time px-1 bg-irinotes-headers border-0 text-center">{formatTimestamp(note.startedAt)}</small>
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    20
              <small className="note-length font-weight-bold text-muted text-center badge" style={{ backgroundColor: bgColor }}>{_.words(note.plain).length} mots</small>
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    21
              <small className="note-time text-irinotes-time px-1 bg-irinotes-headers border-0 text-center">{formatTimestamp(note.finishedAt)}</small>
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    22
            </a>
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    23
        </li>
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    24
        )
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    25
      })}
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    26
    </ul>
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    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;