From a33171ba87b1ea9dbe04c92b4586407ae11df188 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Thu, 2 Nov 2023 01:57:22 +0100 Subject: [PATCH] Add rating and runtime to shows/movies pages --- front/packages/primitives/src/icons.tsx | 6 +++ .../packages/primitives/src/skeleton.web.tsx | 3 -- front/packages/ui/src/components/rating.tsx | 37 +++++++++++++++++++ front/packages/ui/src/details/episode.tsx | 32 ++++++++++++---- front/packages/ui/src/details/header.tsx | 19 +++++++++- 5 files changed, 86 insertions(+), 11 deletions(-) create mode 100644 front/packages/ui/src/components/rating.tsx diff --git a/front/packages/primitives/src/icons.tsx b/front/packages/primitives/src/icons.tsx index aa73c03a..0c297232 100644 --- a/front/packages/primitives/src/icons.tsx +++ b/front/packages/primitives/src/icons.tsx @@ -26,6 +26,7 @@ import { px, Theme, useYoshiki } from "yoshiki/native"; import { PressableFeedback } from "./links"; import { alpha } from "./themes"; import { Breakpoint, ts, useBreakpointValue } from "./utils"; +import { P } from "./text"; declare module "react" { function forwardRef( @@ -124,3 +125,8 @@ export const IconFab = ( /> ); }; + +export const DottedSeparator = () => { + const { css } = useYoshiki(); + return

{String.fromCharCode(0x2022)}

; +}; diff --git a/front/packages/primitives/src/skeleton.web.tsx b/front/packages/primitives/src/skeleton.web.tsx index 781b7cad..f6bc77a2 100644 --- a/front/packages/primitives/src/skeleton.web.tsx +++ b/front/packages/primitives/src/skeleton.web.tsx @@ -59,9 +59,6 @@ export const Skeleton = ({ . + */ + +import { Icon, P, Skeleton, ts } from "@kyoo/primitives"; +import { View } from "react-native"; +import Star from "@material-symbols/svg-400/rounded/star-fill.svg"; +import { rem, useYoshiki } from "yoshiki/native"; + +export const Rating = ({ rating }: { rating?: number }) => { + const { css } = useYoshiki(); + + return ( + + + + {rating !== undefined &&

{rating ? rating / 10 : "??"} / 10

} +
+
+ ); +}; diff --git a/front/packages/ui/src/details/episode.tsx b/front/packages/ui/src/details/episode.tsx index 8cfc6c9d..3356ff7b 100644 --- a/front/packages/ui/src/details/episode.tsx +++ b/front/packages/ui/src/details/episode.tsx @@ -39,6 +39,12 @@ export const episodeDisplayNumber = ( return def; }; +export const displayRuntime = (runtime: number) => { + if (runtime < 60) + return `${runtime}min`; + return `${Math.floor(runtime / 60)}h${runtime % 60}`; +} + export const EpisodeBox = ({ name, overview, @@ -124,6 +130,7 @@ export const EpisodeLine = ({ episodeNumber, seasonNumber, releaseDate, + runtime, ...props }: WithLoading<{ slug: string; @@ -135,6 +142,7 @@ export const EpisodeLine = ({ episodeNumber: number | null; seasonNumber: number | null; releaseDate: Date | null; + runtime: number | null; id: number; }> & Stylable) => { @@ -182,13 +190,23 @@ export const EpisodeLine = ({ {...(css(["poster", { flexShrink: 0, m: ts(1) }]) as { style: ImageStyle })} /> - - {isLoading || ( -
- {name ?? t("show.episodeNoMetadata")} -
- )} -
+ + + {isLoading || ( +
+ {name ?? t("show.episodeNoMetadata")} +
+ )} +
+ {isLoading || (runtime && {isLoading || {displayRuntime(runtime)}})} +
{isLoading ||

{overview}

}
diff --git a/front/packages/ui/src/details/header.tsx b/front/packages/ui/src/details/header.tsx index 5e6298f8..2c1fce5b 100644 --- a/front/packages/ui/src/details/header.tsx +++ b/front/packages/ui/src/details/header.tsx @@ -46,6 +46,7 @@ import { A, ts, Chip, + DottedSeparator, } from "@kyoo/primitives"; import { Fragment } from "react"; import { useTranslation } from "react-i18next"; @@ -66,6 +67,8 @@ import { import { Fetch } from "../fetch"; import PlayArrow from "@material-symbols/svg-400/rounded/play_arrow-fill.svg"; import Theaters from "@material-symbols/svg-400/rounded/theaters-fill.svg"; +import { Rating } from "../components/rating"; +import { displayRuntime } from "./episode"; const TitleLine = ({ isLoading, @@ -73,6 +76,8 @@ const TitleLine = ({ name, tagline, date, + rating, + runtime, poster, studio, trailerUrl, @@ -84,6 +89,8 @@ const TitleLine = ({ name?: string; tagline?: string | null; date?: string | null; + rating?: number; + runtime?: number | null; poster?: KyooImage | null; studio?: Studio | null; trailerUrl?: string | null; @@ -191,7 +198,7 @@ const TitleLine = ({ )} )} - + {playHref !== null && ( )} + + + {runtime && ( + <> + +

{displayRuntime(runtime)}

+ + )}
@@ -372,6 +387,8 @@ export const Header = ({ name={data?.name} tagline={data?.tagline} date={data ? getDisplayDate(data as any) : undefined} + rating={data?.rating} + runtime={"runtime" in data ? data.runtime : null} poster={data?.poster} trailerUrl={data?.trailer} studio={data?.studio}