header.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import type { FC } from 'react'
  2. import React from 'react'
  3. import {
  4. Bars3Icon,
  5. PencilSquareIcon,
  6. } from '@heroicons/react/24/solid'
  7. import AppIcon from '@/app/components/base/app-icon'
  8. export type IHeaderProps = {
  9. title: string
  10. customerIcon?: React.ReactNode
  11. icon: string
  12. icon_background: string
  13. isMobile?: boolean
  14. isEmbedScene?: boolean
  15. onShowSideBar?: () => void
  16. onCreateNewChat?: () => void
  17. }
  18. const Header: FC<IHeaderProps> = ({
  19. title,
  20. isMobile,
  21. customerIcon,
  22. icon,
  23. icon_background,
  24. isEmbedScene = false,
  25. onShowSideBar,
  26. onCreateNewChat,
  27. }) => {
  28. if (!isMobile)
  29. return null
  30. if (isEmbedScene) {
  31. return (
  32. <div
  33. className={`
  34. shrink-0 flex items-center justify-between h-12 px-3 bg-gray-100
  35. bg-gradient-to-r from-blue-600 to-sky-500
  36. `}
  37. >
  38. <div></div>
  39. <div className="flex items-center space-x-2">
  40. {customerIcon || <AppIcon size="small" icon={icon} background={icon_background} />}
  41. <div
  42. className={'text-sm font-bold text-white'}
  43. >
  44. {title}
  45. </div>
  46. </div>
  47. <div></div>
  48. </div>
  49. )
  50. }
  51. return (
  52. <div className="shrink-0 flex items-center justify-between h-12 px-3 bg-gray-100">
  53. <div
  54. className='flex items-center justify-center h-8 w-8 cursor-pointer'
  55. onClick={() => onShowSideBar?.()}
  56. >
  57. <Bars3Icon className="h-4 w-4 text-gray-500" />
  58. </div>
  59. <div className='flex items-center space-x-2'>
  60. <AppIcon size="small" icon={icon} background={icon_background} />
  61. <div className=" text-sm text-gray-800 font-bold">{title}</div>
  62. </div>
  63. <div className='flex items-center justify-center h-8 w-8 cursor-pointer'
  64. onClick={() => onCreateNewChat?.()}
  65. >
  66. <PencilSquareIcon className="h-4 w-4 text-gray-500" />
  67. </div>
  68. </div>
  69. )
  70. }
  71. export default React.memo(Header)