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.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 HeaderInHistory from './header-in-view-history'
  8. import type { HeaderInRestoringProps } from './header-in-restoring'
  9. import HeaderInRestoring from './header-in-restoring'
  10. import { useStore } from '../store'
  11. export type HeaderProps = {
  12. normal?: HeaderInNormalProps
  13. restoring?: HeaderInRestoringProps
  14. }
  15. const Header = ({
  16. normal: normalProps,
  17. restoring: restoringProps,
  18. }: HeaderProps) => {
  19. const pathname = usePathname()
  20. const inWorkflowCanvas = pathname.endsWith('/workflow')
  21. const {
  22. normal,
  23. restoring,
  24. viewHistory,
  25. } = useWorkflowMode()
  26. const maximizeCanvas = useStore(s => s.maximizeCanvas)
  27. return (
  28. <div
  29. 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'
  30. >
  31. {inWorkflowCanvas && maximizeCanvas && <div className='h-14 w-[52px]' />}
  32. {
  33. normal && (
  34. <HeaderInNormal
  35. {...normalProps}
  36. />
  37. )
  38. }
  39. {
  40. viewHistory && (
  41. <HeaderInHistory />
  42. )
  43. }
  44. {
  45. restoring && (
  46. <HeaderInRestoring
  47. {...restoringProps}
  48. />
  49. )
  50. }
  51. </div>
  52. )
  53. }
  54. export default Header