File size: 1,039 Bytes
a8b3f00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use client'
import {
  PortalToFollowElem,
  PortalToFollowElemContent,
  PortalToFollowElemTrigger,
} from '@/app/components/base/portal-to-follow-elem'
import type { PortalToFollowElemOptions } from '@/app/components/base/portal-to-follow-elem'

type IFloatRightContainerProps = {
  isMobile: boolean
  open: boolean
  toggle: () => void
  triggerElement?: React.ReactNode
  children?: React.ReactNode
} & PortalToFollowElemOptions

const FloatRightContainer = ({ open, toggle, triggerElement, isMobile, children, ...portalProps }: IFloatRightContainerProps) => {
  return (
    <>
      {isMobile && (
        <PortalToFollowElem open={open} {...portalProps}>
          <PortalToFollowElemTrigger onClick={toggle}>
            {triggerElement}
          </PortalToFollowElemTrigger>
          <PortalToFollowElemContent>
            {children}
          </PortalToFollowElemContent>
        </PortalToFollowElem>
      )}
      {!isMobile && open && (
        <>{children}</>
      )}
    </>
  )
}

export default FloatRightContainer