|
@@ -1,4 +1,3 @@
|
|
|
-import styled from '@emotion/styled'
|
|
|
import React, { useCallback, useEffect, useState } from 'react'
|
|
|
|
|
|
import {
|
|
@@ -8,10 +7,11 @@ import {
|
|
|
GetVideosConnectionQueryVariables,
|
|
|
VideoWhereInput,
|
|
|
} from '@/api/queries'
|
|
|
-import { Grid, LoadMoreButton, SkeletonLoader, Text } from '@/shared/components'
|
|
|
-import { sizes } from '@/shared/theme'
|
|
|
+import { Button, Grid, GridHeadingContainer, LoadMoreButton } from '@/shared/components'
|
|
|
+import { SvgGlyphChevronRight } from '@/shared/icons'
|
|
|
import { SentryLogger } from '@/utils/logs'
|
|
|
|
|
|
+import { LoadMoreButtonWrapper, StyledSkeletonLoader, Title } from './InfiniteGrid.style'
|
|
|
import { useInfiniteGrid } from './useInfiniteGrid'
|
|
|
|
|
|
import { VideoTile } from '../VideoTile'
|
|
@@ -31,6 +31,10 @@ type InfiniteVideoGridProps = {
|
|
|
showChannel?: boolean
|
|
|
className?: string
|
|
|
currentlyWatchedVideoId?: string
|
|
|
+ additionalLink?: {
|
|
|
+ name: string
|
|
|
+ url: string
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const INITIAL_ROWS = 2
|
|
@@ -51,6 +55,7 @@ export const InfiniteVideoGrid: React.FC<InfiniteVideoGridProps> = ({
|
|
|
showChannel = true,
|
|
|
className,
|
|
|
currentlyWatchedVideoId,
|
|
|
+ additionalLink,
|
|
|
}) => {
|
|
|
const [videosPerRow, setVideosPerRow] = useState(INITIAL_VIDEOS_PER_ROW)
|
|
|
const queryVariables: { where: VideoWhereInput } = {
|
|
@@ -156,7 +161,22 @@ export const InfiniteVideoGrid: React.FC<InfiniteVideoGridProps> = ({
|
|
|
// Right now we'll make the first request and then right after another one based on the resized columns
|
|
|
return (
|
|
|
<section className={className}>
|
|
|
- {title && (!ready ? <StyledSkeletonLoader height={23} width={250} /> : <Title variant="h5">{title}</Title>)}
|
|
|
+ {title && (
|
|
|
+ <GridHeadingContainer>
|
|
|
+ {!ready ? <StyledSkeletonLoader height={23} width={250} /> : <Title variant="h4">{title}</Title>}
|
|
|
+ {additionalLink && (
|
|
|
+ <Button
|
|
|
+ to={additionalLink.url}
|
|
|
+ size="medium"
|
|
|
+ variant="secondary"
|
|
|
+ iconPlacement="right"
|
|
|
+ icon={<SvgGlyphChevronRight width={12} height={12} />}
|
|
|
+ >
|
|
|
+ {additionalLink.name}
|
|
|
+ </Button>
|
|
|
+ )}
|
|
|
+ </GridHeadingContainer>
|
|
|
+ )}
|
|
|
<Grid onResize={(sizes) => setVideosPerRow(sizes.length)}>{gridContent}</Grid>
|
|
|
{!allItemsLoaded && !loading && (
|
|
|
<LoadMoreButtonWrapper>
|
|
@@ -166,15 +186,3 @@ export const InfiniteVideoGrid: React.FC<InfiniteVideoGridProps> = ({
|
|
|
</section>
|
|
|
)
|
|
|
}
|
|
|
-
|
|
|
-const Title = styled(Text)`
|
|
|
- margin-bottom: ${sizes(4)};
|
|
|
-`
|
|
|
-
|
|
|
-const StyledSkeletonLoader = styled(SkeletonLoader)`
|
|
|
- margin-bottom: ${sizes(4)};
|
|
|
-`
|
|
|
-
|
|
|
-const LoadMoreButtonWrapper = styled.div`
|
|
|
- margin-top: ${sizes(10)};
|
|
|
-`
|