@uimkit/uikit-react
Version:
<img style="width:64px" src="https://mgmt.uimkit.chat/media/img/avatar.png"/>
23 lines (20 loc) • 1.41 kB
JavaScript
import React__default from 'react';
import './type.js';
import { ICON_CONFIG } from './config.js';
var changeTypeToIconComponent = function (type) {
var src = ICON_CONFIG[type].url || '';
return React__default.createElement("img", { className: "icon-image icon-image-".concat(type), src: src, alt: type });
};
var changeTypeToIconClassName = function (type) { var _a; return ((_a = ICON_CONFIG[type]) === null || _a === void 0 ? void 0 : _a.className) || ''; };
function Icon(props) {
var children = props.children, type = props.type, _a = props.height, height = _a === void 0 ? 24 : _a, _b = props.width, width = _b === void 0 ? 24 : _b, onClick = props.onClick, _c = props.className, className = _c === void 0 ? '' : _c;
var iconStyle = {
width: typeof width === 'string' ? width : "".concat(width, "px"),
minWidth: typeof width === 'string' ? width : "".concat(width, "px"),
height: typeof height === 'string' ? height : "".concat(height, "px"),
minHeight: typeof height === 'string' ? height : "".concat(height, "px"),
};
return (React__default.createElement("div", { className: "uim-kit-icon ".concat(changeTypeToIconClassName(type), " ").concat(className), role: "button", tabIndex: 0, style: iconStyle, onClick: onClick }, children || changeTypeToIconComponent(type)));
}
export { Icon, changeTypeToIconClassName };
//# sourceMappingURL=Icon.js.map