UNPKG

@wordpress/components

Version:
42 lines (38 loc) 1.18 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import { createElement } from "@wordpress/element"; /** * @typedef OwnProps * * @property {import('./types').IconKey} icon Icon name * @property {string} [className] Class name * @property {number} [size] Size of the icon */ /** * Internal dependencies */ function Dashicon(_ref) { let { icon, className, size = 20, style = {}, ...extraProps } = _ref; const iconClass = ['dashicon', 'dashicons', 'dashicons-' + icon, className].filter(Boolean).join(' '); // For retro-compatibility reasons (for example if people are overriding icon size with CSS), we add inline styles just if the size is different to the default const sizeStyles = // using `!=` to catch both 20 and "20" // eslint-disable-next-line eqeqeq 20 != size ? { fontSize: `${size}px`, width: `${size}px`, height: `${size}px` } : {}; const styles = { ...sizeStyles, ...style }; return createElement("span", _extends({ className: iconClass, style: styles }, extraProps)); } export default Dashicon; //# sourceMappingURL=index.js.map