index.tsx 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. 'use client'
  2. import type { FC } from 'react'
  3. import { init } from 'emoji-mart'
  4. import data from '@emoji-mart/data'
  5. import classNames from '@/utils/classnames'
  6. import type { AppIconType } from '@/types/app'
  7. init({ data })
  8. export type AnswerIconProps = {
  9. iconType?: AppIconType | null
  10. icon?: string | null
  11. background?: string | null
  12. imageUrl?: string | null
  13. }
  14. const AnswerIcon: FC<AnswerIconProps> = ({
  15. iconType,
  16. icon,
  17. background,
  18. imageUrl,
  19. }) => {
  20. const wrapperClassName = classNames(
  21. 'flex',
  22. 'items-center',
  23. 'justify-center',
  24. 'w-full',
  25. 'h-full',
  26. 'rounded-full',
  27. 'border-[0.5px]',
  28. 'border-black/5',
  29. 'text-xl',
  30. )
  31. const isValidImageIcon = iconType === 'image' && imageUrl
  32. return <div
  33. className={wrapperClassName}
  34. style={{ background: background || '#D5F5F6' }}
  35. >
  36. {isValidImageIcon
  37. ? <img src={imageUrl} className="w-full h-full rounded-full" alt="answer icon" />
  38. : (icon && icon !== '') ? <em-emoji id={icon} /> : <em-emoji id='🤖' />
  39. }
  40. </div>
  41. }
  42. export default AnswerIcon