index.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import type { ComponentProps, FC } from 'react'
  2. import classNames from '@/utils/classnames'
  3. type SkeletonProps = ComponentProps<'div'>
  4. export const SkeletonContainer: 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-quaternary my-1', className)} {...rest}>
  24. {children}
  25. </div>
  26. )
  27. }
  28. export const SkeletonPoint: FC<SkeletonProps> = (props) => {
  29. const { className, ...rest } = props
  30. return (
  31. <div className={classNames('text-text-quaternary text-xs font-medium', className)} {...rest}>·</div>
  32. )
  33. }
  34. /** Usage
  35. * <SkeletonContainer>
  36. * <SkeletonRow>
  37. * <SkeletonRectangle className="w-96" />
  38. * <SkeletonPoint />
  39. * <SkeletonRectangle className="w-96" />
  40. * </SkeletonRow>
  41. * <SkeletonRow>
  42. * <SkeletonRectangle className="w-96" />
  43. * </SkeletonRow>
  44. * <SkeletonRow>
  45. */