VideoGrid.tsx 936 B

1234567891011121314151617181920212223242526272829303132333435
  1. import React from 'react'
  2. import styled from '@emotion/styled'
  3. import { navigate } from '@reach/router'
  4. import routes from '@/config/routes'
  5. import { VideoFields } from '@/api/queries/__generated__/VideoFields'
  6. import { VideoPreview, Grid } from '@/shared/components'
  7. const StyledVideoPreview = styled(VideoPreview)`
  8. margin: 0 auto;
  9. `
  10. type VideoGridProps = {
  11. videos: VideoFields[]
  12. }
  13. const VideoGrid: React.FC<VideoGridProps> = ({ videos }) => {
  14. return (
  15. <Grid>
  16. {videos.map((v, idx) => (
  17. <StyledVideoPreview
  18. key={idx}
  19. title={v.title}
  20. channelName={v.channel.handle}
  21. channelAvatarURL={v.channel.avatarPhotoURL}
  22. createdAt={v.publishedOnJoystreamAt}
  23. duration={v.duration}
  24. views={v.views}
  25. posterURL={v.thumbnailURL}
  26. onClick={() => navigate(routes.video(v.id))}
  27. />
  28. ))}
  29. </Grid>
  30. )
  31. }
  32. export default VideoGrid