You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.tsx 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { usePathname } from 'next/navigation'
  2. import {
  3. useWorkflowMode,
  4. } from '../hooks'
  5. import type { HeaderInNormalProps } from './header-in-normal'
  6. import HeaderInNormal from './header-in-normal'
  7. import type { HeaderInRestoringProps } from './header-in-restoring'
  8. import { useStore } from '../store'
  9. import dynamic from 'next/dynamic'
  10. const HeaderInHistory = dynamic(() => import('./header-in-view-history'), {
  11. ssr: false,
  12. })
  13. const HeaderInRestoring = dynamic(() => import('./header-in-restoring'), {
  14. ssr: false,
  15. })
  16. export type HeaderProps = {
  17. normal?: HeaderInNormalProps
  18. restoring?: HeaderInRestoringProps
  19. }
  20. const Header = ({
  21. normal: normalProps,
  22. restoring: restoringProps,
  23. }: HeaderProps) => {
  24. const pathname = usePathname()
  25. const inWorkflowCanvas = pathname.endsWith('/workflow')
  26. const {
  27. normal,
  28. restoring,
  29. viewHistory,
  30. } = useWorkflowMode()
  31. const maximizeCanvas = useStore(s => s.maximizeCanvas)
  32. return (
  33. <div
  34. className='absolute left-0 top-0 z-10 flex h-14 w-full items-center justify-between bg-mask-top2bottom-gray-50-to-transparent px-3'
  35. >
  36. {inWorkflowCanvas && maximizeCanvas && <div className='h-14 w-[52px]' />}
  37. {
  38. normal && (
  39. <HeaderInNormal
  40. {...normalProps}
  41. />
  42. )
  43. }
  44. {
  45. viewHistory && (
  46. <HeaderInHistory />
  47. )
  48. }
  49. {
  50. restoring && (
  51. <HeaderInRestoring
  52. {...restoringProps}
  53. />
  54. )
  55. }
  56. </div>
  57. )
  58. }
  59. export default Header