index.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import type { ComponentProps, FC } from 'react'
  2. import classNames from '@/utils/classnames'
  3. type SkeletonProps = ComponentProps<'div'>
  4. export const SkeletonContanier: FC<SkeletonProps> = (props) => {
  5. const { className, children, ...rest } = props
  6. return (
  7. <div className={classNames('flex flex-col gap-1', className)} {...rest}>
  8. {children}
  9. </div>
  10. )
  11. }
  12. export const SkeletonRow: FC<SkeletonProps> = (props) => {
  13. const { className, children, ...rest } = props
  14. return (
  15. <div className={classNames('flex items-center gap-2', className)} {...rest}>
  16. {children}
  17. </div>
  18. )
  19. }
  20. export const SkeletonRectangle: FC<SkeletonProps> = (props) => {
  21. const { className, children, ...rest } = props
  22. return (
  23. <div className={classNames('h-2 rounded-sm opacity-20 bg-text-tertiary my-1', className)} {...rest}>
  24. {children}
  25. </div>
  26. )
  27. }
  28. export const SkeletonPoint: FC = () =>
  29. <div className='text-text-quaternary text-xs font-medium'>·</div>
  30. /** Usage
  31. * <SkeletonContanier>
  32. * <SkeletonRow>
  33. * <SkeletonRectangle className="w-96" />
  34. * <SkeletonPoint />
  35. * <SkeletonRectangle className="w-96" />
  36. * </SkeletonRow>
  37. * <SkeletonRow>
  38. * <SkeletonRectangle className="w-96" />
  39. * </SkeletonRow>
  40. * <SkeletonRow>
  41. */