|
| 1 | +/** |
| 2 | + * @fileoverview Note item component with simple display mode. |
| 3 | + */ |
| 4 | +import React, { PropTypes } from 'react' |
| 5 | +import CSSModules from 'browser/lib/CSSModules' |
| 6 | +import styles from './NoteList.styl' |
| 7 | + |
| 8 | +/** |
| 9 | + * @description Note item component when using simple display mode. |
| 10 | + * @param {boolean} isActive |
| 11 | + * @param {Object} note |
| 12 | + * @param {Function} handleNoteClick |
| 13 | + * @param {Function} handleNoteContextMenu |
| 14 | + */ |
| 15 | +const NoteItemSimple = ({ isActive, note, handleNoteClick, handleNoteContextMenu }) => ( |
| 16 | + <div styleName={isActive |
| 17 | + ? 'item--active' |
| 18 | + : 'item' |
| 19 | + } |
| 20 | + key={`${note.storage}-${note.key}`} |
| 21 | + onClick={e => handleNoteClick(e, `${note.storage}-${note.key}`)} |
| 22 | + onContextMenu={e => handleNoteContextMenu(e, `${note.storage}-${note.key}`)} |
| 23 | + > |
| 24 | + <div styleName='item-title'> |
| 25 | + {note.title.trim().length > 0 |
| 26 | + ? note.title |
| 27 | + : <span styleName='item-title-empty'>Empty</span> |
| 28 | + } |
| 29 | + </div> |
| 30 | + </div> |
| 31 | +) |
| 32 | + |
| 33 | +NoteItemSimple.propTypes = { |
| 34 | + isActive: PropTypes.bool.isRequired, |
| 35 | + note: PropTypes.shape({ |
| 36 | + storage: PropTypes.string.isRequired, |
| 37 | + key: PropTypes.string.isRequired, |
| 38 | + title: PropTypes.string.isrequired, |
| 39 | + }), |
| 40 | + handleNoteClick: PropTypes.func.isRequired, |
| 41 | + handleNoteContextMenu: PropTypes.func.isRequired, |
| 42 | +} |
| 43 | + |
| 44 | +export default CSSModules(NoteItemSimple, styles) |
0 commit comments