import React, { Component } from 'react'; import PropTypes from 'prop-types'; import cx from 'classnames'; import styles from '../styles'; import ToolbarSubmenuItem from '../toolbar-submenu-item/component'; export default class ToolbarSubmenu extends Component { static getCustomIcon(type, obj) { if (type === 'color') { return ( ); } else if (type === 'thickness') { return ( ); } else if (type === 'font-size') { return (

Aa

); } return null; } static getWrapperClassNames(type) { if (type === 'color') { return cx(styles.colorList, styles.toolbarList); } else if (type === 'thickness') { return cx(styles.thicknessList, styles.toolbarList); } else if (type === 'font-size') { return cx(styles.fontSizeList, styles.toolbarList); } else if (type === 'annotations') { return cx(styles.annotationList, styles.toolbarList); } return null; } constructor() { super(); this.handleMouseEnter = this.handleMouseEnter.bind(this); this.handleMouseLeave = this.handleMouseLeave.bind(this); this.onItemClick = this.onItemClick.bind(this); } onItemClick(objectToReturn) { if (this.props.onItemClick) { this.props.onItemClick(objectToReturn); } } handleMouseEnter() { if (this.props.handleMouseEnter) { this.props.handleMouseEnter(); } } handleMouseLeave() { if (this.props.handleMouseLeave) { this.props.handleMouseLeave(); } } render() { const { type, objectsToRender, objectSelected, label, customIcon } = this.props; return (
{objectsToRender ? objectsToRender.map(obj => ( ), ) : null}
); } } ToolbarSubmenu.propTypes = { onItemClick: PropTypes.func.isRequired, handleMouseEnter: PropTypes.func.isRequired, handleMouseLeave: PropTypes.func.isRequired, type: PropTypes.string.isRequired, objectsToRender: PropTypes.arrayOf( PropTypes.oneOfType([ PropTypes.shape({ value: PropTypes.string.isRequired, }), PropTypes.shape({ value: PropTypes.number.isRequired, }), PropTypes.shape({ value: PropTypes.string.isRequired, icon: PropTypes.string.isRequired, }), ]).isRequired, ).isRequired, objectSelected: PropTypes.oneOfType([ PropTypes.shape({ value: PropTypes.string.isRequired, }), PropTypes.shape({ value: PropTypes.number.isRequired, }), PropTypes.shape({ value: PropTypes.string.isRequired, icon: PropTypes.string.isRequired, }), ]).isRequired, label: PropTypes.string.isRequired, customIcon: PropTypes.bool.isRequired, };