UNPKG

@lobehub/ui

Version:

Lobe UI is an open-source UI component library for building AIGC web apps

1 lines • 1.05 kB
{"version":3,"file":"landingIcon.mjs","names":["IconComponent"],"sources":["../../src/awesome/landingIcon.tsx"],"sourcesContent":["import { type ElementType, isValidElement, type ReactNode } from 'react';\n\nexport type LandingIconSource = ElementType<{ size: number }> | ReactNode;\n\nconst isElementType = (icon: LandingIconSource): icon is ElementType<{ size: number }> =>\n typeof icon === 'function' ||\n (typeof icon === 'object' && icon !== null && !isValidElement(icon) && '$$typeof' in icon);\n\n/** Renders an icon given either a component (e.g. from `@lobehub/icons`) or a ready-made node. */\nexport const renderLandingIcon = (icon: LandingIconSource, size: number): ReactNode => {\n if (!isElementType(icon)) return icon as ReactNode;\n const IconComponent = icon;\n return <IconComponent size={size} />;\n};\n"],"mappings":";;;AAIA,MAAM,iBAAiB,SACrB,OAAO,SAAS,cACf,OAAO,SAAS,YAAY,SAAS,QAAQ,CAAC,eAAe,IAAI,KAAK,cAAc;;AAGvF,MAAa,qBAAqB,MAAyB,SAA4B;CACrF,IAAI,CAAC,cAAc,IAAI,GAAG,OAAO;CAEjC,OAAO,oBAACA,MAAD,EAAqB,KAAO,CAAA;AACrC"}