question.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import type {
  2. FC,
  3. ReactNode,
  4. } from 'react'
  5. import {
  6. memo,
  7. } from 'react'
  8. import type { ChatItem } from '../types'
  9. import type { Theme } from '../embedded-chatbot/theme/theme-context'
  10. import { CssTransform } from '../embedded-chatbot/theme/utils'
  11. import { User } from '@/app/components/base/icons/src/public/avatar'
  12. import { Markdown } from '@/app/components/base/markdown'
  13. import { FileList } from '@/app/components/base/file-uploader'
  14. type QuestionProps = {
  15. item: ChatItem
  16. questionIcon?: ReactNode
  17. theme: Theme | null | undefined
  18. }
  19. const Question: FC<QuestionProps> = ({
  20. item,
  21. questionIcon,
  22. theme,
  23. }) => {
  24. const {
  25. content,
  26. message_files,
  27. } = item
  28. return (
  29. <div className='flex justify-end mb-2 last:mb-0 pl-14'>
  30. <div className='group relative mr-4 max-w-full'>
  31. <div
  32. className='px-4 py-3 bg-[#D1E9FF]/50 rounded-2xl text-sm text-gray-900'
  33. style={theme?.chatBubbleColorStyle ? CssTransform(theme.chatBubbleColorStyle) : {}}
  34. >
  35. {
  36. !!message_files?.length && (
  37. <FileList
  38. files={message_files}
  39. showDeleteAction={false}
  40. showDownloadAction={true}
  41. />
  42. )
  43. }
  44. <Markdown content={content} />
  45. </div>
  46. <div className='mt-1 h-[18px]' />
  47. </div>
  48. <div className='shrink-0 w-10 h-10'>
  49. {
  50. questionIcon || (
  51. <div className='w-full h-full rounded-full border-[0.5px] border-black/5'>
  52. <User className='w-full h-full' />
  53. </div>
  54. )
  55. }
  56. </div>
  57. </div>
  58. )
  59. }
  60. export default memo(Question)