UNPKG

react-icons

Version:

SVG React icons of popular icon packs using ES6 imports

52 lines (46 loc) 1.54 kB
var __assign = this && this.__assign || Object.assign || function (t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; import React from 'react'; import { IconContext, DefaultContext } from './iconContext'; function Tree2Element(tree) { return tree && tree.map(function (node, i) { return React.createElement(node.tag, __assign({ key: i }, node.attr), Tree2Element(node.child)); }); } export function GenIcon(data) { return function (props) { return React.createElement(IconBase, __assign({ attr: __assign({}, data.attr) }, props), Tree2Element(data.child)); }; } export function IconBase(props) { var elem = function (conf) { var computedSize = props.size || conf.size || "1em"; var className; if (conf.className) className = conf.className; if (props.className) className = (className + ' ' || '') + props.className; return React.createElement("svg", __assign({ stroke: "currentColor", fill: "currentColor", strokeWidth: "0" }, props.attr, props, { className: className, style: __assign({ color: props.color || conf.color }, conf.style, props.style), height: computedSize, width: computedSize }), props.children); }; return IconContext !== undefined ? React.createElement(IconContext.Consumer, null, function (conf) { return elem(conf); }) : elem(DefaultContext); }