From dcb199a1fea682ba6c1ebcc523bb17df000c8b80 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Tue, 3 Oct 2023 20:24:09 +0200 Subject: [PATCH] scraping ui Co-authored-by: Jip Frijlink --- .../player/internals/StatusCircle.tsx | 57 +++++++++++++++++++ src/pages/PlayerView.tsx | 3 +- src/pages/parts/player/ScrapingPart.tsx | 32 +++++++++-- tailwind.config.js | 8 +++ 4 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 src/components/player/internals/StatusCircle.tsx diff --git a/src/components/player/internals/StatusCircle.tsx b/src/components/player/internals/StatusCircle.tsx new file mode 100644 index 00000000..bd1f59b8 --- /dev/null +++ b/src/components/player/internals/StatusCircle.tsx @@ -0,0 +1,57 @@ +import { Icon, Icons } from "@/components/Icon"; + +interface StatusCircle { + type: "loading" | "done" | "error" | "pending" | "noresult"; +} + +interface StatusCircleLoading extends StatusCircle { + type: "loading"; + percentage: number; +} + +function statusIsLoading( + props: StatusCircle | StatusCircleLoading +): props is StatusCircleLoading { + return props.type === "loading"; +} + +export function StatusCircle(props: StatusCircle | StatusCircleLoading) { + let classes = ""; + if (props.type === "loading") classes = "text-video-scraping-loading"; + if (props.type === "noresult") + classes = "text-video-scraping-noresult text-opacity-50"; + if (props.type === "error") + classes = "text-video-scraping-error bg-video-scraping-error"; + + return ( +
+ + {statusIsLoading(props) ? ( + + ) : null} + + {props.type === "error" ? ( + + ) : null} +
+ ); +} diff --git a/src/pages/PlayerView.tsx b/src/pages/PlayerView.tsx index 10c56323..21e98e63 100644 --- a/src/pages/PlayerView.tsx +++ b/src/pages/PlayerView.tsx @@ -15,7 +15,8 @@ export function PlayerView() { { const source = sources[order.id]; if (!source) return null; + + // Progress circle + let Circle = ; + if (source.status === "pending") + Circle = ( + + ); + if (source.status === "notfound") + Circle = ; + + // Main thing return ( -
-

{source.name}

-

- status: {source.status} ({source.percentage}%) -

-

reason: {source.reason}

+
+
+ {Circle} +
+

{source.name}

+

+ status: {source.status} ({source.percentage}%) +

+

reason: {source.reason}

+
+
{order.children.map((embedId) => { const embed = sources[embedId]; if (!embed) return null; diff --git a/tailwind.config.js b/tailwind.config.js index b591d47c..fc662a88 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -107,6 +107,14 @@ module.exports = { video: { buttonBackground: "#444B5C", + scraping: { + card: "#161620", + error: "#E44F4F", + success: "#40B44B", + loading: "#B759D8", + noresult: "#64647B" + }, + progress: { background: "#8787A8", preloaded: "#8787A8",