/** * @fileoverview Note item component. */ import PropTypes from 'prop-types' import React from 'react' import { isArray, sortBy } from 'lodash' import invertColor from 'invert-color' import Emoji from 'react-emoji-render' import CSSModules from 'browser/lib/CSSModules' import { getTodoStatus } from 'browser/lib/getTodoStatus' import styles from './NoteItem.styl' import TodoProcess from './TodoProcess' import i18n from 'browser/lib/i18n' /** * @description Tag element component. * @param {string} tagName * @param {string} color * @return {React.Component} */ const TagElement = ({ tagName, color }) => { const style = {} if (color) { style.backgroundColor = color style.color = invertColor(color, { black: '#222', white: '#f1f1f1', threshold: 0.3 }) } return ( #{tagName} ) } /** * @description Tag element list component. * @param {Array|null} tags * @param {boolean} showTagsAlphabetically * @param {Object} coloredTags * @return {React.Component} */ const TagElementList = (tags, showTagsAlphabetically, coloredTags) => { if (!isArray(tags)) { return [] } if (showTagsAlphabetically) { return sortBy(tags).map(tag => TagElement({ tagName: tag, color: coloredTags[tag] }) ) } else { return tags.map(tag => TagElement({ tagName: tag, color: coloredTags[tag] }) ) } } /** * @description Note item component when using normal display mode. * @param {boolean} isActive * @param {Object} note * @param {Function} handleNoteClick * @param {Function} handleNoteContextMenu * @param {Function} handleDragStart * @param {Object} coloredTags * @param {string} dateDisplay */ const NoteItem = ({ isActive, note, dateDisplay, handleNoteClick, handleNoteContextMenu, handleDragStart, pathname, storageName, folderName, viewType, showTagsAlphabetically, coloredTags }) => (