VideoGrid.tsx 1010 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import styled from '@emotion/styled'
  2. import React from 'react'
  3. import { VideoFieldsFragment } from '@/api/queries'
  4. import { Grid } from '@/shared/components'
  5. import { VideoTile } from './VideoTile'
  6. const StyledVideoTile = styled(VideoTile)`
  7. margin: 0 auto;
  8. width: 100%;
  9. `
  10. type VideoGridProps = {
  11. videos: VideoFieldsFragment[]
  12. showChannel?: boolean
  13. onVideoClick?: (id: string) => void
  14. onChannelClick?: (id: string) => void
  15. }
  16. export const VideoGrid: React.FC<VideoGridProps> = ({ videos, showChannel = true, onVideoClick, onChannelClick }) => {
  17. return (
  18. <Grid>
  19. {videos.map((v, idx) => (
  20. <StyledVideoTile
  21. key={idx}
  22. id={v.id}
  23. showChannel={showChannel}
  24. onClick={() => {
  25. if (onVideoClick) {
  26. onVideoClick(v.id)
  27. }
  28. }}
  29. onChannelClick={() => {
  30. if (onChannelClick) {
  31. onChannelClick(v.channel.id)
  32. }
  33. }}
  34. />
  35. ))}
  36. </Grid>
  37. )
  38. }