2
0
Files
bot/apps/builder/components/shared/EmojiOrImageIcon.tsx

40 lines
857 B
TypeScript
Raw Normal View History

import { ToolIcon } from 'assets/icons'
import React from 'react'
2022-05-13 15:22:44 -07:00
import { chakra, IconProps, Image } from '@chakra-ui/react'
type Props = {
icon?: string | null
emojiFontSize?: string
boxSize?: string
2022-05-13 15:22:44 -07:00
defaultIcon?: (props: IconProps) => JSX.Element
}
2022-05-13 15:22:44 -07:00
export const EmojiOrImageIcon = ({
icon,
boxSize = '25px',
emojiFontSize,
2022-05-13 15:22:44 -07:00
defaultIcon = ToolIcon,
}: Props) => {
return (
<>
{icon ? (
icon.startsWith('http') ? (
<Image
src={icon}
boxSize={boxSize}
objectFit={icon.endsWith('.svg') ? undefined : 'cover'}
alt="typebot icon"
2022-05-13 15:22:44 -07:00
rounded="10%"
/>
) : (
<chakra.span role="img" fontSize={emojiFontSize}>
{icon}
</chakra.span>
)
) : (
2022-05-13 15:22:44 -07:00
defaultIcon({ boxSize })
)}
</>
)
}