@atlaskit/icon
Version:
An icon is a symbol representing a command, device, directory, or common action.
105 lines (101 loc) • 4.04 kB
JavaScript
/* icon-new.tsx generated by @compiled/babel-plugin v0.39.1 */
;
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.Icon = void 0;
require("./icon-new.compiled.css");
var _react = _interopRequireWildcard(require("react"));
var React = _react;
var _runtime = require("@compiled/react/runtime");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
/**
* We are hiding this props from consumers as it's reserved
* for use by Icon Tile.
*/
var svgStyles = null;
var iconStyles = null;
var smallIconStyles = null;
var scaleStyles = null;
/**
* For windows high contrast mode
*/
var baseHcmStyles = null;
var scaleSize = null;
var coreSizeMedium = {
none: "_1bsbpxbi _4t3ipxbi",
compact: "_1bsb1ejb _4t3i1ejb",
spacious: "_1bsb1ejb _4t3i1ejb"
};
var coreSizeSmall = {
none: "_1bsbutpp _4t3iutpp",
compact: "_1bsbpxbi _4t3ipxbi",
spacious: "_1bsb1ejb _4t3i1ejb"
};
var paddingMap = {
medium: {
none: 0,
compact: 4,
spacious: 4
},
small: {
none: 0,
compact: 2.66,
spacious: 8
}
};
/**
* __Icon__
*
* An icon is used as a visual representation of common actions and commands to provide context.
*
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/icon)
*/
var Icon = exports.Icon = /*#__PURE__*/(0, _react.memo)(function Icon(props) {
var _ref = props,
_ref$color = _ref.color,
color = _ref$color === void 0 ? 'currentColor' : _ref$color,
testId = _ref.testId,
label = _ref.label,
dangerouslySetGlyph = _ref.dangerouslySetGlyph,
shouldScale = _ref.shouldScale,
_ref$spacing = _ref.spacing,
spacing = _ref$spacing === void 0 ? 'none' : _ref$spacing,
name = _ref.name;
var dangerouslySetInnerHTML = dangerouslySetGlyph ? {
__html: dangerouslySetGlyph
} : undefined;
var size = 'medium';
if ('size' in props && props.size !== undefined) {
if (typeof props.size === 'string') {
size = props.size === 'small' || props.size === 'medium' ? props.size : size;
} else if (name) {
var newSize = props.size(name);
size = newSize === 'small' || newSize === 'medium' ? newSize : size;
}
}
var baseSize = 16;
var viewBoxPadding = paddingMap[size][spacing];
var viewBoxSize = baseSize + 2 * viewBoxPadding;
return /*#__PURE__*/React.createElement("span", {
"data-testid": testId,
role: label ? 'img' : undefined,
"aria-label": label ? label : undefined,
"aria-hidden": label ? undefined : true,
style: {
color: color
},
className: (0, _runtime.ax)(["_1e0c1o8l _vchhusvi _1o9zidpf _vwz4kb7n _y4ti1igz _bozg1mb9", "_12va1onz _jcxd1r8n", shouldScale && "_1bsb1kw7 _4t3i1kw7", size === 'small' && "_vwz4utpp"])
}, /*#__PURE__*/React.createElement("svg", {
fill: "none"
// Adjusting the viewBox allows the icon padding to scale with the contents of the SVG, which
// we want for Icon Tile
,
viewBox: "".concat(0 - viewBoxPadding, " ").concat(0 - viewBoxPadding, " ").concat(viewBoxSize, " ").concat(viewBoxSize),
role: "presentation",
dangerouslySetInnerHTML: dangerouslySetInnerHTML,
className: (0, _runtime.ax)(["_1reo15vq _18m915vq _syaz1r31 _lcxvglyw _s7n4yfq0 _vc881r31", shouldScale ? "_1bsb1kw7 _4t3i1kw7" : size === 'small' ? coreSizeSmall[spacing] : coreSizeMedium[spacing]])
}));
});
var _default = exports.default = Icon;