diff --git a/front/packages/ui/src/details/header.tsx b/front/packages/ui/src/details/header.tsx index 3905e056..310d7637 100644 --- a/front/packages/ui/src/details/header.tsx +++ b/front/packages/ui/src/details/header.tsx @@ -169,14 +169,16 @@ const TitleLine = ({ })} {...tooltip(t("show.play"))} /> - {trailerUrl && } + {trailerUrl && ( + + )} @@ -249,7 +251,7 @@ const Description = ({ {t("show.genre")}:{" "} {(isLoading ? [...Array(3)] : genres!).map((genre, i) => ( -

{i !== 0 && ", "}

+

{i !== 0 && ", "}

{isLoading ? ( ) : ( diff --git a/front/packages/ui/src/details/season.tsx b/front/packages/ui/src/details/season.tsx index 4d5d91bd..09fcdf2a 100644 --- a/front/packages/ui/src/details/season.tsx +++ b/front/packages/ui/src/details/season.tsx @@ -41,7 +41,7 @@ export const EpisodeList = ({ return ( { const { css } = useYoshiki(); @@ -52,38 +53,41 @@ const query = (slug: string): QueryIdentifier => ({ export const ShowDetails: QueryPage<{ slug: string; season: string }> = ({ slug, season }) => { const { css, theme } = useYoshiki(); - const ShowHeader = ({ children, ...props }: ViewProps) => ( - theme.background }, - Platform.OS === "web" && { - flexGrow: 1, - flexShrink: 1, - // @ts-ignore Web only property - overflow: "auto" as any, - // @ts-ignore Web only property - overflowX: "hidden", - // @ts-ignore Web only property - overflowY: "overlay", - }, - ], - props, - )} - > - {/* TODO: Remove the slug quickfix for the play button */} -
- {/* */} - - {/* */} - - {children} + const ShowHeader = forwardRef(function _ShowHeader({ children, ...props }, ref) { + return ( + theme.background }, + Platform.OS === "web" && { + flexGrow: 1, + flexShrink: 1, + // @ts-ignore Web only property + overflow: "auto" as any, + // @ts-ignore Web only property + overflowX: "hidden", + // @ts-ignore Web only property + overflowY: "overlay", + }, + ], + props, + )} + > + {/* TODO: Remove the slug quickfix for the play button */} +
+ {/* */} + + {/* */} + + {children} + - - ); + ); + }); return ( diff --git a/front/packages/ui/src/fetch-infinite.web.tsx b/front/packages/ui/src/fetch-infinite.web.tsx index 526c56c0..25fa65cb 100644 --- a/front/packages/ui/src/fetch-infinite.web.tsx +++ b/front/packages/ui/src/fetch-infinite.web.tsx @@ -20,7 +20,7 @@ import { Page, QueryIdentifier, useInfiniteFetch } from "@kyoo/models"; import { HR } from "@kyoo/primitives"; -import { ComponentType, Fragment, ReactElement, useMemo, useRef } from "react"; +import { ComponentType, Fragment, isValidElement, ReactElement, useMemo, useRef } from "react"; import { Stylable, useYoshiki } from "yoshiki"; import { EmptyView, ErrorView, Layout, WithLoading } from "./fetch"; @@ -31,6 +31,7 @@ const InfiniteScroll = ({ loadMore, hasMore = true, isFetching, + Header, ...props }: { children?: ReactElement | (ReactElement | null)[] | null; @@ -39,23 +40,25 @@ const InfiniteScroll = ({ loadMore: () => void; hasMore: boolean; isFetching: boolean; + Header: ComponentType<{ children: JSX.Element }> | ReactElement | undefined; } & Stylable) => { const ref = useRef(null); const { css } = useYoshiki(); - return ( -
{ - if (!ref.current || !hasMore || isFetching) return; - const scroll = - layout === "horizontal" - ? ref.current.scrollWidth - ref.current.scrollLeft - : ref.current.scrollHeight - ref.current.scrollTop; - const offset = layout === "horizontal" ? ref.current.offsetWidth : ref.current.offsetHeight; + const onScroll = () => { + if (!ref.current || !hasMore || isFetching) return; + const scroll = + layout === "horizontal" + ? ref.current.scrollWidth - ref.current.scrollLeft + : ref.current.scrollHeight - ref.current.scrollTop; + const offset = layout === "horizontal" ? ref.current.offsetWidth : ref.current.offsetHeight; - if (scroll <= offset * 1.2) loadMore(); - }} + if (scroll <= offset * 1.2) loadMore(); + }; + const scrollProps = { ref, onScroll }; + + const list = (props: object) => ( +
); + + if (!Header) return list({ ...scrollProps, ...props }); + if (!isValidElement(Header)) return
{list(props)}
; + return ( + <> + {Header} + {list({ ...scrollProps, ...props })} + + ); }; export const InfiniteFetch = ({ @@ -125,7 +137,7 @@ export const InfiniteFetch = ({ return ; } - const list = ( + return ( ({ {children({ isLoading: true } as any, i)} ))} + Header={Header} {...props} > {items?.map((item, i) => ( @@ -147,7 +160,6 @@ export const InfiniteFetch = ({ ))} ); - return addHeader(Header, list); }; const addHeader = (