header-in-mobile.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { useState } from 'react'
  2. import { useChatWithHistoryContext } from './context'
  3. import Sidebar from './sidebar'
  4. import AppIcon from '@/app/components/base/app-icon'
  5. import {
  6. Edit05,
  7. Menu01,
  8. } from '@/app/components/base/icons/src/vender/line/general'
  9. const HeaderInMobile = () => {
  10. const {
  11. appData,
  12. handleNewConversation,
  13. } = useChatWithHistoryContext()
  14. const [showSidebar, setShowSidebar] = useState(false)
  15. return (
  16. <>
  17. <div className='shrink-0 flex items-center px-3 h-[44px] border-b-[0.5px] border-b-gray-200'>
  18. <div
  19. className='shrink-0 flex items-center justify-center w-8 h-8 rounded-lg'
  20. onClick={() => setShowSidebar(true)}
  21. >
  22. <Menu01 className='w-4 h-4 text-gray-700' />
  23. </div>
  24. <div className='grow flex justify-center items-center px-3'>
  25. <AppIcon
  26. className='mr-2'
  27. size='tiny'
  28. icon={appData?.site.icon}
  29. iconType={appData?.site.icon_type}
  30. imageUrl={appData?.site.icon_url}
  31. background={appData?.site.icon_background}
  32. />
  33. <div className='py-1 text-base font-semibold text-gray-800 truncate'>
  34. {appData?.site.title}
  35. </div>
  36. </div>
  37. <div
  38. className='shrink-0 flex items-center justify-center w-8 h-8 rounded-lg'
  39. onClick={handleNewConversation}
  40. >
  41. <Edit05 className='w-4 h-4 text-gray-700' />
  42. </div>
  43. </div>
  44. {
  45. showSidebar && (
  46. <div className='fixed inset-0 z-50'
  47. style={{ backgroundColor: 'rgba(35, 56, 118, 0.2)' }}
  48. onClick={() => setShowSidebar(false)}
  49. >
  50. <div className='inline-block h-full bg-white' onClick={e => e.stopPropagation()}>
  51. <Sidebar />
  52. </div>
  53. </div>
  54. )
  55. }
  56. </>
  57. )
  58. }
  59. export default HeaderInMobile