UNPKG

@shopgate/engage

Version:
7 lines 2.45 kB
var _excluded=["html","navigate"];function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import React from'react';import PropTypes from'prop-types';import{SurroundPortals,PlaceholderParagraph,HtmlSanitizer,I18n}from'@shopgate/engage/components';import{PRODUCT_DESCRIPTION}from'@shopgate/engage/product';import classNames from'classnames';import{container,title,placeholder,content}from"./style";import connect from"./connector";/** * The product description. * @param {Object} props The component props. * @param {string} props.html html describing the product * @param {Function} props.navigate where to navigate on click * @returns {JSX.Element} */function Description(_ref){var html=_ref.html,navigate=_ref.navigate,props=_objectWithoutProperties(_ref,_excluded);return React.createElement(SurroundPortals,{portalName:PRODUCT_DESCRIPTION,portalProps:_extends({html:html,navigate:navigate},props)},html!==''&&React.createElement("div",{className:"".concat(container," engage__product__description")},React.createElement("div",{className:classNames(title,'theme__description_heading')},React.createElement(I18n.Text,{string:"product.description_heading"})),React.createElement(PlaceholderParagraph,{className:placeholder,ready:!!html},React.createElement("div",{className:content,"data-test-id":"description"},React.createElement(HtmlSanitizer,{settings:{html:html,handleClick:navigate}},html)))));}Description.defaultProps={html:null,navigate:function navigate(){}};export default connect(Description);