@uimkit/uikit-react
Version:
<img style="width:64px" src="https://mgmt.uimkit.chat/media/img/avatar.png"/>
32 lines (25 loc) • 1.74 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var React = require('react');
require('./type.js');
var config = require('./config.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
var changeTypeToIconComponent = function (type) {
var src = config.ICON_CONFIG[type].url || '';
return React__default["default"].createElement("img", { className: "icon-image icon-image-".concat(type), src: src, alt: type });
};
var changeTypeToIconClassName = function (type) { var _a; return ((_a = config.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["default"].createElement("div", { className: "uim-kit-icon ".concat(changeTypeToIconClassName(type), " ").concat(className), role: "button", tabIndex: 0, style: iconStyle, onClick: onClick }, children || changeTypeToIconComponent(type)));
}
exports.Icon = Icon;
exports.changeTypeToIconClassName = changeTypeToIconClassName;
//# sourceMappingURL=Icon.js.map