UNPKG

@spark-ui/components

Version:

Spark (Leboncoin design system) components.

68 lines (64 loc) 1.63 kB
import { VisuallyHidden } from "./chunk-NBZKMCHF.mjs"; // src/icon/Icon.tsx import { Children, cloneElement } from "react"; // src/icon/Icon.styles.tsx import { makeVariants } from "@spark-ui/internal-utils"; import { cva } from "class-variance-authority"; var iconStyles = cva(["fill-current shrink-0"], { variants: { /** * Color scheme of the icon. */ intent: makeVariants({ current: ["text-current"], main: ["text-main"], support: ["text-support"], accent: ["text-accent"], basic: ["text-basic"], success: ["text-success"], alert: ["text-alert"], error: ["text-error"], info: ["text-info"], neutral: ["text-neutral"] }), /** * Sets the size of the icon. */ size: makeVariants({ current: ["u-current-font-size"], sm: ["w-sz-16", "h-sz-16"], md: ["w-sz-24", "h-sz-24"], lg: ["w-sz-32", "h-sz-32"], xl: ["w-sz-40", "h-sz-40"] }) } }); // src/icon/Icon.tsx import { Fragment, jsx, jsxs } from "react/jsx-runtime"; var Icon = ({ label, className, size = "current", intent = "current", children, ...others }) => { const child = Children.only(children); return /* @__PURE__ */ jsxs(Fragment, { children: [ cloneElement(child, { className: iconStyles({ className, size, intent }), "data-spark-component": "icon", "aria-hidden": "true", focusable: "false", ...others }), label && /* @__PURE__ */ jsx(VisuallyHidden, { children: label }) ] }); }; Icon.displayName = "Icon"; export { Icon }; //# sourceMappingURL=chunk-AESXFMCC.mjs.map