import { useStyles } from '~/hooks'; import { Components } from '~/utils/components-list'; import { _unstable_createComponent, _unstable_createEl, createPolymorphicComponent, } from '../../utils'; import { SIZES_MAP } from '../Avatar/styles'; import { Box } from '../Box'; import { Tag } from '../Tag'; import { useAssetProps } from './Asset'; import type { AssetIconDef } from './defs'; import { styles } from './styles'; const _AssetIcon = _unstable_createComponent( Components.AssetIcon, ({ as: Root = 'img', icon, ...props }) => { const { asset, iconSize = 'md' } = useAssetProps(); const classes = useStyles(styles, props, ['icon']); const size = typeof iconSize === 'string' ? SIZES_MAP[iconSize] : iconSize; if (icon) { return ( {icon} ); } if (!asset.imageUrl) { return ( {asset.symbol.slice(0, 2).toUpperCase()} ); } return ( ); }, ); export const AssetIcon = createPolymorphicComponent(_AssetIcon); AssetIcon.id = 'AssetIcon';