ExploreContent.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import React from 'react';
  2. import { Link } from 'react-router-dom';
  3. import Section from '@polkadot/joy-utils/Section';
  4. import { VideoPreviewProps, VideoPreview } from '../video/VideoPreview';
  5. import { ChannelEntity } from '../entities/ChannelEntity';
  6. import { ChannelPreview } from '../channels/ChannelPreview';
  7. const LatestVideosTitle = () => (
  8. <div>
  9. Latest videos
  10. <Link to={'/media/videos'} className='ViewAllLink'>All videos</Link>
  11. </div>
  12. );
  13. const LatestChannelsTitle = () => (
  14. <div>
  15. Latest video channels
  16. <Link to={'/media/channels'} className='ViewAllLink'>All channels</Link>
  17. </div>
  18. );
  19. export type ExploreContentProps = {
  20. featuredVideos?: VideoPreviewProps[];
  21. latestVideos?: VideoPreviewProps[];
  22. latestVideoChannels?: ChannelEntity[];
  23. }
  24. export function ExploreContent (props: ExploreContentProps) {
  25. const { featuredVideos = [], latestVideos = [], latestVideoChannels = [] } = props;
  26. return <div>
  27. {featuredVideos.length > 0 &&
  28. <Section title={'Featured videos'} className='ListOfVideos'>
  29. {featuredVideos.map((x) =>
  30. <VideoPreview key={x.id} {...x} withChannel />
  31. )}
  32. </Section>
  33. }
  34. {latestVideos.length > 0 &&
  35. <Section className='ListOfVideos' title={<LatestVideosTitle />}>
  36. {latestVideos.map((x) =>
  37. <VideoPreview key={x.id} {...x} withChannel />
  38. )}
  39. </Section>
  40. }
  41. {latestVideoChannels.length > 0 &&
  42. <Section className='ListOfChannels' title={<LatestChannelsTitle />}>
  43. {latestVideoChannels.map((x) =>
  44. <ChannelPreview key={x.id} channel={x} withSubtitle={false} />
  45. )}
  46. </Section>
  47. }
  48. </div>;
  49. }