styled-icons
Version:
Icons from packs like Font Awesome, Material, Octicons, Feather, Icomoon, and Boxicons available as Styled Components
30 lines (29 loc) • 2.01 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = tslib_1.__importStar(require("react"));
var styled_components_1 = tslib_1.__importDefault(require("styled-components"));
var is_prop_valid_1 = tslib_1.__importDefault(require("@emotion/is-prop-valid"));
function isValidProp(key) {
return is_prop_valid_1.default(key);
}
function filterSVGProps(props) {
return Object.keys(props).reduce(function (p, k) {
if (isValidProp(k)) {
// hack to satisfy TypeScript complexity
;
p[k] = props[k];
}
return p;
}, {});
}
var StyledIconBaseBase = React.forwardRef(function (props, ref) {
var children = props.children, iconAttrs = props.iconAttrs, iconVerticalAlign = props.iconVerticalAlign, iconViewBox = props.iconViewBox, size = props.size, title = props.title, otherProps = tslib_1.__rest(props, ["children", "iconAttrs", "iconVerticalAlign", "iconViewBox", "size", "title"]);
var iconProps = tslib_1.__assign({ viewBox: iconViewBox, height: props.height !== undefined ? props.height : size, width: props.width !== undefined ? props.width : size, 'aria-hidden': title == null ? 'true' : undefined, focusable: 'false', role: title != null ? 'img' : undefined }, iconAttrs);
var svgProps = filterSVGProps(otherProps);
return (React.createElement("svg", tslib_1.__assign({}, iconProps, svgProps, { ref: ref }),
title && React.createElement("title", { key: "icon-title" }, title),
children));
});
exports.StyledIconBase = styled_components_1.default(StyledIconBaseBase).withConfig({ displayName: "StyledIconBase", componentId: "sc-bdy9j4" })(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n display: inline-block;\n vertical-align: ", ";\n overflow: hidden;\n"], ["\n display: inline-block;\n vertical-align: ", ";\n overflow: hidden;\n"])), function (props) { return props.iconVerticalAlign; });
var templateObject_1;
;