@shopgate/engage
Version:
Shopgate's ENGAGE library.
4 lines • 1.76 kB
JavaScript
function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{useCallback}from'react';import{css}from'glamor';import PropTypes from'prop-types';import{connect}from'react-redux';import{InfoIcon}from'@shopgate/engage/components';import{nl2br,showModal as showModalAction}from'@shopgate/engage/core';import{responsiveMediaQuery}from'@shopgate/engage/styles';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var mapDispatchToProps={showModal:showModalAction};var variables=themeConfig.variables;var styles={textWrapper:css({paddingTop:variables.gap.xsmall,fontSize:'0.75rem',color:'var(--color-state-alert)'}).toString(),iconWrapper:css(_defineProperty({cursor:'pointer',color:'var(--color-primary)',fontSize:'1.5rem',display:'inline-flex',verticalAlign:'bottom'},responsiveMediaQuery('<=xs',{appAlways:true}),{fontSize:'1.375rem'})).toString()};/**
* @param {Object} props The components props
* @returns {JSX}
*/var CheckoutSectionInfo=function CheckoutSectionInfo(_ref){var text=_ref.text,showModal=_ref.showModal,renderIcon=_ref.renderIcon;var showPopup=useCallback(function(){showModal({message:text,title:null,confirm:null,dismiss:'modal.ok'});},[showModal,text]);if(!text){return null;}if(!renderIcon){return React.createElement("div",{className:styles.textWrapper,dangerouslySetInnerHTML:{__html:nl2br(text)}});}return React.createElement("span",{onClick:showPopup,onKeyDown:showPopup,className:styles.iconWrapper,role:"button",tabIndex:0},React.createElement(InfoIcon,null));};CheckoutSectionInfo.defaultProps={text:null,renderIcon:true};export default connect(null,mapDispatchToProps)(CheckoutSectionInfo);