index.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. 'use client'
  2. import type { FC, ReactNode } from 'react'
  3. import React from 'react'
  4. import cn from 'classnames'
  5. export type IFeaturePanelProps = {
  6. className?: string
  7. headerIcon?: ReactNode
  8. title: ReactNode
  9. headerRight?: ReactNode
  10. hasHeaderBottomBorder?: boolean
  11. isFocus?: boolean
  12. noBodySpacing?: boolean
  13. children?: ReactNode
  14. }
  15. const FeaturePanel: FC<IFeaturePanelProps> = ({
  16. className,
  17. headerIcon,
  18. title,
  19. headerRight,
  20. hasHeaderBottomBorder,
  21. isFocus,
  22. noBodySpacing,
  23. children,
  24. }) => {
  25. return (
  26. <div
  27. className={cn(className, isFocus && 'border border-[#2D0DEE]', 'rounded-xl bg-gray-50 pt-2 pb-3', noBodySpacing && '!pb-0')}
  28. style={isFocus
  29. ? {
  30. boxShadow: '0px 4px 8px -2px rgba(16, 24, 40, 0.1), 0px 2px 4px -2px rgba(16, 24, 40, 0.06)',
  31. }
  32. : {}}
  33. >
  34. {/* Header */}
  35. <div className={cn('pb-2 px-3', hasHeaderBottomBorder && 'border-b border-gray-100')}>
  36. <div className='flex justify-between items-center h-8'>
  37. <div className='flex items-center space-x-1 shrink-0'>
  38. {headerIcon && <div className='flex items-center justify-center w-6 h-6'>{headerIcon}</div>}
  39. <div className='text-sm font-semibold text-gray-800'>{title}</div>
  40. </div>
  41. <div>
  42. {headerRight}
  43. </div>
  44. </div>
  45. </div>
  46. {/* Body */}
  47. {children && (
  48. <div className={cn(!noBodySpacing && 'mt-1 px-3')}>
  49. {children}
  50. </div>
  51. )}
  52. </div>
  53. )
  54. }
  55. export default React.memo(FeaturePanel)