index.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import cn from 'classnames'
  5. import s from './style.module.css'
  6. import Switch from '@/app/components/base/switch'
  7. export type IFeatureItemProps = {
  8. icon: React.ReactNode
  9. previewImgClassName?: string
  10. title: string
  11. description: string
  12. value: boolean
  13. onChange: (value: boolean) => void
  14. }
  15. const FeatureItem: FC<IFeatureItemProps> = ({
  16. icon,
  17. previewImgClassName,
  18. title,
  19. description,
  20. value,
  21. onChange,
  22. }) => {
  23. return (
  24. <div className={cn(s.wrap, 'relative flex justify-between p-3 rounded-xl border border-transparent bg-gray-50 hover:border-gray-200 cursor-pointer')}>
  25. <div className='flex space-x-3 mr-2'>
  26. {/* icon */}
  27. <div
  28. className='shrink-0 flex items-center justify-center w-8 h-8 rounded-lg border border-gray-200 bg-white'
  29. style={{
  30. boxShadow: '0px 1px 2px rgba(16, 24, 40, 0.05)',
  31. }}
  32. >
  33. {icon}
  34. </div>
  35. <div>
  36. <div className='text-sm font-semibold text-gray-800'>{title}</div>
  37. <div className='text-xs font-normal text-gray-500'>{description}</div>
  38. </div>
  39. </div>
  40. <Switch onChange={onChange} defaultValue={value} />
  41. {
  42. previewImgClassName && (
  43. <div className={cn(s.preview, s[previewImgClassName])}>
  44. </div>)
  45. }
  46. </div>
  47. )
  48. }
  49. export default React.memo(FeatureItem)