|
@@ -1,4 +1,3 @@
|
|
-import styled from '@emotion/styled'
|
|
|
|
import React, { useCallback, useEffect, useState } from 'react'
|
|
import React, { useCallback, useEffect, useState } from 'react'
|
|
|
|
|
|
import {
|
|
import {
|
|
@@ -8,10 +7,11 @@ import {
|
|
GetVideosConnectionQueryVariables,
|
|
GetVideosConnectionQueryVariables,
|
|
VideoWhereInput,
|
|
VideoWhereInput,
|
|
} from '@/api/queries'
|
|
} 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 { SentryLogger } from '@/utils/logs'
|
|
|
|
|
|
|
|
+import { LoadMoreButtonWrapper, StyledSkeletonLoader, Title } from './InfiniteGrid.style'
|
|
import { useInfiniteGrid } from './useInfiniteGrid'
|
|
import { useInfiniteGrid } from './useInfiniteGrid'
|
|
|
|
|
|
import { VideoTile } from '../VideoTile'
|
|
import { VideoTile } from '../VideoTile'
|
|
@@ -31,6 +31,10 @@ type InfiniteVideoGridProps = {
|
|
showChannel?: boolean
|
|
showChannel?: boolean
|
|
className?: string
|
|
className?: string
|
|
currentlyWatchedVideoId?: string
|
|
currentlyWatchedVideoId?: string
|
|
|
|
+ additionalLink?: {
|
|
|
|
+ name: string
|
|
|
|
+ url: string
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
const INITIAL_ROWS = 2
|
|
const INITIAL_ROWS = 2
|
|
@@ -51,6 +55,7 @@ export const InfiniteVideoGrid: React.FC<InfiniteVideoGridProps> = ({
|
|
showChannel = true,
|
|
showChannel = true,
|
|
className,
|
|
className,
|
|
currentlyWatchedVideoId,
|
|
currentlyWatchedVideoId,
|
|
|
|
+ additionalLink,
|
|
}) => {
|
|
}) => {
|
|
const [videosPerRow, setVideosPerRow] = useState(INITIAL_VIDEOS_PER_ROW)
|
|
const [videosPerRow, setVideosPerRow] = useState(INITIAL_VIDEOS_PER_ROW)
|
|
const queryVariables: { where: VideoWhereInput } = {
|
|
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
|
|
// Right now we'll make the first request and then right after another one based on the resized columns
|
|
return (
|
|
return (
|
|
<section className={className}>
|
|
<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>
|
|
<Grid onResize={(sizes) => setVideosPerRow(sizes.length)}>{gridContent}</Grid>
|
|
{!allItemsLoaded && !loading && (
|
|
{!allItemsLoaded && !loading && (
|
|
<LoadMoreButtonWrapper>
|
|
<LoadMoreButtonWrapper>
|
|
@@ -166,15 +186,3 @@ export const InfiniteVideoGrid: React.FC<InfiniteVideoGridProps> = ({
|
|
</section>
|
|
</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)};
|
|
|
|
-`
|
|
|