import React from 'react'; import PropTypes from 'prop-types';
const defaultIcon = '<svg viewBox="0 0 30 30"><path d="m 5 5 l 5 25 l 25 25 l 25 5 z"/></svg>';
function validateSvgString(svgString) { return !!svgString; }
export default function render(props) { if (!validateSvgString(props.icon)) { console.log( `InlineSvgIconWidget won't render, invalid icon property: ${props.icon}` ); return null; }
const style = Object.assign({}, props.style, { width: props.width, height: props.height, });
return ( <div style={style} className={props.className} onClick={props.onClick} dangerouslySetInnerHTML={{ __html: props.icon }} /> ); }
render.propTypes = { className: PropTypes.string, height: PropTypes.string, icon: PropTypes.string, width: PropTypes.string, style: PropTypes.object, onClick: PropTypes.func, };
render.defaultProps = { className: '', icon: defaultIcon, style: {}, width: undefined, height: undefined, onClick: undefined, };
|