item.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import cn from 'classnames'
  5. import s from './item.module.css'
  6. import Switch from '@/app/components/base/switch'
  7. export type IItemProps = {
  8. icon: React.ReactNode
  9. name: string
  10. description?: string
  11. more?: React.ReactNode
  12. enabled: boolean
  13. onChange: (enabled: boolean) => void
  14. readonly?: boolean
  15. }
  16. const Item: FC<IItemProps> = ({
  17. icon,
  18. name,
  19. description,
  20. more,
  21. enabled,
  22. onChange,
  23. readonly,
  24. }) => {
  25. return (
  26. <div className={cn('bg-white rounded-xl border border-gray-200 overflow-hidden', s.shadow)}>
  27. <div className='flex justify-between items-center min-h-[48px] px-2'>
  28. <div className='flex items-center space-x-2'>
  29. {icon}
  30. <div className='leading-[18px]'>
  31. <div className='text-[13px] font-medium text-gray-800'>{name}</div>
  32. {description && <div className='text-xs leading-[18px] text-gray-500'>{description}</div>}
  33. </div>
  34. </div>
  35. <Switch size='md' defaultValue={enabled} onChange={onChange} disabled={readonly} />
  36. </div>
  37. {more}
  38. </div>
  39. )
  40. }
  41. export default React.memo(Item)