index.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import cn from '@/utils/classnames'
  5. import { useTranslation } from 'react-i18next'
  6. import Button from '../button'
  7. import { RiCloseLine } from '@remixicon/react'
  8. type Props = {
  9. title: string
  10. className?: string
  11. beforeHeader?: React.ReactNode
  12. onClose: () => void
  13. hideCloseBtn?: boolean
  14. onConfirm: () => void
  15. children: React.ReactNode
  16. }
  17. const ModalLikeWrap: FC<Props> = ({
  18. title,
  19. className,
  20. beforeHeader,
  21. children,
  22. onClose,
  23. hideCloseBtn,
  24. onConfirm,
  25. }) => {
  26. const { t } = useTranslation()
  27. return (
  28. <div className={cn('w-[320px] rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg px-3 pb-4 pt-3.5 shadow-xl', className)}>
  29. {beforeHeader || null}
  30. <div className='mb-1 flex h-6 items-center justify-between'>
  31. <div className='system-xl-semibold text-text-primary'>{title}</div>
  32. {!hideCloseBtn && (
  33. <div
  34. className='cursor-pointer p-1.5 text-text-tertiary'
  35. onClick={onClose}
  36. >
  37. <RiCloseLine className='size-4' />
  38. </div>
  39. )}
  40. </div>
  41. <div className='mt-2'>{children}</div>
  42. <div className='mt-4 flex justify-end'>
  43. <Button
  44. className='mr-2'
  45. onClick={onClose}>{t('common.operation.cancel')}</Button>
  46. <Button
  47. onClick={onConfirm}
  48. variant='primary'
  49. >{t('common.operation.save')}</Button>
  50. </div>
  51. </div>
  52. )
  53. }
  54. export default React.memo(ModalLikeWrap)