Add Footer component

This commit is contained in:
0x1eef 2024-04-05 15:03:26 -03:00
parent 86a82fe25e
commit 05e7d1afa6
6 changed files with 29 additions and 10 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View file

@ -1,6 +1,7 @@
import React from "react"; import React from "react";
import { ErrorRenderer } from "~/components/ErrorRenderer"; import { ErrorRenderer } from "~/components/ErrorRenderer";
import { ResponseRenderer } from "~/components/ResponseRenderer"; import { ResponseRenderer } from "~/components/ResponseRenderer";
import { Loader } from "~/components/Loader";
import { useWebService } from "~/hooks/useWebService"; import { useWebService } from "~/hooks/useWebService";
export function App() { export function App() {
@ -11,11 +12,6 @@ export function App() {
} else if (error) { } else if (error) {
return <ErrorRenderer error={error} />; return <ErrorRenderer error={error} />;
} else { } else {
return ( return <Loader />;
<div className="w-full h-48" data-testid="loader">
<div className="flex flex-col h-5/6 justify-center w-3/4 m-auto"></div>
<footer className="flex items-center justify-center h-10">{t("loading")}</footer>
</div>
);
} }
} }

View file

@ -1,13 +1,14 @@
import React from "react"; import React from "react";
import { Footer } from "~/components/Footer";
export function ErrorRenderer({ error }: { error: Error }) { export function ErrorRenderer({ error }: { error: Error }) {
const t = chrome.i18n.getMessage; const t = chrome.i18n.getMessage;
return ( return (
<div data-testid="error" className="w-full h-48"> <div data-testid="error" className="w-full h-48">
<div className="flex flex-col h-5/6 justify-center w-3/4 m-auto"></div> <div className="flex flex-col h-5/6 justify-center w-3/4 m-auto"></div>
<footer className="flex items-center justify-center h-10"> <Footer>
<span className="font-bold">{t("error")}</span>: {error.message} <span className="font-bold">{t("error")}</span>: {error.message}
</footer> </Footer>
</div> </div>
); );
} }

View file

@ -0,0 +1,9 @@
import React, { ReactNode } from "react";
export function Footer({ children }: { children: ReactNode }) {
return (
<footer className="flex h-10">
<div className="w-3/4 m-auto">{children}</div>
</footer>
);
}

View file

@ -0,0 +1,12 @@
import React, { ReactNode } from "react";
import { Footer } from "~/components/Footer";
export function Loader() {
const t = chrome.i18n.getMessage;
return (
<div className="w-full h-48" data-testid="loader">
<div className="flex flex-col h-5/6 justify-center w-3/4 m-auto"></div>
<Footer>{t("loading")}</Footer>
</div>
);
}

View file

@ -1,5 +1,6 @@
import React, { useEffect, ReactNode } from "react"; import React, { useEffect, ReactNode } from "react";
import { TResponse } from "~/lib/response"; import { TResponse } from "~/lib/response";
import { Footer } from "~/components/Footer";
type TFunction = typeof chrome.i18n.getMessage; type TFunction = typeof chrome.i18n.getMessage;
export function ResponseRenderer({ response }: { response: TResponse }) { export function ResponseRenderer({ response }: { response: TResponse }) {
@ -28,11 +29,11 @@ export function ResponseRenderer({ response }: { response: TResponse }) {
<Row name={t("isp")} value={response.ISP} /> <Row name={t("isp")} value={response.ISP} />
<Row name={t("tor_exit_node")} value={<BooleanLabel on={response.isTorExitNode} t={t} />} /> <Row name={t("tor_exit_node")} value={<BooleanLabel on={response.isTorExitNode} t={t} />} />
</div> </div>
<footer className="flex items-center justify-center h-10"> <Footer>
<a target="_blank" href="https://clean.myip.wtf"> <a target="_blank" href="https://clean.myip.wtf">
clean.myip.wtf clean.myip.wtf
</a> </a>
</footer> </Footer>
</div> </div>
); );
} }