Repository URL to install this package:
|
Version:
2.7.3 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const classnames_1 = tslib_1.__importDefault(require("classnames"));
const exotic_1 = require("exotic");
class Vector extends react_1.default.PureComponent {
render() {
const _a = this.props,
{
children,
//
title,
description,
//
namespace,
vectorClassName,
className,
//
height,
width,
viewBox,
isDynamicViewBox,
dataQa
} = _a,
passthroughProps = tslib_1.__rest(_a, ["children", "title", "description", "namespace", "vectorClassName", "className", "height", "width", "viewBox", "isDynamicViewBox", "dataQa"]); // dynamically set viewBox with width & height
const shouldUseDynamicViewBox = (viewBox === undefined || isDynamicViewBox === true) && width !== undefined && height !== undefined;
const computedViewBox = shouldUseDynamicViewBox ? `0 0 ${width} ${height}` : viewBox; // @todo @remove
const computedClassName = exotic_1.isString(vectorClassName) ? 'svg-icon-' + vectorClassName + ' ' + vectorClassName : vectorClassName;
const classNamed = classnames_1.default('svg-icon', computedClassName, className); // props
const attributes = {
className: classNamed,
viewBox: computedViewBox,
// @note
'data-qa': dataQa,
height,
width
};
if (exotic_1.isString(title)) {
attributes['aria-labelledby'] = namespace;
} // accessibility
const titleView = exotic_1.isString(title) && react_1.default.createElement("title", {
id: namespace
}, title);
const descriptionView = exotic_1.isString(description) && react_1.default.createElement("desc", null, description);
return react_1.default.createElement("svg", Object.assign({
xmlns: "http://www.w3.org/2000/svg",
version: "1.1",
role: "img"
}, attributes, passthroughProps), titleView, descriptionView, children);
}
}
Vector.defaultProps = {
className: '',
isDynamicViewBox: false
};
exports.Vector = Vector;
exports.default = Vector; //# sourceMappingURL=Vector.js.map