@clayui/icon
Version:
ClayIcon component
37 lines (36 loc) • 974 B
JavaScript
import classNames from "classnames";
import React from "react";
import warning from "warning";
const ClayIconSpriteContext = React.createContext("");
const Icon = React.forwardRef(
({ className, spritemap, symbol, ...otherProps }, ref) => {
let spriteMapVal = React.useContext(ClayIconSpriteContext);
if (spritemap) {
spriteMapVal = spritemap;
}
warning(
spriteMapVal,
"ClayIcon requires a `spritemap` via prop or ClayIconSpriteContext"
);
return /* @__PURE__ */ React.createElement(
"svg",
{
...otherProps,
className: classNames(
`lexicon-icon lexicon-icon-${symbol}`,
className
),
key: symbol,
ref,
role: "presentation"
},
/* @__PURE__ */ React.createElement("use", { href: `${spriteMapVal}#${symbol}` })
);
}
);
Icon.displayName = "ClayIcon";
var src_default = Icon;
export {
ClayIconSpriteContext,
src_default as default
};