ChannelGallery.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import React from 'react'
  2. import styled from '@emotion/styled'
  3. import { ChannelPreviewBase, Gallery } from '@/shared/components'
  4. import ChannelPreview from './ChannelPreviewWithNavigation'
  5. import { sizes } from '@/shared/theme'
  6. import { ChannelFields } from '@/api/queries/__generated__/ChannelFields'
  7. type ChannelGalleryProps = {
  8. title?: string
  9. channels?: ChannelFields[]
  10. loading?: boolean
  11. }
  12. const PLACEHOLDERS_COUNT = 12
  13. const ChannelGallery: React.FC<ChannelGalleryProps> = ({ title, channels, loading }) => {
  14. const displayPlaceholders = loading || !channels
  15. return (
  16. <Gallery title={title} itemWidth={220} exactWidth={true} paddingLeft={sizes(2, true)} paddingTop={sizes(2, true)}>
  17. {displayPlaceholders
  18. ? Array.from({ length: PLACEHOLDERS_COUNT }).map((_, idx) => (
  19. <ChannelPreviewBase key={`channel-placeholder-${idx}`} />
  20. ))
  21. : channels!.map((channel) => (
  22. <StyledChannelPreview
  23. id={channel.id}
  24. name={channel.handle}
  25. avatarURL={channel.avatarPhotoUrl}
  26. key={channel.id}
  27. animated
  28. />
  29. ))}
  30. </Gallery>
  31. )
  32. }
  33. const StyledChannelPreview = styled(ChannelPreview)`
  34. + * {
  35. margin-left: 16px;
  36. }
  37. `
  38. export default ChannelGallery