setting-modal.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. 'use client'
  2. import { memo } from 'react'
  3. import {
  4. PortalToFollowElem,
  5. PortalToFollowElemContent,
  6. PortalToFollowElemTrigger,
  7. } from '@/app/components/base/portal-to-follow-elem'
  8. import SettingContent from '@/app/components/base/features/new-feature-panel/file-upload/setting-content'
  9. import type { OnFeaturesChange } from '@/app/components/base/features/types'
  10. type FileUploadSettingsProps = {
  11. open: boolean
  12. onOpen: (state: any) => void
  13. onChange?: OnFeaturesChange
  14. disabled?: boolean
  15. children?: React.ReactNode
  16. imageUpload?: boolean
  17. }
  18. const FileUploadSettings = ({
  19. open,
  20. onOpen,
  21. onChange,
  22. disabled,
  23. children,
  24. imageUpload,
  25. }: FileUploadSettingsProps) => {
  26. return (
  27. <PortalToFollowElem
  28. open={open}
  29. onOpenChange={onOpen}
  30. placement='left'
  31. offset={{
  32. mainAxis: 32,
  33. }}
  34. >
  35. <PortalToFollowElemTrigger className='flex' onClick={() => !disabled && onOpen((open: boolean) => !open)}>
  36. {children}
  37. </PortalToFollowElemTrigger>
  38. <PortalToFollowElemContent style={{ zIndex: 50 }}>
  39. <div className='w-[360px] p-4 bg-components-panel-bg rounded-2xl border-[0.5px] border-components-panel-border shadow-2xl'>
  40. <SettingContent
  41. imageUpload={imageUpload}
  42. onClose={() => onOpen(false)}
  43. onChange={(v) => {
  44. onChange?.(v)
  45. onOpen(false)
  46. }} />
  47. </div>
  48. </PortalToFollowElemContent>
  49. </PortalToFollowElem>
  50. )
  51. }
  52. export default memo(FileUploadSettings)