UNPKG

@veracity/vui

Version:

Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.

36 lines (34 loc) 1.29 kB
import { cs } from "../utils/styles.js"; import { useStyleConfig } from "../core/theme.js"; import vui from "../core/vui.js"; import { Icon } from "../icon/icon.js"; import { useButtonContext } from "./context.js"; import { useEffect } from "react"; import { jsx } from "react/jsx-runtime"; //#region src/button/buttonIcon.tsx const isConceptualIcon = (name) => name?.startsWith("con"); /** Displays an icon within the Button. */ const ButtonIcon = vui((props, ref) => { const { className, name, ...rest } = props; const buttonContext = useButtonContext(); const styles = useStyleConfig("Button", buttonContext); useEffect(() => { if (isConceptualIcon(name)) console.warn(`[ButtonIcon] Conceptual icon "${name}" is not supported inside a Button. Use a UI icon (name starting with "ui") instead.`); }, [name]); if (isConceptualIcon(name)) return null; const iconSize = `var(--vui-button-icon-size, ${styles.icon?.fontSize || "1rem"})`; return /* @__PURE__ */ jsx(Icon, { className: cs("vui-buttonIcon", className), fontSize: iconSize, h: iconSize, w: iconSize, name, ref, ...rest }); }); ButtonIcon.displayName = "ButtonIcon"; //#endregion export { ButtonIcon, ButtonIcon as default }; globalThis.__vuiVersion__ = "5.3.1" //# sourceMappingURL=buttonIcon.js.map