@shopgate/engage
Version:
Shopgate's ENGAGE library.
7 lines • 2.29 kB
JavaScript
import React from'react';import PropTypes from'prop-types';import{css}from'glamor';import{connect}from'react-redux';import{i18n}from'@shopgate/engage/core';import{getWishlistItemNotesEnabled}from"../../../core/selectors/shopSettings";var styles={root:css({display:'flex',flexWrap:'wrap',alignItems:'center'}),addCommentButton:css({fontSize:17,color:'var(--color-secondary)',fontWeight:500,whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis',paddingLeft:0,paddingRight:0,textAlign:'left'}),comment:css({fontSize:17,color:'var(--color-text-high-emphasis)',fontWeight:500,whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis'}),notes:css({paddingRight:4,fontStyle:'italic'}),buttons:css({whiteSpace:'nowrap'})};/**
* @return {Function} The extended component props.
*/var makeMapStateToProps=function makeMapStateToProps(){return function(state){return{wishlistItemNotesEnabled:getWishlistItemNotesEnabled(state)};};};/**
*
* @param {Object} props The component props
* @returns {JSX}
*/var ItemNotes=function ItemNotes(_ref){var wishlistItemNotesEnabled=_ref.wishlistItemNotesEnabled,notes=_ref.notes,onClickOpenComment=_ref.onClickOpenComment,onClickDeleteComment=_ref.onClickDeleteComment,notesButtonRef=_ref.notesButtonRef;if(!wishlistItemNotesEnabled){return null;}/* eslint-disable jsx-a11y/aria-role */return React.createElement("div",{className:styles.root},notes&&React.createElement("span",{role:"text"},React.createElement("span",{className:styles.comment},"".concat(i18n.text('favorites.comments.notes'),": ")),React.createElement("span",{className:styles.notes},"\"".concat(notes,"\""))),React.createElement("span",{className:styles.buttons},React.createElement("button",{type:"button",onClick:onClickOpenComment,className:styles.addCommentButton,ref:notesButtonRef},notes?i18n.text('favorites.comments.edit'):i18n.text('favorites.comments.add')),notes&&React.createElement(React.Fragment,null,React.createElement("span",{"aria-hidden":true}," | "),React.createElement("button",{type:"button",onClick:onClickDeleteComment,className:styles.addCommentButton},i18n.text('favorites.comments.delete')))));/* eslint-enable jsx-a11y/aria-role */};ItemNotes.defaultProps={notes:null,notesButtonRef:null};export default connect(makeMapStateToProps)(ItemNotes);