index.tsx 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. 'use client'
  2. import {
  3. PortalToFollowElem,
  4. PortalToFollowElemContent,
  5. PortalToFollowElemTrigger,
  6. } from '@/app/components/base/portal-to-follow-elem'
  7. import type { PortalToFollowElemOptions } from '@/app/components/base/portal-to-follow-elem'
  8. type IFloatRightContainerProps = {
  9. isMobile: boolean
  10. open: boolean
  11. toggle: () => void
  12. triggerElement?: React.ReactNode
  13. children?: React.ReactNode
  14. } & PortalToFollowElemOptions
  15. const FloatRightContainer = ({ open, toggle, triggerElement, isMobile, children, ...portalProps }: IFloatRightContainerProps) => {
  16. return (
  17. <>
  18. {isMobile && (
  19. <PortalToFollowElem open={open} {...portalProps}>
  20. <PortalToFollowElemTrigger onClick={toggle}>
  21. {triggerElement}
  22. </PortalToFollowElemTrigger>
  23. <PortalToFollowElemContent>
  24. {children}
  25. </PortalToFollowElemContent>
  26. </PortalToFollowElem>
  27. )}
  28. {!isMobile && open && (
  29. <>{children}</>
  30. )}
  31. </>
  32. )
  33. }
  34. export default FloatRightContainer