UNPKG

@kubit-ui-web/react-components

Version:

Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience

29 lines 1.22 kB
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime"; import React from 'react'; import { IconBasic } from '../icon/icon'; import { IconHost as Icon } from '../icon/iconHost'; const ElementOrIconComponent = ({ basic = false, ...props }, ref) => { const { icon: element, ...rest } = props; if (!element) { return _jsx(_Fragment, {}); } // element as string if (typeof element === 'string') { return basic ? (_jsx(IconBasic, { ...rest, ref: ref, icon: element })) : (_jsx(Icon, { ...rest, ref: ref, icon: element })); } // element as jsx element return _jsx(_Fragment, { children: element }); }; /** * ElementOrIcon component is a component that can be used to display either an element or an icon. * It offers flexibility in rendering either icons or more complex components within a given context. * @param {IElementOrIcon} props * @returns {JSX.Element} * @constructor * @example * <ElementOrIcon icon="icon" /> * <ElementOrIcon icon={<Icon icon="icon" />} /> * <ElementOrIcon icon={<Button variant="primary">Button</Button>} /> */ export const ElementOrIcon = React.forwardRef(ElementOrIconComponent); //# sourceMappingURL=elementOrIcon.js.map