empty.tsx 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import React, { type FC } from 'react'
  2. import { RiFileList2Line } from '@remixicon/react'
  3. import { useTranslation } from 'react-i18next'
  4. type IEmptyProps = {
  5. onClearFilter: () => void
  6. }
  7. const EmptyCard = React.memo(() => {
  8. return (
  9. <div className='w-full h-32 rounded-xl opacity-30 bg-background-section-burn shrink-0' />
  10. )
  11. })
  12. EmptyCard.displayName = 'EmptyCard'
  13. type LineProps = {
  14. className?: string
  15. }
  16. const Line = React.memo(({
  17. className,
  18. }: LineProps) => {
  19. return (
  20. <svg xmlns="http://www.w3.org/2000/svg" width="2" height="241" viewBox="0 0 2 241" fill="none" className={className}>
  21. <path d="M1 0.5L1 240.5" stroke="url(#paint0_linear_1989_74474)"/>
  22. <defs>
  23. <linearGradient id="paint0_linear_1989_74474" x1="-7.99584" y1="240.5" x2="-7.88094" y2="0.50004" gradientUnits="userSpaceOnUse">
  24. <stop stopColor="white" stopOpacity="0.01"/>
  25. <stop offset="0.503965" stopColor="#101828" stopOpacity="0.08"/>
  26. <stop offset="1" stopColor="white" stopOpacity="0.01"/>
  27. </linearGradient>
  28. </defs>
  29. </svg>
  30. )
  31. })
  32. Line.displayName = 'Line'
  33. const Empty: FC<IEmptyProps> = ({
  34. onClearFilter,
  35. }) => {
  36. const { t } = useTranslation()
  37. return (
  38. <div className={'h-full relative flex items-center justify-center z-0'}>
  39. <div className='flex flex-col items-center'>
  40. <div className='relative z-10 flex items-center justify-center w-14 h-14 border border-divider-subtle bg-components-card-bg rounded-xl shadow-lg shadow-shadow-shadow-5'>
  41. <RiFileList2Line className='w-6 h-6 text-text-secondary' />
  42. <Line className='absolute -right-[1px] top-1/2 -translate-y-1/2' />
  43. <Line className='absolute -left-[1px] top-1/2 -translate-y-1/2' />
  44. <Line className='absolute top-0 left-1/2 -translate-x-1/2 -translate-y-1/2 rotate-90' />
  45. <Line className='absolute top-full left-1/2 -translate-x-1/2 -translate-y-1/2 rotate-90' />
  46. </div>
  47. <div className='text-text-tertiary system-md-regular mt-3'>
  48. {t('datasetDocuments.segment.empty')}
  49. </div>
  50. <button
  51. type='button'
  52. className='text-text-accent system-sm-medium mt-1'
  53. onClick={onClearFilter}
  54. >
  55. {t('datasetDocuments.segment.clearFilter')}
  56. </button>
  57. </div>
  58. <div className='h-full w-full absolute top-0 left-0 flex flex-col gap-y-3 -z-20 overflow-hidden'>
  59. {
  60. Array.from({ length: 10 }).map((_, i) => (
  61. <EmptyCard key={i} />
  62. ))
  63. }
  64. </div>
  65. <div className='h-full w-full absolute top-0 left-0 bg-dataset-chunk-list-mask-bg -z-10' />
  66. </div>
  67. )
  68. }
  69. export default React.memo(Empty)