Style the extension onboarding

This commit is contained in:
mrjvs 2024-01-21 15:28:46 +01:00
parent faa58f9ce6
commit 4fa500013e
4 changed files with 69 additions and 32 deletions

View File

@ -506,18 +506,18 @@
"extension": { "extension": {
"title": "Let's start with an extension", "title": "Let's start with an extension",
"explainer": "Using the browser extension, you can get the best streams we have to offer. With just a simple install.", "explainer": "Using the browser extension, you can get the best streams we have to offer. With just a simple install.",
"extensionHelp": "If you've installed the extension but it's not detected. <bold>Open the extension through your browsers extension menu</bold> and follow the steps on screen.",
"link": "Install extension", "link": "Install extension",
"back": "Go back", "back": "Go back",
"status": { "status": {
"loading": "Waiting on extension", "loading": "Waiting for you to install the extension",
"disallowed": "Extension disabled for this page", "disallowed": "Extension is not enabled for this page",
"disallowedAction": "Enabled extension",
"failed": "Failed to request status", "failed": "Failed to request status",
"outdated": "Extension version too old", "outdated": "Extension version too old",
"noperms": "Extension does not have sufficient permissions",
"success": "Extension is working as expected!" "success": "Extension is working as expected!"
}, },
"submitCheck": "Check for extension", "submit": "Continue"
"submitFinal": "Continue"
}, },
"defaultConfirm": { "defaultConfirm": {
"title": "Are you sure?", "title": "Are you sure?",

View File

@ -22,7 +22,7 @@ export function CenterContainer(props: ThinContainerProps) {
return ( return (
<div <div
className={classNames( className={classNames(
"min-h-screen w-full flex justify-center p-8 items-center", "min-h-screen w-full flex justify-center p-8 py-24 items-center",
props.classNames, props.classNames,
)} )}
> >

View File

@ -1,11 +1,12 @@
import { ReactNode } from "react"; import { ReactNode } from "react";
import { useTranslation } from "react-i18next"; import { Trans, useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { useAsyncFn, useInterval } from "react-use"; import { useAsyncFn, useInterval } from "react-use";
import { isAllowedExtensionVersion } from "@/backend/extension/compatibility"; import { isAllowedExtensionVersion } from "@/backend/extension/compatibility";
import { extensionInfo } from "@/backend/extension/messaging"; import { extensionInfo, sendPage } from "@/backend/extension/messaging";
import { Button } from "@/components/buttons/Button"; import { Button } from "@/components/buttons/Button";
import { Icon, Icons } from "@/components/Icon";
import { Loading } from "@/components/layout/Loading"; import { Loading } from "@/components/layout/Loading";
import { Stepper } from "@/components/layout/Stepper"; import { Stepper } from "@/components/layout/Stepper";
import { CenterContainer } from "@/components/layout/ThinContainer"; import { CenterContainer } from "@/components/layout/ThinContainer";
@ -47,23 +48,57 @@ export function ExtensionStatus(props: {
<p>{t("onboarding.extension.status.loading")}</p> <p>{t("onboarding.extension.status.loading")}</p>
</> </>
); );
// TODO make proper actions for all of these states below if (props.status === "disallowed" || props.status === "noperms")
if (props.status === "disallowed") content = (
content = <p>{t("onboarding.extension.status.disallowed")}</p>; <>
<p>{t("onboarding.extension.status.disallowed")}</p>
<Button
onClick={() => {
sendPage({
page: "PermissionGrant",
redirectUrl: window.location.href,
});
}}
theme="purple"
padding="md:px-12 p-2.5"
className="mt-6"
>
{t("onboarding.extension.status.disallowedAction")}
</Button>
</>
);
else if (props.status === "failed") else if (props.status === "failed")
content = <p>{t("onboarding.extension.status.failed")}</p>; content = <p>{t("onboarding.extension.status.failed")}</p>;
else if (props.status === "outdated") else if (props.status === "outdated")
content = <p>{t("onboarding.extension.status.outdated")}</p>; content = <p>{t("onboarding.extension.status.outdated")}</p>;
else if (props.status === "noperms")
content = <p>{t("onboarding.extension.status.noperms")}</p>;
else if (props.status === "success") else if (props.status === "success")
content = <p>{t("onboarding.extension.status.success")}</p>; content = (
<p className="flex items-center">
<Icon icon={Icons.CHECKMARK} className="text-type-success mr-4" />
{t("onboarding.extension.status.success")}
</p>
);
return ( return (
<>
<Card> <Card>
<div className="flex py-6 flex-col space-y-2 items-center justify-center"> <div className="flex py-6 flex-col space-y-2 items-center justify-center">
{content} {content}
</div> </div>
</Card> </Card>
<Card className="mt-4">
<div className="flex items-center space-x-7">
<Icon icon={Icons.WARNING} className="text-type-danger text-2xl" />
<p className="flex-1">
<Trans
i18nKey="onboarding.extension.extensionHelp"
components={{
bold: <span className="text-white" />,
}}
/>
</p>
</div>
</Card>
</>
); );
} }
@ -103,13 +138,11 @@ export function OnboardingExtensionPage() {
<Button onClick={() => navigate("/onboarding")} theme="secondary"> <Button onClick={() => navigate("/onboarding")} theme="secondary">
{t("onboarding.extension.back")} {t("onboarding.extension.back")}
</Button> </Button>
{value === "success" ? (
<Button onClick={() => exec(true)} theme="purple"> <Button onClick={() => exec(true)} theme="purple">
{t( {t("onboarding.extension.submit")}
value === "success"
? "onboarding.extension.submitFinal"
: "onboarding.extension.submitCheck",
)}
</Button> </Button>
) : null}
</div> </div>
</CenterContainer> </CenterContainer>
</MinimalPageLayout> </MinimalPageLayout>

View File

@ -7,16 +7,20 @@ import { Heading2, Heading3, Paragraph } from "@/components/utils/Text";
export function Card(props: { export function Card(props: {
children?: React.ReactNode; children?: React.ReactNode;
className?: string;
onClick?: () => void; onClick?: () => void;
}) { }) {
return ( return (
<div <div
className={classNames({ className={classNames(
{
"bg-onboarding-card duration-300 border border-onboarding-border rounded-lg p-7": "bg-onboarding-card duration-300 border border-onboarding-border rounded-lg p-7":
true, true,
"hover:bg-onboarding-cardHover transition-colors cursor-pointer": "hover:bg-onboarding-cardHover transition-colors cursor-pointer":
!!props.onClick, !!props.onClick,
})} },
props.className,
)}
onClick={props.onClick} onClick={props.onClick}
> >
{props.children} {props.children}