header-in-mobile.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. background={appData?.site.icon_background}
  30. />
  31. <div className='py-1 text-base font-semibold text-gray-800 truncate'>
  32. {appData?.site.title}
  33. </div>
  34. </div>
  35. <div
  36. className='shrink-0 flex items-center justify-center w-8 h-8 rounded-lg'
  37. onClick={handleNewConversation}
  38. >
  39. <Edit05 className='w-4 h-4 text-gray-700' />
  40. </div>
  41. </div>
  42. {
  43. showSidebar && (
  44. <div className='fixed inset-0 z-50'
  45. style={{ backgroundColor: 'rgba(35, 56, 118, 0.2)' }}
  46. onClick={() => setShowSidebar(false)}
  47. >
  48. <div className='inline-block h-full bg-white' onClick={e => e.stopPropagation()}>
  49. <Sidebar />
  50. </div>
  51. </div>
  52. )
  53. }
  54. </>
  55. )
  56. }
  57. export default HeaderInMobile