@atlaskit/icon
Version:
An icon is a symbol representing a command, device, directory, or common action.
19 lines (18 loc) • 787 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useSvgMaskId = void 0;
var _react = require("react");
/**
* Returns an id for an SVG `<mask>` inside an animated icon's glyph, unique to this instance.
*
* `url(#id)` resolves to the first element with that id in the document, so a shared id would draw every
* instance of the icon through the first instance's mask, and animate them all together. The `useId()` value
* is stripped to characters that are safe inside `url(#…)`, since it includes `:` or non-ASCII characters
* depending on the React version.
*/
var useSvgMaskId = exports.useSvgMaskId = function useSvgMaskId(name) {
var id = (0, _react.useId)().replace(/[^A-Za-z0-9_-]/g, '');
return "".concat(name, "-").concat(id);
};