diff --git a/src/components/player/internals/ScrapeCard.tsx b/src/components/player/internals/ScrapeCard.tsx index 479bf2b1..dc057901 100644 --- a/src/components/player/internals/ScrapeCard.tsx +++ b/src/components/player/internals/ScrapeCard.tsx @@ -2,7 +2,10 @@ import classNames from "classnames"; import { ReactNode } from "react"; import { useTranslation } from "react-i18next"; -import { StatusCircle } from "@/components/player/internals/StatusCircle"; +import { + StatusCircle, + StatusCircleProps, +} from "@/components/player/internals/StatusCircle"; import { Transition } from "@/components/utils/Transition"; export interface ScrapeItemProps { @@ -23,13 +26,14 @@ const statusTextMap: Partial> = { pending: "player.scraping.items.pending", }; -const statusMap: Record = { - failure: "error", - notfound: "noresult", - pending: "loading", - success: "success", - waiting: "waiting", -}; +const statusMap: Record = + { + failure: "error", + notfound: "noresult", + pending: "loading", + success: "success", + waiting: "waiting", + }; export function ScrapeItem(props: ScrapeItemProps) { const { t } = useTranslation(); diff --git a/src/components/player/internals/StatusCircle.tsx b/src/components/player/internals/StatusCircle.tsx index 32855321..ede7392e 100644 --- a/src/components/player/internals/StatusCircle.tsx +++ b/src/components/player/internals/StatusCircle.tsx @@ -4,23 +4,24 @@ import classNames from "classnames"; import { Icon, Icons } from "@/components/Icon"; import { Transition } from "@/components/utils/Transition"; -export interface StatusCircle { +export interface StatusCircleProps { type: "loading" | "success" | "error" | "noresult" | "waiting"; percentage?: number; + className?: string; } -export interface StatusCircleLoading extends StatusCircle { +export interface StatusCircleLoading extends StatusCircleProps { type: "loading"; percentage: number; } function statusIsLoading( - props: StatusCircle | StatusCircleLoading, + props: StatusCircleProps | StatusCircleLoading, ): props is StatusCircleLoading { return props.type === "loading"; } -export function StatusCircle(props: StatusCircle | StatusCircleLoading) { +export function StatusCircle(props: StatusCircleProps | StatusCircleLoading) { const [spring] = useSpring( () => ({ percentage: statusIsLoading(props) ? props.percentage : 0, @@ -30,18 +31,21 @@ export function StatusCircle(props: StatusCircle | StatusCircleLoading) { return (
diff --git a/src/pages/parts/settings/SetupPart.tsx b/src/pages/parts/settings/SetupPart.tsx index f639b43b..478722c6 100644 --- a/src/pages/parts/settings/SetupPart.tsx +++ b/src/pages/parts/settings/SetupPart.tsx @@ -1,9 +1,19 @@ +import classNames from "classnames"; +import { t } from "i18next"; +import { ReactNode } from "react"; import { useNavigate } from "react-router-dom"; import { useAsync } from "react-use"; import { isExtensionActive } from "@/backend/extension/messaging"; import { singularProxiedFetch } from "@/backend/helpers/fetch"; import { Button } from "@/components/buttons/Button"; +import { Icon, Icons } from "@/components/Icon"; +import { SettingsCard } from "@/components/layout/SettingsCard"; +import { + StatusCircle, + StatusCircleProps, +} from "@/components/player/internals/StatusCircle"; +import { Heading3 } from "@/components/utils/Text"; import { useAuthStore } from "@/stores/auth"; const testUrl = "https://postman-echo.com/get"; @@ -63,17 +73,110 @@ function useIsSetup() { }; } +function SetupCheckList(props: { + status: Status; + grey?: boolean; + children?: ReactNode; +}) { + const statusMap: Record = { + error: "error", + success: "success", + unset: "noresult", + }; + + return ( +
+ +
+

+ {props.children} +

+ {props.status === "error" ? ( +

+ There is something wrong with this setting. Go through setup again + to fix it. +

+ ) : null} +
+
+ ); +} + export function SetupPart() { const navigate = useNavigate(); const { loading, setupStates, globalState } = useIsSetup(); if (loading || !setupStates) return

Loading states...

; + + const textLookupMap: Record = { + error: { + title: "err1", + desc: "err2", + }, + success: { + title: "success1", + desc: "success2", + }, + unset: { + title: "unset1", + desc: "unset2", + }, + }; + return ( -
-

state: {globalState}

-

extension: {setupStates.extension}

-

proxy: {setupStates.proxy}

-

defaults: {setupStates.defaultProxy}

- -
+ +
+
+
+ +
+
+
+ + {t(textLookupMap[globalState].title)} + +

+ {t(textLookupMap[globalState].desc)} +

+ + Extension + + + Custom proxy + + + Default setup + +
+
+ +
+
+
); } diff --git a/themes/default.ts b/themes/default.ts index dfda2d86..bd31b3ff 100644 --- a/themes/default.ts +++ b/themes/default.ts @@ -152,6 +152,7 @@ export const defaultTheme = { divider: tokens.ash.c500, secondary: tokens.ash.c100, danger: tokens.semantic.red.c100, + success: tokens.semantic.green.c100, link: tokens.purple.c100, linkHover: tokens.purple.c50, },